1 import { Component, Input, OnInit, SimpleChanges } 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";
5 import * as moment from "moment";
6 import { INTERVAL_TIME } from "../constant";
8 selector: "app-csmf-slicing-business-management",
9 templateUrl: "./csmf-slicing-business-management.component.html",
10 styleUrls: ["./csmf-slicing-business-management.component.less"],
12 export class CsmfSlicingBusinessManagementComponent implements OnInit {
14 private myhttp: SlicingTaskServices,
15 private modalService: NzModalService,
16 private message: NzMessageService
18 @Input() currentTabTitle;
20 intervalTime: number = INTERVAL_TIME;
22 ngOnChanges(changes: SimpleChanges) {
23 if (changes.currentTabTitle.currentValue === "Communication Service") {
24 this.getCSMFBusinessList();
26 this.progressingTimer.forEach((item) => {
27 clearInterval(item.timer);
29 this.progressingTimer = [];
36 this.progressingTimer.forEach((item) => {
37 clearInterval(item.timer);
41 selectedValue: string = BUSINESS_STATUS[0];
42 listOfData: any[] = [];
43 pageIndex: number = 1;
44 pageSize: number = 10;
47 statusOptions: any[] = BUSINESS_STATUS;
48 progressingTimer: any[] = [];
49 terminateStart: any[] = [];
50 businessOrderShow: boolean = false;
51 inputBusinessOrderShow: boolean = false;
53 getCSMFBusinessList(): void {
55 // this.listOfData = []; //solve the problem of blank screen after each operation
57 status: this.selectedValue.toLocaleLowerCase(),
58 pageNo: this.pageIndex,
59 pageSize: this.pageSize,
61 const getCSMFSlicingBusinessListFailedCallback = () => {
65 .getCSMFSlicingBusinessList(
67 getCSMFSlicingBusinessListFailedCallback
71 result_body: { slicing_order_list, record_number },
74 this.total = record_number;
76 slicing_order_list !== null &&
77 slicing_order_list.length > 0
79 this.listOfData = slicing_order_list.map((item, index) => {
80 item.order_creation_time = moment(
81 Number(item.order_creation_time)
82 ).format("YYYY-MM-DD HH:mm:ss");
84 item.last_operation_progress &&
85 item.last_operation_type &&
86 Number(item.last_operation_progress) < 100
88 const updata = (prodata: {
89 operation_progress: string;
91 item.last_operation_progress =
92 prodata.operation_progress ||
93 item.last_operation_progress;
95 const obj = { serviceId: item.order_id };
97 item.last_operation_type.toUpperCase() ===
100 this.terminateStart[index] = true;
101 else this.terminateStart[index] = false;
102 this.queryProgress(obj, index, updata).then(() => {
103 item.last_operation_progress = "100";
104 this.getCSMFBusinessList();
113 getListOfProcessingStatus(): void {
116 this.progressingTimer.forEach((item) => {
117 clearInterval(item.timer);
119 this.progressingTimer = [];
120 this.getCSMFBusinessList();
124 this.progressingTimer.forEach((item) => {
125 clearInterval(item.timer);
127 this.progressingTimer = [];
128 this.getCSMFBusinessList();
131 switchChange(slicing: any, i: number): void {
132 this.modalService.confirm({
133 nzTitle: "<i>Are you sure you want to perform this task?</i>",
134 nzContent: "<b>Name:" + slicing.order_name + "</b>",
137 serviceId: slicing.order_id,
139 if (slicing.order_status === "activated") {
140 this.changeActivate(paramsObj, false, i);
142 this.changeActivate(paramsObj, true, i);
147 const singleSlicing = Object.assign({}, this.listOfData[i]);
148 this.listOfData[i] = singleSlicing;
149 this.listOfData = [...this.listOfData];
153 changeActivate(paramsObj: any, isActivate: boolean, index: number): void {
154 const changeActivateFailedCallback = () => {
155 const singleSlicing = Object.assign({}, this.listOfData[index]);
156 this.listOfData[index] = singleSlicing;
157 this.listOfData = [...this.listOfData];
158 this.getCSMFBusinessList();
161 .changeActivateSlicingService(
164 changeActivateFailedCallback
167 this.getCSMFBusinessList();
171 terminate(slicing: any, index: number): void {
172 this.modalService.confirm({
173 nzTitle: "Are you sure you want to terminate this task?",
174 nzContent: "<b>Name: </b>" + slicing.order_name,
176 const paramsObj = { serviceId: slicing.order_id };
177 this.terminateStart[index] = true;
178 const terminateFailedCallback = () => {
179 this.terminateStart[index] = false;
182 .terminateSlicingService(paramsObj, terminateFailedCallback)
184 this.getCSMFBusinessList();
189 console.info("Cancel termination");
193 queryProgress(obj: any, index: number, callback: any) {
194 return new Promise((res) => {
195 const requery = () => {
196 const queryProgressFailedCallback = () => {
197 this.progressingTimer.forEach((item) => {
198 if (item.serviceId === obj.serviceId) {
199 clearInterval(item.timer);
202 this.getCSMFBusinessList();
205 .getSlicingBusinessProgress(
207 queryProgressFailedCallback
211 data.result_body.operation_progress &&
212 Number(data.result_body.operation_progress) < 100
214 callback(data.result_body);
215 let progressSetTimeOut = setTimeout(() => {
217 }, this.intervalTime);
218 this.progressingTimer.push({
220 timer: progressSetTimeOut,
223 this.progressingTimer.forEach((item) => {
224 if (item.serviceId === obj.serviceId) {
225 clearInterval(item.timer);
228 res(data.result_body);
236 OrderModelShow(): void {
237 this.orderForm = null;
238 this.businessOrderShow = true;
240 orderModelClose($event: any): void {
241 this.businessOrderShow = $event;
242 this.getCSMFBusinessList();
244 inputOrderModelShow(): void {
245 this.inputBusinessOrderShow = true;
247 inputOrderModelClose($event: any): void {
248 this.inputBusinessOrderShow = false;
252 this.orderForm = $event.param;
253 this.businessOrderShow = true;