From b45d377a6114b2e3f6bcfbbaee1ce9668b91e0aa Mon Sep 17 00:00:00 2001 From: Lvbo163 Date: Fri, 1 Sep 2017 14:31:04 +0800 Subject: support setting microservice info support setting microservice info for workflow Issue-ID: SDC-266 Change-Id: I8c6ad2a95f63a86db0789f9c400be38131404b66 Signed-off-by: Lvbo163 --- .../src/app/components/menu/menu.component.css | 19 +++++++ .../src/app/components/menu/menu.component.html | 24 ++++++++ .../src/app/components/menu/menu.component.spec.ts | 36 ++++++++++++ .../src/app/components/menu/menu.component.ts | 37 +++++++++++++ .../microservice-detail.component.html | 33 +++++++++++ .../microservice-detail.component.ts | 60 ++++++++++++++++++++ .../microservice-list.component.css | 15 +++++ .../microservice-list.component.html | 32 +++++++++++ .../microservice-list.component.ts | 64 ++++++++++++++++++++++ .../menu/microservice/microservice.component.html | 39 +++++++++++++ .../menu/microservice/microservice.component.ts | 46 ++++++++++++++++ .../src/app/components/menus/menu.component.css | 19 ------- .../src/app/components/menus/menu.component.html | 20 ------- .../app/components/menus/menu.component.spec.ts | 36 ------------ .../src/app/components/menus/menu.component.ts | 33 ----------- 15 files changed, 405 insertions(+), 108 deletions(-) create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/menu.component.css create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/menu.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/menu.component.spec.ts create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/menu.component.ts create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.ts create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.css create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.ts create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.ts delete mode 100644 sdc-workflow-designer-ui/src/app/components/menus/menu.component.css delete mode 100644 sdc-workflow-designer-ui/src/app/components/menus/menu.component.html delete mode 100644 sdc-workflow-designer-ui/src/app/components/menus/menu.component.spec.ts delete mode 100644 sdc-workflow-designer-ui/src/app/components/menus/menu.component.ts (limited to 'sdc-workflow-designer-ui/src/app/components') diff --git a/sdc-workflow-designer-ui/src/app/components/menu/menu.component.css b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.css new file mode 100644 index 00000000..2fa48afa --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.css @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ + +.btn-right{ + float: right; +} + +button i{ + padding-right: 3px; +} diff --git a/sdc-workflow-designer-ui/src/app/components/menu/menu.component.html b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.html new file mode 100644 index 00000000..16234898 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.html @@ -0,0 +1,24 @@ + + +
+ + + +
+ diff --git a/sdc-workflow-designer-ui/src/app/components/menu/menu.component.spec.ts b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.spec.ts new file mode 100644 index 00000000..b80edce7 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.spec.ts @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MenuComponent } from './menu.component'; + +describe('MenuComponent', () => { + let component: MenuComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MenuComponent] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MenuComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sdc-workflow-designer-ui/src/app/components/menu/menu.component.ts b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.ts new file mode 100644 index 00000000..2c03cbfc --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.ts @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ +import { Component, OnInit, ViewChild } from '@angular/core'; + +import { WorkflowService } from '../../services/workflow.service'; +import { MicroserviceComponent } from "./microservice/microservice.component"; + +@Component({ + selector: 'b4t-menu', + templateUrl: './menu.component.html', + styleUrls: ['./menu.component.css'] +}) +export class MenuComponent { + @ViewChild(MicroserviceComponent) public microserviceComponent: MicroserviceComponent; + + constructor(private workflowService: WorkflowService) { } + + public save(): void { + this.workflowService.save(); + } + + public showMicroserviceModal(): void { + this.microserviceComponent.show(); + } + + public test() { + } +} diff --git a/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.html b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.html new file mode 100644 index 00000000..12228f24 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.html @@ -0,0 +1,33 @@ + +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
diff --git a/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.ts b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.ts new file mode 100644 index 00000000..924b40f5 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.ts @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ + +import { Component, Input, OnChanges, ViewChild } from '@angular/core'; +import { ModalDirective } from 'ngx-bootstrap/modal'; + +import { Microservice } from '../../../../model/workflow/microservice'; +import { WorkflowConfigService } from '../../../../services/workflow-config.service'; + +/** + * toolbar component contains some basic operations(save) and all of the supported workflow nodes. + * The supported nodes can be dragged to container component. which will add a new node to the workflow. + */ +@Component({ + selector: 'b4t-microservice-detail', + templateUrl: 'microservice-detail.component.html', +}) +export class MicroserviceDetailComponent implements OnChanges { + @Input() microservice: Microservice; + + public detail: string; + + constructor() { + } + + public ngOnChanges() { + if(this.microservice == null) { + this.microservice = new Microservice('', '', {}); + } + this.parseSwagger2String(); + } + + private parseSwagger2String() { + if (this.microservice.swagger) { + this.detail = JSON.stringify(this.microservice.swagger); + } else { + this.detail = ''; + } + } + + public onDetailChanged(detail: string) { + try { + const swagger = JSON.parse(detail); + this.detail = detail; + console.log(swagger); + this.microservice.swagger = swagger; + } catch (e) { + // if detail is not a json object, then not change the swagger + } + } +} diff --git a/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.css b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.css new file mode 100644 index 00000000..f403890e --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.css @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ + + .swagger-list{ + overflow: auto; + } \ No newline at end of file diff --git a/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.html b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.html new file mode 100644 index 00000000..ce4730f7 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.html @@ -0,0 +1,32 @@ + +
+
+
+ Config List + +
+ +
    +
  • +
    {{microservice.name}}
    +
    + +
    +
  • +
+
+
+ diff --git a/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.ts b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.ts new file mode 100644 index 00000000..2e22699d --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.ts @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ + +import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core'; +import { ModalDirective } from 'ngx-bootstrap/modal'; + +import { Microservice } from '../../../../model/workflow/microservice'; + +/** + * toolbar component contains some basic operations(save) and all of the supported workflow nodes. + * The supported nodes can be dragged to container component. which will add a new node to the workflow. + */ +@Component({ + selector: 'b4t-microservice-list', + templateUrl: 'microservice-list.component.html', +}) +export class MicroserviceListComponent { + @Input() microservices: Microservice[]; + @Output() microserviceSelected = new EventEmitter(); + + public onMicroserviceSelected(microservice: Microservice) { + this.microserviceSelected.emit(microservice); + } + + public addMicroservice() { + const microservice = new Microservice('new microservice', '', {}); + this.microservices.push(microservice); + + this.onMicroserviceSelected(microservice); + } + + public deleteMicroservice(index: number, microservice: Microservice) { + this.deleteMicroService(microservice.name, microservice.version); + + // set the next microservice selected + let selectedMicroservice; + if (this.microservices.length > 0) { + if (this.microservices[index]) { + selectedMicroservice = this.microservices[index]; + } else { + selectedMicroservice = this.microservices[index - 1]; + } + } + this.onMicroserviceSelected(selectedMicroservice); + } + + private deleteMicroService(name: string, version: string) { + const index = this.microservices.findIndex(service => (service.name === name && service.version === version)); + if(index !== -1) { + return this.microservices.splice(index, 1)[0]; + } + + return undefined; + } +} diff --git a/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.html b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.html new file mode 100644 index 00000000..e8483c22 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.html @@ -0,0 +1,39 @@ + + diff --git a/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.ts b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.ts new file mode 100644 index 00000000..4591eef4 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.ts @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ + +import { AfterViewInit, Component, ViewChild } from '@angular/core'; +import { ModalDirective } from 'ngx-bootstrap/modal'; + +import { MicroserviceListComponent } from './microservice-list/microservice-list.component'; +import { Microservice } from "../../../model/workflow/microservice"; +import { WorkflowConfigService } from "../../../services/workflow-config.service"; + +/** + * microservice component + * open a model to set microservice info + */ +@Component({ + selector: 'b4t-microservice', + templateUrl: 'microservice.component.html', +}) +export class MicroserviceComponent { + @ViewChild('microserviceModal') public microserviceModal: ModalDirective; + + public microservices: Microservice[]; + public currentMicroservice: Microservice; + + constructor(private workflowConfigService: WorkflowConfigService) { + } + + public microserviceSelected(microservice: any) { + this.currentMicroservice = microservice; + } + + public show() { + this.microservices = this.workflowConfigService.getMicroservices(); + this.microserviceModal.show(); + } + +} diff --git a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.css b/sdc-workflow-designer-ui/src/app/components/menus/menu.component.css deleted file mode 100644 index 2fa48afa..00000000 --- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.css +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2017 ZTE Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and the Apache License 2.0 which both accompany this distribution, - * and are available at http://www.eclipse.org/legal/epl-v10.html - * and http://www.apache.org/licenses/LICENSE-2.0 - * - * Contributors: - * ZTE - initial API and implementation and/or initial documentation - */ - -.btn-right{ - float: right; -} - -button i{ - padding-right: 3px; -} diff --git a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.html b/sdc-workflow-designer-ui/src/app/components/menus/menu.component.html deleted file mode 100644 index edee3618..00000000 --- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.html +++ /dev/null @@ -1,20 +0,0 @@ - - -
- - -
diff --git a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.spec.ts b/sdc-workflow-designer-ui/src/app/components/menus/menu.component.spec.ts deleted file mode 100644 index 52f2c772..00000000 --- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2017 ZTE Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and the Apache License 2.0 which both accompany this distribution, - * and are available at http://www.eclipse.org/legal/epl-v10.html - * and http://www.apache.org/licenses/LICENSE-2.0 - * - * Contributors: - * ZTE - initial API and implementation and/or initial documentation - */ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MenuComponent } from './menu.component'; - -describe('MenuComponent', () => { - let component: MenuComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ MenuComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MenuComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.ts b/sdc-workflow-designer-ui/src/app/components/menus/menu.component.ts deleted file mode 100644 index 347f1a24..00000000 --- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2017 ZTE Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * and the Apache License 2.0 which both accompany this distribution, - * and are available at http://www.eclipse.org/legal/epl-v10.html - * and http://www.apache.org/licenses/LICENSE-2.0 - * - * Contributors: - * ZTE - initial API and implementation and/or initial documentation - */ -import { Component, OnInit, ViewChild } from '@angular/core'; - -import { WorkflowService } from '../../services/workflow.service'; - -@Component({ - selector: 'b4t-menu', - templateUrl: './menu.component.html', - styleUrls: ['./menu.component.css'] -}) -export class MenuComponent { - - public canSave = true; - - constructor(private workflowService: WorkflowService) { } - - public save(): void { - this.workflowService.save(); - } - - public test() { - } -} -- cgit 1.2.3-korg