aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/api.service.ts21
-rw-r--r--src/app/app-routing.module.ts8
-rw-r--r--src/app/app.component.html24
-rw-r--r--src/app/app.module.ts10
-rw-r--r--src/app/create-identity/create-identity.component.html10
-rw-r--r--src/app/create-identity/create-identity.component.ts6
-rw-r--r--src/app/error-message/error-message.component.html25
-rw-r--r--src/app/gns-page/gns-page.component.html47
-rw-r--r--src/app/gns-page/gns-page.component.spec.ts (renamed from src/app/heroes/heroes.component.spec.ts)12
-rw-r--r--src/app/gns-page/gns-page.component.ts57
-rw-r--r--src/app/heroes/heroes.component.html4
-rw-r--r--src/app/heroes/heroes.component.scss0
-rw-r--r--src/app/heroes/heroes.component.ts20
-rw-r--r--src/app/identity-page/identity-page.component.html61
-rw-r--r--src/app/identity-page/identity-page.component.ts31
-rw-r--r--src/app/messages.service.ts39
-rw-r--r--src/app/namestore-page/namestore-page.component.html3
-rw-r--r--src/app/namestore-page/namestore-page.component.spec.ts25
-rw-r--r--src/app/namestore-page/namestore-page.component.ts14
-rw-r--r--src/app/peerstore-page/peerstore-page.component.html3
-rw-r--r--src/app/peerstore-page/peerstore-page.component.spec.ts25
-rw-r--r--src/app/peerstore-page/peerstore-page.component.ts14
22 files changed, 383 insertions, 76 deletions
diff --git a/src/app/api.service.ts b/src/app/api.service.ts
index 9756bd4..579939d 100644
--- a/src/app/api.service.ts
+++ b/src/app/api.service.ts
@@ -12,11 +12,14 @@ import { MessagesService } from './messages.service';
12export class ApiService { 12export class ApiService {
13 apis: RestAPI[] = [ 13 apis: RestAPI[] = [
14 {name: 'Identity API', desc: 'This is the identity API', link: 'identity'}, 14 {name: 'Identity API', desc: 'This is the identity API', link: 'identity'},
15 {name: 'Rest API 2', desc: 'Lorem ipsum dolor sit amet consectetur adipiscing elit sed, diam dictum inceptos nostra mus enim id scelerisque, nam congue ligula penatibus dui arcu cubilia. Placerat dapibus felis euismod ligula pellentesque facilisi magna eu curae ridiculus arcu venenatis, ad justo auctor mollis faucibus viverra odio netus lectus risus vitae. Quisque morbi dapibus mollis ut cursus leo nascetur vitae aliquet venenatis per sociosqu, vivamus pulvinar risus nunc libero feugiat auctor gravida commodo proin.', link: 'rest_api2'}, 15 {name: 'GNS API', desc: 'This is the gns API', link: 'gns'},
16 {name: 'Rest API 3', desc: 'Lorem ipsum dolor sit amet consectetur adipiscing elit sed, diam dictum inceptos nostra mus enim id scelerisque, nam congue ligula penatibus dui arcu cubilia. Placerat dapibus felis euismod ligula pellentesque facilisi magna eu curae ridiculus arcu venenatis, ad justo auctor mollis faucibus viverra odio netus lectus risus vitae. Quisque morbi dapibus mollis ut cursus leo nascetur vitae aliquet venenatis per sociosqu, vivamus pulvinar risus nunc libero feugiat auctor gravida commodo proin.', link: 'rest_api3'} 16 {name: 'Namestore API', desc: 'This is the namestore API', link: 'namestore'},
17 {name: 'Peerstore API', desc: 'This is the peerstore API', link: 'peerstore'},
17 ]; 18 ];
18 19
19 private identityURL = 'http://localhost:7776/identity'; // URL to GNUnet identity web api 20 private restURL = 'http://localhost:7776/'
21 private identityURL = this.restURL+'identity';
22 private gnsURL = this.restURL+'gns';
20 23
21 constructor(private http: HttpClient, 24 constructor(private http: HttpClient,
22 private messages:MessagesService) { } 25 private messages:MessagesService) { }
@@ -62,6 +65,18 @@ export class ApiService {
62 catchError(this.handleError('changeIdentity', [])) 65 catchError(this.handleError('changeIdentity', []))
63 ); 66 );
64 } 67 }
68
69 searchNameSystem (url: string): Observable<any>{
70 this.messages.dismissError();
71 return this.http.get(this.gnsURL+'/'+url)
72 .pipe(
73 tap(json => this.handleJSON(json)),
74 catchError(this.handleError('searchNameSystem', []))
75 );
76 }
77
78
79
65 /** 80 /**
66 * Handle Http operation that failed. 81 * Handle Http operation that failed.
67 * Let the app continue. 82 * Let the app continue.
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 5d38c0f..82a9d64 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -4,12 +4,18 @@ import { RouterModule, Routes } from '@angular/router';
4import { RestApisComponent } from './rest-apis/rest-apis.component'; 4import { RestApisComponent } from './rest-apis/rest-apis.component';
5import { MainPageComponent } from './main-page/main-page.component'; 5import { MainPageComponent } from './main-page/main-page.component';
6import { IdentityPageComponent } from './identity-page/identity-page.component'; 6import { IdentityPageComponent } from './identity-page/identity-page.component';
7import { GnsPageComponent } from './gns-page/gns-page.component';
8import { PeerstorePageComponent } from './peerstore-page/peerstore-page.component';
9import { NamestorePageComponent } from './namestore-page/namestore-page.component';
7 10
8 11
9const routes: Routes = [ 12const routes: Routes = [
10 { path: '', component: MainPageComponent }, 13 { path: '', component: MainPageComponent },
11 { path: 'apis', component: RestApisComponent }, 14 { path: 'apis', component: RestApisComponent },
12 { path: 'identity', component: IdentityPageComponent } 15 { path: 'identity', component: IdentityPageComponent },
16 { path: 'gns', component: GnsPageComponent },
17 { path: 'peerstore', component: PeerstorePageComponent },
18 { path: 'namestore', component: NamestorePageComponent }
13]; 19];
14 20
15@NgModule({ 21@NgModule({
diff --git a/src/app/app.component.html b/src/app/app.component.html
index c13abbe..7f098f2 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -1,5 +1,5 @@
1<!--The content below is only a placeholder and can be replaced.--> 1<!--The content below is only a placeholder and can be replaced.-->
2<header class="u-bgcolor-purple u-color-white u-p-x3"> 2<header class="c-header u-p-x2">
3 <div class="o-container o-container--size-small"> 3 <div class="o-container o-container--size-small">
4 <div class="o-media o-media--middle"> 4 <div class="o-media o-media--middle">
5 <div class="o-media__fixed"> 5 <div class="o-media__fixed">
@@ -14,6 +14,15 @@
14 <li class="o-list__item"> 14 <li class="o-list__item">
15 <a routerLink="identity" class="c-link">Identity</a> 15 <a routerLink="identity" class="c-link">Identity</a>
16 </li> 16 </li>
17 <li class="o-list__item">
18 <a routerLink="gns" class="c-link">GNS</a>
19 </li>
20 <li class="o-list__item">
21 <a routerLink="namestore" class="c-link">Namestore</a>
22 </li>
23 <li class="o-list__item">
24 <a routerLink="peerstore" class="c-link">Peerstore</a>
25 </li>
17 </ul> 26 </ul>
18 </nav> 27 </nav>
19 </div> 28 </div>
@@ -21,16 +30,23 @@
21 </div> 30 </div>
22</header> 31</header>
23 32
24<main class="u-pv-x3 o-container"> 33<main class="u-mv-x2 o-container">
25 <error-message></error-message> 34 <error-message></error-message>
26 <router-outlet></router-outlet> 35 <router-outlet></router-outlet>
27</main> 36</main>
28 37
29<footer class="u-bgcolor-purple u-color-white u-p-x3"> 38<footer class="c-footer u-p-x2">
30 <div class="o-container o-container--size-small"> 39 <div class="o-container o-container--size-small">
31 <div class="o-media o-media--middle"> 40 <div class="o-media o-media--middle">
32 <div class="o-media__fixed"> 41 <div class="o-media__fixed">
33 <a class="c-link">Impressum</a> 42 <ul class="o-list o-list--inline o-list--gutter-x4">
43 <li class="o-list__item">
44 <a routerLink="/" class="c-link">Impressum</a>
45 </li>
46 <li class="o-list__item">
47 <a routerLink="/" class="c-link">Documentation</a>
48 </li>
49 </ul>
34 </div> 50 </div>
35 <div class="o-media__fluid u-text-right"> 51 <div class="o-media__fluid u-text-right">
36 Copyright things 52 Copyright things
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index c1b600d..80b303f 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -4,7 +4,6 @@ import { FormsModule } from '@angular/forms';
4import { HttpClientModule } from '@angular/common/http'; 4import { HttpClientModule } from '@angular/common/http';
5 5
6import { AppComponent } from './app.component'; 6import { AppComponent } from './app.component';
7import { HeroesComponent } from './heroes/heroes.component';
8import { RestApisComponent } from './rest-apis/rest-apis.component'; 7import { RestApisComponent } from './rest-apis/rest-apis.component';
9import { AppRoutingModule } from './app-routing.module'; 8import { AppRoutingModule } from './app-routing.module';
10import { MainPageComponent } from './main-page/main-page.component'; 9import { MainPageComponent } from './main-page/main-page.component';
@@ -12,17 +11,22 @@ import { IdentityPageComponent } from './identity-page/identity-page.component';
12import { CreateIdentityComponent } from './create-identity/create-identity.component'; 11import { CreateIdentityComponent } from './create-identity/create-identity.component';
13import { MyFilterPipe } from './filter.pipe'; 12import { MyFilterPipe } from './filter.pipe';
14import { ErrorMessageComponent } from './error-message/error-message.component'; 13import { ErrorMessageComponent } from './error-message/error-message.component';
14import { GnsPageComponent } from './gns-page/gns-page.component';
15import { NamestorePageComponent } from './namestore-page/namestore-page.component';
16import { PeerstorePageComponent } from './peerstore-page/peerstore-page.component';
15 17
16@NgModule({ 18@NgModule({
17 declarations: [ 19 declarations: [
18 AppComponent, 20 AppComponent,
19 HeroesComponent,
20 RestApisComponent, 21 RestApisComponent,
21 MainPageComponent, 22 MainPageComponent,
22 IdentityPageComponent, 23 IdentityPageComponent,
23 CreateIdentityComponent, 24 CreateIdentityComponent,
24 MyFilterPipe, 25 MyFilterPipe,
25 ErrorMessageComponent 26 ErrorMessageComponent,
27 GnsPageComponent,
28 NamestorePageComponent,
29 PeerstorePageComponent
26 ], 30 ],
27 imports: [ 31 imports: [
28 BrowserModule, 32 BrowserModule,
diff --git a/src/app/create-identity/create-identity.component.html b/src/app/create-identity/create-identity.component.html
index 328e447..d2e27fe 100644
--- a/src/app/create-identity/create-identity.component.html
+++ b/src/app/create-identity/create-identity.component.html
@@ -1,8 +1,8 @@
1<div class="c-card c-card--no-padding u-p-x3"> 1<div class="c-card u-p-x3">
2 <div class="o-type-20 u-pb-x1" >Create new identity</div> 2 <div class="o-type-20 u-pb-x1" >Create new identity</div>
3 <div class="u-ph-x2"> 3 <div class="o-list o-list--inline">
4 <input [(ngModel)]="this.input_text" type="text" class="c-input" placeholder="Identity Name"/> 4 <input [(ngModel)]="this.input_text" type="text" class="o-list__item c-input" placeholder="Identity Name"/>
5 <span class="u-ph-x3"><a class="c-button" (click)="onClick()">Create</a></span> 5 <a class="o-list__item c-button" (click)="onClick()"><i class="fa fa-plus"></i></a>
6 <span *ngIf="!is_free">Loading... Please wait.</span> 6 <div *ngIf="!is_free" class="o-list__item c-spinner"></div>
7 </div> 7 </div>
8</div> 8</div>
diff --git a/src/app/create-identity/create-identity.component.ts b/src/app/create-identity/create-identity.component.ts
index 2ba7fce..1f20d65 100644
--- a/src/app/create-identity/create-identity.component.ts
+++ b/src/app/create-identity/create-identity.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
2 2
3import { ApiService } from '../api.service'; 3import { ApiService } from '../api.service';
4import { IdentityPageComponent } from '../identity-page/identity-page.component'; 4import { IdentityPageComponent } from '../identity-page/identity-page.component';
5import { MessagesService } from '../messages.service';
5 6
6@Component({ 7@Component({
7 selector: 'create-identity-component', 8 selector: 'create-identity-component',
@@ -14,6 +15,7 @@ export class CreateIdentityComponent implements OnInit {
14 private is_free:boolean = true; 15 private is_free:boolean = true;
15 16
16 constructor(private apiService: ApiService, 17 constructor(private apiService: ApiService,
18 private message: MessagesService,
17 private identity: IdentityPageComponent) { } 19 private identity: IdentityPageComponent) { }
18 20
19 ngOnInit() { 21 ngOnInit() {
@@ -23,12 +25,14 @@ export class CreateIdentityComponent implements OnInit {
23 if (this.input_text != "" && this.is_free){ 25 if (this.input_text != "" && this.is_free){
24 this.is_free = false; 26 this.is_free = false;
25 this.json.name = this.input_text; 27 this.json.name = this.input_text;
28 this.input_text = '';
26 this.apiService.createIdentity(this.json).subscribe(test => { 29 this.apiService.createIdentity(this.json).subscribe(test => {
30 this.message.pushSuccess('Created new identity');
27 this.identity.getAPIs(); 31 this.identity.getAPIs();
28 this.is_free = true; 32 this.is_free = true;
29 }); 33 });
30 } else { 34 } else {
31 alert("No input"); 35 this.message.pushError('Missing input. Define name of new object');
32 } 36 }
33 } 37 }
34 38
diff --git a/src/app/error-message/error-message.component.html b/src/app/error-message/error-message.component.html
index fc7cc10..a481548 100644
--- a/src/app/error-message/error-message.component.html
+++ b/src/app/error-message/error-message.component.html
@@ -1,7 +1,28 @@
1 1
2<div *ngIf="messages.getError()" class="c-error u-mb-x2"> 2<div *ngIf="messages.getError()" class="c-alert c-alert--error u-mb-x2">
3 <div class="o-media"> 3 <div class="o-media">
4 <span class="o-media__fixed u-text-left">Error: {{messages.getError()}}</span> 4 <span class="o-media__fixed u-text-left">Error: {{messages.getError()}}</span>
5 <a class="o-media__fluid u-text-right c-link" (click)="dismissError()">X</a> 5 <a class="o-media__fluid u-text-right c-link" (click)="messages.dismissError()">X</a>
6 </div>
7</div>
8
9<div *ngIf="messages.getWarning()" class="c-alert c-alert--warning u-mb-x2">
10 <div class="o-media">
11 <span class="o-media__fixed u-text-left">Warning: {{messages.getWarning()}}</span>
12 <a class="o-media__fluid u-text-right c-link" (click)="messages.dismissWarning()">X</a>
13 </div>
14</div>
15
16<div *ngIf="messages.getSuccess()" class="c-alert c-alert--success u-mb-x2">
17 <div class="o-media">
18 <span class="o-media__fixed u-text-left">Success: {{messages.getSuccess()}}</span>
19 <a class="o-media__fluid u-text-right c-link" (click)="messages.dismissSuccess()">X</a>
20 </div>
21</div>
22
23<div *ngIf="messages.getInformation()" class="c-alert c-alert--information u-mb-x2">
24 <div class="o-media">
25 <span class="o-media__fixed u-text-left">Information: {{messages.getInformation()}}</span>
26 <a class="o-media__fluid u-text-right c-link" (click)="messages.dismissInformation()">X</a>
6 </div> 27 </div>
7</div> 28</div>
diff --git a/src/app/gns-page/gns-page.component.html b/src/app/gns-page/gns-page.component.html
new file mode 100644
index 0000000..47e5102
--- /dev/null
+++ b/src/app/gns-page/gns-page.component.html
@@ -0,0 +1,47 @@
1<div class="o-grid">
2 <div class="o-grid__col u-1/3">
3 <div class="c-card u-p-x3 u-mr-x2">
4 <div class="o-type-20 u-pb-x1" >Search for namesystem</div>
5 <div class="">
6 Name:<br>
7 <input class="c-input u-2/2" placeholder="Name" [(ngModel)]="gns_name" /><br><br>
8 Record Type (optional):<br>
9 <select class="c-input c-input--select u-2/2" [(ngModel)]="gns_recordtype" name="record_type">
10 <option [value]="0">ANY</option>
11 <option [value]="65536">PKEY</option>
12 <option [value]="65537">NICK</option>
13 <option [value]="65538">LEHO</option>
14 <option [value]="65539">VPN</option>
15 <option [value]="65540">GNS2DNS</option>
16 <option [value]="65541">BOX</option>
17 <option [value]="65542">PLACE</option>
18 <option [value]="65543">PHONE</option>
19 <option [value]="65544">ID_ATTR</option>
20 <option [value]="65545">ID_TOKEN</option>
21 <option [value]="65546">ID_TOKEN_METADATA</option>
22 <option [value]="65547">CREDENTIAL</option>
23 <option [value]="65548">POLICY</option>
24 <option [value]="65549">ATTRIBUTE</option>
25 <option [value]="65550">ABE_KEY</option>
26 <option [value]="65551">ABE_MASTER</option>
27 </select><br><br>
28 Search in:<br>
29 <div class="">
30 <input type="radio" name="options" [(ngModel)]="gns_options" [value]="0"> local namestore, then DHT<br>
31 <input type="radio" name="options" [(ngModel)]="gns_options" [value]="1"> local namestore only<br>
32 <input type="radio" name="options" [(ngModel)]="gns_options" [value]="2"> local namestore only for rightmost label, for others in DHT
33 </div><br>
34 Zone key (optional):<br>
35 <input *ngIf="display_zonekey" class="c-input u-2/2" placeholder="Zone Key" [(ngModel)]="gns_zonekey" (input)="toggleEgo()"/><br><br>
36 <div *ngIf="display_ego">Ego identifier (optional):<br>
37 <input class="c-input u-2/2" placeholder="Ego" [(ngModel)]="gns_ego" (input)="toggleZonekey()" /><br></div>
38 <div class="u-text-right"><a class="c-button u-mt-x2" (click)="onSearch()">Search</a></div>
39 </div>
40 </div>
41 </div>
42 <div class="o-grid__col u-2/3">
43 <div class="c-card u-p-x3">
44 {{gns_response}}
45 </div>
46 </div>
47</div>
diff --git a/src/app/heroes/heroes.component.spec.ts b/src/app/gns-page/gns-page.component.spec.ts
index 66518e4..c76f655 100644
--- a/src/app/heroes/heroes.component.spec.ts
+++ b/src/app/gns-page/gns-page.component.spec.ts
@@ -1,20 +1,20 @@
1import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 1import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 2
3import { HeroesComponent } from './heroes.component'; 3import { GnsPageComponent } from './gns-page.component';
4 4
5describe('HeroesComponent', () => { 5describe('GnsPageComponent', () => {
6 let component: HeroesComponent; 6 let component: GnsPageComponent;
7 let fixture: ComponentFixture<HeroesComponent>; 7 let fixture: ComponentFixture<GnsPageComponent>;
8 8
9 beforeEach(async(() => { 9 beforeEach(async(() => {
10 TestBed.configureTestingModule({ 10 TestBed.configureTestingModule({
11 declarations: [ HeroesComponent ] 11 declarations: [ GnsPageComponent ]
12 }) 12 })
13 .compileComponents(); 13 .compileComponents();
14 })); 14 }));
15 15
16 beforeEach(() => { 16 beforeEach(() => {
17 fixture = TestBed.createComponent(HeroesComponent); 17 fixture = TestBed.createComponent(GnsPageComponent);
18 component = fixture.componentInstance; 18 component = fixture.componentInstance;
19 fixture.detectChanges(); 19 fixture.detectChanges();
20 }); 20 });
diff --git a/src/app/gns-page/gns-page.component.ts b/src/app/gns-page/gns-page.component.ts
new file mode 100644
index 0000000..ea25fc5
--- /dev/null
+++ b/src/app/gns-page/gns-page.component.ts
@@ -0,0 +1,57 @@
1import { Component, OnInit } from '@angular/core';
2import { ApiService } from '../api.service';
3
4@Component({
5 selector: 'gns-page',
6 templateUrl: './gns-page.component.html'
7})
8export class GnsPageComponent implements OnInit {
9
10 private gns_name:string;
11 private gns_recordtype:number = 0;
12 private gns_options:number = 0;
13 private gns_zonekey:string = '';
14 private display_ego: boolean = true;
15 private display_zonekey: boolean = true;
16 private gns_ego:string = '';
17 private gns_response:any =[];
18
19 private url: string;
20
21 constructor(private apiService:ApiService) { }
22
23 ngOnInit() {
24 }
25
26 onSearch(){
27 this.url = '?name='+this.gns_name;
28 if(this.gns_recordtype != null && this.gns_recordtype != ''){
29 this.url += '&record_type='+this.gns_recordtype;
30 }
31 if(this.gns_options != null && this.gns_options != ''){
32 this.url += '&options='+this.gns_options;
33 }
34 if(this.gns_zonekey != null && this.gns_zonekey != ''){
35 this.url += '&pkey='+this.gns_zonekey;
36 }
37 if(this.gns_ego != null && this.gns_ego != ''){
38 this.url += '&ego='+this.gns_ego;
39 }
40 console.log(this.url);
41 this.apiService.searchNameSystem(this.url).subscribe(data => {
42 this.gns_response = data;
43 });
44 }
45
46 toggleEgo(){
47 if(this.gns_zonekey == ''){ this.display_ego = true; }
48 else { this.display_ego = false; }
49 }
50
51 toggleZonekey(){
52 if(this.gns_ego == ''){ this.display_zonekey = true; }
53 else { this.display_zonekey = false; }
54 }
55
56
57}
diff --git a/src/app/heroes/heroes.component.html b/src/app/heroes/heroes.component.html
deleted file mode 100644
index 0bc287b..0000000
--- a/src/app/heroes/heroes.component.html
+++ /dev/null
@@ -1,4 +0,0 @@
1{{hero.name | uppercase}} Details <br>id: {{hero.id}}<br>name: {{hero.name}}
2<br>
3<br>
4<input [(ngModel)]="hero.name" placeholder="name">
diff --git a/src/app/heroes/heroes.component.scss b/src/app/heroes/heroes.component.scss
deleted file mode 100644
index e69de29..0000000
--- a/src/app/heroes/heroes.component.scss
+++ /dev/null
diff --git a/src/app/heroes/heroes.component.ts b/src/app/heroes/heroes.component.ts
deleted file mode 100644
index 0f72ae9..0000000
--- a/src/app/heroes/heroes.component.ts
+++ /dev/null
@@ -1,20 +0,0 @@
1import { Component, OnInit } from '@angular/core';
2import { Hero } from '../hero';
3
4@Component({
5 selector: 'app-heroes',
6 templateUrl: './heroes.component.html',
7 styleUrls: ['./heroes.component.scss']
8})
9export class HeroesComponent implements OnInit {
10 hero: Hero ={
11 id: 1,
12 name: 'Windstorm'
13 };
14
15 constructor() { }
16
17 ngOnInit() {
18 }
19
20}
diff --git a/src/app/identity-page/identity-page.component.html b/src/app/identity-page/identity-page.component.html
index edcac69..4eeb8da 100644
--- a/src/app/identity-page/identity-page.component.html
+++ b/src/app/identity-page/identity-page.component.html
@@ -1,36 +1,33 @@
1 1<div *ngIf="is_displayed">
2<div class="o-grid u-pb-x3"> 2<div class="o-grid">
3 <div class="o-grid__col u-1/2"> 3 <div class="o-grid__col u-1/2">
4 <create-identity-component></create-identity-component> 4 <create-identity-component></create-identity-component>
5 </div> 5 </div>
6 <div class="o-grid__col u-1/2"> 6 <div class="o-grid__col u-1/2">
7 <div class="c-card c-card--no-padding u-p-x3"> 7 <div class="c-card c-card--no-padding u-p-x3">
8 <div class="o-type-20 u-pb-x1" >Search</div> 8 <div class="o-type-20 u-pb-x1" >Search</div>
9 <div class="u-ph-x2"> 9 <div class="">
10 <input #myInput class="c-input" placeholder="Search" [(ngModel)]="name" (input)="filterItem(myInput.value)"/> 10 <input #myInput class="c-input u-2/2" placeholder="Search" [(ngModel)]="name" (input)="filterItem(myInput.value)"/>
11 </div> 11 </div>
12 </div> 12 </div>
13 </div> 13 </div>
14</div> 14</div>
15 15
16<div class="c-card" *ngIf="this.rename"> 16<div class="c-card u-mt-x2">
17 <div class="o-type-20 u-pb-x1" >Search</div> 17 <table class=" u-2/2 c-table">
18 <div class="u-color-grey">ID: <span>{{changeIdentity.id}}</span></div>
19 <div>
20 <span class="u-m-x2">Name: <input class="c-input" placeholder="Change Name" [(ngModel)]="changeIdentity.name"/></span>
21 <a class="c-button u-m-x2" (click)="onRename(changeIdentity)">Rename now</a>
22 <a class="c-button c-button--outline u-m-x2" (click)="onRenameCancel()">Cancel</a>
23 </div>
24</div>
25
26<div class="o-grid c-card u-mt-x3">
27 <table class="o-grid__col u-2/2 c-table">
28 <tr> 18 <tr>
29 <th>Type</th> 19 <th class="u-text-center">Type</th>
30 <th>Name</th> 20 <th>Name</th>
31 <th>ID</th> 21 <th>ID</th>
32 <th>Rename</th> 22 <th class="u-text-center">Rename</th>
33 <th>Delete</th> 23 <th class="u-text-center">Delete</th>
24 </tr>
25 <tr *ngIf="request">
26 <td class="u-text-center"><div class="c-spinner"></div></td>
27 <td class="u-text-center"><div class="c-spinner"></div></td>
28 <td class="u-text-center"><div class="c-spinner"></div></td>
29 <td class="u-text-center"><div class="c-spinner"></div></td>
30 <td class="u-text-center"><div class="c-spinner"></div></td>
34 </tr> 31 </tr>
35 <tr *ngFor="let identity of filteredItems"> 32 <tr *ngFor="let identity of filteredItems">
36 <td class="u-text-center"><span class="fa fa-user o-type-20" *ngIf="identity.type == 'ego'"></span></td> 33 <td class="u-text-center"><span class="fa fa-user o-type-20" *ngIf="identity.type == 'ego'"></span></td>
@@ -38,8 +35,30 @@
38 <span class="">{{identity.name}}</span> 35 <span class="">{{identity.name}}</span>
39 </td> 36 </td>
40 <td>{{identity.id}}</td> 37 <td>{{identity.id}}</td>
41 <td><a class="c-button" (click)="onClickRename(identity)">Rename</a></td> 38 <td class="u-text-center"><a class="c-button c-button--rename" (click)="onClickRename(identity)"><i class="fa fa-pencil"></i></a></td>
42 <td><a class="c-button" (click)="onClickDelete(identity.id)">Delete</a></td> 39 <td class="u-text-center"><a class="c-button c-button--danger" (click)="onClickDelete(identity)"><i class="fa fa-trash"></i></a></td>
43 </tr> 40 </tr>
44 </table> 41 </table>
45</div> 42</div>
43</div>
44
45
46<div class="c-card u-p-x3 u-mt-x2" *ngIf="this.rename">
47 <div class="o-type-20 u-pb-x1" >Rename</div>
48 <div class="u-color-grey">ID: <span>{{changeIdentity.id}}</span></div>
49 <div>
50 <span class="u-mr-x2"><span class="u-mr-x3">Name: </span><input class="c-input" placeholder="Change Name" [(ngModel)]="changeIdentity.name"/></span>
51 <a class="c-button" (click)="onRename(changeIdentity)">Rename</a>
52 <a class="c-button c-button--outline u-m-x2" (click)="onReset()">Cancel</a>
53 </div>
54</div>
55
56<div class="c-card u-p-x3 u-mt-x2" *ngIf="this.delete">
57 <div class="o-type-20 u-pb-x1" >Rename</div>
58 <div >ID: <span>{{changeIdentity.id}}</span></div>
59 <div >Name: <span>{{changeIdentity.name}}</span></div>
60 <div>
61 <a class="c-button" (click)="onDelete(changeIdentity.id)">Delete</a>
62 <a class="c-button c-button--outline u-m-x2" (click)="onReset()">Cancel</a>
63 </div>
64</div>
diff --git a/src/app/identity-page/identity-page.component.ts b/src/app/identity-page/identity-page.component.ts
index 296fe4c..0d6e784 100644
--- a/src/app/identity-page/identity-page.component.ts
+++ b/src/app/identity-page/identity-page.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
2import { Pipe } from "@angular/core"; 2import { Pipe } from "@angular/core";
3import { ApiService } from '../api.service'; 3import { ApiService } from '../api.service';
4import { IdentityAPI } from '../identity-api'; 4import { IdentityAPI } from '../identity-api';
5import { MessagesService } from '../messages.service';
5 6
6@Component({ 7@Component({
7 selector: 'app-identity-page', 8 selector: 'app-identity-page',
@@ -12,14 +13,19 @@ export class IdentityPageComponent implements OnInit {
12 identities: IdentityAPI[]; 13 identities: IdentityAPI[];
13 filteredItems: IdentityAPI[]; 14 filteredItems: IdentityAPI[];
14 rename: boolean = false; 15 rename: boolean = false;
16 delete: boolean = false;
15 changeIdentity: IdentityAPI; 17 changeIdentity: IdentityAPI;
16 json: any; 18 json: any;
19 is_displayed: boolean = true;
20 request: boolean = false;
17 21
18 constructor(private apiService: ApiService) { } 22 constructor(private apiService: ApiService,private message: MessagesService) { }
19 23
20 getAPIs(): void { 24 getAPIs(): void {
25 this.request = true;
21 this.apiService.getIdentities().subscribe(data => { 26 this.apiService.getIdentities().subscribe(data => {
22 this.identities = data; 27 this.identities = data;
28 this.request = false;
23 this.assignCopy(); 29 this.assignCopy();
24 }); 30 });
25 } 31 }
@@ -33,7 +39,7 @@ export class IdentityPageComponent implements OnInit {
33 } 39 }
34 40
35 filterItem(value : string){ 41 filterItem(value : string){
36 this.onRenameCancel(); 42 this.onReset();
37 if(!value) this.assignCopy(); //when nothing has typed 43 if(!value) this.assignCopy(); //when nothing has typed
38 this.filteredItems = Object.assign([], this.identities).filter( 44 this.filteredItems = Object.assign([], this.identities).filter(
39 item => { 45 item => {
@@ -44,27 +50,40 @@ export class IdentityPageComponent implements OnInit {
44 } 50 }
45 51
46 onClickRename(identity: IdentityAPI){ 52 onClickRename(identity: IdentityAPI){
53 this.is_displayed = false;
47 this.rename = true; 54 this.rename = true;
48 this.changeIdentity = Object.assign({},identity); 55 this.changeIdentity = Object.assign({},identity);
49 } 56 }
50 57
51 onRename(identity: IdentityAPI){ 58 onRename(identity: IdentityAPI){
52 this.rename = false; 59 this.request = true;
60 this.onReset();
53 this.filteredItems = []; 61 this.filteredItems = [];
54 this.json = {'newname':identity.name}; 62 this.json = {'newname':identity.name};
55 this.apiService.changeIdentity(identity.id,this.json).subscribe(data => { 63 this.apiService.changeIdentity(identity.id,this.json).subscribe(data => {
64 this.message.pushSuccess('Rename was successful.');
56 this.getAPIs(); 65 this.getAPIs();
57 }); 66 });
58 } 67 }
59 68
60 onRenameCancel(){ 69 onReset(){
61 this.rename = false; 70 this.rename = false;
71 this.delete = false;
72 this.is_displayed = true;
73 }
74
75 onClickDelete(identity: IdentityAPI){
76 this.is_displayed = false;
77 this.delete = true;
78 this.changeIdentity = Object.assign({},identity);
62 } 79 }
63 80
64 onClickDelete(id: string){ 81 onDelete(id:string){
65 this.onRenameCancel(); 82 this.request = true;
83 this.onReset();
66 this.filteredItems = []; 84 this.filteredItems = [];
67 this.apiService.deleteIdentity(id).subscribe(data => { 85 this.apiService.deleteIdentity(id).subscribe(data => {
86 this.message.pushSuccess('Delete was successful.');
68 this.getAPIs(); 87 this.getAPIs();
69 }); 88 });
70 } 89 }
diff --git a/src/app/messages.service.ts b/src/app/messages.service.ts
index 6d18405..0d323bb 100644
--- a/src/app/messages.service.ts
+++ b/src/app/messages.service.ts
@@ -6,6 +6,9 @@ import { Injectable } from '@angular/core';
6export class MessagesService { 6export class MessagesService {
7 7
8 private error:string; 8 private error:string;
9 private warning:string;
10 private info:string;
11 private success:string;
9 12
10 constructor() { } 13 constructor() { }
11 14
@@ -20,4 +23,40 @@ export class MessagesService {
20 dismissError(){ 23 dismissError(){
21 this.error=''; 24 this.error='';
22 } 25 }
26
27 getWarning() :string{
28 return this.warning;
29 }
30
31 pushWarning(errorText:string){
32 this.warning = errorText;
33 }
34
35 dismissWarning(){
36 this.warning='';
37 }
38
39 getSuccess() :string{
40 return this.success;
41 }
42
43 pushSuccess(errorText:string){
44 this.success = errorText;
45 }
46
47 dismissSuccess(){
48 this.success='';
49 }
50
51 getInformation() :string{
52 return this.info;
53 }
54
55 pushInformation(errorText:string){
56 this.info = errorText;
57 }
58
59 dismissInformation(){
60 this.info='';
61 }
23} 62}
diff --git a/src/app/namestore-page/namestore-page.component.html b/src/app/namestore-page/namestore-page.component.html
new file mode 100644
index 0000000..f235c16
--- /dev/null
+++ b/src/app/namestore-page/namestore-page.component.html
@@ -0,0 +1,3 @@
1<p>
2 namestore-page works!
3</p>
diff --git a/src/app/namestore-page/namestore-page.component.spec.ts b/src/app/namestore-page/namestore-page.component.spec.ts
new file mode 100644
index 0000000..540a7cc
--- /dev/null
+++ b/src/app/namestore-page/namestore-page.component.spec.ts
@@ -0,0 +1,25 @@
1import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
3import { NamestorePageComponent } from './namestore-page.component';
4
5describe('NamestorePageComponent', () => {
6 let component: NamestorePageComponent;
7 let fixture: ComponentFixture<NamestorePageComponent>;
8
9 beforeEach(async(() => {
10 TestBed.configureTestingModule({
11 declarations: [ NamestorePageComponent ]
12 })
13 .compileComponents();
14 }));
15
16 beforeEach(() => {
17 fixture = TestBed.createComponent(NamestorePageComponent);
18 component = fixture.componentInstance;
19 fixture.detectChanges();
20 });
21
22 it('should create', () => {
23 expect(component).toBeTruthy();
24 });
25});
diff --git a/src/app/namestore-page/namestore-page.component.ts b/src/app/namestore-page/namestore-page.component.ts
new file mode 100644
index 0000000..ec5cbba
--- /dev/null
+++ b/src/app/namestore-page/namestore-page.component.ts
@@ -0,0 +1,14 @@
1import { Component, OnInit } from '@angular/core';
2
3@Component({
4 selector: 'app-namestore-page',
5 templateUrl: './namestore-page.component.html'
6})
7export class NamestorePageComponent implements OnInit {
8
9 constructor() { }
10
11 ngOnInit() {
12 }
13
14}
diff --git a/src/app/peerstore-page/peerstore-page.component.html b/src/app/peerstore-page/peerstore-page.component.html
new file mode 100644
index 0000000..8bdd960
--- /dev/null
+++ b/src/app/peerstore-page/peerstore-page.component.html
@@ -0,0 +1,3 @@
1<p>
2 peerstore-page works!
3</p>
diff --git a/src/app/peerstore-page/peerstore-page.component.spec.ts b/src/app/peerstore-page/peerstore-page.component.spec.ts
new file mode 100644
index 0000000..f96c645
--- /dev/null
+++ b/src/app/peerstore-page/peerstore-page.component.spec.ts
@@ -0,0 +1,25 @@
1import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
3import { PeerstorePageComponent } from './peerstore-page.component';
4
5describe('PeerstorePageComponent', () => {
6 let component: PeerstorePageComponent;
7 let fixture: ComponentFixture<PeerstorePageComponent>;
8
9 beforeEach(async(() => {
10 TestBed.configureTestingModule({
11 declarations: [ PeerstorePageComponent ]
12 })
13 .compileComponents();
14 }));
15
16 beforeEach(() => {
17 fixture = TestBed.createComponent(PeerstorePageComponent);
18 component = fixture.componentInstance;
19 fixture.detectChanges();
20 });
21
22 it('should create', () => {
23 expect(component).toBeTruthy();
24 });
25});
diff --git a/src/app/peerstore-page/peerstore-page.component.ts b/src/app/peerstore-page/peerstore-page.component.ts
new file mode 100644
index 0000000..6abc3dc
--- /dev/null
+++ b/src/app/peerstore-page/peerstore-page.component.ts
@@ -0,0 +1,14 @@
1import { Component, OnInit } from '@angular/core';
2
3@Component({
4 selector: 'app-peerstore-page',
5 templateUrl: './peerstore-page.component.html'
6})
7export class PeerstorePageComponent implements OnInit {
8
9 constructor() { }
10
11 ngOnInit() {
12 }
13
14}