6dec5c72ab75c98f5c5d3aafbdb2cdce7ce98597
[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} 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     ) {
18     }
19
20     @Input() currentTabName;
21
22     ngOnChanges(changes: SimpleChanges) {
23         if (changes.currentTabName.currentValue === 'Slicing Subnet Instance Management') {
24             this.getNssiList()
25         }
26     }
27     ngOnInit() {}
28
29     selectedValue: string = BUSINESS_STATUS[0];
30     listOfData: any[] = [];
31     pageIndex: number = 1;
32     pageSize: number = 10;
33     total: number = 0;
34     loading = false;
35     isSelect: boolean = false;
36     statusOptions: any[] = BUSINESS_STATUS;
37
38     getNssiList(): void {
39         this.loading = true;
40         this.isSelect = false;
41         this.listOfData = [];
42         let paramsObj = {
43             pageNo: this.pageIndex,
44             pageSize: this.pageSize
45         };
46         if (this.selectedValue !== BUSINESS_STATUS[0]) {
47             paramsObj["instanceStatus"] = this.selectedValue.toLocaleLowerCase();
48             this.isSelect = true;
49         }
50         this.myhttp.getSlicingNssiList(paramsObj, this.isSelect).subscribe(res => {
51             const {result_header: {result_code}, result_body: {nssi_service_instances, record_number}} = res;
52             this.loading = false;
53             if (+result_code === 200) {
54                 this.total = record_number;
55                 this.loading = false;
56                 if (nssi_service_instances !== null && nssi_service_instances.length > 0) {
57                     this.listOfData = nssi_service_instances;
58                 }
59             }
60         }, (res) => {
61             this.loading = false;
62             console.error(res);
63         })
64     }
65
66     getListOfProcessingStatus() {
67         this.pageIndex = 1;
68         this.pageSize = 10;
69         this.getNssiList();
70     }
71
72     searchData(reset: boolean = false) {
73         this.getNssiList();
74     }
75
76     showdetail(data) {
77         const nssiModal = this.modalService.create({
78             nzTitle: "Detail",
79             nzContent: NssiModelComponent,
80             nzWidth: "70%",
81             nzOkText: null,
82             nzCancelText: null,
83             nzComponentParams: {
84                 nssiId: data.service_instance_id
85             }
86         })
87     }
88 }