aboutsummaryrefslogtreecommitdiff
path: root/src/app/identity-page/identity-page.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/identity-page/identity-page.component.ts')
-rw-r--r--src/app/identity-page/identity-page.component.ts30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/app/identity-page/identity-page.component.ts b/src/app/identity-page/identity-page.component.ts
index f347f44..7588799 100644
--- a/src/app/identity-page/identity-page.component.ts
+++ b/src/app/identity-page/identity-page.component.ts
@@ -38,10 +38,12 @@ export class IdentityPageComponent implements OnInit {
38 filteredItems: IdentityAPI[]; 38 filteredItems: IdentityAPI[];
39 rename: boolean = false; 39 rename: boolean = false;
40 delete: boolean = false; 40 delete: boolean = false;
41 addsubsystem: boolean = false;
41 changeIdentity: IdentityAPI; 42 changeIdentity: IdentityAPI;
42 json: any; 43 json: any;
43 is_displayed: boolean = true; 44 is_displayed: boolean = true;
44 request: boolean = false; 45 request: boolean = false;
46 newsubsystem: string="";
45 47
46 constructor(private apiService: ApiService,private message: MessagesService) { } 48 constructor(private apiService: ApiService,private message: MessagesService) { }
47 49
@@ -68,8 +70,7 @@ export class IdentityPageComponent implements OnInit {
68 this.filteredItems = Object.assign([], this.identities).filter( 70 this.filteredItems = Object.assign([], this.identities).filter(
69 item => { 71 item => {
70 return ((item.name.indexOf(value) > -1) || 72 return ((item.name.indexOf(value) > -1) ||
71 (item.id.indexOf(value) > -1) || 73 (item.pubkey.indexOf(value) > -1))
72 (item.type.indexOf(value) > -1 ))
73 }); 74 });
74 } 75 }
75 76
@@ -79,12 +80,13 @@ export class IdentityPageComponent implements OnInit {
79 this.changeIdentity = Object.assign({},identity); 80 this.changeIdentity = Object.assign({},identity);
80 } 81 }
81 82
83
82 onRename(identity: IdentityAPI){ 84 onRename(identity: IdentityAPI){
83 this.request = true; 85 this.request = true;
84 this.onReset(); 86 this.onReset();
85 this.filteredItems = []; 87 this.filteredItems = [];
86 this.json = {'newname':identity.name}; 88 this.json = {'newname':identity.name,'pubkey':identity.pubkey};
87 this.apiService.changeIdentity(identity.id,this.json).subscribe(data => { 89 this.apiService.changeIdentity(this.json).subscribe(data => {
88 this.message.pushSuccess('Rename was successful.'); 90 this.message.pushSuccess('Rename was successful.');
89 this.getAPIs(); 91 this.getAPIs();
90 }); 92 });
@@ -93,6 +95,7 @@ export class IdentityPageComponent implements OnInit {
93 onReset(){ 95 onReset(){
94 this.rename = false; 96 this.rename = false;
95 this.delete = false; 97 this.delete = false;
98 this.addsubsystem = false;
96 this.is_displayed = true; 99 this.is_displayed = true;
97 } 100 }
98 101
@@ -112,6 +115,25 @@ export class IdentityPageComponent implements OnInit {
112 }); 115 });
113 } 116 }
114 117
118
119 onClickAddSubsystem(identity: IdentityAPI){
120 this.is_displayed = false;
121 this.addsubsystem = true;
122 this.changeIdentity = Object.assign({},identity);
123 }
124
125 onAddSubsystem(pubkey:string){
126 this.request = true;
127 this.onReset();
128 this.filteredItems = [];
129 this.json = {'subsystem':this.newsubsystem,'pubkey':pubkey};
130 this.apiService.assignIdentity(this.json).subscribe(data => {
131 this.newsubsystem = "";
132 this.message.pushSuccess('Subsystem was successfully added.');
133 this.getAPIs();
134 });
135 }
136
115 intFromHash(str:string): number{ 137 intFromHash(str:string): number{
116 let hash: number = 0; 138 let hash: number = 0;
117 for (var i = 0; i < str.length; i++) { 139 for (var i = 0; i < str.length; i++) {