ba2b8971222d98e1c2539cdda755563fb6d64b63
[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         this.myhttp.getSlicingNssiList(paramsObj, this.isSelect).subscribe(res => {
52             const {result_header: {result_code}, result_body: {nssi_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 (nssi_service_instances !== null && nssi_service_instances.length > 0) {
58                     this.listOfData = nssi_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.getNssiList();
73     }
74
75     searchData(reset: boolean = false) {
76         this.getNssiList();
77     }
78
79     showdetail(data) {
80         const nssiModal = this.modalService.create({
81             nzTitle: "Detail",
82             nzContent: NssiModelComponent,
83             nzWidth: "70%",
84             nzOkText: null,
85             nzCancelText: null,
86             nzComponentParams: {
87                 nssiId: data.service_instance_id
88             }
89         })
90     }
91 }