diff options
Diffstat (limited to 'src/app/create-identity')
3 files changed, 68 insertions, 0 deletions
diff --git a/src/app/create-identity/create-identity.component.html b/src/app/create-identity/create-identity.component.html new file mode 100644 index 0000000..328e447 --- /dev/null +++ b/src/app/create-identity/create-identity.component.html | |||
@@ -0,0 +1,8 @@ | |||
1 | <div class="c-card c-card--no-padding u-p-x3"> | ||
2 | <div class="o-type-20 u-pb-x1" >Create new identity</div> | ||
3 | <div class="u-ph-x2"> | ||
4 | <input [(ngModel)]="this.input_text" type="text" class="c-input" placeholder="Identity Name"/> | ||
5 | <span class="u-ph-x3"><a class="c-button" (click)="onClick()">Create</a></span> | ||
6 | <span *ngIf="!is_free">Loading... Please wait.</span> | ||
7 | </div> | ||
8 | </div> | ||
diff --git a/src/app/create-identity/create-identity.component.spec.ts b/src/app/create-identity/create-identity.component.spec.ts new file mode 100644 index 0000000..cc43e69 --- /dev/null +++ b/src/app/create-identity/create-identity.component.spec.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
2 | |||
3 | import { CreateIdentityComponent } from './create-identity.component'; | ||
4 | |||
5 | describe('CreateIdentityComponent', () => { | ||
6 | let component: CreateIdentityComponent; | ||
7 | let fixture: ComponentFixture<CreateIdentityComponent>; | ||
8 | |||
9 | beforeEach(async(() => { | ||
10 | TestBed.configureTestingModule({ | ||
11 | declarations: [ CreateIdentityComponent ] | ||
12 | }) | ||
13 | .compileComponents(); | ||
14 | })); | ||
15 | |||
16 | beforeEach(() => { | ||
17 | fixture = TestBed.createComponent(CreateIdentityComponent); | ||
18 | component = fixture.componentInstance; | ||
19 | fixture.detectChanges(); | ||
20 | }); | ||
21 | |||
22 | it('should create', () => { | ||
23 | expect(component).toBeTruthy(); | ||
24 | }); | ||
25 | }); | ||
diff --git a/src/app/create-identity/create-identity.component.ts b/src/app/create-identity/create-identity.component.ts new file mode 100644 index 0000000..2ba7fce --- /dev/null +++ b/src/app/create-identity/create-identity.component.ts | |||
@@ -0,0 +1,35 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | ||
2 | |||
3 | import { ApiService } from '../api.service'; | ||
4 | import { IdentityPageComponent } from '../identity-page/identity-page.component'; | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'create-identity-component', | ||
8 | templateUrl: './create-identity.component.html' | ||
9 | }) | ||
10 | export class CreateIdentityComponent implements OnInit { | ||
11 | |||
12 | private input_text: string = ''; | ||
13 | private json: any = {'name':''}; | ||
14 | private is_free:boolean = true; | ||
15 | |||
16 | constructor(private apiService: ApiService, | ||
17 | private identity: IdentityPageComponent) { } | ||
18 | |||
19 | ngOnInit() { | ||
20 | } | ||
21 | |||
22 | onClick() { | ||
23 | if (this.input_text != "" && this.is_free){ | ||
24 | this.is_free = false; | ||
25 | this.json.name = this.input_text; | ||
26 | this.apiService.createIdentity(this.json).subscribe(test => { | ||
27 | this.identity.getAPIs(); | ||
28 | this.is_free = true; | ||
29 | }); | ||
30 | } else { | ||
31 | alert("No input"); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | } | ||