summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/intent-management/intent-management.component.ts
blob: acd37ec92fa178b2d363ab259c66f1d5efd5efb9 (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
import { Component, OnInit } from '@angular/core';
import { IntentManagementService } from '../../core/services/intentManagement.service'

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

  constructor(private myhttp: IntentManagementService) { }

  ngOnInit() {
    this.getIntentManagementData()
  }

  listOfData: any[] = [];
  intentModuleShow: boolean = false;
  editIntentTableList: Object={};
  currentIndex: number=-1;

  getIntentManagementData():void{
    this.myhttp.getIntentManagementData()
    .subscribe(
      (data) => {
        this.listOfData=data
      },
      (err) => {
        console.error(err);
      }
    )
  }
  inputIntentModuleShow(): void {
    this.intentModuleShow = true;
  }
  inputIntentModuleClose($event: any): void {
    this.intentModuleShow = false;
    this.editIntentTableList={}
    if ($event.cancel) {
        return;
    }
    if(this.currentIndex>-1){
      this.listOfData[this.currentIndex]=$event.param
      this.currentIndex=-1
    }
    this.getIntentManagementData()
  }
  editIntentList(data,i): void {
    this.editIntentTableList=JSON.parse(JSON.stringify(data))
    this.currentIndex=i
    this.intentModuleShow = true
  }
  deleteIntentList(data): void{
    this.myhttp.deleteIntentManagementData(data.intentId).subscribe((data) => {
      this.getIntentManagementData()
    }, (err) => {
      console.log(err);
    });
  }
}