-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add domain namespace annotation editor
- Loading branch information
Showing
8 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export class KeyValue { | ||
key; | ||
value; | ||
} |
3 changes: 3 additions & 0 deletions
3
src/app/shared/domain-namespace-annotations/domain-namespace-annotations.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.border-red { | ||
border: 1px solid red; | ||
} |
48 changes: 48 additions & 0 deletions
48
src/app/shared/domain-namespace-annotations/domain-namespace-annotations.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div class="panel panel-default" > | ||
<div class="panel-heading"> | ||
<div style="display: flex; justify-content: start; align-items: center"> | ||
<div> | ||
{{"Domain namespace annotations creation"}} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="panel-body"> | ||
<div style="display: flex; justify-content: end"> | ||
<button type="button" class="btn btn-success" (click)="addAnnotation()">{{"Add annotation"}}</button> | ||
</div> | ||
<div class="grid flex flex-grow-1"> | ||
<div class="col-4"> | ||
{{'KEY'}} | ||
<!-- <div *ngIf="isKeysUnique === false"><em class="pi pi-exclamation-circle" style="color: red"></em></div>--> | ||
</div> | ||
<div class="col-6"> | ||
{{'VALUE'}} | ||
</div> | ||
</div> | ||
<div class="grid flex flex-grow-1 mt-4 mb-2" *ngFor="let kv of keyValue"> | ||
<div class="flex grid flex-grow-1"> | ||
<div class="col-4"> | ||
<input pInputText type="text" (focusout)="emmitValue()" [(ngModel)]="kv.key" class="flex flex-grow-1" style="width: 100%" [ngClass]="{ 'border-red': isKeyNotUnique(kv.key)}"> | ||
</div> | ||
<div class="col-6"> | ||
<input pInputText type="text" (focusout)="emmitValue()" [(ngModel)]="kv.value" class="flex flex-grow-1" style="width: 100%"> | ||
</div> | ||
<div class="col-2 flex justify-content-end"> | ||
<button type="button" class="btn btn-danger" (click)="deleteAnnotation(kv.key)">Delete</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
<nmaas-modal> | ||
<div class="nmaas-modal-header">{{'DOMAINS.LIST.GROUP' | translate}}</div> | ||
<div class="nmaas-modal-body" style="height: 300px"> | ||
|
||
</div> | ||
<div class="nmaas-modal-footer"> | ||
|
||
</div> | ||
</nmaas-modal> |
23 changes: 23 additions & 0 deletions
23
src/app/shared/domain-namespace-annotations/domain-namespace-annotations.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DomainNamespaceAnnotationsComponent } from './domain-namespace-annotations.component'; | ||
|
||
describe('DomainNamespaceAnnotationsComponent', () => { | ||
let component: DomainNamespaceAnnotationsComponent; | ||
let fixture: ComponentFixture<DomainNamespaceAnnotationsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ DomainNamespaceAnnotationsComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DomainNamespaceAnnotationsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
70 changes: 70 additions & 0 deletions
70
src/app/shared/domain-namespace-annotations/domain-namespace-annotations.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; | ||
import {KeyValue} from '../../model/key-value'; | ||
|
||
@Component({ | ||
selector: 'app-domain-namespace-annotations', | ||
templateUrl: './domain-namespace-annotations.component.html', | ||
styleUrls: ['./domain-namespace-annotations.component.css'] | ||
}) | ||
export class DomainNamespaceAnnotationsComponent implements OnInit { | ||
|
||
@Input() | ||
public annotationRead: KeyValue[]; | ||
|
||
@Output() | ||
public annotations: EventEmitter<KeyValue[]> = new EventEmitter<KeyValue[]>(); | ||
|
||
public keyValue: KeyValue[] = [] | ||
|
||
private keySetNotUnique: string[] = []; | ||
|
||
public isKeysUnique = true; | ||
|
||
constructor() { | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
public emmitValue() { | ||
this.checkDuplicate() | ||
if ( this.isKeysUnique) { | ||
this.annotations.emit(this.keyValue); | ||
} | ||
} | ||
|
||
public checkDuplicate() { | ||
const keySet = new Set<string>(); | ||
this.keyValue.forEach(kv => { | ||
if (keySet.has(kv.key)) { | ||
console.error("duplicated keys in annotations") | ||
this.isKeysUnique = false; | ||
this.keySetNotUnique.push(kv.key) | ||
} else { | ||
keySet.add(kv.key) | ||
} | ||
}) | ||
if (this.keyValue.length === keySet.size) { | ||
this.isKeysUnique = true; | ||
this.keySetNotUnique = []; | ||
} | ||
console.warn("after checking", this.isKeysUnique, keySet) | ||
} | ||
|
||
showModal() { | ||
|
||
} | ||
|
||
addAnnotation() { | ||
this.keyValue.push(new KeyValue()) | ||
} | ||
|
||
deleteAnnotation(key: any) { | ||
this.keyValue = this.keyValue.filter(val => val.key !== key) | ||
} | ||
|
||
public isKeyNotUnique(key: string) { | ||
return this.keySetNotUnique.some(val => val === key) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters