1 import {Component, OnInit} from '@angular/core';
2 import {BUSINESS_STATUS} from "../../../../../constants/constants";
3 import {SlicingTaskServices} from '.././../../../core/services/slicingTaskServices';
4 import { NzModalService, NzMessageService } from 'ng-zorro-antd';
6 selector: 'app-csmf-slicing-business-management',
7 templateUrl: './csmf-slicing-business-management.component.html',
8 styleUrls: ['./csmf-slicing-business-management.component.less']
10 export class CsmfSlicingBusinessManagementComponent implements OnInit {
13 private myhttp: SlicingTaskServices,
14 private modalService: NzModalService,
15 private message: NzMessageService
20 this.getCSMFBusinessList()
23 this.progressingTimer.forEach((item) => {
24 clearInterval(item.timer);
26 this.progressingTimer = [];
29 selectedValue: string = BUSINESS_STATUS[0];
30 listOfData: any[] = [];
31 pageIndex: number = 1;
32 pageSize: number = 10;
35 statusOptions: any[] = BUSINESS_STATUS;
36 progressingTimer: any[] = [];
37 terminateStart: boolean = false;
39 getCSMFBusinessList() {
43 status: this.selectedValue,
44 pageNo: this.pageIndex,
45 pageSize: this.pageSize
47 this.myhttp.getCSMFSlicingBusinessList(paramsObj).subscribe(res => {
48 const {result_header: {result_code}, result_body: {slicing_service_list, record_number}} = res;
50 if (+result_code === 200) {
51 this.total = record_number;
52 if (slicing_service_list !== null && slicing_service_list.length > 0) {
53 this.listOfData = slicing_service_list.map((item, index) => {
54 if (item.last_operation_process && item.last_operation_type && Number(item.last_operation_process) < 100) {
55 let updata = (prodata: { operation_progress: string }) => {
56 item.last_operation_process = prodata.operation_progress || item.last_operation_process;
59 serviceId: item.service_instance_id
61 if (item.last_operation_type === 'DELETE') this.terminateStart = true;
62 this.queryProgress(obj, index, updata).then((res) => {
63 item.last_operation_process = '100';
64 this.getCSMFBusinessList();
74 getListOfProcessingStatus() {
77 this.progressingTimer.forEach((item) => {
78 clearInterval(item.timer);
80 this.progressingTimer = [];
81 this.getCSMFBusinessList();
84 searchData(reset: boolean = false) {
85 this.progressingTimer.forEach((item) => {
86 clearInterval(item.timer);
88 this.progressingTimer = [];
89 this.getCSMFBusinessList();
92 switchChange(slicing, i) {
93 console.log(slicing, i, "slicing");
94 this.modalService.confirm({
95 nzTitle: '<i>Are you sure you want to perform this task?</i>',
96 nzContent: '<b>Name:' + slicing.service_name + '</b>',
99 serviceId: slicing.service_id
101 if (slicing.service_status === 'activated') {
102 this.changeActivate(paramsObj, false, slicing, "deactivate", "deactivated", i)
104 this.changeActivate(paramsObj, true, slicing, "activate", "activated", i);
109 let singleSlicing = Object.assign({}, this.listOfData[i]);
110 this.listOfData[i] = singleSlicing;
111 this.listOfData = [...this.listOfData];
115 changeActivate(paramsObj, isActivate, slicing, activateValue, finished, index) {
117 this.myhttp.csmfChangeActivate(paramsObj, isActivate).subscribe(res => {
118 const { result_header: { result_code, result_message }, result_body: { operation_id } } = res;
119 this.loading = false;
120 if (+result_code === 200) {
121 this.getCSMFBusinessList();
123 let singleSlicing = Object.assign({}, this.listOfData[index]);
124 this.listOfData[index] = singleSlicing;
125 this.listOfData = [...this.listOfData];
126 this.getCSMFBusinessList();
128 this.getCSMFBusinessList();
130 this.loading = false;
131 let singleSlicing = Object.assign({}, this.listOfData[index]);
132 this.listOfData[index] = singleSlicing;
133 this.listOfData = [...this.listOfData];
134 this.getCSMFBusinessList();
139 console.log(slicing, "slicing");
140 this.modalService.confirm({
141 nzTitle: 'Are you sure you want to terminate this task?',
142 nzContent: '<b>Name: </b>' + slicing.service_name,
144 let paramsObj = { serviceId: slicing.service_id };
145 this.terminateStart = true;
147 this.myhttp.csmfTerminate(paramsObj).subscribe(res => {
148 const { result_header: { result_code, result_message }, result_body: { operation_id } } = res;
149 this.loading = false;
150 if (+result_code === 200) {
151 this.getCSMFBusinessList();
153 this.terminateStart = false;
156 this.loading = false;
157 this.terminateStart = false;
162 console.info('Cancel termination')
166 queryProgress(obj, index, callback) {
167 return new Promise(res => {
168 let requery = () => {
169 this.myhttp.csmfSlicingProgress(obj)
170 .subscribe((data) => {
171 const { result_header: { result_code, result_message }, result_body: { operation_id } } = data;
172 if (+result_code === 200) {
173 if (data.result_body.operation_progress && Number(data.result_body.operation_progress) < 100) {
174 callback(data.result_body);
175 let progressSetTimeOut = setTimeout(() => {
178 this.progressingTimer.push({
180 timer: progressSetTimeOut
183 this.progressingTimer.forEach((item) => {
184 if (item.serviceId === obj.serviceId) {
185 clearInterval(item.timer);
188 res(data.result_body);
191 this.progressingTimer.forEach((item) => {
192 if (item.serviceId === obj.serviceId) {
193 clearInterval(item.timer);
196 this.getCSMFBusinessList();
197 this.message.error(result_message);
200 this.progressingTimer.forEach((item) => {
201 if (item.serviceId === obj.serviceId) {
202 clearInterval(item.timer);
205 this.getCSMFBusinessList();
206 this.message.error(err);