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 } from '@angular/core';
 
  14 import { ModalDirective } from 'ngx-bootstrap/modal';
 
  16 import { Swagger } from '../../../../model/swagger';
 
  17 import { RestConfig } from '../../../../model/rest-config';
 
  18 import { RestService } from '../../../../services/rest.service';
 
  21  * toolbar component contains some basic operations(save) and all of the supported workflow nodes.
 
  22  * The supported nodes can be dragged to container component. which will add a new node to the workflow.
 
  25     selector: 'b4t-rest-config-detail',
 
  26     templateUrl: 'rest-config-detail.component.html',
 
  28 export class RestConfigDetailComponent implements OnChanges {
 
  29     @Input() restConfig: RestConfig;
 
  31     public detail: string;
 
  33     constructor(private restService: RestService) {
 
  36     public ngOnChanges() {
 
  37         if (this.restConfig == null) {
 
  38             this.restConfig = new RestConfig('', '', '', '', '');
 
  40         this.parseSwagger2String();
 
  43     private parseSwagger2String() {
 
  44         if (this.restConfig.swagger) {
 
  45             this.detail = JSON.stringify(this.restConfig.swagger);
 
  51     public onDetailChanged(detail: string) {
 
  54         let swagger: Swagger = null;
 
  56             swagger = new Swagger(JSON.parse(detail));
 
  59             console.log('detail transfer error');
 
  62         this.restConfig.swagger = swagger;
 
  65     public toggleDynamic(dynamic: boolean) {
 
  66         // this.restConfig.dynamic = dynamic;
 
  68         // if (this.restConfig.dynamic && this.restConfig.definition) {
 
  69         //     this.restService.getDynamicSwaggerInfo(this.restConfig.definition)
 
  70         //         .subscribe(response => {
 
  72         //                 this.restConfig.swagger = new Swagger(response);
 
  73         //                 this.parseSwagger2String();
 
  75         //                 console.log('detail transfer error');