aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil <phil.buschmann@tum.de>2018-06-24 21:53:16 +0200
committerPhil <phil.buschmann@tum.de>2018-06-24 21:53:16 +0200
commitde6217c4b4ed2194ea49db1b61f527cd8dc49f63 (patch)
tree3acc5f062f5398913d5f7da110f0150c0e8b1568
parent6c6a674e02d3f4460dbcfa049ba717873895dbde (diff)
downloadgnunet-webui-de6217c4b4ed2194ea49db1b61f527cd8dc49f63.tar.gz
gnunet-webui-de6217c4b4ed2194ea49db1b61f527cd8dc49f63.zip
finished identity page
-rw-r--r--src/app/api.service.ts16
-rw-r--r--src/app/identity-api.ts7
-rw-r--r--src/app/identity-page/identity-page.component.html27
-rw-r--r--src/app/identity-page/identity-page.component.ts30
-rw-r--r--src/scss/components/_modal.scss73
-rw-r--r--src/scss/main.scss1
6 files changed, 136 insertions, 18 deletions
diff --git a/src/app/api.service.ts b/src/app/api.service.ts
index b659198..6597514 100644
--- a/src/app/api.service.ts
+++ b/src/app/api.service.ts
@@ -62,7 +62,7 @@ export class ApiService {
62 62
63 deleteIdentity (id: string): Observable<any>{ 63 deleteIdentity (id: string): Observable<any>{
64 this.messages.dismissError(); 64 this.messages.dismissError();
65 return this.http.delete(this.identityURL+'/'+id) 65 return this.http.delete(this.identityURL+'?pubkey='+id)
66 .pipe( 66 .pipe(
67 tap(json => this.handleJSON(json)), 67 tap(json => this.handleJSON(json)),
68 catchError(this.handleError('deleteIdentity', [])) 68 catchError(this.handleError('deleteIdentity', []))
@@ -70,10 +70,20 @@ export class ApiService {
70 } 70 }
71 71
72 72
73 changeIdentity (id: string, json: any): Observable<any>{ 73 changeIdentity (json: any): Observable<any>{
74 this.messages.dismissError(); 74 this.messages.dismissError();
75 const options = {headers: {'Content-Type': 'application/json'}}; 75 const options = {headers: {'Content-Type': 'application/json'}};
76 return this.http.put(this.identityURL+'/'+id, json, options) 76 return this.http.put(this.identityURL, json, options)
77 .pipe(
78 tap(json => this.handleJSON(json)),
79 catchError(this.handleError('changeIdentity', []))
80 );
81 }
82
83 assignIdentity (json: any): Observable<any>{
84 this.messages.dismissError();
85 const options = {headers: {'Content-Type': 'application/json'}};
86 return this.http.put(this.identityURL, json, options)
77 .pipe( 87 .pipe(
78 tap(json => this.handleJSON(json)), 88 tap(json => this.handleJSON(json)),
79 catchError(this.handleError('changeIdentity', [])) 89 catchError(this.handleError('changeIdentity', []))
diff --git a/src/app/identity-api.ts b/src/app/identity-api.ts
index d694110..005276f 100644
--- a/src/app/identity-api.ts
+++ b/src/app/identity-api.ts
@@ -11,19 +11,18 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18/** 18/**
19 * @author Philippe Buschmann 19 * @author Philippe Buschmann
20 * @file src/app/identity-api.ts 20 * @file src/app/identity-api.ts
21 * @brief 21 * @brief
22 * 22 *
23 */ 23 */
24 24
25export class IdentityAPI{ 25export class IdentityAPI{
26 id: string; 26 pubkey: string;
27 name: string; 27 name: string;
28 type: string;
29} 28}
diff --git a/src/app/identity-page/identity-page.component.html b/src/app/identity-page/identity-page.component.html
index fe72dc1..b0f22d8 100644
--- a/src/app/identity-page/identity-page.component.html
+++ b/src/app/identity-page/identity-page.component.html
@@ -18,12 +18,13 @@
18 <div class="u-mv-x1" *ngFor="let identity of filteredItems"> 18 <div class="u-mv-x1" *ngFor="let identity of filteredItems">
19 <div class="c-card c-card--no-padding u-p-x1"> 19 <div class="c-card c-card--no-padding u-p-x1">
20 <div class="o-grid"> 20 <div class="o-grid">
21 <div class="o-grid__col u-1/12"><div class="c-circle" [ngStyle]="{'background-color': returnHSL(identity.id)}">{{identity.name | slice:0:1 | uppercase}}</div></div> 21 <div class="o-grid__col u-1/12"><div class="c-circle" [ngStyle]="{'background-color': returnHSL(identity.pubkey)}">{{identity.name | slice:0:1 | uppercase}}</div></div>
22 <div class="o-grid__col u-9/12"> 22 <div class="o-grid__col u-8/12">
23 <p class="u-color-grey">Public Key: <span class="">{{identity.id}}</span></p> 23 <p class="u-color-grey">Public Key: <span class="">{{identity.pubkey}}</span></p>
24 <span class="o-type-20">{{identity.name}}</span> 24 <span class="o-type-20">{{identity.name}}</span>
25 </div> 25 </div>
26 <div class="o-grid__col u-1/12"><p class="u-color-grey">Rename</p><a class="c-button c-button--rename" (click)="onClickRename(identity)"><i class="fa fa-pencil"></i></a></div> 26 <div class="o-grid__col u-1/12"><p class="u-color-grey">Rename</p><a class="c-button c-button--rename" (click)="onClickRename(identity)"><i class="fa fa-pencil"></i></a></div>
27 <div class="o-grid__col u-1/12"><p class="u-color-grey">Subsystem</p><a class="c-button c-button--rename" (click)="onClickAddSubsystem(identity)"><i class="fa fa-plus"></i></a></div>
27 <div class="o-grid__col u-1/12"><p class="u-color-grey">Delete</p><a class="c-button c-button--danger" (click)="onClickDelete(identity)"><i class="fa fa-trash"></i></a></div> 28 <div class="o-grid__col u-1/12"><p class="u-color-grey">Delete</p><a class="c-button c-button--danger" (click)="onClickDelete(identity)"><i class="fa fa-trash"></i></a></div>
28 </div> 29 </div>
29 </div> 30 </div>
@@ -32,20 +33,32 @@
32 33
33<div class="c-card u-p-x3 u-mt-x2" *ngIf="this.rename"> 34<div class="c-card u-p-x3 u-mt-x2" *ngIf="this.rename">
34 <h1 class="o-type-22 u-pb-x1 u-color-primary-light" >Rename</h1> 35 <h1 class="o-type-22 u-pb-x1 u-color-primary-light" >Rename</h1>
35 <div class="u-color-grey">Public Key: <span>{{changeIdentity.id}}</span></div> 36 <div class="u-color-grey u-pb-x1">Public Key: <span>{{changeIdentity.pubkey}}</span></div>
36 <div> 37 <div>
37 <span class="u-mr-x2"><span class="u-mr-x3">Name: </span><input class="c-input" placeholder="Change Name" [(ngModel)]="changeIdentity.name"/></span> 38 <span class="u-mr-x2"><span class="u-mr-x3">Name: </span><input class="c-input" placeholder="Change Name" [(ngModel)]="changeIdentity.name"/></span>
38 <a class="c-button" (click)="onRename(changeIdentity)">Rename</a> 39 <a class="c-button" (click)="onRename(changeIdentity)">Save</a>
39 <a class="c-button c-button--outline u-m-x2" (click)="onReset()">Cancel</a> 40 <a class="c-button c-button--outline u-m-x2" (click)="onReset()">Cancel</a>
40 </div> 41 </div>
41</div> 42</div>
42 43
44<div class="c-card u-p-x3 u-mt-x2" *ngIf="this.addsubsystem">
45 <h1 class="o-type-22 u-pb-x1 u-color-primary-light" >Add Subsystem</h1>
46 <div class="u-color-grey">Public Key: <span>{{changeIdentity.pubkey}}</span></div>
47 <div class="u-color-grey">Name: <span>{{changeIdentity.name}}</span></div>
48 <span class="u-mr-x2">
49 <span class="u-mr-x3">Subsystem: </span>
50 <input class="c-input" placeholder="e.g. namestore, ..." [(ngModel)]="newsubsystem"/>
51 </span>
52 <a class="c-button" (click)="onAddSubsystem(changeIdentity.pubkey)">Add</a>
53 <a class="c-button c-button--outline u-m-x2" (click)="onReset()">Cancel</a>
54</div>
55
43<div class="c-card u-p-x3 u-mt-x2" *ngIf="this.delete"> 56<div class="c-card u-p-x3 u-mt-x2" *ngIf="this.delete">
44 <h1 class="o-type-22 u-pb-x1 u-color-primary-light" >Delete</h1> 57 <h1 class="o-type-22 u-pb-x1 u-color-primary-light" >Delete</h1>
45 <div >Public Key: <span>{{changeIdentity.id}}</span></div> 58 <div >Public Key: <span>{{changeIdentity.pubkey}}</span></div>
46 <div >Name: <span>{{changeIdentity.name}}</span></div> 59 <div >Name: <span>{{changeIdentity.name}}</span></div>
47 <div> 60 <div>
48 <a class="c-button" (click)="onDelete(changeIdentity.id)">Delete</a> 61 <a class="c-button" (click)="onDelete(changeIdentity.pubkey)">Delete</a>
49 <a class="c-button c-button--outline u-m-x2" (click)="onReset()">Cancel</a> 62 <a class="c-button c-button--outline u-m-x2" (click)="onReset()">Cancel</a>
50 </div> 63 </div>
51</div> 64</div>
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++) {
diff --git a/src/scss/components/_modal.scss b/src/scss/components/_modal.scss
new file mode 100644
index 0000000..bca0ac1
--- /dev/null
+++ b/src/scss/components/_modal.scss
@@ -0,0 +1,73 @@
1// Modal Comp
2// Options
3$iota-components-modal : true;
4
5$iota-components-modal-namespace : 'modal' !default;
6$iota-components-modal-dialog-name : 'dialog' !default;
7$iota-components-modal-open-name : 'is-modal-open' !default;
8$iota-components-modal-active-name : 'is-active' !default;
9
10$iota-components-modal-padding : $iota-global-gutter-default !default;
11$iota-components-modal-background : rgba(0, 0, 0, 0.5) !default;
12$iota-components-modal-dialog-background : rgb(255, 255, 255) !default;
13
14// Helper Local Variables
15$iota-components-modal-var-modal : $iota-global-components-namespace + $iota-components-modal-namespace;
16$iota-components-modal-var-modal-active : $iota-components-modal-var-modal + '.' + $iota-components-modal-active-name;
17$iota-components-modal-var-modal-dialog : $iota-components-modal-var-modal + '__' + $iota-components-modal-dialog-name;
18
19// Modal Component
20
21.#{$iota-components-modal-open-name} {
22 position: fixed;
23 top: 0;
24 left: 0;
25 width: 100%;
26 height: 100%;
27 overflow: hidden;
28}
29
30
31.#{$iota-components-modal-var-modal} {
32 position: fixed;
33 visibility: hidden;
34 top: 0;
35 right: 0;
36 bottom: 0;
37 left: 0;
38 overflow: auto;
39 text-align: center;
40 opacity: 0;
41 z-index: 10000;
42 background: $iota-components-modal-background;
43
44 -webkit-overflow-scrolling: touch;
45 backface-visibility: hidden;
46}
47
48.#{$iota-components-modal-var-modal-active} {
49 visibility: visible;
50 opacity: 1;
51}
52
53.#{$iota-components-modal-var-modal}:after {
54 display: inline-block;
55 height: 100%;
56 margin-left: -0.05em;
57 content: "";
58 vertical-align: middle;
59}
60
61
62 .#{$iota-components-modal-var-modal-dialog} {
63 position: relative;
64 display: inline-block;
65 padding: $iota-components-modal-padding;
66 max-width: 700px;
67 width: 100%;
68 background: $iota-components-modal-dialog-background;
69 vertical-align: middle;
70 transform: translate3d(0,0,0);
71 text-size-adjust: 100%;
72 box-sizing: border-box;
73}
diff --git a/src/scss/main.scss b/src/scss/main.scss
index 18b0408..3865945 100644
--- a/src/scss/main.scss
+++ b/src/scss/main.scss
@@ -34,6 +34,7 @@
34@import 'components/markdown'; 34@import 'components/markdown';
35@import 'components/circle'; 35@import 'components/circle';
36@import 'components/dropdown'; 36@import 'components/dropdown';
37@import 'components/modal';
37 38
38//@import 'utilities/align-items'; 39//@import 'utilities/align-items';
39@import 'utilities/align'; 40@import 'utilities/align';