08716e98a649286fead3e915f13c3e8e97f9eae3
[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, NzMessageService} 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         private message: NzMessageService
18     ) {
19     }
20
21     @Input() currentTabName;
22
23     ngOnChanges(changes: SimpleChanges) {
24         if (changes.currentTabName.currentValue === 'Slicing Instance Management') {
25             this.getNsiList()
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     getNsiList(): 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         this.myhttp.getSlicingNsiList(paramsObj, this.isSelect).subscribe(res => {
52             const {result_header: {result_code}, result_body: {nsi_service_instances, record_number}} = res;
53             this.loading = false;
54             if (+result_code === 200) {
55                 this.total = record_number;
56                 this.loading = false;
57                 if (nsi_service_instances !== null && nsi_service_instances.length > 0) {
58                     this.listOfData = nsi_service_instances;
59                 }
60             }else {
61                 this.message.error(res.result_header.result_message)
62             }
63         }, (res) => {
64             this.loading = false;
65             this.message.error(res);
66         })
67     }
68
69     getListOfProcessingStatus() {
70         this.pageIndex = 1;
71         this.pageSize = 10;
72         this.getNsiList();
73     }
74
75     searchData(reset: boolean = false) {
76         this.getNsiList();
77     }
78
79     showdetail(data) {
80         const nsiModal = this.modalService.create({
81             nzTitle: "Detail",
82             nzContent: NsiModelComponent,
83             nzWidth: "70%",
84             nzOkText: null,
85             nzCancelText: null,
86             nzComponentParams: {
87                 nsiId: data.service_instance_id
88             }
89         })
90     }
91 }