diff options
author | 2018-01-10 15:05:39 +0800 | |
---|---|---|
committer | 2018-01-10 15:05:39 +0800 | |
commit | 38dfd59a8b5d05266e5567f79dcf30fd10ef7c54 (patch) | |
tree | 043a724663d3324ce80cc546a241898e99796897 /sdc-workflow-designer-ui/src/app/components/property | |
parent | eb2d1c385e5c3d96e770b776f74ddbde9f2b133f (diff) |
split element by type
split elements by type in toolbar
Issue-ID: SDC-895
Change-Id: I0254c9c5f938df80942d60ffefe4b8577c788233
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/components/property')
4 files changed, 36 insertions, 90 deletions
diff --git a/sdc-workflow-designer-ui/src/app/components/property/properties.component.html b/sdc-workflow-designer-ui/src/app/components/property/properties.component.html index 2870a4b1..19d0dce1 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/properties.component.html +++ b/sdc-workflow-designer-ui/src/app/components/property/properties.component.html @@ -14,19 +14,12 @@ <div class="wm-properties-wrapper" *ngIf="show"> <div class="form-group row"> - <div *ngIf="!titleEditing" class="view col-md-10" (dblclick)="titleEditing = !titleEditing"> - <h4>{{node.name}}</h4> - </div> - <div class="col-md-10" *ngIf="titleEditing"> - <input class="form-control" (blur)="nodeNameChanged()" type="text" [(ngModel)]="node.name"/> - </div> - + <b4t-editable-property class="col-md-10" [(name)]="node.name"></b4t-editable-property> <div class="col-md-2"> - <button (click)="deleteNode()" type="button" class="btn btn-danger"> + <button (click)="deleteNode()" type="button" class="btn white"> <i class="fa fa-trash" style="margin-right: 5px;"></i> </button> </div> - </div> <hr> diff --git a/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts b/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts index 2091d83c..d3a6a416 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts +++ b/sdc-workflow-designer-ui/src/app/components/property/properties.component.ts @@ -35,8 +35,8 @@ export class PropertiesComponent implements AfterViewInit { public planItems: PlanTreeviewItem[]; constructor(private broadcastService: BroadcastService, - private jsPlumnService: JsPlumbService, - private processService: ModelService) { + private jsPlumbService: JsPlumbService, + private modelService: ModelService) { } @@ -44,19 +44,14 @@ export class PropertiesComponent implements AfterViewInit { this.broadcastService.showProperty$.subscribe(show => this.show = show); this.broadcastService.nodeProperty$.subscribe(node => { this.node = node; - this.planItems = this.processService.getPlanParameters(this.node.id); + this.planItems = this.modelService.getPlanParameters(this.node.id); }); } - public nodeNameChanged() { - this.titleEditing = !this.titleEditing; - this.jsPlumnService.jsplumbInstance.repaintEverything(); - } - public deleteNode() { this.show = false; - - this.jsPlumnService.remove(this.node.id); - this.processService.deleteNode(this.node.id); + const parentId = this.jsPlumbService.getParentNodeId(this.node.id); + this.jsPlumbService.remove(this.node); + this.modelService.deleteNode(parentId, this.node.id); } } diff --git a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task-parameters/rest-task-parameters.component.ts b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task-parameters/rest-task-parameters.component.ts index 7f8bbf43..8e8cc94f 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task-parameters/rest-task-parameters.component.ts +++ b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task-parameters/rest-task-parameters.component.ts @@ -21,6 +21,7 @@ import { ValueSource } from "../../../../model/value-source.enum"; import { SwaggerTreeConverterService } from "../../../../services/swagger-tree-converter.service"; import { PlanTreeviewItem } from "../../../../model/plan-treeview-item"; import { WorkflowConfigService } from "../../../../services/workflow-config.service"; +import { RestService } from '../../../../services/rest.service'; /** * property component presents information of a workflow node. @@ -44,7 +45,7 @@ export class RestTaskParametersComponent implements OnInit { private index = 1; constructor(private broadcastService: BroadcastService, - private workflowConfigService: WorkflowConfigService, + private restService: RestService, private swaggerTreeConverterService: SwaggerTreeConverterService) { } @@ -62,7 +63,7 @@ export class RestTaskParametersComponent implements OnInit { this.task.parameters.forEach(param => { if (param.position === 'body') { const requestTreeNode = this.swaggerTreeConverterService - .schema2TreeNode(this.workflowConfigService.getSwaggerInfo(this.task.serviceName, this.task.serviceVersion), 'Request Param', param.schema, param.value); + .schema2TreeNode(this.restService.getSwaggerInfo(this.task.restConfigId), 'Request Param', param.schema, param.value); param.value = requestTreeNode.value; param.value = param.schema.value; this.bodyParameter.push(requestTreeNode); diff --git a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts index d0c92dfd..eb1c81bd 100644 --- a/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts +++ b/sdc-workflow-designer-ui/src/app/components/property/rest-task/rest-task.component.ts @@ -9,91 +9,61 @@ * Contributors: * ZTE - initial API and implementation and/or initial documentation *******************************************************************************/ -import { AfterViewInit, Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { Subscription } from 'rxjs/Subscription'; +import { PlanTreeviewItem } from '../../../model/plan-treeview-item'; import { Swagger, SwaggerMethod, SwaggerParameter, SwaggerResponse } from '../../../model/swagger'; import { ValueSource } from '../../../model/value-source.enum'; import { ValueType } from '../../../model/value-type.enum'; +import { RestParameter } from '../../../model/workflow/rest-parameter'; import { RestTask } from '../../../model/workflow/rest-task'; import { BroadcastService } from '../../../services/broadcast.service'; -import { WorkflowConfigService } from '../../../services/workflow-config.service'; -import { Microservice } from "../../../model/workflow/microservice"; -import { WorkflowUtil } from "../../../util/workflow-util"; -import { RestParameter } from "../../../model/workflow/rest-parameter"; -import { PlanTreeviewItem } from "../../../model/plan-treeview-item"; +import { RestService } from '../../../services/rest.service'; +import { WorkflowUtil } from '../../../util/workflow-util'; @Component({ selector: 'b4t-rest-task', templateUrl: 'rest-task.component.html', }) -export class RestTaskComponent implements AfterViewInit, OnInit { +export class RestTaskComponent implements OnInit { @Input() public node: RestTask; @Input() public planItems: PlanTreeviewItem[]; - public swaggerJson: any = {}; public restInterfaces: any[]; public restOperations: any = []; - public microservices: Microservice[]; - public selectedMicroservice: Microservice; private swagger: Swagger; - constructor(private broadcastService: BroadcastService, - private configService: WorkflowConfigService) { } - - ngOnInit(): void { - this.microservices = this.configService.getMicroservices(); - this.selectedMicroservice = this.microservices.find(service => - (this.node.serviceName === service.name && this.node.serviceVersion === service.version)); - } - public ngAfterViewInit() { - setTimeout(() => { - this.loadInterfaces(); - this.notifyTaskChanged(); - }, 0); - } - - private notifyTaskChanged() { - this.broadcastService.broadcast(this.broadcastService.nodeTaskChange, this.node); - } + constructor(private broadcastService: BroadcastService, public restService: RestService) { } - public getText4Microservice(microservice: Microservice): string { - return `${microservice.name} [${microservice.version}] `; + public ngOnInit() { + this.loadInterfaces(); } - public serviceChanged(service: Microservice) { - this.selectedMicroservice = service; - this.node.serviceName = service.name; - this.node.serviceVersion = service.version; - this.urlChanged(''); + public serviceChanged(configId: string) { + this.node.restConfigId = configId; + this.pathChanged(''); this.loadInterfaces(); } - public urlChanged(url: string) { - this.node.url = url; - + public pathChanged(path: string) { + this.node.path = path; this.node.consumes = []; this.node.produces = []; this.methodChanged(''); - this.loadOperations(); } public methodChanged(method: string) { this.node.method = method; - this.node.parameters = []; this.node.responses = []; - this.updateMethodInfo(); - - this.notifyTaskChanged(); } - private loadInterfaces() { - if (this.node.serviceName && this.node.serviceVersion) { - this.swagger = this.configService.getSwaggerInfo(this.node.serviceName, this.node.serviceVersion); + if (this.node.restConfigId) { + this.swagger = this.restService.getSwaggerInfo(this.node.restConfigId); if (this.swagger) { this.restInterfaces = []; @@ -101,15 +71,13 @@ export class RestTaskComponent implements AfterViewInit, OnInit { this.restInterfaces.push(key); } this.loadOperations(); - } else { - // TODO error handler } } } private loadOperations() { - if (this.node.url) { - const swaggerPath: any = this.swagger.paths[this.node.url]; + if (this.node.path) { + const swaggerPath: any = this.swagger.paths[this.node.path]; this.restOperations = []; for (const key of Object.keys(swaggerPath)) { @@ -120,34 +88,23 @@ export class RestTaskComponent implements AfterViewInit, OnInit { private updateMethodInfo() { if (this.node.method) { - const path: any = this.swagger.paths[this.node.url]; + const path: any = this.swagger.paths[this.node.path]; const method: SwaggerMethod = path[this.node.method]; this.node.consumes = WorkflowUtil.deepClone(method.consumes); this.node.produces = WorkflowUtil.deepClone(method.produces); - // request parameters + let tempParameters: RestParameter[] = []; method.parameters.forEach(param => { const nodeParam = new RestParameter(param.name, '', ValueSource[ValueSource.String], - param.type, param.position, param.schema); - this.node.parameters.push(nodeParam); + ValueType[ValueType.String], param.position, param.schema, param.required); + tempParameters.push(WorkflowUtil.deepClone(nodeParam)); }); + this.node.parameters = tempParameters; - // response parameters - const responseParams = this.getResponseParameters(method.responses); + const responseParams = this.restService.getResponseParameters( + this.swagger, this.node.path, this.node.method); this.node.responses = responseParams.map(param => WorkflowUtil.deepClone(param)); } } - - private getResponseParameters(responses: any) { - let response: SwaggerResponse = null; - - for (const key of Object.keys(responses)) { - if (key.startsWith('20')) { - response = responses[key]; - } - } - - return [response]; - } } |