From 008518dc35ded3bb6dc3e6352472b5816271f583 Mon Sep 17 00:00:00 2001 From: Lvbo163 Date: Thu, 11 Jan 2018 10:22:16 +0800 Subject: adjust folder change fold menu to menus Issue-ID: SDC-900 Change-Id: Ifce180badf4f468a3291b118bfd4f631483541ec Signed-off-by: Lvbo163 --- .../microservice-detail.component.html | 49 ++++++++++ .../microservice-detail.component.ts | 100 +++++++++++++++++++++ .../microservice-list.component.css | 15 ++++ .../microservice-list.component.html | 32 +++++++ .../microservice-list.component.ts | 81 +++++++++++++++++ .../menus/microservice/microservice.component.html | 39 ++++++++ .../menus/microservice/microservice.component.ts | 48 ++++++++++ 7 files changed, 364 insertions(+) create mode 100644 sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.ts create mode 100644 sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.css create mode 100644 sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.ts create mode 100644 sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.html create mode 100644 sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.ts (limited to 'sdc-workflow-designer-ui/src/app/components/menus/microservice') diff --git a/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.html b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.html new file mode 100644 index 00000000..d13895dd --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.html @@ -0,0 +1,49 @@ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
diff --git a/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.ts b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.ts new file mode 100644 index 00000000..bffaef42 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-detail/microservice-detail.component.ts @@ -0,0 +1,100 @@ +/** + * 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'; +import { Swagger } from "../../../../model/swagger"; +import { RestConfig } from '../../../../model/rest-config'; + +/** + * 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: RestConfig; + + public detail: string; + public dynamic = false; + + constructor(private configService: WorkflowConfigService) { + } + + public ngOnChanges() { + if(this.microservice == null) { + this.microservice = new RestConfig('', '', null, ''); + } + this.checkDynamic(); + this.parseSwagger2String(); + } + + private checkDynamic() { + if(this.microservice.url) { + this.dynamic = true; + } else { + this.dynamic = false; + } + } + + private parseSwagger2String() { + if (this.microservice.swagger) { + this.detail = JSON.stringify(this.microservice.swagger); + } else { + this.detail = ''; + } + } + + public onDetailChanged(detail: string) { + try { + if(detail) { + const swagger = new Swagger(JSON.parse(detail)); + this.detail = detail; + console.log(swagger); + this.microservice.swagger = swagger; + } else { + this.detail = ''; + this.microservice.swagger = null; + } + } catch (e) { + // if detail is not a json object, then not change the swagger + } + } + + public toggleDynamic(dynamic: boolean) { + this.dynamic = dynamic; + this.onDetailChanged(null); + + if(!dynamic) { + this.microservice.url = null; + } + } + + private loadDynamicInfo() { + this.configService.loadDynamicInfo(this.microservice.url) + .subscribe(response => { + try { + + this.microservice.swagger = response; + this.parseSwagger2String(); + } catch (e) { + console.log('detail transfer error'); + console.error(e); + } + }); + } +} diff --git a/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.css b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.css new file mode 100644 index 00000000..f403890e --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menus/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/menus/microservice/microservice-list/microservice-list.component.html b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.html new file mode 100644 index 00000000..ce4730f7 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menus/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/menus/microservice/microservice-list/microservice-list.component.ts b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.ts new file mode 100644 index 00000000..b44d423f --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice-list/microservice-list.component.ts @@ -0,0 +1,81 @@ +/** + * 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'; +import { RestConfig } from '../../../../model/rest-config'; + +/** + * 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: RestConfig[]; + @Output() microserviceSelected = new EventEmitter(); + + public onMicroserviceSelected(microservice: RestConfig) { + this.microserviceSelected.emit(microservice); + } + + public addMicroservice() { + const microservice = new RestConfig(this.getConfigId(), 'new microservice', '', null); + 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; + } + + private getConfigId(): string { + const idSet = new Set(); + this.microservices.forEach(config => { + idSet.add(config.id); + }); + + for(let index = 0; index < idSet.size; index++) { + const id = `config${index}`; + if(!idSet.has(id)) { + return id; + } + } + + return `config0`; + } +} diff --git a/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.html b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.html new file mode 100644 index 00000000..e8483c22 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.html @@ -0,0 +1,39 @@ + + diff --git a/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.ts b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.ts new file mode 100644 index 00000000..eeedac47 --- /dev/null +++ b/sdc-workflow-designer-ui/src/app/components/menus/microservice/microservice.component.ts @@ -0,0 +1,48 @@ +/** + * 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"; +import { RestService } from '../../../services/rest.service'; +import { RestConfig } from '../../../model/rest-config'; + +/** + * 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: RestConfig[]; + public currentMicroservice: Microservice; + + constructor(private restService: RestService) { + } + + public microserviceSelected(microservice: any) { + this.currentMicroservice = microservice; + } + + public show() { + this.microservices = this.restService.getRestConfigs(); + this.microserviceModal.show(); + } + +} -- cgit 1.2.3-korg