0397de9cfcb403965a731a98cc62c4f3e2e85b10
[usecase-ui.git] /
1 import {Component, OnInit} from '@angular/core';
2 import {SlicingTaskServices} from '.././../../../../../core/services/slicingTaskServices';
3 import {BUSINESS_STATUS} from '../../../../../../../constants/constants';
4 import { NzModalService } from 'ng-zorro-antd';
5
6 @Component({
7     selector: 'app-slicing-business-table',
8     templateUrl: './slicing-business-table.component.html',
9     styleUrls: ['./slicing-business-table.component.less']
10 })
11 export class SlicingBusinessTableComponent implements OnInit {
12
13     constructor(
14         private myhttp: SlicingTaskServices,
15         private modalService: NzModalService
16         ) {
17     }
18
19     ngOnInit() {
20         this.getBusinessList()
21     }
22
23     selectedValue = null;
24     switchStatusAll: any[] = [];
25     listOfData: any[] = [];
26     pageIndex: number = 1;
27     pageSize: number = 10;
28     total: number = 100;
29     loading = false;
30     statusOptions: any[] = BUSINESS_STATUS;
31
32
33     getBusinessList (): void{
34         this.loading = true;
35         let paramsObj = {
36             pageNo: this.pageIndex,
37             pageSize: this.pageSize
38         };
39         this.myhttp.getSlicingBusinessList(paramsObj).subscribe (res => {
40             const { result_header: { result_code }, result_body: { slicing_business_list } } = res;
41             if (+result_code === 200) {
42                 this.listOfData = slicing_business_list;
43                 this.total = slicing_business_list.length;
44                 this.switchStatusAll = slicing_business_list.map((item)=>{
45                     return item.orchestration_status
46                 });
47                 this.loading = false;
48             }
49         })
50     }
51     searchData(reset: boolean = false) {
52         this.getBusinessList();
53     }
54     switchChange(data,i){
55         console.log(data,i,"----- switchChange");
56         this.modalService.confirm({
57             nzTitle: '<i>Do you Want to'+(data.orchestration_status === 'activated'?'deactivated':'activated')+ 'slicing business?</i>',
58             nzContent: '<b>service_instance_id:'+data.service_instance_id+'</b>',
59             nzOnOk: () => {
60                 let paramsObj = {
61                     serviceId:data.service_instance_id
62                 };
63                 if(data.orchestration_status === 'activated'){
64                     this.myhttp.changeActivateSlicingService(paramsObj,false).subscribe (res => {
65                         const { result_header: { result_code }, result_body: { operation_id } } = res;
66                         if (+result_code === 200) {
67                             this.switchStatusAll[i] = 'deactivated';
68                             console.log(operation_id,"operation_id")
69                         }
70                     })
71                 }else {
72                     this.myhttp.changeActivateSlicingService(paramsObj,true).subscribe (res => {
73                         const { result_header: { result_code, result_message }} = res;
74                         if (+result_code === 200) {
75                             this.switchStatusAll[i] = 'activated';
76                             console.log(result_message,"result_message")
77                         }
78                     })
79                 }
80             },
81             nzCancelText: 'No',
82             nzOnCancel: () => {
83                 this.switchStatusAll[i] = data.orchestration_status
84             }
85         });
86     }
87     terminate(data){
88
89     }
90     showdetail(data){
91
92     }
93     getListOfProcessingStatus(){
94
95     }
96 }