2 * Copyright (c) 2017 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial API and implementation and/or initial documentation
13 import { Component, Input, OnChanges, ViewChild } from '@angular/core';
14 import { ModalDirective } from 'ngx-bootstrap/modal';
16 import { Microservice } from '../../../../model/workflow/microservice';
17 import { WorkflowConfigService } from '../../../../services/workflow-config.service';
18 import { Swagger } from "../../../../model/swagger";
19 import { RestConfig } from '../../../../model/rest-config';
22 * toolbar component contains some basic operations(save) and all of the supported workflow nodes.
23 * The supported nodes can be dragged to container component. which will add a new node to the workflow.
26 selector: 'b4t-microservice-detail',
27 templateUrl: 'microservice-detail.component.html',
29 export class MicroserviceDetailComponent implements OnChanges {
30 @Input() microservice: RestConfig;
32 public detail: string;
33 public dynamic = false;
35 constructor(private configService: WorkflowConfigService) {
38 public ngOnChanges() {
39 if(this.microservice == null) {
40 this.microservice = new RestConfig('', '', null, '');
43 this.parseSwagger2String();
46 private checkDynamic() {
47 if(this.microservice.url) {
54 private parseSwagger2String() {
55 if (this.microservice.swagger) {
56 this.detail = JSON.stringify(this.microservice.swagger);
62 public onDetailChanged(detail: string) {
65 const swagger = new Swagger(JSON.parse(detail));
68 this.microservice.swagger = swagger;
71 this.microservice.swagger = null;
74 // if detail is not a json object, then not change the swagger
78 public toggleDynamic(dynamic: boolean) {
79 this.dynamic = dynamic;
80 this.onDetailChanged(null);
83 this.microservice.url = null;
87 private loadDynamicInfo() {
88 this.configService.loadDynamicInfo(this.microservice.url)
89 .subscribe(response => {
92 this.microservice.swagger = response;
93 this.parseSwagger2String();
95 console.log('detail transfer error');