summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/services/intent-based-services/intent-instance/intent-instance.component.ts
blob: d13b9d7ea54659f7a7791abb0432e915901562d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { NzMessageService } from "ng-zorro-antd";
import { intentBaseService } from "../../../../core/services/intentBase.service";

@Component({
  selector: 'app-intent-instance',
  templateUrl: './intent-instance.component.html',
  styleUrls: ['./intent-instance.component.less']
})
export class IntentInstanceComponent implements OnInit {

  constructor(
    private router:Router,
    private myHttp: intentBaseService,
    private nzMessage: NzMessageService 
  ) {}

	ngOnChanges() {}

	ngOnInit() {
    this.pageIndex = 1;
    this.pageSize = 10;
    this.getIntentionInstanceList();
  }

	ngOnDestroy() {}

  // table lists
	listOfData: any[] = [];
  // pageSize or pageNum
	pageIndex: number = 1;
	pageSize: number = 10;
	total: number = 0;
	loading = false;
  
  // init source data
	getIntentionInstanceList(): void {
    this.myHttp.getIntentInstanceList({
      currentPage: this.pageIndex,
      pageSize: this.pageSize
    }).subscribe((response) => {
      const { code, message, data:{ totalRecords, list } } = response;
      if (code !== 200) {
        this.nzMessage.error(message);
				return;
      }
      
      this.total = totalRecords;
      this.listOfData = list;
    }, (err) => {
      console.log(err);
    });
  }

  // change page message
  searchData(): void {
    this.getIntentionInstanceList();
  }

  verificationIntentionInstance(row): void {
    this.myHttp.verifyIntentInstance({
      id: row.id
    }).subscribe((response) => {
      const { code, message, data } = response;
      if (code !== 200) {
        this.nzMessage.error(message);
				return;
      }
      this.nzMessage.success(data);
      this.resetParam2Query();
    }, (err) => {
      console.log(err);
    });
  }

  deleteIntentionInstance(row): void {
    this.myHttp.delIntentInstance(row.id).subscribe((response) => {
      const { code, message } = response;
      if (code !== 200) {
        this.nzMessage.error(message);
				return;
      }
      this.nzMessage.success('Delete IntentionInstance Success');
      this.resetParam2Query();
    }, (err) => {
      console.log(err);
    });
  }

  resetParam2Query() {
    this.pageIndex = 1;
    this.pageSize = 10;
    this.getIntentionInstanceList();
  }
}