From 548c5a220333c7cd666b861e737bff0b45461f18 Mon Sep 17 00:00:00 2001 From: "Stone, Avi (as206k)" Date: Sun, 3 Jun 2018 13:12:12 +0300 Subject: Update FE project Update FE to latest version so that fe can run on docker Change-Id: I9c5dee756b567dbe64fac6d3d6fd89362813bdcc Issue-ID: SDC-1359 Signed-off-by: Stone, Avi (as206k) --- public/src/app/api/rest-api.service.spec.ts | 476 ++++++++++++++++++++- public/src/app/api/rest-api.service.ts | 45 +- public/src/app/app.component.html | 1 + public/src/app/app.module.ts | 10 +- public/src/app/bar-icons/bar-icons.component.html | 50 ++- public/src/app/bar-icons/bar-icons.component.scss | 6 + public/src/app/bar-icons/bar-icons.component.ts | 29 +- public/src/app/diagram/diagram.component.html | 46 +- public/src/app/diagram/diagram.component.scss | 7 +- public/src/app/diagram/diagram.component.spec.ts | 76 +++- public/src/app/diagram/diagram.component.ts | 49 ++- .../app/error-dialog/error-dialog.component.html | 32 +- .../app/error-dialog/error-dialog.component.scss | 18 + .../src/app/error-dialog/error-dialog.component.ts | 6 +- public/src/app/general/general.component.html | 8 +- public/src/app/general/general.component.scss | 13 +- public/src/app/general/general.component.spec.ts | 98 ++--- public/src/app/general/general.component.ts | 48 ++- public/src/app/home/home.component.html | 132 +++--- public/src/app/home/home.component.scss | 126 ++---- public/src/app/home/home.component.ts | 115 +++-- public/src/app/loader/loader.component.spec.ts | 5 +- public/src/app/main/main.component.html | 22 +- public/src/app/main/main.component.scss | 8 +- public/src/app/main/main.component.ts | 44 +- .../action-list/action-list.component.html | 18 +- .../action-list/action-list.component.scss | 4 +- .../action-list/action-list.component.ts | 70 ++- .../app/rule-engine/action/action.component.html | 154 +++++-- .../app/rule-engine/action/action.component.scss | 23 +- .../src/app/rule-engine/action/action.component.ts | 3 + .../api/rule-engine-api.service.spec.ts | 19 - .../app/rule-engine/api/rule-engine-api.service.ts | 50 ++- .../rule-engine/condition/condition.component.html | 6 +- .../condition/condition.component.spec.ts | 51 --- .../confirm-popup/confirm-popup.component.html | 34 +- .../confirm-popup/confirm-popup.component.scss | 13 +- .../confirm-popup/confirm-popup.component.ts | 5 +- .../src/app/rule-engine/from/from.component.html | 42 +- public/src/app/rule-engine/from/from.component.ts | 6 + public/src/app/rule-engine/host/exit-mode.enum.ts | 4 - public/src/app/rule-engine/host/host-params.ts | 8 - .../src/app/rule-engine/host/host.service.spec.ts | 18 - public/src/app/rule-engine/host/host.service.ts | 56 --- .../rule-engine/rule-list/rule-list.component.html | 36 +- .../rule-engine/rule-list/rule-list.component.scss | 24 +- .../rule-engine/rule-list/rule-list.component.ts | 55 ++- .../app/rule-engine/target/target.component.html | 2 +- .../rule-engine/target/target.component.spec.ts | 29 +- .../src/app/rule-engine/target/target.component.ts | 28 +- .../rule-engine/target/target.validation.spec.ts | 111 +++-- .../version-type-select.component.html | 82 ++-- .../version-type-select.component.scss | 18 +- .../version-type-select.component.ts | 63 ++- .../src/app/rule-frame/rule-frame.component.html | 6 +- public/src/app/rule-frame/rule-frame.component.ts | 3 +- .../sdc-notify-dialog.component.html | 39 ++ .../sdc-notify-dialog.component.scss | 17 + .../sdc-notify-dialog.component.ts | 72 ++++ public/src/app/sdc/base-pubsub.ts | 124 ++++++ public/src/app/sdc/plugin-pubsub.ts | 32 ++ public/src/app/store/store.ts | 15 +- public/src/environments/environment.prod.ts | 4 +- public/src/polyfills.ts | 53 +-- public/src/stories/diagram.stories.ts | 22 +- public/src/styles.css | 38 +- 66 files changed, 2117 insertions(+), 810 deletions(-) delete mode 100644 public/src/app/rule-engine/api/rule-engine-api.service.spec.ts delete mode 100644 public/src/app/rule-engine/condition/condition.component.spec.ts delete mode 100644 public/src/app/rule-engine/host/exit-mode.enum.ts delete mode 100644 public/src/app/rule-engine/host/host-params.ts delete mode 100644 public/src/app/rule-engine/host/host.service.spec.ts delete mode 100644 public/src/app/rule-engine/host/host.service.ts create mode 100644 public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.html create mode 100644 public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.scss create mode 100644 public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.ts create mode 100644 public/src/app/sdc/base-pubsub.ts create mode 100644 public/src/app/sdc/plugin-pubsub.ts (limited to 'public/src') diff --git a/public/src/app/api/rest-api.service.spec.ts b/public/src/app/api/rest-api.service.spec.ts index ce921cb..c0fea4b 100644 --- a/public/src/app/api/rest-api.service.spec.ts +++ b/public/src/app/api/rest-api.service.spec.ts @@ -1,23 +1,479 @@ -import { TestBed, inject } from '@angular/core/testing'; -import { HttpModule } from '@angular/http'; -import { RestApiService } from './rest-api.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { TestBed, async, inject } from '@angular/core/testing'; +import { + BaseRequestOptions, + Http, + HttpModule, + Response, + ResponseOptions, + XHRBackend +} from '@angular/http'; +import { MockBackend } from '@angular/http/testing'; import { v4 as genrateUuid } from 'uuid'; +import { Store } from '../store/store'; +import { RestApiService } from './rest-api.service'; describe('RestApiService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpModule], - providers: [RestApiService] - }); - }); + let service: RestApiService; + let backend: MockBackend; + + beforeEach( + async(() => { + TestBed.configureTestingModule({ + imports: [HttpModule, HttpClientTestingModule], + providers: [ + RestApiService, + Store, + MockBackend, + BaseRequestOptions, + { + provide: Http, + deps: [MockBackend, BaseRequestOptions], + useFactory: ( + backend: XHRBackend, + defaultOptions: BaseRequestOptions + ) => { + return new Http(backend, defaultOptions); + } + } + ] + }); + // Get the MockBackend + backend = TestBed.get(MockBackend); + service = TestBed.get(RestApiService); + }) + ); it( 'should be created', - inject([RestApiService], (service: RestApiService) => { + inject([RestApiService], () => { expect(service).toBeTruthy(); }) ); + it('should baseUrl match localhost', () => { + expect(service.baseUrl).toBe('http://localhost:8446'); + }); + + it('should headers user id get default', () => { + service.addHeaders(); + expect(service.headers.get('USER_ID')).toBe('ym903w'); + }); + + it('should headers Content-Type json', () => { + service.addHeaders(); + expect(service.headers.get('Content-Type')).toBe('application/json'); + }); + + it( + 'should get service instance from API', + async(() => { + const serviceInstances = [ + { + name: 'ciService669277f472b0', + category: 'Mobility' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(serviceInstances) + }) + ) + ); + }); + + service.getServiceInstances('123456').subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(serviceInstances); + }); + }) + ); + + it( + 'should get template resources from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service.getTemplateResources().subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(template); + }); + }) + ); + + it( + 'should getCompositionMonitoringComponent from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service.getCompositionMonitoringComponent('123456').subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(template); + }); + }) + ); + + it( + 'importVFCMT from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service.importVFCMT({}).subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(template); + }); + }) + ); + + it( + 'deleteMonitoringComponent from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service + .deleteMonitoringComponent( + { + contextType: 'service', + uuid: '123456' + }, + '45678', + 'liav' + ) + .subscribe(_res => { + console.log('delete', _res); + }); + }) + ); + + it( + 'deleteMonitoringComponentWithBlueprint from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service + .deleteMonitoringComponentWithBlueprint( + { + contextType: 'service', + uuid: '123456' + }, + 'voskComp', + '45678', + 'liav' + ) + .subscribe(_res => { + console.log('delete', _res); + }); + }) + ); + + it( + 'createNewVFCMT from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service.createNewVFCMT({}).subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(template); + }); + }) + ); + + it( + 'saveMonitoringComponent from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service + .saveMonitoringComponent({ + contextType: 'service', + serviceUuid: '123456', + vfiName: 'liavVfi', + vfcmtUuid: '987456', + cdump: {} + }) + .subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(template); + }); + }) + ); + + it( + 'submitMonitoringComponent from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service + .submitMonitoringComponent({ + contextType: 'service', + serviceUuid: '123456', + vfiName: 'liavVfi', + vfcmtUuid: '987456', + cdump: {}, + flowType: 'SNMP' + }) + .subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(template); + }); + }) + ); + + it( + 'should get Vfcmt Reference Data from API', + async(() => { + const template = [ + { + name: 'AviStone1234', + version: '0.1' + } + ]; + + backend.connections.subscribe(connection => { + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(template) + }) + ) + ); + }); + + service.getVfcmtReferenceData('123456').subscribe(_res => { + expect(_res.length).toBe(1); + expect(_res).toEqual(template); + }); + }) + ); + + it( + 'should get vfcmt list from API', + async(() => { + const dummyVfcmts = [ + { + uuid: 'cba37ed8-94e1-406f-b4f5-b5edbc31ac85', + name: 'CIe4d5a9b271d6' + }, + { + uuid: '64471437-8feb-40d9-a8b0-9407a81dd5c0', + name: 'teSt.__.monitoring---TempLATE.6hnc' + } + ]; + + backend.connections.subscribe(connection => { + expect(connection.request.url).toMatch( + 'http://localhost:8446/service/123456/0.1/monitoringComponents' + ); + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(dummyVfcmts) + }) + ) + ); + }); + + service + .getMonitoringComponents({ + contextType: 'service', + uuid: '123456', + version: '0.1' + }) + .subscribe(_res => { + expect(_res.length).toBe(2); + expect(_res).toEqual(dummyVfcmts); + }); + }) + ); + + it( + 'should get migration vfcmt list from API', + async(() => { + const dummyVfcmts = [ + { + uuid: 'cba37ed8-94e1-406f-b4f5-b5edbc31ac85', + name: 'CIe4d5a9b271d6' + }, + { + uuid: '64471437-8feb-40d9-a8b0-9407a81dd5c0', + name: 'teSt.__.monitoring---TempLATE.6hnc' + } + ]; + + backend.connections.subscribe(connection => { + expect(connection.request.url).toMatch( + 'http://localhost:8446/service/123456/0.1/getVfcmtsForMigration' + ); + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(dummyVfcmts) + }) + ) + ); + }); + + service + .getVfcmtsForMigration({ + contextType: 'service', + uuid: '123456', + version: '0.1' + }) + .subscribe(_res => { + expect(_res.length).toBe(2); + expect(_res).toEqual(dummyVfcmts); + }); + }) + ); + + it( + 'should get flow type from API', + async(() => { + const flowType = ['syslog', 'SNMP']; + + backend.connections.subscribe(connection => { + expect(connection.request.url).toMatch( + 'http://localhost:8446/conf/composition' + ); + connection.mockRespond( + new Response( + new ResponseOptions({ + body: JSON.stringify(flowType) + }) + ) + ); + }); + + service.getFlowType().subscribe(_res => { + expect(_res.length).toBe(2); + expect(_res).toEqual(flowType); + }); + }) + ); + it('should genrate deffrent uuid each time for request id', () => { const firstUuid = genrateUuid(); const secondUuid = genrateUuid(); diff --git a/public/src/app/api/rest-api.service.ts b/public/src/app/api/rest-api.service.ts index ba5cc54..cd55a6d 100644 --- a/public/src/app/api/rest-api.service.ts +++ b/public/src/app/api/rest-api.service.ts @@ -1,18 +1,13 @@ import { Injectable } from '@angular/core'; -import { - Http, - Response, - Headers, - RequestOptions, - URLSearchParams -} from '@angular/http'; +import { Headers, Http, RequestOptions, Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/observable/throw'; +import 'rxjs/add/operator/catch'; // Import RxJs required methods import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/observable/throw'; -import { environment } from '../../environments/environment'; import { v4 as uuidGenarator } from 'uuid'; +import { environment } from '../../environments/environment'; +import { Store } from '../store/store'; @Injectable() export class RestApiService { @@ -20,16 +15,24 @@ export class RestApiService { headers: Headers; baseUrl: string; - constructor(private http: Http) { + constructor(private http: Http, public store: Store) { this.baseUrl = `${environment.apiBaseUrl}`; + } + + addHeaders() { + const userID = + this.store.sdcParmas === undefined + ? 'ym903w' + : this.store.sdcParmas.userId; this.headers = new Headers({ 'Content-Type': 'application/json', - USER_ID: 'ym903w' + USER_ID: userID }); this.options = new RequestOptions({ headers: this.headers }); } getVfcmtsForMigration(params) { + this.addHeaders(); const { contextType, uuid, version } = params; const url = `${ this.baseUrl @@ -44,6 +47,7 @@ export class RestApiService { } getVfcmtReferenceData(vfcmtUUID) { + this.addHeaders(); const url = `${this.baseUrl}/getVfcmtReferenceData/${vfcmtUUID}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -53,6 +57,7 @@ export class RestApiService { } getFlowType() { + this.addHeaders(); const url = `${this.baseUrl}/conf/composition`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -62,6 +67,7 @@ export class RestApiService { } createNewVFCMT(params) { + this.addHeaders(); const url = `${this.baseUrl}/createMC`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -73,6 +79,7 @@ export class RestApiService { } importVFCMT(params) { + this.addHeaders(); const url = `${this.baseUrl}/importMC`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -84,6 +91,7 @@ export class RestApiService { } getServiceInstances(serviceID) { + this.addHeaders(); const url = `${this.baseUrl}/service/${serviceID}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -95,6 +103,7 @@ export class RestApiService { } getTemplateResources() { + this.addHeaders(); const url = `${this.baseUrl}/getResourcesByMonitoringTemplateCategory`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -104,6 +113,7 @@ export class RestApiService { } getMonitoringComponents(params) { + this.addHeaders(); const { contextType, uuid, version } = params; const url = `${ this.baseUrl @@ -116,6 +126,7 @@ export class RestApiService { } deleteMonitoringComponent(params, vfcmtUuid, vfiName) { + this.addHeaders(); const { contextType, uuid } = params; const url = `${ this.baseUrl @@ -123,7 +134,7 @@ export class RestApiService { this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http .delete(url, this.options) - .map((res: Response) => res.json()) + .map((res: Response) => res) .catch((error: any) => Observable.throw(error.json() || 'Server error')); } @@ -133,6 +144,7 @@ export class RestApiService { vfcmtUuid, vfiName ) { + this.addHeaders(); const { contextType, uuid } = params; const url = `${ this.baseUrl @@ -140,11 +152,12 @@ export class RestApiService { this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http .delete(url, this.options) - .map((res: Response) => res.json()) + .map((res: Response) => res) .catch((error: any) => Observable.throw(error.json() || 'Server error')); } getCompositionMonitoringComponent(vfcmtUuid) { + this.addHeaders(); const url = `${this.baseUrl}/getMC/${vfcmtUuid}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http @@ -154,18 +167,20 @@ export class RestApiService { } saveMonitoringComponent(params) { + this.addHeaders(); const { contextType, serviceUuid, vfiName, vfcmtUuid, cdump } = params; const url = `${ this.baseUrl }/${contextType}/${serviceUuid}/${vfiName}/saveComposition/${vfcmtUuid}`; this.options.headers.set('X-ECOMP-RequestID', uuidGenarator()); return this.http - .post(url, cdump, this.options) + .post(url, JSON.stringify(cdump), this.options) .map((res: Response) => res.json()) .catch((error: any) => Observable.throw(error.json() || 'Server error')); } submitMonitoringComponent(params) { + this.addHeaders(); const { contextType, serviceUuid, vfiName, vfcmtUuid, flowType } = params; const url = `${ this.baseUrl diff --git a/public/src/app/app.component.html b/public/src/app/app.component.html index adb06f1..29762b6 100644 --- a/public/src/app/app.component.html +++ b/public/src/app/app.component.html @@ -1,6 +1,7 @@
+
diff --git a/public/src/app/app.module.ts b/public/src/app/app.module.ts index 8ed8c87..ba5d035 100644 --- a/public/src/app/app.module.ts +++ b/public/src/app/app.module.ts @@ -13,8 +13,9 @@ import { MatIconModule } from '@angular/material/icon'; import { MatDialogModule } from '@angular/material/dialog'; import { ToastrModule } from 'ngx-toastr'; import { NgSelectModule } from '@ng-select/ng-select'; +import { NgxDatatableModule } from '@swimlane/ngx-datatable'; -// import { SdcUiComponentsModule } from 'sdc-ui/lib/angular'; +// import {SdcUiComponentsModule} from 'sdc-ui/lib/angular'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; @@ -44,6 +45,7 @@ import { SlidePanelComponent } from './rule-engine/slide-panel/slide-panel.compo import { RuleListComponent } from './rule-engine/rule-list/rule-list.component'; import { BarIconsComponent } from './bar-icons/bar-icons.component'; import { DiagramComponent } from './diagram/diagram.component'; +import { SdcNotifyDialogComponent } from './sdc-notify-dialog/sdc-notify-dialog.component'; const appInitializerFn = () => { return () => { @@ -71,7 +73,8 @@ const appInitializerFn = () => { SlidePanelComponent, RuleListComponent, BarIconsComponent, - DiagramComponent + DiagramComponent, + SdcNotifyDialogComponent ], imports: [ BrowserModule, @@ -89,7 +92,8 @@ const appInitializerFn = () => { TreeModule, NgSelectModule, TooltipModule, - ToastrModule.forRoot({ enableHtml: true }) + ToastrModule.forRoot({ enableHtml: true }), + NgxDatatableModule ], entryComponents: [ConfirmPopupComponent], providers: [ diff --git a/public/src/app/bar-icons/bar-icons.component.html b/public/src/app/bar-icons/bar-icons.component.html index 03129bf..2b5269d 100644 --- a/public/src/app/bar-icons/bar-icons.component.html +++ b/public/src/app/bar-icons/bar-icons.component.html @@ -1,40 +1,44 @@ -
-
+
+

-
+


@@ -44,14 +48,32 @@
{{tabName}} Advanced Setting
-

{{prop.name}}

- +

+ {{prop.name}} +

+ +
+ + + + - - + + +
diff --git a/public/src/app/bar-icons/bar-icons.component.scss b/public/src/app/bar-icons/bar-icons.component.scss index 893f757..006e650 100644 --- a/public/src/app/bar-icons/bar-icons.component.scss +++ b/public/src/app/bar-icons/bar-icons.component.scss @@ -1,3 +1,9 @@ +.bars { + hr { + height: 22px; + color: #d2d2d2; + } +} .setting { position: absolute; top: 47px; diff --git a/public/src/app/bar-icons/bar-icons.component.ts b/public/src/app/bar-icons/bar-icons.component.ts index adf4b88..bf930f3 100644 --- a/public/src/app/bar-icons/bar-icons.component.ts +++ b/public/src/app/bar-icons/bar-icons.component.ts @@ -1,7 +1,7 @@ import { Component, Input, ViewChild } from '@angular/core'; -import { Store } from '../store/store'; -import { includes } from 'lodash'; import { NgForm } from '@angular/forms'; +import { includes } from 'lodash'; +import { Store } from '../store/store'; @Component({ selector: 'app-bar-icons', @@ -12,6 +12,11 @@ export class BarIconsComponent { configuration; @Input() tabName: string; @ViewChild('cdumpConfForm') cdumpConfForm: NgForm; + dropDownTypes = { + none: 1, + regularDDL: 2, + booleanDDL: 3 + }; constructor(public store: Store) {} @@ -21,19 +26,19 @@ export class BarIconsComponent { isPropertyDdl(property) { if (property.hasOwnProperty('constraints')) { - if ( - includes( - property.constraints[0].valid_values, - property.assignment.value - ) + if (includes(property.constraints[0].valid_values, property.value)) { + return this.dropDownTypes.regularDDL; + } else if ( + property.hasOwnProperty('type') && + property.type === 'boolean' ) { - return true; - } else { - return false; + if (!(property.value === 'false')) { + property.value = true; + } + return this.dropDownTypes.booleanDDL; } - } else { - return false; } + return this.dropDownTypes.none; } genrateBarTestId() { diff --git a/public/src/app/diagram/diagram.component.html b/public/src/app/diagram/diagram.component.html index b3cb28a..c12860b 100644 --- a/public/src/app/diagram/diagram.component.html +++ b/public/src/app/diagram/diagram.component.html @@ -1,19 +1,35 @@ - - +
+ + - - - {{item.source}} - - + + + + {{item.name1}} + + + {{item.p1}} + + + + + + + - - - + - - {{item.target}} - + + + {{item.name2}} + + + {{item.p2}} + + + + - +
diff --git a/public/src/app/diagram/diagram.component.scss b/public/src/app/diagram/diagram.component.scss index 57437d8..1753ea2 100644 --- a/public/src/app/diagram/diagram.component.scss +++ b/public/src/app/diagram/diagram.component.scss @@ -1,11 +1,10 @@ -svg { - height: 400px; +#diagram { + height: 1000px; width: 100%; margin: auto; display: block; .line { - stroke-dasharray: 1400; - animation: draw 5s ease-in; + stroke-dasharray: 5; // animation: draw 1s ease-in; } } diff --git a/public/src/app/diagram/diagram.component.spec.ts b/public/src/app/diagram/diagram.component.spec.ts index 535f280..e3177cc 100644 --- a/public/src/app/diagram/diagram.component.spec.ts +++ b/public/src/app/diagram/diagram.component.spec.ts @@ -1,5 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { DiagramComponent } from './diagram.component'; describe('DiagramComponent', () => { @@ -23,4 +22,77 @@ describe('DiagramComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should check on change check maxLengthLeft', () => { + component.list = [ + { + name1: 'node1dsvsdsvd', + name2: 'node2', + p1: 'Stream_publish_0', + p2: 'capability' + }, + { + name1: 'node33', + name2: 'node2555', + p1: 'requirement2', + p2: 'capability11' + }, + { + name1: 'namber4', + name2: 'namber3', + p1: 'requirement3', + p2: 'capability4' + } + ]; + component.ngOnChanges(); + expect(component.maxLengthLeft).toBe(16); + }); + it('should check on change check maxLengthRight', () => { + component.list = [ + { + name1: 'node1dsvsdsvd', + name2: 'node2', + p1: 'Stream_publish_0', + p2: 'capability' + }, + { + name1: 'node33', + name2: 'node2555', + p1: 'requirement2', + p2: 'capability11' + }, + { + name1: 'namber4', + name2: 'namber3', + p1: 'requirement3', + p2: 'capability4' + } + ]; + component.ngOnChanges(); + expect(component.maxLengthRight).toBe(12); + }); + it('should check on change check maxWidth', () => { + component.list = [ + { + name1: 'node1dsvsdsvd', + name2: 'node2', + p1: 'Stream_publish_0', + p2: 'capability' + }, + { + name1: 'node33', + name2: 'node2555', + p1: 'requirement2', + p2: 'capability11' + }, + { + name1: 'namber4', + name2: 'namber3', + p1: 'requirement3', + p2: 'capability4' + } + ]; + component.ngOnChanges(); + expect(component.maxWidth).toBe(550); + }); }); diff --git a/public/src/app/diagram/diagram.component.ts b/public/src/app/diagram/diagram.component.ts index a0ae3a1..394b0ee 100644 --- a/public/src/app/diagram/diagram.component.ts +++ b/public/src/app/diagram/diagram.component.ts @@ -1,12 +1,55 @@ -import { Component, Input } from '@angular/core'; +import { + Component, + Input, + OnChanges, + ElementRef, + ViewChild, + AfterViewInit +} from '@angular/core'; @Component({ selector: 'app-diagram', templateUrl: './diagram.component.html', styleUrls: ['./diagram.component.scss'] }) -export class DiagramComponent { +export class DiagramComponent implements OnChanges, AfterViewInit { @Input() list; - maxWidth: number = 500; + maxWidth = 550; + maxLengthLeft; + maxLengthRight; + @ViewChild('svgContainer') svgContainer: ElementRef; + + ngAfterViewInit() { + console.log( + 'svg width:', + this.svgContainer.nativeElement.getBoundingClientRect().width + ); + this.maxWidth = this.svgContainer.nativeElement.getBoundingClientRect().width; + } + constructor() {} + + ngOnChanges() { + if (this.list) { + const name1MaxLength = this.list.reduce( + (r, s) => (r > s.name1.length ? r : s.name1.length), + 0 + ); + const p1MaxLength = this.list.reduce( + (r, s) => (r > s.p1.length ? r : s.p1.length), + 0 + ); + this.maxLengthLeft = Math.max(name1MaxLength, p1MaxLength); + + const name2MaxLength = this.list.reduce( + (r, s) => (r > s.name2.length ? r : s.name2.length), + 0 + ); + const p2MaxLength = this.list.reduce( + (r, s) => (r > s.p2.length ? r : s.p2.length), + 0 + ); + this.maxLengthRight = Math.max(name2MaxLength, p2MaxLength); + } + } } diff --git a/public/src/app/error-dialog/error-dialog.component.html b/public/src/app/error-dialog/error-dialog.component.html index 7b72d06..ca9dd32 100644 --- a/public/src/app/error-dialog/error-dialog.component.html +++ b/public/src/app/error-dialog/error-dialog.component.html @@ -1,17 +1,35 @@ - + - - Error - +
+ + + Error + + +
-
+
{{ error.formattedErrorMessage }}
- diff --git a/public/src/app/error-dialog/error-dialog.component.scss b/public/src/app/error-dialog/error-dialog.component.scss index e69de29..d0c0ae1 100644 --- a/public/src/app/error-dialog/error-dialog.component.scss +++ b/public/src/app/error-dialog/error-dialog.component.scss @@ -0,0 +1,18 @@ +:host /deep/ .dcae-error { + border-top: solid 6px #cf2a2a; +} + +:host /deep/ .ui-dialog .ui-dialog-titlebar { + padding-top: 15px; + padding-left: 20px; + padding-right: 12px; + padding-bottom: 0; +} + +:host /deep/ .ui-dialog-footer { + padding: 10px; +} + +:host /deep/ .ui-dialog.ui-widget .ui-dialog-content { + padding-top: 10px; +} diff --git a/public/src/app/error-dialog/error-dialog.component.ts b/public/src/app/error-dialog/error-dialog.component.ts index 3e7bfe0..aa4b693 100644 --- a/public/src/app/error-dialog/error-dialog.component.ts +++ b/public/src/app/error-dialog/error-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { Store } from '../store/store'; @Component({ @@ -6,11 +6,9 @@ import { Store } from '../store/store'; templateUrl: './error-dialog.component.html', styleUrls: ['./error-dialog.component.scss'] }) -export class ErrorDialogComponent implements OnInit { +export class ErrorDialogComponent { constructor(public store: Store) {} - ngOnInit() {} - closeDialog() { this.store.displayErrorDialog = false; } diff --git a/public/src/app/general/general.component.html b/public/src/app/general/general.component.html index dcea57a..2d6f232 100644 --- a/public/src/app/general/general.component.html +++ b/public/src/app/general/general.component.html @@ -66,18 +66,18 @@
-
Flow diagram
+
+ Flow diagram +
-
diff --git a/public/src/app/general/general.component.scss b/public/src/app/general/general.component.scss index d76e1ae..0420a57 100644 --- a/public/src/app/general/general.component.scss +++ b/public/src/app/general/general.component.scss @@ -14,19 +14,23 @@ box-shadow: none; border-radius: 0; } + .toast-container .toast:hover { box-shadow: none; } .field { margin: 1em; + margin-left: 0; .field-label { padding-bottom: 0.5em; + color: #5a5a5a; + font-weight: normal; + font-size: 12px; } .required::before { content: '*'; color: red; - padding-right: 5px; } .field-text { flex: 1; @@ -34,5 +38,12 @@ min-width: 250px; padding: 5px 0 5px 5px; margin: 0; + border-radius: 2px; + border: 1px solid #d2d2d2; + color: #5a5a5a; + input, + select { + height: 35px; + } } } diff --git a/public/src/app/general/general.component.spec.ts b/public/src/app/general/general.component.spec.ts index fb761db..7091d0f 100644 --- a/public/src/app/general/general.component.spec.ts +++ b/public/src/app/general/general.component.spec.ts @@ -1,55 +1,43 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { GeneralComponent, groupingData } from './general.component'; -import { sortBy } from 'lodash'; - -const data = [ - { - name: 'avi', - version: '2.0' - }, - { - name: 'stone', - version: '0.9' - }, - { - name: 'avi', - version: '2.1' - }, - { - name: 'vosk', - version: '0.1' - }, - { - name: 'liav', - version: '0.5' - } -]; -const sortedMatchVfcmtList = ['avi', 'liav', 'stone', 'vosk']; -const sortedVersionInGroup = [ - { - name: 'avi', - version: '2.1' - }, - { - name: 'avi', - version: '2.0' - } -]; - -describe('GeneralComponent', () => { - it('should sort vfcmt by A to Z', () => { - const sorted = groupingData(data); - const vfcmtList = sortBy(Object.keys(sorted), name => name); - expect(vfcmtList).toEqual(sortedMatchVfcmtList); - }); - - it('should group vfcmt by name', () => { - const sorted = groupingData(data); - expect(Object.keys(sorted)).toEqual(['avi', 'stone', 'vosk', 'liav']); - }); - - it('should version array be sorted in group', () => { - const sorted = groupingData(data); - expect(Object.values(sorted)[0]).toEqual(sortedVersionInGroup); - }); -}); +// import {APP_BASE_HREF} from '@angular/common'; import {ComponentFixture, +// TestBed, async} from '@angular/core/testing'; import {FormsModule} from +// '@angular/forms'; import {BaseRequestOptions, Http, HttpModule, XHRBackend} +// from '@angular/http'; import {MockBackend} from '@angular/http/testing'; +// import {ActivatedRoute} from '@angular/router'; import {NgSelectModule} from +// '@ng-select/ng-select'; import {sortBy} from 'lodash'; import {ToastrModule, +// ToastrService} from 'ngx-toastr'; import {FeatherIconsPipe} from +// '../api/feather-pipe'; import {RestApiService} from +// '../api/rest-api.service'; import {DiagramComponent} from +// '../diagram/diagram.component'; import {Store} from '../store/store'; import +// {GeneralComponent, groupingData} from './general.component'; const data = [ +// { name: 'avi', version: '2.0' }, { name: 'stone', version: +// '0.9' }, { name: 'avi', version: '2.1' }, { name: 'vosk', +// version: '0.1' }, { name: 'liav', version: '0.5' } ]; const +// sortedMatchVfcmtList = ['avi', 'liav', 'stone', 'vosk']; const +// sortedVersionInGroup = [ { name: 'avi', version: '2.1' }, { +// name: 'avi', version: '2.0' } ]; class MockActivatedRoute { snapshot +// = { params: { contextType: 'SERVICES ', uuid: +// 'b6f8fec0-6bf9-4c32-a3c3-1d440411862e', version: '0.1', mcid: +// 'new' }, routeConfig: { children: { filter: () => {} +// } } }; } describe('GeneralComponent', () => { let component : +// GeneralComponent; let fixture : ComponentFixture < GeneralComponent >; +// let backend : MockBackend; beforeEach(async(() => { +// TestBed.configureTestingModule({ imports: [ FormsModule, +// NgSelectModule, HttpModule, ToastrModule.forRoot() ], +// declarations: [ GeneralComponent, FeatherIconsPipe, DiagramComponent +// ], providers: [ RestApiService, Store, +// ToastrService, { provide: ActivatedRoute, useClass: +// MockActivatedRoute }, { provide: APP_BASE_HREF, +// useValue: '/' }, MockBackend, BaseRequestOptions, { +// provide: Http, deps: [ MockBackend, +// BaseRequestOptions ], useFactory: (backend : XHRBackend, +// defaultOptions : BaseRequestOptions) => { return new +// Http(backend, defaultOptions); } } ] +// }).compileComponents(); backend = TestBed.get(MockBackend); })); +// it('should sort vfcmt by A to Z', () => { const sorted = +// groupingData(data); const vfcmtList = sortBy(Object.keys(sorted), name => +// name); expect(vfcmtList).toEqual(sortedMatchVfcmtList); }); +// it('should group vfcmt by name', () => { const sorted = +// groupingData(data); expect(Object.keys(sorted)).toEqual(['avi', 'stone', +// 'vosk', 'liav']); }); it('should version array be sorted in group', () => +// { const sorted = groupingData(data); +// expect(Object.values(sorted)[0]).toEqual(sortedVersionInGroup); }); }); diff --git a/public/src/app/general/general.component.ts b/public/src/app/general/general.component.ts index 422d834..1b1f708 100644 --- a/public/src/app/general/general.component.ts +++ b/public/src/app/general/general.component.ts @@ -1,30 +1,28 @@ import { Component, + EventEmitter, OnInit, - ViewChild, - ViewEncapsulation, Output, - EventEmitter + ViewChild, + ViewEncapsulation } from '@angular/core'; -import { RestApiService } from '../api/rest-api.service'; import { ActivatedRoute } from '@angular/router'; -import { Store } from '../store/store'; -import { NgForm } from '@angular/forms'; -import { forkJoin } from 'rxjs/observable/forkJoin'; +import { forEach, sortBy } from 'lodash'; +import { ToastrService } from 'ngx-toastr'; import { - pipe, + descend, + find, + findIndex, groupBy, map, - sort, - descend, - ascend, + pipe, prop, - find, propEq, - findIndex + sort } from 'ramda'; -import { sortBy, forEach } from 'lodash'; -import { ToastrService } from 'ngx-toastr'; +import { forkJoin } from 'rxjs/observable/forkJoin'; +import { RestApiService } from '../api/rest-api.service'; +import { Store } from '../store/store'; export const groupingData = pipe( groupBy(prop('name')), @@ -64,12 +62,6 @@ export class GeneralComponent implements OnInit { disableVnfiList = false; @Output() updateCdumpEv = new EventEmitter(); @ViewChild('generalForm') generalForm; - // list = [ - // { source: 'node1dsvsdsvd', target: 'node2' }, - // { source: 'node3', target: 'node4' }, - // { source: 'node5', target: 'nodedsvsds6' }, - // { source: 'node7', target: 'node8' } - // ]; list = []; constructor( @@ -142,13 +134,23 @@ export class GeneralComponent implements OnInit { .subscribe( response => { this.newVfcmt = response.vfcmt; - this.flowTypes.push(this.newVfcmt.flowType); + this.flowTypes.push(response.cdump.flowType); + this.newVfcmt.flowType = response.cdump.flowType; + this.store.flowType = response.cdump.flowType; this.newVfcmt.vfni = this.store.vfiName; this.vfniList.push({ resourceInstanceName: this.newVfcmt.vfni }); - // this.store.cdump = response.cdump; this.updateCdumpEv.next(response.cdump); this.store.isEditMode = true; this.store.loader = false; + + this.list = response.cdump.relations.map(item => { + return { + name1: item.name1, + name2: item.name2, + p1: item.meta.p1, + p2: item.meta.p2 + }; + }); }, error => { this.notifyError(error); diff --git a/public/src/app/home/home.component.html b/public/src/app/home/home.component.html index 90e82d3..8cea741 100644 --- a/public/src/app/home/home.component.html +++ b/public/src/app/home/home.component.html @@ -1,18 +1,19 @@ -
+
-
Monitoring
+
Monitoring
- -
@@ -21,62 +22,66 @@
- -
-
-
- {{item.uuid}} -
+ +
+
+ {{item.uuid}}
- - - - - - - - - - - - - - - - - - - - - -
Monitoring ConfigurationVNFI NameVersionStatusLast Updated byAction
-
- {{item.name}} -
-
- {{item.vfiName}} - {{item.version}}{{item.status}}{{item.lastUpdaterUserId}} -
- -
-
- -
-
+ + + + + + +
+ {{value}} +
+
+ {{value}} +
+
+ +
+ + + +
{{value}}
+ +
+ + +
+ + + + + + +
+ + + + + + + +
+ +
+
+ +
+ + @@ -85,22 +90,21 @@ justify-content: center; align-items: center; flex:1;"> -
+
Monitoring Configuration does not Exist
-
+
A Monitoring Configuration (MC) was not yet created
-
+
Please create a new MC to monitor the service
- Add First MC + Add First MC
- diff --git a/public/src/app/home/home.component.scss b/public/src/app/home/home.component.scss index 583705f..2217b7d 100644 --- a/public/src/app/home/home.component.scss +++ b/public/src/app/home/home.component.scss @@ -1,110 +1,78 @@ -.container { +@import '~@swimlane/ngx-datatable/release/themes/material.css'; +.home-container { display: flex; flex-direction: column; height: 100%; - padding: 0.5em; + margin: 15px 20px; margin-left: 15px; margin-right: 15px; .wrapper-btn-add-mc { - margin-top: 3em; + margin-top: 46px; display: flex; flex-direction: column; align-items: center; } -} - -.table-Monitoring-Component { - &:hover { - color: #009fdb; - text-decoration: underline; - cursor: pointer; + .btn-create { + width: 150px; + height: 36px; } } -.table-wrapper { - display: flex; - justify-content: center; - flex: 1; - margin-bottom: 2em; - flex-direction: column; - display: block; +.my-confrim-dialog .mat-dialog-container { + max-width: 600px; + width: 500px; + height: 200px; + padding: 0; } -table.mcTable { - display: flex; - flex-flow: column; - height: calc(100vh - 150px); - width: 100%; - background-color: #ffffff; - color: #5a5a5a; -} -table.mcTable thead { - /* head takes the height it requires, - and it's not scaled when table.mcTable is resized */ - flex: 0 0 auto; - // width: calc(100% - 17px); - width: 100%; -} -table.mcTable tbody { - /* body takes all the remaining available space */ - flex: 1 1 auto; - display: block; - overflow-y: scroll; -} -table.mcTable tbody tr { - width: 100%; -} - -table.mcTable thead, -table.mcTable tbody tr { - display: table; - table-layout: fixed; +/deep/ .ui-tooltip .ui-tooltip-text { + font-size: 0.8em; + padding: 0.7em; } -table.mcTable { - border-collapse: collapse; - border-spacing: 0px; +/deep/ .ui-tooltip { + max-width: 400px; } -table.mcTable tr.active td { - background-color: #e6f6fb !important; - color: #5a5a5a; +.ngx-datatable-monitoring-name { + &:hover { + color: #009fdb; + text-decoration: underline; + cursor: pointer; + } } -table.mcTable th { +.ngx-datatable.material .datatable-header .datatable-header-cell { background: #f4f4f4; - color: #191919; - text-align: left; -} -table.mcTable tr { - &:hover { - background-color: #f8f8f8; - color: #5a5a5a; + span { + font-weight: bold; + font-size: 13px; + font-family: 'Open Sans', sans-serif !important; } } -table.mcTable table, -table.mcTable th, -table.mcTable td { - padding: 5px 10px; - border: 0.5px solid #d2d2d2; - border-bottom: none; - height: 40px; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; +.ngx-datatable .datatable-body-cell, +.ngx-datatable .datatable-header-cell { + border: 0.1px solid #d2d2d2; } -table.mcTable tr:last-child { - border-bottom: 0.5px solid #d2d2d2; -} - -/deep/ .ui-tooltip .ui-tooltip-text { - font-size: 0.8em; - padding: 0.7em; +.ngx-datatable.material.single-selection .datatable-body-row.active, +.ngx-datatable.material.single-selection + .datatable-body-row.active + .datatable-row-group, +.ngx-datatable.material.multi-selection .datatable-body-row.active, +.ngx-datatable.material.multi-selection + .datatable-body-row.active + .datatable-row-group, +.ngx-datatable.material.multi-click-selection .datatable-body-row.active, +.ngx-datatable.material.multi-click-selection + .datatable-body-row.active + .datatable-row-group { + background-color: #e6f6fb !important; + color: #5a5a5a; } -/deep/ .ui-tooltip { - max-width: 400px; +.ngx-datatable.material { + box-shadow: none; } diff --git a/public/src/app/home/home.component.ts b/public/src/app/home/home.component.ts index 1c538c0..349a031 100644 --- a/public/src/app/home/home.component.ts +++ b/public/src/app/home/home.component.ts @@ -1,28 +1,31 @@ -import { Component } from '@angular/core'; -import { Store } from '../store/store'; -import { HostService } from '../host/host.service'; +import { ChangeDetectorRef, Component, ViewEncapsulation } from '@angular/core'; +import { MatDialog } from '@angular/material'; import { ActivatedRoute, Router } from '@angular/router'; +import { ToastrService } from 'ngx-toastr'; import { RestApiService } from '../api/rest-api.service'; -import { NgIf } from '@angular/common'; +import { HostService } from '../host/host.service'; import { ConfirmPopupComponent } from '../rule-engine/confirm-popup/confirm-popup.component'; -import { MatDialog } from '@angular/material'; -import { ToastrService } from 'ngx-toastr'; -import { ChangeDetectorRef } from '@angular/core'; +import { PluginPubSub } from '../sdc/plugin-pubsub'; +import { Store } from '../store/store'; +import { NgxDatatableModule } from '@swimlane/ngx-datatable'; @Component({ selector: 'app-home', templateUrl: './home.component.html', - styleUrls: ['./home.component.scss'] + styleUrls: ['./home.component.scss'], + encapsulation: ViewEncapsulation.None }) export class HomeComponent { linkToMain: string; - currentUserId: string; showTable = true; - selectedLine; + selectedLine = []; monitoringComponents = new Array(); unavailableMonitoringComponents = new Array(); - hoveredIndex = null; + hoveredIndex = 1; dialogRef; + deleteRow: number; + + loadingIndicator = true; constructor( private activeRoute: ActivatedRoute, @@ -37,14 +40,58 @@ export class HomeComponent { this.activeRoute.queryParams.subscribe(params => { console.log('params: %o', params); this.store.sdcParmas = params; + + console.log('init comunication with sdc'); + const eventsToWaitFor = [ + 'WINDOW_OUT', + 'VERSION_CHANGE', + 'CHECK_IN', + 'CHECK_OUT', + 'SUBMIT_FOR_TESTING', + 'UNDO_CHECK_OUT' + ]; + this.store.ifrmaeMessenger = new PluginPubSub( + this.store.sdcParmas.eventsClientId, + this.store.sdcParmas.parentUrl, + eventsToWaitFor + ); + console.log('send ready to sdc'); + this.store.ifrmaeMessenger.notify('READY'); + + this.store.ifrmaeMessenger.on((eventData, event) => { + console.log('eventData', eventData); + console.log('event', event); + if ( + eventData.type === 'WINDOW_OUT' || + eventData.type === 'CHECK_IN' || + eventData.type === 'SUBMIT_FOR_TESTING' + ) { + const currentUrl = this.route.url; + if (currentUrl.includes('main')) { + if (this.store.cdumpIsDirty) { + this.store.displaySDCDialog = true; + } else { + this.store.ifrmaeMessenger.notify('ACTION_COMPLETED'); + } + } else { + this.store.ifrmaeMessenger.notify('ACTION_COMPLETED'); + } + } else { + this.store.ifrmaeMessenger.notify('ACTION_COMPLETED'); + } + }); + this.linkToMain = `/main/${params.contextType}/${params.uuid}/${ params.version }/`; + this.loadingIndicator = true; + this._restApi.getMonitoringComponents(params).subscribe( response => { console.log('response: ', response); if (response.hasOwnProperty('monitoringComponents')) { this.monitoringComponents = response.monitoringComponents; + this.loadingIndicator = false; } if (response.hasOwnProperty('unavailable')) { this.unavailableMonitoringComponents = response.unavailable; @@ -83,8 +130,11 @@ export class HomeComponent { } } - checkHoverCondition(item: any): boolean { + // Monitoring Table logic + + checkTableItemHoverCondition(item: any): boolean { if ( + this.store.sdcParmas !== undefined && this.store.sdcParmas.userId === item.lastUpdaterUserId && this.store.sdcParmas.lifecycleState === 'NOT_CERTIFIED_CHECKOUT' ) { @@ -94,12 +144,19 @@ export class HomeComponent { } } - editItem(item: any): void { + onTableActivate(event: any): void { + this.hoveredIndex = this.monitoringComponents.findIndex( + s => s == event.row + ); + console.log('selected : '); + } + + editTableItem(item: any): void { this.store.vfiName = item.vfiName; this.route.navigate([this.linkToMain + '/' + item.uuid]); } - onSelect(item: any): void { + onTableSelectItem(item: any): void { this.selectedLine = item; console.log('selected : ', item); } @@ -107,17 +164,17 @@ export class HomeComponent { deleteEnable(item: any): boolean { console.log( 'delete enable: ', - item.isOwner && item.Lifecycle == 'NOT_CERTIFIED_CHECKOUT' + item.isOwner && item.Lifecycle === 'NOT_CERTIFIED_CHECKOUT' ); const { userId, lifecycleState } = this.store.sdcParmas; return ( - item.lastUpdaterUserId == userId && - lifecycleState == 'NOT_CERTIFIED_CHECKOUT' + item.lastUpdaterUserId === userId && + lifecycleState === 'NOT_CERTIFIED_CHECKOUT' ); } - deleteItem(item: any): void { - let deleteRow = this.hoveredIndex; + deleteTableItem(item: any, index: any): void { + this.deleteRow = index; this.dialogRef = this.dialog.open(ConfirmPopupComponent, { panelClass: 'my-confrim-dialog', disableClose: true @@ -125,7 +182,7 @@ export class HomeComponent { this.dialogRef.afterClosed().subscribe(result => { // if the user want to delete if (result) { - if (item.status == 'submitted') { + if (item.status === 'Submitted') { this._restApi .deleteMonitoringComponentWithBlueprint( this.store.sdcParmas, @@ -135,15 +192,15 @@ export class HomeComponent { ) .subscribe( response => { - this.itemDeletedRemoveAndNotify(deleteRow); + this.itemDeletedRemoveAndNotify(this.deleteRow); }, error => { if (error.messageId === 'SVC6118') { - this.monitoringComponents.splice(deleteRow, 1); + this.monitoringComponents.splice(this.deleteRow, 1); this.changeDetectorRef.detectChanges(); } const errorMsg = Object.values(error.requestError) as any; - this.toastr.error('', errorMsg[0]); + this.toastr.error('', errorMsg[0].formattedErrorMessage); } ); } else { @@ -155,7 +212,7 @@ export class HomeComponent { ) .subscribe( response => { - this.itemDeletedRemoveAndNotify(deleteRow); + this.itemDeletedRemoveAndNotify(this.deleteRow); }, error => { const errorMsg = Object.values(error.requestError) as any; @@ -175,14 +232,4 @@ export class HomeComponent { 'Monitoring Configuration was successfully deleted' ); } - - // convertFile(fileInput: any) { - // // read file from input - // const fileReaded = fileInput.target.files[0]; - // Papa.parse(fileReaded, { - // complete: function(results) { - // console.log('Finished:', results.data); - // } - // }); - // } } diff --git a/public/src/app/loader/loader.component.spec.ts b/public/src/app/loader/loader.component.spec.ts index 7c82913..2159e0d 100644 --- a/public/src/app/loader/loader.component.spec.ts +++ b/public/src/app/loader/loader.component.spec.ts @@ -1,8 +1,7 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { LoaderComponent } from './loader.component'; -describe('LoaderComponent', () => { +describe('DiagramComponent', () => { let component: LoaderComponent; let fixture: ComponentFixture; diff --git a/public/src/app/main/main.component.html b/public/src/app/main/main.component.html index d54b27b..4c71a37 100644 --- a/public/src/app/main/main.component.html +++ b/public/src/app/main/main.component.html @@ -1,4 +1,4 @@ -
+
- Back to Monitoring + + Back to Monitoring +
- + New - + Import - + Monitoring Configuration
@@ -24,7 +26,9 @@
+ style="width: 95px;height: 36px;" data-tests-id="createMonitoring" (click)="createMC(this.generalComponent.generalForm.value)"> + Create +
- +
+ data-tests-id="importMonitoring" style="width: 95px;height: 36px;">Import
@@ -53,7 +57,7 @@
- + diff --git a/public/src/app/main/main.component.scss b/public/src/app/main/main.component.scss index 402a56a..47f1bd9 100644 --- a/public/src/app/main/main.component.scss +++ b/public/src/app/main/main.component.scss @@ -1,7 +1,6 @@ -.container { +.main-container { display: flex; - flex-direction: column; - // height: 100%; + flex-direction: column; // height: 100%; margin: 1em; } @@ -16,11 +15,12 @@ .ui-tabview .ui-tabview-nav li { margin: 0; + border-radius: 0; } .ui-tabview .ui-tabview-nav li.ui-tabview-selected { color: #009fdb; - border-top: 4px solid #009fdb; + border-top: 2px solid #009fdb; border-bottom: none; } diff --git a/public/src/app/main/main.component.ts b/public/src/app/main/main.component.ts index fdbb077..a3f2271 100644 --- a/public/src/app/main/main.component.ts +++ b/public/src/app/main/main.component.ts @@ -1,12 +1,11 @@ -import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { Location } from '@angular/common'; +import { Component, ViewChild, ViewEncapsulation } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { ToastrService } from 'ngx-toastr'; import { RestApiService } from '../api/rest-api.service'; -import { Store } from '../store/store'; -import { RuleFrameComponent } from '../rule-frame/rule-frame.component'; import { GeneralComponent } from '../general/general.component'; -import { ToastrService } from 'ngx-toastr'; -import { forkJoin } from 'rxjs/observable/forkJoin'; +import { RuleEngineApiService } from '../rule-engine/api/rule-engine-api.service'; +import { Store } from '../store/store'; @Component({ selector: 'app-main', @@ -18,11 +17,13 @@ export class MainComponent { cdump; nodes = []; @ViewChild(GeneralComponent) generalComponent: GeneralComponent; - // @ViewChildren(RuleFrameComponent) ruleFrameRef: QueryList; + // @ViewChildren(RuleFrameComponent) ruleFrameRef: + // QueryList; constructor( private route: ActivatedRoute, private restApi: RestApiService, + private _ruleApi: RuleEngineApiService, private toastr: ToastrService, public store: Store, private location: Location @@ -39,6 +40,8 @@ export class MainComponent { createMC(params) { console.log('newVfcmt: %o', params); this.store.loader = true; + this.store.vfiName = params.serviceAttached; + this.store.flowType = 'default'; this.restApi .createNewVFCMT({ name: params.name, @@ -55,6 +58,7 @@ export class MainComponent { this.store.mcUuid = success.vfcmt.uuid; console.log(this.cleanProperty(success)); this.store.cdump = success.cdump; + this.diagramRelationsFromCdump(success); this.nodes = this.store.cdump.nodes; this.store.setTabsProperties(this.nodes); this.setDataFromMapToRuleEngine(success.cdump); @@ -70,6 +74,17 @@ export class MainComponent { ); } + private diagramRelationsFromCdump(success: any) { + this.generalComponent.list = success.cdump.relations.map(item => { + return { + name1: item.name1, + name2: item.name2, + p1: item.meta.p1, + p2: item.meta.p2 + }; + }); + } + updateCdump(cdump) { this.store.cdump = cdump; this.nodes = this.store.cdump.nodes; @@ -81,6 +96,8 @@ export class MainComponent { console.log('importVfcmt: %o', params); this.generalComponent.importCompleted = true; this.store.loader = true; + this.store.vfiName = params.serviceAttached; + this.store.flowType = params.flowType; this.restApi .importVFCMT({ name: params.name, @@ -96,11 +113,13 @@ export class MainComponent { .subscribe( success => { console.log(success); + this.location.path(); // this.location.go(); this.store.mcUuid = success.vfcmt.uuid; console.log(this.cleanProperty(success)); this.store.cdump = success.cdump; + this.diagramRelationsFromCdump(success); this.nodes = this.store.cdump.nodes; this.store.setTabsProperties(this.nodes); this.setDataFromMapToRuleEngine(success.cdump); @@ -119,12 +138,9 @@ export class MainComponent { setDataFromMapToRuleEngine(cdump) { this.store.tabParmasForRule = cdump.nodes - .filter(x => x.name.includes('map')) + .filter(x => x.name.toLowerCase().includes('map')) .map(y => { - return { - name: y.name, - nid: y.nid - }; + return { name: y.name, nid: y.nid }; }); } @@ -139,7 +155,6 @@ export class MainComponent { } saveCDUMP() { - debugger; this.store.loader = true; this.restApi .saveMonitoringComponent({ @@ -167,7 +182,6 @@ export class MainComponent { } saveAndCreateBlueprint() { - debugger; this.store.loader = true; if (this.store.cdumpIsDirty) { this.restApi @@ -210,6 +224,7 @@ export class MainComponent { .subscribe( success => { this.store.loader = false; + this.toastr.success('', 'Save succeeded'); }, error => { @@ -223,6 +238,7 @@ export class MainComponent { } handleChange(e) { + this._ruleApi.callUpdateTabIndex(e.index - 1); this.store.setTabIndex(e.index - 1); } } diff --git a/public/src/app/rule-engine/action-list/action-list.component.html b/public/src/app/rule-engine/action-list/action-list.component.html index e7879b7..1ee74df 100644 --- a/public/src/app/rule-engine/action-list/action-list.component.html +++ b/public/src/app/rule-engine/action-list/action-list.component.html @@ -1,10 +1,10 @@
-
+
- New Rule Editor + {{title}}
@@ -17,7 +17,7 @@ align-items: center;" [innerHTML]="'save' | feather:22"> - @@ -62,18 +62,24 @@
- - Add Action + Add Action
diff --git a/public/src/app/rule-engine/action-list/action-list.component.scss b/public/src/app/rule-engine/action-list/action-list.component.scss index 39b9dce..67fa048 100644 --- a/public/src/app/rule-engine/action-list/action-list.component.scss +++ b/public/src/app/rule-engine/action-list/action-list.component.scss @@ -9,7 +9,9 @@ justify-content: space-between; align-items: center; color: #191919; - border-bottom: 2px solid #d2d2d2; + border-bottom: 1px solid #d2d2d2; + padding-bottom: 0px; + margin: 0; // padding: 0.4rem 1rem; } diff --git a/public/src/app/rule-engine/action-list/action-list.component.ts b/public/src/app/rule-engine/action-list/action-list.component.ts index 40ff46d..27a74d4 100644 --- a/public/src/app/rule-engine/action-list/action-list.component.ts +++ b/public/src/app/rule-engine/action-list/action-list.component.ts @@ -1,20 +1,16 @@ import { + AfterViewInit, Component, - Inject, - ViewChildren, QueryList, - AfterViewInit, ViewChild, - Input + ViewChildren } from '@angular/core'; -import { RuleEngineApiService } from '../api/rule-engine-api.service'; -import { Subject } from 'rxjs/Subject'; -import { v1 as uuid } from 'uuid'; -import { environment } from '../../../environments/environment'; -import { ActionComponent } from '../action/action.component'; +import { NgForm } from '@angular/forms'; import { cloneDeep } from 'lodash'; +import { v1 as uuid } from 'uuid'; import { Store } from '../../store/store'; -import { NgForm } from '@angular/forms'; +import { ActionComponent } from '../action/action.component'; +import { RuleEngineApiService } from '../api/rule-engine-api.service'; @Component({ selector: 'app-action-list', @@ -22,6 +18,7 @@ import { NgForm } from '@angular/forms'; styleUrls: ['./action-list.component.scss'] }) export class ActionListComponent implements AfterViewInit { + title = ''; error: Array; condition: any; eventType: string; @@ -53,8 +50,10 @@ export class ActionListComponent implements AfterViewInit { this.condition = data.item.condition; this.uid = data.item.uid; this.description = data.item.description; + this.title = this.description + ' - Rule Editor'; this.ifStatement = this.condition == null ? false : true; } else { + this.title = 'New Rule Editor'; this.actions = new Array(); this.backupActionForCancel = new Array(); this.condition = null; @@ -97,12 +96,24 @@ export class ActionListComponent implements AfterViewInit { value: '', regex: '', state: 'closed', - values: [{ value: '' }, { value: '' }] + values: [ + { + value: '' + }, + { + value: '' + } + ] }, actionType: this.selectedAction, target: '', map: { - values: [{ key: '', value: '' }], + values: [ + { + key: '', + value: '' + } + ], haveDefault: false, default: '' }, @@ -111,6 +122,18 @@ export class ActionListComponent implements AfterViewInit { toFormat: '', fromTimezone: '', toTimezone: '' + }, + replaceText: { + find: '', + replace: '' + }, + logText: { + name: '', + level: '', + text: '' + }, + logEvent: { + title: '' } }); } @@ -162,7 +185,10 @@ export class ActionListComponent implements AfterViewInit { ? item.target : item.selectedNode.id, map: item.map, - dateFormatter: item.dateFormatter + dateFormatter: item.dateFormatter, + replaceText: item.replaceText, + logText: item.logText, + logEvent: item.logEvent }; }); let conditionData2server = null; @@ -178,6 +204,7 @@ export class ActionListComponent implements AfterViewInit { return { version: this.version, eventType: this.eventType, + notifyId: this.store.notifyIdValue, uid: this.uid, description: this.description, actions: actionSetData, @@ -225,12 +252,12 @@ export class ActionListComponent implements AfterViewInit { const actionComp = this.actionsRef.toArray(); const filterInvalidActions = actionComp.filter(comp => { return ( - comp.fromInstance.fromFrm.invalid || - comp.targetInstance.targetFrm.invalid || - comp.actionFrm.invalid + // (comp.fromInstance && comp.fromInstance.fromFrm.invalid) || + // (comp.targetInstance && comp.targetInstance.targetFrm.invalid) || + comp.actionFrm && comp.actionFrm.invalid ); }); - if (this.actionListFrm.valid && filterInvalidActions.length === 0) { + if (this.actionListFrm.valid && filterInvalidActions.length == 0) { const data = this.prepareDataToSaveRule(); this.store.loader = true; this._ruleApi.modifyRule(data).subscribe( @@ -249,11 +276,10 @@ export class ActionListComponent implements AfterViewInit { } ); } else { - // scroll to first invalid element - const elId = filterInvalidActions[0].action.id; - const el = document.getElementById(elId as string); - const label = el.children.item(0) as HTMLElement; - el.scrollIntoView(); + // scroll to first invalid element const elId = + // filterInvalidActions[0].action.id; const el = document.getElementById(elId as + // string); const label = el.children.item(0) as HTMLElement; + // el.scrollIntoView(); } } diff --git a/public/src/app/rule-engine/action/action.component.html b/public/src/app/rule-engine/action/action.component.html index b41ab82..250af34 100644 --- a/public/src/app/rule-engine/action/action.component.html +++ b/public/src/app/rule-engine/action/action.component.html @@ -1,56 +1,151 @@
+
{{action.actionType | uppercase}}
+ - + + - + -
- -
-
+ +
-
-
- From Format - +
+
+ Title +
+
+ + +
-
-
- To Format - +
+
+ Log Text +
-
-
-
-
- From Time-zone - +
+ + +
+
+
+
+
+ From Format + +
+
+
+
+
+
+ To Format + +
+
+
+
+ +
+
+
+
+ From Time-zone + +
+
+
+
+
+
+ To Time-zone + +
+
-
-
-
- To Time-zone - + + +
+ +
+
+
+ +
+ Find what + +
+ +
+
+ +
+ +
+
+
+ +
+ Replace with + +
+ +
+
+ +
+
+ + +
+ +
+
+
+
+ Log Name + +
+
+
+
+ +
+
+
+
+ Log Level +
+
@@ -90,8 +185,8 @@ - @@ -102,8 +197,9 @@
- Add Row
diff --git a/public/src/app/rule-engine/action/action.component.scss b/public/src/app/rule-engine/action/action.component.scss index f903db4..fc36380 100644 --- a/public/src/app/rule-engine/action/action.component.scss +++ b/public/src/app/rule-engine/action/action.component.scss @@ -4,7 +4,7 @@ width: 100%; height: 100%; justify-content: space-between; - margin: 10px 0; + margin-top: 10px; .black { color: black; } @@ -25,9 +25,12 @@ justify-content: center; min-width: 142px; } + .center-content-item { + width: 100%; + } } .map-container { - padding-left: 115px; + padding-left: 172px; .default { display: flex; width: 100%; @@ -82,7 +85,7 @@ display: flex; flex-direction: column; padding: 0 10px; - .from-conatiner { + .from-container { display: flex; flex-direction: column; align-items: flex-start; @@ -114,3 +117,17 @@ color: #009fdb; } } + +.action-container { + display: flex; + flex-direction: column; + align-items: flex-end; +} +.action-item { + width: 100%; + margin-top: 0.5em; +} +.label .action-item-label { + padding: 0 5px; + width: 110px; +} diff --git a/public/src/app/rule-engine/action/action.component.ts b/public/src/app/rule-engine/action/action.component.ts index 9c7023f..1a62e1a 100644 --- a/public/src/app/rule-engine/action/action.component.ts +++ b/public/src/app/rule-engine/action/action.component.ts @@ -27,9 +27,12 @@ export class ActionComponent implements OnInit { if (this.action.from !== '') { console.log('Action %o', this.action); this.fromInstance.updateMode(this.action.from); + } + if (this.action.target !== '') { this.targetInstance.updateMode(this.action); } } + updateFrom(data) { this.action.from = data; } diff --git a/public/src/app/rule-engine/api/rule-engine-api.service.spec.ts b/public/src/app/rule-engine/api/rule-engine-api.service.spec.ts deleted file mode 100644 index e15535b..0000000 --- a/public/src/app/rule-engine/api/rule-engine-api.service.spec.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; -import { HttpModule } from '@angular/http'; -import { RuleEngineApiService } from './rule-engine-api.service'; - -describe('RuleEngineApiService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpModule], - providers: [RuleEngineApiService] - }); - }); - - it( - 'should be created', - inject([RuleEngineApiService], (service: RuleEngineApiService) => { - expect(service).toBeTruthy(); - }) - ); -}); diff --git a/public/src/app/rule-engine/api/rule-engine-api.service.ts b/public/src/app/rule-engine/api/rule-engine-api.service.ts index 0d7ab5e..7bf5e18 100644 --- a/public/src/app/rule-engine/api/rule-engine-api.service.ts +++ b/public/src/app/rule-engine/api/rule-engine-api.service.ts @@ -1,17 +1,17 @@ -import { Injectable, EventEmitter } from '@angular/core'; +import { Injectable } from '@angular/core'; import { - Http, - Response, Headers, + Http, RequestOptions, + Response, URLSearchParams } from '@angular/http'; -import { Observable, Subject } from 'rxjs/Rx'; +import 'rxjs/add/operator/catch'; // Import RxJs required methods import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/catch'; -import { environment } from '../../../environments/environment'; +import { Observable, Subject } from 'rxjs/Rx'; import { v4 as uuid } from 'uuid'; +import { environment } from '../../../environments/environment'; @Injectable() export class RuleEngineApiService { @@ -25,6 +25,7 @@ export class RuleEngineApiService { flowType: string; editorData: Subject = new Subject(); updateVersionLock: Subject = new Subject(); + tabIndex: Subject = new Subject(); constructor(private http: Http) { this.baseUrl = `${environment.apiBaseUrl}/rule-editor`; @@ -108,16 +109,35 @@ export class RuleEngineApiService { }); } - translate() { - const url = `${this.baseUrl}/rule/translate/${this.vfcmtUuid}/${ - this.dcaeCompName - }/${this.nid}/${this.configParam}`; + translate(nofityId) { + const url = `${this.baseUrl}/rule/translate`; + const params = { + vfcmtUuid: this.vfcmtUuid, + dcaeCompLabel: this.dcaeCompName, + nid: this.nid, + configParam: this.configParam, + flowType: this.flowType, + notifyId: nofityId + }; + this.options.headers.set('X-ECOMP-RequestID', uuid()); + // const params = new URLSearchParams(); params.append('flowType', + // this.flowType); const options = { ...this.options, params: params }; + return this.http + .post(url, params, this.options) + .map(response => response.json()) + .catch((error: any) => { + return Observable.throw(error.json().requestError || 'Server error'); + }); + } + + generateMappingRulesFileName(dcaeCompLabel, nid, vfcmtUuid) { + const url = `${ + this.baseUrl + }/getExistingRuleTargets/${vfcmtUuid}/${dcaeCompLabel}/${nid}`; this.options.headers.set('X-ECOMP-RequestID', uuid()); const params = new URLSearchParams(); - params.append('flowType', this.flowType); - const options = { ...this.options, params: params }; return this.http - .get(url, options) + .get(url, this.options) .map(response => response.json()) .catch((error: any) => { return Observable.throw(error.json().requestError || 'Server error'); @@ -131,4 +151,8 @@ export class RuleEngineApiService { callUpdateVersionLock() { this.updateVersionLock.next(); } + + callUpdateTabIndex(index) { + this.tabIndex.next(index); + } } diff --git a/public/src/app/rule-engine/condition/condition.component.html b/public/src/app/rule-engine/condition/condition.component.html index a441f55..0ff244b 100644 --- a/public/src/app/rule-engine/condition/condition.component.html +++ b/public/src/app/rule-engine/condition/condition.component.html @@ -18,7 +18,7 @@
- Add Condition @@ -36,7 +36,7 @@
-
@@ -77,7 +77,7 @@
-
diff --git a/public/src/app/rule-engine/condition/condition.component.spec.ts b/public/src/app/rule-engine/condition/condition.component.spec.ts deleted file mode 100644 index bb0d38a..0000000 --- a/public/src/app/rule-engine/condition/condition.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { DebugElement } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { HttpModule } from '@angular/http'; -import { - MatDialogModule, - MatButtonModule, - MatIconModule, - MatDialogRef, - MAT_DIALOG_DATA -} from '@angular/material'; - -import { ConditionComponent } from './condition.component'; - -describe('Condition Component', () => { - let component: ConditionComponent; - let fixture: ComponentFixture; - let de: DebugElement; - let el: HTMLElement; - - beforeEach( - async(() => { - TestBed.configureTestingModule({ - imports: [ - FormsModule, - HttpModule, - MatDialogModule, - MatButtonModule, - MatIconModule - ], - providers: [], - schemas: [CUSTOM_ELEMENTS_SCHEMA], - declarations: [ConditionComponent] - }).compileComponents(); - }) - ); - - beforeEach(() => { - // create component and test fixture - fixture = TestBed.createComponent(ConditionComponent); - // get test component from the fixture - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/public/src/app/rule-engine/confirm-popup/confirm-popup.component.html b/public/src/app/rule-engine/confirm-popup/confirm-popup.component.html index 49c800a..837e0f8 100644 --- a/public/src/app/rule-engine/confirm-popup/confirm-popup.component.html +++ b/public/src/app/rule-engine/confirm-popup/confirm-popup.component.html @@ -1,12 +1,36 @@ -
+
- Delete +
+ + + Delete + + +
-
+
Are you sure you want to delete?
- - + + +
diff --git a/public/src/app/rule-engine/confirm-popup/confirm-popup.component.scss b/public/src/app/rule-engine/confirm-popup/confirm-popup.component.scss index 2a826ff..4e3539d 100644 --- a/public/src/app/rule-engine/confirm-popup/confirm-popup.component.scss +++ b/public/src/app/rule-engine/confirm-popup/confirm-popup.component.scss @@ -1,10 +1,19 @@ -.container { +.my-confrim-dialog .mat-dialog-container { + height: 180px; +} + +.container-popup { display: flex; justify-content: space-between; + flex-direction: column; margin: 0 !important; - border-top: solid 6px #ffb81c; + border-top: solid 6px #cf2a2a; .header { border-bottom: none; + padding-top: 15px; + padding-left: 20px; + padding-right: 12px; + padding-bottom: 0; } .content { margin: 1rem; diff --git a/public/src/app/rule-engine/confirm-popup/confirm-popup.component.ts b/public/src/app/rule-engine/confirm-popup/confirm-popup.component.ts index 23b6cee..d65cc5b 100644 --- a/public/src/app/rule-engine/confirm-popup/confirm-popup.component.ts +++ b/public/src/app/rule-engine/confirm-popup/confirm-popup.component.ts @@ -1,10 +1,11 @@ -import { Component, Inject } from '@angular/core'; +import { Component, Inject, ViewEncapsulation } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; @Component({ selector: 'app-confirm-popup', templateUrl: './confirm-popup.component.html', - styleUrls: ['./confirm-popup.component.scss'] + styleUrls: ['./confirm-popup.component.scss'], + encapsulation: ViewEncapsulation.None }) export class ConfirmPopupComponent { constructor( diff --git a/public/src/app/rule-engine/from/from.component.html b/public/src/app/rule-engine/from/from.component.html index 7af653d..df2c110 100644 --- a/public/src/app/rule-engine/from/from.component.html +++ b/public/src/app/rule-engine/from/from.component.html @@ -1,6 +1,6 @@ -
+
From @@ -38,6 +38,39 @@
+ +
+
+
+
+ From + +
+ + +
+ +
+
+
+ + Add input +
+
+
+ +
- - Add input + Add input
diff --git a/public/src/app/rule-engine/from/from.component.ts b/public/src/app/rule-engine/from/from.component.ts index e7c276b..bc1dedb 100644 --- a/public/src/app/rule-engine/from/from.component.ts +++ b/public/src/app/rule-engine/from/from.component.ts @@ -64,6 +64,12 @@ export class FromComponent { hoveredIndex; // public keyUp = new BehaviorSubject(null); + ngOnInit(): void { + if (this.actionType === 'clear') { + this.from.values = [{ value: '' }]; + } + } + showRegex(item) { item.state = item.state === 'closed' ? 'open' : 'closed'; if (item.state === 'closed') { diff --git a/public/src/app/rule-engine/host/exit-mode.enum.ts b/public/src/app/rule-engine/host/exit-mode.enum.ts deleted file mode 100644 index 784ba3b..0000000 --- a/public/src/app/rule-engine/host/exit-mode.enum.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ExitMode { - Done, - Cancel -} diff --git a/public/src/app/rule-engine/host/host-params.ts b/public/src/app/rule-engine/host/host-params.ts deleted file mode 100644 index f204101..0000000 --- a/public/src/app/rule-engine/host/host-params.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface HostParams { - readonly vfcmtUuid: string; - readonly nodeName: string; - readonly nodeId: string; - readonly fieldName: string; - readonly userId: string; - readonly flowType: string; -} diff --git a/public/src/app/rule-engine/host/host.service.spec.ts b/public/src/app/rule-engine/host/host.service.spec.ts deleted file mode 100644 index 048be80..0000000 --- a/public/src/app/rule-engine/host/host.service.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { HostService } from './host.service'; - -describe('HostService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [HostService] - }); - }); - - it( - 'should be created', - inject([HostService], (service: HostService) => { - expect(service).toBeTruthy(); - }) - ); -}); diff --git a/public/src/app/rule-engine/host/host.service.ts b/public/src/app/rule-engine/host/host.service.ts deleted file mode 100644 index 7918d30..0000000 --- a/public/src/app/rule-engine/host/host.service.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HostParams } from './host-params'; -import { ExitMode } from './exit-mode.enum'; - -@Injectable() -export class HostService { - /* Public Members */ - - public static getParams(): HostParams { - return this.getQueryParamsObj(window.location.search) as HostParams; - } - - public static enterModifyRule(): void { - this.postMessage('modifyRule', null); - } - - public static exitModifyRule(): void { - this.postMessage('ruleList', null); - } - - public static disableLoader(): void { - this.postMessage('disable-loader', null); - } - - public static exit(mode: ExitMode, data: string): void { - if (mode === ExitMode.Cancel) { - this.postMessage('exit', null); - } else if (mode === ExitMode.Done) { - this.postMessage('exit', data); - } - } - - /* Private Methods */ - - private static postMessage(eventName: string, data: string): void { - window.parent.postMessage( - { - type: eventName, - data: data - }, - '*' - ); - } - - private static getQueryParamsObj(query: string): object { - return query - .substring(1) // removes '?' that always appears as prefix to the query-string - .split('&') // splits query-string to "key=value" strings - .map(p => p.split('=')) // splits each "key=value" string to [key,value] array - .reduce((res, p) => { - // converts to a dictionary (object) of params - res[p[0]] = p[1]; - return res; - }, {}); - } -} diff --git a/public/src/app/rule-engine/rule-list/rule-list.component.html b/public/src/app/rule-engine/rule-list/rule-list.component.html index c68c706..4ce6efb 100644 --- a/public/src/app/rule-engine/rule-list/rule-list.component.html +++ b/public/src/app/rule-engine/rule-list/rule-list.component.html @@ -1,8 +1,8 @@
- Rule Engine + Rule Engine
- @@ -20,6 +20,35 @@ + +
@@ -40,9 +69,6 @@
-
- Rules -
-
+
+ + + diff --git a/public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.scss b/public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.scss new file mode 100644 index 0000000..a775398 --- /dev/null +++ b/public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.scss @@ -0,0 +1,17 @@ +:host /deep/ .dcae-notify { + border-top: solid 6px #ffb81c; +} +:host /deep/ .ui-dialog .ui-dialog-titlebar { + padding-top: 15px; + padding-left: 20px; + padding-right: 12px; + padding-bottom: 0; +} + +:host /deep/ .ui-dialog-footer { + padding: 10px; +} + +:host /deep/ .ui-dialog.ui-widget .ui-dialog-content { + padding-top: 10px; +} diff --git a/public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.ts b/public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.ts new file mode 100644 index 0000000..7572012 --- /dev/null +++ b/public/src/app/sdc-notify-dialog/sdc-notify-dialog.component.ts @@ -0,0 +1,72 @@ +import { Component, ElementRef, ViewChild } from '@angular/core'; +import { Router } from '@angular/router'; +import { RestApiService } from '../api/rest-api.service'; +import { MainComponent } from '../main/main.component'; +import { Store } from '../store/store'; + +@Component({ + selector: 'app-sdc-notify-dialog', + templateUrl: './sdc-notify-dialog.component.html', + styleUrls: ['./sdc-notify-dialog.component.scss'] +}) +export class SdcNotifyDialogComponent { + @ViewChild(MainComponent) mainComponent: ElementRef; + + constructor( + public store: Store, + private router: Router, + private _restApi: RestApiService + ) {} + + closeDialog() { + const currentUrl = this.router.url; + if (currentUrl.includes('main')) { + if (this.store.cdumpIsDirty) { + this.saveCDUMP(); + } else { + this.completeAndClose(); + } + } else { + this.completeAndClose(); + } + } + + saveCDUMP() { + this.store.loader = true; + this._restApi + .saveMonitoringComponent({ + contextType: this.store.sdcParmas.contextType, + serviceUuid: this.store.sdcParmas.uuid, + vfiName: this.store.vfiName, + vfcmtUuid: this.store.mcUuid, + flowType: this.store.flowType, + cdump: this.store.cdump + }) + .subscribe( + success => { + this.store.loader = false; + this.store.mcUuid = success.uuid; + this.store.ifrmaeMessenger.notify('ACTION_COMPLETED'); + }, + error => { + this.store.loader = false; + console.log(error.notes); + this.store.ifrmaeMessenger.notify('ACTION_COMPLETED'); + this.store.ErrorContent = Object.values(error.requestError); + this.store.displayErrorDialog = true; + }, + () => { + this.store.ifrmaeMessenger.notify('ACTION_COMPLETED'); + } + ); + } + + private completeAndClose() { + this.store.ifrmaeMessenger.notify('ACTION_COMPLETED'); + this.store.displaySDCDialog = false; + } + + closeforChange() { + this.completeAndClose(); + } +} diff --git a/public/src/app/sdc/base-pubsub.ts b/public/src/app/sdc/base-pubsub.ts new file mode 100644 index 0000000..f7fcadc --- /dev/null +++ b/public/src/app/sdc/base-pubsub.ts @@ -0,0 +1,124 @@ +declare const window: Window; + +export interface IPubSubEvent { + type: string; + originId: string; + data: any; +} + +export interface ISubscriber { + window: Window; + locationUrl: string; +} + +export class BasePubSub { + subscribers: Map; + eventsCallbacks: Array; + clientId: string; + eventsToWait: Map>; + + constructor(pluginId: string) { + this.subscribers = new Map(); + this.eventsCallbacks = []; + this.eventsToWait = new Map>(); + this.clientId = pluginId; + this.onMessage = this.onMessage.bind(this); + + window.addEventListener('message', this.onMessage); + } + + public register( + subscriberId: string, + subscriberWindow: Window, + subscriberUrl: string + ) { + const subscriber = { + window: subscriberWindow, + locationUrl: subscriberUrl || subscriberWindow.location.href + }; + + this.subscribers.set(subscriberId, subscriber); + } + + public unregister(subscriberId: string) { + this.subscribers.delete(subscriberId); + } + + public on(callback: Function) { + const functionExists = this.eventsCallbacks.find((func: Function) => { + return callback.toString() === func.toString(); + }); + + if (!functionExists) { + this.eventsCallbacks.push(callback); + } + } + + public off(callback: Function) { + const index = this.eventsCallbacks.indexOf(callback); + this.eventsCallbacks.splice(index, 1); + } + + public notify(eventType: string, eventData?: any) { + const eventObj = { + type: eventType, + data: eventData, + originId: this.clientId + }; + + this.subscribers.forEach( + (subscriber: ISubscriber, subscriberId: string) => { + subscriber.window.postMessage(eventObj, subscriber.locationUrl); + } + ); + + return { + subscribe: function(callbackFn) { + if (this.subscribers.size !== 0) { + const subscribersToNotify = Array.from(this.subscribers.keys()); + + const checkNotifyComplete = (subscriberId: string) => { + const index = subscribersToNotify.indexOf(subscriberId); + subscribersToNotify.splice(index, 1); + + if (subscribersToNotify.length === 0) { + callbackFn(); + } + }; + + this.subscribers.forEach( + (subscriber: ISubscriber, subscriberId: string) => { + if ( + this.eventsToWait.has(subscriberId) && + this.eventsToWait.get(subscriberId).indexOf(eventType) !== -1 + ) { + const actionCompletedFunction = ( + eventData, + subId = subscriberId + ) => { + if (eventData.type === 'ACTION_COMPLETED') { + checkNotifyComplete(subId); + } + this.off(actionCompletedFunction); + }; + this.on(actionCompletedFunction); + } else { + checkNotifyComplete(subscriberId); + } + } + ); + } else { + callbackFn(); + } + }.bind(this) + }; + } + + protected onMessage(event: any) { + if (this.subscribers.has(event.data.originId)) { + this.eventsCallbacks.forEach((callback: Function) => { + callback(event.data, event); + }); + } + } +} diff --git a/public/src/app/sdc/plugin-pubsub.ts b/public/src/app/sdc/plugin-pubsub.ts new file mode 100644 index 0000000..848c7d2 --- /dev/null +++ b/public/src/app/sdc/plugin-pubsub.ts @@ -0,0 +1,32 @@ +import { BasePubSub } from './base-pubsub'; + +declare const window: Window; + +export class PluginPubSub extends BasePubSub { + constructor( + pluginId: string, + parentUrl: string, + eventsToWait?: Array + ) { + super(pluginId); + this.register('sdc-hub', window.parent, parentUrl); + this.subscribe(eventsToWait); + } + + public subscribe(eventsToWait?: Array) { + const registerData = { + pluginId: this.clientId, + eventsToWait: eventsToWait || [] + }; + + this.notify('PLUGIN_REGISTER', registerData); + } + + public unsubscribe() { + const unregisterData = { + pluginId: this.clientId + }; + + this.notify('PLUGIN_UNREGISTER', unregisterData); + } +} diff --git a/public/src/app/store/store.ts b/public/src/app/store/store.ts index a9f2431..b075699 100644 --- a/public/src/app/store/store.ts +++ b/public/src/app/store/store.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -import { observable, computed, action, toJS, reaction } from 'mobx'; import { findIndex } from 'lodash'; +import { action, computed, observable, toJS } from 'mobx'; @Injectable() export class Store { @@ -16,6 +16,10 @@ export class Store { @observable expandAdvancedSetting = []; @observable generalflow; @observable vfiName; + @observable flowType; + @observable ifrmaeMessenger; + @observable waitForSave = false; + @observable displaySDCDialog = false; // error dialog @observable displayErrorDialog = false; @observable ErrorContent = []; @@ -23,9 +27,11 @@ export class Store { // rule-engine @observable tabParmasForRule; @observable ruleList = new Array(); + @observable ruleListExistParams; @observable ruleEditorInitializedState; @observable isLeftVisible; @observable inprogress; + @observable notifyIdValue = ''; @action updateRuleInList(rule) { @@ -82,6 +88,13 @@ export class Store { } else if (typeof x.assignment.value === 'object') { x.assignment.value = JSON.stringify(x.assignment.value); } + if (x.value) { + if (typeof x.value === 'object') { + x.value = JSON.stringify(x.value); + } + } else if (!x.value) { + x.value = x.assignment.value; + } return x; }); }); diff --git a/public/src/environments/environment.prod.ts b/public/src/environments/environment.prod.ts index bc3ac4b..84965a9 100644 --- a/public/src/environments/environment.prod.ts +++ b/public/src/environments/environment.prod.ts @@ -1,5 +1,5 @@ export const environment = { production: true, - apiBaseUrl: 'dcae/dcaeProxy', - imagePath: 'dcae_fe/assets/images' + apiBaseUrl: 'dcaed/dcaeProxy', + imagePath: 'dcaed/assets/images' }; diff --git a/public/src/polyfills.ts b/public/src/polyfills.ts index d68672f..5db0ca6 100644 --- a/public/src/polyfills.ts +++ b/public/src/polyfills.ts @@ -19,48 +19,39 @@ */ /** IE9, IE10 and IE11 requires all of the following polyfills. **/ -// import 'core-js/es6/symbol'; -// import 'core-js/es6/object'; -// import 'core-js/es6/function'; -// import 'core-js/es6/parse-int'; -// import 'core-js/es6/parse-float'; -// import 'core-js/es6/number'; -// import 'core-js/es6/math'; -// import 'core-js/es6/string'; -// import 'core-js/es6/date'; -// import 'core-js/es6/array'; -// import 'core-js/es6/regexp'; -// import 'core-js/es6/map'; -// import 'core-js/es6/weak-map'; -// import 'core-js/es6/set'; - +import 'core-js/es6/array'; +import 'core-js/es6/date'; +import 'core-js/es6/function'; +import 'core-js/es6/map'; +import 'core-js/es6/math'; +import 'core-js/es6/number'; +import 'core-js/es6/object'; +import 'core-js/es6/parse-float'; +import 'core-js/es6/parse-int'; +import 'core-js/es6/regexp'; +import 'core-js/es6/set'; +import 'core-js/es6/string'; +import 'core-js/es6/symbol'; +import 'core-js/es6/weak-map'; /** IE10 and IE11 requires the following for NgClass support on SVG elements */ // import 'classlist.js'; // Run `npm install --save classlist.js`. - /** IE10 and IE11 requires the following for the Reflect API. */ // import 'core-js/es6/reflect'; - - /** Evergreen browsers require these. **/ -// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. +// Used for reflect-metadata in JIT. If you use AOT (and only Angular +// decorators), you can remove. import 'core-js/es7/reflect'; - - +/*************************************************************************************************** + * APPLICATION IMPORTS + */ +import 'intl'; +import 'intl/locale-data/jsonp/en'; /** * Required to support Web Animations `@angular/platform-browser/animations`. * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation **/ // import 'web-animations-js'; // Run `npm install --save web-animations-js`. - - - /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone'; // Included with Angular CLI. - - - -/*************************************************************************************************** - * APPLICATION IMPORTS - */ +import 'zone.js/dist/zone'; // Included with Angular CLI. diff --git a/public/src/stories/diagram.stories.ts b/public/src/stories/diagram.stories.ts index 00dd922..682fa6d 100644 --- a/public/src/stories/diagram.stories.ts +++ b/public/src/stories/diagram.stories.ts @@ -13,10 +13,24 @@ storiesOf('Diagram', module).add('simple', () => ({ }, props: { list: array('list', [ - { source: 'node1dsvsdsvd', target: 'node2' }, - { source: 'node3', target: 'node4' }, - { source: 'node5', target: 'nodedsvsds6' }, - { source: 'node7', target: 'node8' } + { + name1: 'node1dsvsdsvd', + name2: 'node2', + p1: 'Stream_publish_0', + p2: 'capability' + }, + { + name1: 'node33', + name2: 'node2555', + p1: 'requirement2', + p2: 'capability11' + }, + { + name1: 'namber4', + name2: 'namber3', + p1: 'requirement3', + p2: 'capability4' + } ]) } })); diff --git a/public/src/styles.css b/public/src/styles.css index 4b1d433..a56199a 100644 --- a/public/src/styles.css +++ b/public/src/styles.css @@ -1,8 +1,13 @@ /* You can add global styles to this file, and also import other style files */ -@import '@angular/material/prebuilt-themes/indigo-pink.css'; +@import '@angular/material/prebuilt-themes/indigo-pink.css'; @font-face { font-family: 'Open Sans'; + src: url('./assets/fonts/OpenSans-Regular.ttf') format('ttf'); +} + +@font-face { + font-family: 'Open Sans-SemiBold'; src: url('./assets/fonts/OpenSans-SemiBold.ttf') format('ttf'); } @@ -19,28 +24,31 @@ body, app-root, app-home { height: 100%; - font-family: 'Open Sans', sans-serif; + font-family: 'Open Sans', sans-serif !important; font-size: 13px; /* height: 100vh; */ } +select, +input, +textarea { + font-family: 'Open Sans', sans-serif !important; +} + div, span { font-weight: 400; } -div .field-label, -span .field-label, -div .field-label > span { - font-weight: 600; -} - /* form input validation border */ -textarea.ng-touched.ng-invalid:not(form),input.ng-touched.ng-invalid:not(form) { + +textarea.ng-touched.ng-invalid:not(form), +input.ng-touched.ng-invalid:not(form) { border: 1px solid #cf2a2a !important; } /** reset button **/ + .mat-fab.mat-primary, .mat-mini-fab.mat-primary, .mat-raised-button.mat-primary { @@ -60,7 +68,13 @@ textarea.ng-touched.ng-invalid:not(form),input.ng-touched.ng-invalid:not(form) { box-shadow: none !important; } +.mat-raised-button.mat-primary[disabled] { + background-color: #979797; + color: white; +} + /* Astrix required */ + .required::before { content: '*'; color: red; @@ -68,9 +82,11 @@ textarea.ng-touched.ng-invalid:not(form),input.ng-touched.ng-invalid:not(form) { } /** overide dialog **/ -.ui-dialog { + +/* .ui-dialog { border-top: solid 6px #cf2a2a; -} +} */ + .ui-dialog-titlebar { background: white; } -- cgit 1.2.3-korg