3c08463d02a456f1fd608e2f7fc9ee80d77e206f
[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 {NsiModelComponent} from "../nsi-model/nsi-model.component";
5 import {NzModalService} from 'ng-zorro-antd';
6
7 @Component({
8     selector: 'app-nsi-table',
9     templateUrl: './nsi-table.component.html',
10     styleUrls: ['./nsi-table.component.less']
11 })
12 export class NsiTableComponent 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 Instance Management') {
24             this.getNsiList()
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     getNsiList(): 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.getSlicingNsiList(paramsObj, this.isSelect).subscribe(res => {
51             const {result_header: {result_code}, result_body: {nsi_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 (nsi_service_instances !== null && nsi_service_instances.length > 0) {
57                     this.listOfData = nsi_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.getNsiList();
70     }
71
72     searchData(reset: boolean = false) {
73         this.getNsiList();
74     }
75
76     showdetail(data) {
77         const nsiModal = this.modalService.create({
78             nzTitle: "Detail",
79             nzContent: NsiModelComponent,
80             nzWidth: "70%",
81             nzOkText: null,
82             nzCancelText: null,
83             nzComponentParams: {
84                 nsiId: data.service_instance_id
85             }
86         })
87     }
88 }