summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/services/sotn-management/monitor-service/monitor-service.component.ts
blob: 6ad98216fce1e3458b3f45b1c9d3fe474469a80c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import { Component, OnInit } from '@angular/core';
import { Network, Node, Edge } from 'vis';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { baseUrl } from '../../../../datainterface';
import { getLocaleDateFormat } from '@angular/common';
@Component({
  selector: 'app-monitor-service',
  templateUrl: './monitor-service.component.html',
  styleUrls: ['./monitor-service.component.less']
})
export class MonitorServiceComponent implements OnInit {

  selectedSubscriptionType: string = "";
  serviceSubscriptionList = [] as Array<any>;
  selectedServiceInstance: string = "" ;
  serviceInstanceList = [] as Array<any>;

  selectedTopology:string = 'i18nTextDefine_serviceTopology';
  baseUrl = baseUrl.baseUrl

  title = 'Network';
    public nodes: Node;
    public edges: Edge;
    public network: Network;
    public serviceList: any;
    public vpnBindingList:any;
    public tempNode: any;
    public tempEdge: any;
    public selectedNode: any;
    public selectedNodeIds: any;
    public x: any;
    public abc = [];
    container: any;
    isdisabled:boolean = true;
    serviceTopologyList:any = [
      {
        topologyType:"i18nTextDefine_serviceTopology",
      },
      {
        topologyType:"i18nTextDefine_resourceTopology",
      }
    ];
  
    
    networkOptions = {
      layout: { 
          randomSeed: 15
      },
      nodes: {
          borderWidth: 13,
          size: 30,
          color: {
              border: '#54bd55',
              background: '#666666'
          },
          font: { color: '#eeeeee' }
      },
      edges: {
          color: 'lightgray',
      },

      interaction: {
          tooltipDelay: 200,
          hideEdgesOnDrag: true,
          navigationButtons: false,
          keyboard: true,
          hover: true
      },
    };

  constructor(private http: HttpClient) { }

  intervalData: any;
  returnResponse: boolean = true;

  onBack(){
     if(this.serviceList.length > 0) {
      this.refreshData("");
     } else {
       this.getData("");
     }
     this.isdisabled = true;
  };

   //Get SubscriptionType
   getSubscribeTypes() {
    this.serviceList = [];
    this.vpnBindingList = [];
    this.isdisabled = true;
    let httpOptions = {
      headers: new HttpHeaders({
        'Content-Type':  'application/json'
      })
    };
    let url = this.baseUrl + "/uui-lcm/customers/service-subscriptions";
    this.http.get<any>(url, httpOptions).subscribe((data) => {
      this.serviceSubscriptionList = data.subscriptions;
    }, (err) => {
      console.log(err);
    });
  }

  //Get subscription instanceID by calling With Subscription Type
  getServiceInstanceList(subscriptionType) {
    this.serviceList = [];
    this.vpnBindingList = [];
    this.isdisabled = true;
    this.serviceInstanceList = [];
    this.selectedServiceInstance="";
    let httpOptions = {
      headers: new HttpHeaders({
        'Content-Type':  'application/json'
      })
    };
    let url = this.baseUrl + "/uui-lcm/Sotnservices/ServiceInstances/" + subscriptionType;
    this.http.get<any>(url,httpOptions).subscribe((data) => {
      this.serviceInstanceList = data.serviceInstanceList; 
    }, (err) => {
      console.log(err);
    });    
  }

  getTopologyInfo (topo) {
    this.selectedTopology = topo;
    this.getData("");
    this.refreshData("");
  }
  //Get subscription instanceID by calling With Subscription Type
  ngOnInit() {
      this.container = document.getElementById('mynetwork');
      this.getSubscribeTypes();
  }

  refreshData(data) {
      const com = this
      var id ;
      var data1 = {
          nodes: data.nodes,
          edges: data.edges
      };
      var network = new Network(this.container, data1, this.networkOptions);
      network.on('doubleClick', function (selection) {
           var selectedvpnid = selection.nodes[0];
          com.getData(selectedvpnid)
          this.selectedNodeIds = selection.nodes[0]; // array of selected node's ids
          var filteredNode = data1.nodes.filter(item => (
              item.id == this.selectedNodeIds
          ));
          var t1 = '<div class="tblDiv">\
          <nz-form-label class="lblCls">Node Information</nz-form-label>\
          <table class="monitor-table">\
              <thead>\
                  <tr>\
                      <th class="monitor-table-td-th ">Specification</th>\
                      <th class="monitor-table-td-th ">Value</th>\
                  </tr>\
              </thead>\
              <tbody>\
          ';
          Object.entries(filteredNode[0].dataNode).forEach(entry => {                
              if( entry[1] !== "null")
              {
                  t1 += '<tr class="popup-table-row">\
                      <td class="monitor-table-td-th  ">'+ entry[0] + ':</td>\
                      <td class="monitor-table-td-th   ">'+ entry[1] + '</td>\
                  </tr>\
                  ';
              }    
          });
          t1 += '</tbody>\
          </table>\
          </div>\
          ';
          document.getElementById('nodeDetails').innerHTML = t1;
      });
      network.on("afterDrawing", function (this) {
          network.fit();
      });
  }

  getData (vpnid){
    var comp = this;
    let url = "";
    if(vpnid != "" ) {
      if(this.vpnBindingList.length > 0) {
          this.refreshData(this.vpnBindingList)
        } else {
        url = this.baseUrl+'/uui-lcm/Sotnservices/vpnbindingTopology/service/service-subscriptions/service-subscription/'+this.selectedSubscriptionType.toLowerCase()+'/service-instances/service-instance/'+this.selectedServiceInstance+'/vpn-informations/vpn-information/'+ vpnid;
      }
    } else {
      if(this.serviceList.length > 0 && vpnid == "") {
        this.refreshData(this.serviceList);
      } else {
        url = this.baseUrl+'/uui-lcm/Sotnservices/serviceTopology/service/service-subscriptions/service-subscription/'+this.selectedSubscriptionType.toLowerCase()+'/service-instances/service-instance/'+this.selectedServiceInstance;
      }
    }
    let httpOptions = {
      headers: new HttpHeaders({
        'Content-Type':  'application/json'
      })
    };
    this.http.get<any>(url, httpOptions).subscribe((data) => {
      if(vpnid == "") {
        this.serviceList = data;
      } else {
        this.vpnBindingList = data;
        this.isdisabled = false;
    }
    comp.refreshData(data);
  }, (err) => {
        console.log(err);
    });
  }

  // Getting sitedata Based On Type and ID
  getSelectedsubscriptionInfo() {       
      this.getData("");
      if (this.intervalData) {
          clearInterval(this.intervalData);
      }        
  }

  
  ngOnDestroy() {
      console.log('clear interval');
      if (this.intervalData) {
          clearInterval(this.intervalData);
      }

  }

  ngOnDelete() {
      console.log('clear interval');
      if (this.intervalData) {
          clearInterval(this.intervalData);
      }
  }

}