summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app/components
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2017-09-01 14:31:04 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2017-09-01 14:31:04 +0800
commitb45d377a6114b2e3f6bcfbbaee1ce9668b91e0aa (patch)
tree3d12edc17843fa21dc1e9715897d5e60271e9392 /sdc-workflow-designer-ui/src/app/components
parente0597dc5b0a3718aa3b5991a65096c609d23dba2 (diff)
support setting microservice info
support setting microservice info for workflow Issue-ID: SDC-266 Change-Id: I8c6ad2a95f63a86db0789f9c400be38131404b66 Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/components')
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/menu.component.css (renamed from sdc-workflow-designer-ui/src/app/components/menus/menu.component.css)0
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/menu.component.html24
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/menu.component.spec.ts (renamed from sdc-workflow-designer-ui/src/app/components/menus/menu.component.spec.ts)32
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/menu.component.ts (renamed from sdc-workflow-designer-ui/src/app/components/menus/menu.component.ts)24
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.html33
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-detail/microservice-detail.component.ts60
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.css (renamed from sdc-workflow-designer-ui/src/app/components/menus/menu.component.html)11
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.html32
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.ts64
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.html39
-rw-r--r--sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice.component.ts46
11 files changed, 331 insertions, 34 deletions
diff --git a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.css b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.css
index 2fa48afa..2fa48afa 100644
--- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.css
+++ b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.css
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 @@
+<!--
+/**
+ * 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
+ */
+-->
+
+<div class="btn-right">
+ <button type="button" class="btn white" (click)="save()">
+ <i class="fa fa-save"></i>Save
+ </button>
+ <button type="button" class="btn white" (click)="showMicroserviceModal()">
+ <i class="fa fa-cog"></i>Setting
+ </button>
+ <!-- <button type="button" class="btn white" (click)="test()">test</button> -->
+</div>
+<b4t-microservice></b4t-microservice>
diff --git a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.spec.ts b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.spec.ts
index 52f2c772..b80edce7 100644
--- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.spec.ts
+++ b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.spec.ts
@@ -14,23 +14,23 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MenuComponent } from './menu.component';
describe('MenuComponent', () => {
- let component: MenuComponent;
- let fixture: ComponentFixture<MenuComponent>;
+ let component: MenuComponent;
+ let fixture: ComponentFixture<MenuComponent>;
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [ MenuComponent ]
- })
- .compileComponents();
- }));
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [MenuComponent]
+ })
+ .compileComponents();
+ }));
- beforeEach(() => {
- fixture = TestBed.createComponent(MenuComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
+ beforeEach(() => {
+ fixture = TestBed.createComponent(MenuComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
- it('should be created', () => {
- expect(component).toBeTruthy();
- });
+ 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/menu/menu.component.ts
index 347f1a24..2c03cbfc 100644
--- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.ts
+++ b/sdc-workflow-designer-ui/src/app/components/menu/menu.component.ts
@@ -12,22 +12,26 @@
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']
+ selector: 'b4t-menu',
+ templateUrl: './menu.component.html',
+ styleUrls: ['./menu.component.css']
})
export class MenuComponent {
+ @ViewChild(MicroserviceComponent) public microserviceComponent: MicroserviceComponent;
- public canSave = true;
+ constructor(private workflowService: WorkflowService) { }
- constructor(private workflowService: WorkflowService) { }
+ public save(): void {
+ this.workflowService.save();
+ }
- public save(): void {
- this.workflowService.save();
- }
+ public showMicroserviceModal(): void {
+ this.microserviceComponent.show();
+ }
- public test() {
- }
+ 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 @@
+<!--
+/**
+ * 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
+ */
+-->
+<div class="form-group row">
+ <label class="col-md-2 form-control-label text-md-right">Name</label>
+ <div class="col-md-10">
+ <input class="form-control" [(ngModel)]="microservice.name">
+ </div>
+</div>
+<div class="form-group row">
+ <label class="col-md-2 form-control-label text-md-right">version</label>
+ <div class="col-md-10">
+ <input class="form-control" [(ngModel)]="microservice.version">
+ </div>
+</div>
+
+<div class="form-group row">
+ <label class="col-md-2 form-control-label text-md-right">Detail</label>
+ <div class="col-md-10">
+ <textarea class="form-control" rows="8" [ngModel]="detail"
+ (ngModelChange)="onDetailChanged($event)"></textarea>
+ </div>
+</div>
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/menus/menu.component.html b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.css
index edee3618..f403890e 100644
--- a/sdc-workflow-designer-ui/src/app/components/menus/menu.component.html
+++ b/sdc-workflow-designer-ui/src/app/components/menu/microservice/microservice-list/microservice-list.component.css
@@ -1,4 +1,3 @@
-<!--
/**
* Copyright (c) 2017 ZTE Corporation.
* All rights reserved. This program and the accompanying materials
@@ -10,11 +9,7 @@
* Contributors:
* ZTE - initial API and implementation and/or initial documentation
*/
--->
-<div class="btn-right">
- <button type="button" class="btn white" (click)="save()" [disabled]="!canSave">
- <i class="fa fa-save"></i>Save
- </button>
- <!-- <button type="button" class="btn white" (click)="test()">test</button> -->
-</div>
+ .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 @@
+<!--
+/**
+ * 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
+ */
+-->
+<div class="scroll" style="overflow:hidden; max-height: 300px; height: 300px;">
+ <div class="card">
+ <div class="card-header d-flex justify-content-between align-items-center">
+ <span>Config List</span>
+ <span class="badge badge-success badge-pill" (click)="addMicroservice()"><i class="fa fa-plus"></i></span>
+ </div>
+
+ <ul class="list-group">
+ <li class="list-group-item d-flex justify-content-between align-items-center"
+ *ngFor="let microservice of microservices; index as i">
+ <div (click)="onMicroserviceSelected(microservice)">{{microservice.name}}</div>
+ <div class="badge badge-danger badge-pill" (click)="deleteMicroservice(i, microservice)">
+ <i class="fa fa-minus"></i>
+ </div>
+ </li>
+ </ul>
+ </div>
+</div>
+
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<Microservice>();
+
+ 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 @@
+<!--
+/**
+ * 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
+ */
+-->
+<div class="modal fade" bsModal #microserviceModal="bs-modal" [config]="{backdrop: 'static'}"
+ tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title pull-left">microservice Setting</h4>
+ <button type="button" class="close pull-right" aria-label="Close" (click)="microserviceModal.hide()">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <div class="row">
+ <div class="col-sm-4">
+ <b4t-microservice-list [microservices]="microservices" (microserviceSelected)="microserviceSelected($event)"></b4t-microservice-list>
+ </div>
+ <div class="col-sm-8">
+ <b4t-microservice-detail [microservice]="currentMicroservice"></b4t-microservice-detail>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn over-grey" (click)="microserviceModal.hide()">close</button>
+ </div>
+ </div>
+ </div>
+</div>
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();
+ }
+
+}