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.getCloudLeasedLineList();
136 smartCloudLeasedLineShow(): void {
137 this.smartCloudLeasedLineShowFlag = true;
139 // smart dialog close
140 smartCloudLeasedLineClose(param): void {
141 this.smartCloudLeasedLineShowFlag = false;
146 this.resolveResult = param.data;
147 this.cloudLeasedLineShowFlag = true;
150 goMonitorService(data): void {
151 // this.router.navigateByUrl('/fcaps/monitor_service');navigate
152 this.router.navigate(['/fcaps/monitor_service'], {
154 instanceId: data.instanceId
156 skipLocationChange: true
160 activeCloudLeasedLine(row): void {
161 this.myHttp.activeIntentInstance({
162 instanceId: row.instanceId
163 }).subscribe((data) => {
164 const { code, message } = data;
166 this.nzMessage.error(message);
169 this.getCloudLeasedLineList();
175 inactiveCloudLeasedLine(row): void {
176 this.myHttp.invalidIntentInstance({
177 instanceId: row.instanceId
178 }).subscribe((data) => {
179 const { code, message } = data;
181 this.nzMessage.error(message);
184 this.getCloudLeasedLineList();
190 deleteCloudLeasedLine(row): void {
191 this.myHttp.deleteIntentInstance(row.instanceId).subscribe((data) => {
192 const { code, message } = data;
194 this.nzMessage.error(message);
197 this.getCloudLeasedLineList();