Commit 5ee9358d authored by Olivia Madrid's avatar Olivia Madrid

yuck changes

parent 66e69f2f
No related merge requests found
......@@ -219,9 +219,11 @@ t3-trust {
align-items: center;
}
.detailsHeader__right {
&:hover {
text-decoration: underline;
}
color: rgba($coolGrey, 0.7);
text-decoration: underline;
// &:hover {
// text-decoration: underline;
// }
}
}
.detailsContent {
......
......@@ -70,46 +70,83 @@ export class T3TrustComponent implements OnInit, OnDestroy {
lastIndex: number;
currentIndex: number = 0;
hasRecalculated: boolean = false;
isPaging: boolean = false;
// scoreChanged: boolean = false;
trustTreeRaw: Array<any> = [];
finalTrustTree: Array<any> = [];
// trustTreeRaw: Array<any> = [
// {
// entity_did: 'did:fake:2',
// actor_did: 'did:fake:1',
// vote: 0,
// degree: 1
// },
// {
// entity_did: 'did:fake:3',
// actor_did: 'did:fake:1',
// vote: -1,
// degree: 1
// },
// {
// entity_did: 'did:fake:4',
// actor_did: 'did:fake:2',
// vote: 1,
// degree: 2
// }
// ];
// ! remove one of these later
usersRaw: Array<any> = [
{
entity_did: 'did:fake:2',
score: 0.33,
name: 'Sideshow Bob',
avatarUrl: '/assets/brewski.jpg'
},
{
entity_did: 'did:fake:3',
score: 0.77,
name: 'Good girl',
avatarUrl: '/assets/avatar.png'
},
{
entity_did: 'did:fake:4',
score: 1.0,
name: 'Astronaut Lily',
avatarUrl: '/assets/moonlily.jpg'
}
];
users: Array<any> = [
{
actor_did: '000',
entity_did: '111',
entity_type: 'user',
vote: -1,
degree: 1,
entity_did: 'did:fake:2',
score: 0.33,
name: 'Sideshow Bob',
avatarUrl: '/assets/brewski.jpg'
},
{
actor_did: 1,
entity_did: '222',
entity_type: 'user',
vote: 0,
degree: 1,
entity_did: 'did:fake:3',
score: 0.77,
name: 'Good girl',
avatarUrl: '/assets/avatar.png'
},
{
actor_did: 1,
entity_did: '333',
entity_type: 'user',
vote: 1,
degree: 1,
entity_did: 'did:fake:4',
score: 1.0,
name: 'Astronaut Lily',
avatarUrl: '/assets/moonlily.jpg'
}
];
usersNew: Array<any> = []; //!!
constructor(public trustService: T3TrustService) {}
ngOnInit() {
this.finalTrustTree = this.trustService.getTrustTree('1');
console.log(this.finalTrustTree);
this.joinArrays(); // ! TODO : switch trustTreeRaw for finalTrustTree
this.actorDid = this.users[0].actor_did;
this.user = this.users[0];
......@@ -119,6 +156,20 @@ export class T3TrustComponent implements OnInit, OnDestroy {
this.lastIndex = this.users.length - 1;
}
joinArrays() {
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < this.trustTreeRaw.length; i++) {
this.users.push({
...this.trustTreeRaw[i],
...this.usersRaw.find(
itmInner => itmInner.entity_did === this.trustTreeRaw[i].entity_did
)
});
}
console.log(this.users);
}
switchView(view) {
this.view = view;
// do something with router or url?
......@@ -187,4 +238,6 @@ export class T3TrustComponent implements OnInit, OnDestroy {
clearTimeout(this.pagingTimeout);
}
}
// -------------------------------------------------------------------------------------------
}
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable()
export class T3TrustService {
constructor() {
this.getTrustTree();
constructor() {}
getTrustTree(actorDid: string) {
let finalTrustTree: Array<any> = [];
// END STRUCTURE
// [
// {
// actor_did: '1',
// entity_did: '2',
// vote: 1,
// degree: 1
// },
// {
// actor_did: '1',
// entity_did: '3',
// vote: 0,
// degree: 2
// },
// {...},
// {...},
// {...},
// {...},
// {...},
// {...},
// {...}
// ]
// QUERY FAKE DB
const fakeResponse = this.getBlockchainResponse(actorDid);
const fakeResponseWithAllDidsArray = this.makeAllDidsArray(fakeResponse);
// PROCESS BLOCKCHAIN RESPONSE
// fakeResponse.forEach(function(value) {
// const tempArray = value.split(':');
// this.currentActorObj.allDids.push(tempArray[1]);
// switch (tempArray[2]) {
// case '1':
// currentActorObj.trustedDids.push(tempArray[2]);
// break;
// case '0':
// currentActorObj.neutralDids.push(tempArray[2]);
// break;
// case '-1':
// currentActorObj.distrustedDids.push(tempArray[2]);
// }
// });
// AFTER CURRENTACTOROBJ is populated,
// add all
// go through each actor in network[] and get their network
console.log(finalTrustTree);
return finalTrustTree;
}
getTrustTree() {}
makeAllDidsArray(fakeResponse) {
const newFakeResponse = fakeResponse;
console.log(newFakeResponse[0].blockchainResponse);
let allDids: Array<any>;
allDids = newFakeResponse[0].blockchainResponse.trustedDids
.concat(newFakeResponse[0].blockchainResponse.NeutralDids)
.concat(newFakeResponse[0].blockchainResponse.DistrustedDids);
// allDids = allDids.concat(newFakeResponse[0].blockchainResponse.NeutralDids);
// allDids = allDids.concat(
// newFakeResponse[0].blockchainResponse.DistrustedDids
// );
console.log(allDids);
return newFakeResponse;
}
getBlockchainResponse(actorDid: string) {
const fakeDatabase = [
{
actorDid: '1',
blockchainResponse: {
trustedDids: ['2'],
neutralDids: ['3'],
distrustedDids: ['4']
}
},
{
actorDid: '2',
blockchainResponse: {
trustedDids: ['1', '3', '5'],
neutralDids: ['4'],
distrustedDids: []
}
},
{
actorDid: '3',
blockchainResponse: {
trustedDids: ['1'],
neutralDids: ['4', '5'],
distrustedDids: ['2']
}
},
{
actorDid: '4',
blockchainResponse: {
trustedDids: ['3'],
neutralDids: ['1'],
distrustedDids: ['2', '5']
}
},
{
actorDid: '5',
blockchainResponse: {
trustedDids: ['3', '6'],
neutralDids: ['2'],
distrustedDids: ['4']
}
},
{
actorDid: '6',
blockchainResponse: {
trustedDids: [],
neutralDids: ['3'],
distrustedDids: ['7', '8']
}
}
];
// tslint:disable-next-line: only-arrow-functions
let result = fakeDatabase.filter(function(item) {
return item.actorDid === actorDid;
});
console.log('raw Result');
console.log(result);
return result;
}
}
// OLD
// const fakeBlockchainDatabase = [
// {
// actorDid: '2',
// blockchainResponse: ['did:1:1', 'did:3:1', 'did:4:0', 'did:5:1']
// },
// {
// actorDid: '3',
// blockchainResponse: ['did:1:1', 'did:2:-1', 'did:4:0', 'did:5:0']
// },
// {
// actorDid: '4',
// blockchainResponse: ['did:1:0', 'did:2:-1', 'did:3:1', 'did:5:-1']
// },
// {
// actorDid: '5',
// blockchainResponse: ['did:2:0', 'did:3:1', 'did:4:-1', 'did:6:1']
// }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment