5fe303b0be25c3c80b0ec6424fbc113d77b65d55
[usecase-ui.git] /
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 {NssiModelComponent} from "../nssi-model/nssi-model.component";
6
7 @Component({
8     selector: 'app-nssi-table',
9     templateUrl: './nssi-table.component.html',
10     styleUrls: ['./nssi-table.component.less']
11 })
12 export class NssiTableComponent implements OnInit {
13
14     constructor(
15         private myhttp: SlicingTaskServices,
16         private modalService: NzModalService,
17         private message: NzMessageService
18     ) {
19     }
20
21     @Input() currentTabName;
22
23     ngOnChanges(changes: SimpleChanges) {
24         if (changes.currentTabName.currentValue === 'Slicing Subnet Instance Management') {
25             this.getNssiList()
26         }
27     }
28     ngOnInit() {}
29
30     selectedValue: string = BUSINESS_STATUS[0];
31     listOfData: any[] = [];
32     pageIndex: number = 1;
33     pageSize: number = 10;
34     total: number = 0;
35     loading = false;
36     isSelect: boolean = false;
37     statusOptions: any[] = BUSINESS_STATUS;
38
39     getNssiList(): void {
40         this.loading = true;
41         this.isSelect = false;
42         this.listOfData = [];
43         let paramsObj = {
44             pageNo: this.pageIndex,
45             pageSize: this.pageSize
46         };
47         if (this.selectedValue !== BUSINESS_STATUS[0]) {
48             paramsObj["instanceStatus"] = this.selectedValue.toLocaleLowerCase();
49             this.isSelect = true;
50         }
51         let getSlicingNssiListFailedCallback  = () => {
52             this.loading = false;
53         }
54         this.myhttp.getSlicingNssiList(paramsObj, this.isSelect, getSlicingNssiListFailedCallback).then(res => {
55             const { result_body: {nssi_service_instances, record_number} } = res;
56             this.loading = false;
57             this.total = record_number;
58             this.loading = false;
59             if (nssi_service_instances !== null && nssi_service_instances.length > 0) {
60                 this.listOfData = nssi_service_instances;
61             }
62         })
63     }
64
65     getListOfProcessingStatus() {
66         this.pageIndex = 1;
67         this.pageSize = 10;
68         this.getNssiList();
69     }
70
71     searchData(reset: boolean = false) {
72         this.getNssiList();
73     }
74
75     showdetail(data) {
76         const nssiModal = this.modalService.create({
77             nzTitle: "Detail",
78             nzContent: NssiModelComponent,
79             nzWidth: "70%",
80             nzOkText: null,
81             nzCancelText: null,
82             nzComponentParams: {
83                 nssiId: data.service_instance_id
84             }
85         })
86     }
87 }