1 import { Component, OnInit } from "@angular/core";
2 import { Router } from "@angular/router";
3 import { NzMessageService } from "ng-zorro-antd";
4 import { intentBaseService } from "../../../../core/services/intentBase.service";
7 selector: 'app-cloud-leased-line',
8 templateUrl: './cloud-leased-line.component.html',
9 styleUrls: ['./cloud-leased-line.component.less']
11 export class CloudLeasedLineComponent implements OnInit {
14 private router:Router,
15 private myHttp: intentBaseService,
16 private nzMessage: NzMessageService
24 this.getCloudLeasedLineList();
36 listOfData: any[] = [];
37 // pageSize or pageNum
38 pageIndex: number = 1;
39 pageSize: number = 10;
42 // cantrol dialog show or hidden
43 cloudLeasedLineShowFlag: boolean = false;
44 smartCloudLeasedLineShowFlag: boolean = false;
46 resolveResult: any = null;
47 intervalTime: number = 5000;
48 progressingTimer: any[] = [];
51 getCloudLeasedLineList(): void {
52 this.myHttp.getInstanceList({
53 currentPage: this.pageIndex,
54 pageSize: this.pageSize
55 }).subscribe((response) => {
56 const { code, message, data } = response;
58 this.nzMessage.error(message);
61 this.total = data.totalRecords;
62 if (data.list === 0) {
66 this.listOfData = data.list.map((item, index) => {
67 if (this.statusObj[item.status] === 'Incomplete') {
68 const updateStatus = (prodata) => {
69 item.status = prodata.status || item.status;
72 const obj = { instanceId: item.instanceId };
73 this.queryStatus(obj, index, updateStatus).then(() => {
84 queryStatus(obj: any, index: number, callback: any) {
85 return new Promise((res) => {
86 const requery = () => {
90 this.myHttp.getInstanceStatus(param).subscribe((response) => {
91 const { code, data:{ IntentInstances } } = response;
92 if (code !== 200 || !IntentInstances || IntentInstances.length === 0) {
95 const intentInstance = IntentInstances[0];
96 if (this.statusObj[intentInstance.status] === 'Incomplete') {
97 callback(intentInstance);
98 let progressSetTimeOut = setTimeout(() => {
100 }, this.intervalTime);
101 this.progressingTimer.push({
102 instanceId: obj.instanceId,
103 timer: progressSetTimeOut,
106 this.progressingTimer.forEach((item) => {
107 if (item.instanceId === obj.instanceId) {
108 clearInterval(item.timer);
119 // change page message
121 this.getCloudLeasedLineList();
125 cloudLeasedLineShow(): void {
126 this.cloudLeasedLineShowFlag = true;
129 cloudLeasedLineClose(): void {
130 this.cloudLeasedLineShowFlag = false;
133 this.resolveResult = null;
134 this.getCloudLeasedLineList();
137 smartCloudLeasedLineShow(): void {
138 this.smartCloudLeasedLineShowFlag = true;
140 // smart dialog close
141 smartCloudLeasedLineClose(param): void {
142 this.smartCloudLeasedLineShowFlag = false;
147 this.resolveResult = param.data;
148 this.cloudLeasedLineShowFlag = true;
151 goMonitorService(data): void {
152 // this.router.navigateByUrl('/fcaps/monitor_service');navigate
153 this.router.navigate(['/fcaps/monitor_service'], {
155 instanceId: data.instanceId
157 skipLocationChange: true
161 activeCloudLeasedLine(row): void {
162 this.myHttp.activeIntentInstance({
163 instanceId: row.instanceId
164 }).subscribe((data) => {
165 const { code, message } = data;
167 this.nzMessage.error(message);
170 this.getCloudLeasedLineList();
176 inactiveCloudLeasedLine(row): void {
177 this.myHttp.invalidIntentInstance({
178 instanceId: row.instanceId
179 }).subscribe((data) => {
180 const { code, message } = data;
182 this.nzMessage.error(message);
185 this.getCloudLeasedLineList();
191 modifyCloudLeasedLine(row): void {
192 this.resolveResult = {
194 instanceId: row.instanceId,
195 protect: row.protectStatus ? true : false,
197 name: row.accessPointOneName,
198 bandwidth: row.accessPointOneBandWidth
200 cloudPointName: row.cloudPointName,
203 this.cloudLeasedLineShowFlag = true;
206 deleteCloudLeasedLine(row): void {
207 this.myHttp.deleteIntentInstance(row.instanceId).subscribe((data) => {
208 const { code, message } = data;
210 this.nzMessage.error(message);
213 this.getCloudLeasedLineList();