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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
import { Component, OnInit } from '@angular/core';
import { IntentManagementService } from '../../core/services/intentManagement.service'
import {NzMessageService} from "ng-zorro-antd";
@Component({
selector: 'app-intent-management',
templateUrl: './intent-management.component.html',
styleUrls: ['./intent-management.component.less']
})
export class IntentManagementComponent implements OnInit {
constructor(
private myhttp: IntentManagementService,
private message: NzMessageService,
) { }
ngOnInit() {
this.getIntentManagementData()
}
ngOnDestroy(){
window.clearInterval(this.timer)
}
listOfData: any[] = [];
reportData: any[] = [];
intentInfo: Object={
intentId:'',
intentName:'',
reportTime: ''
};
timer: any;
intentModuleShow: boolean = false;
intentReportDetailShow: boolean = false;
editIntentTableList: Object={};
currentIndex: number=-1;
getIntentManagementData():void{
this.myhttp.getIntentManagementData()
.subscribe(
(data) => {
this.listOfData=data.result_body
this.getIntentReportData(this.listOfData)
this.timer=setInterval(()=>{
this.getIntentReportData(this.listOfData)
},5000)
},
(err) => {
this.message.error('Failed to obtain intent data');
}
)
}
getIntentReportData(data): void{
data.forEach(item => {
this.myhttp.getIntentReportData(item.intentId).subscribe(
(data) => {
item.intentStatus=data.result_body.fulfillmentInfos[0].fulfillmentStatus
},
(err) => {
this.message.error('Failed to obtain Report data');
}
)
});
}
inputIntentModuleShow(): void {
this.intentModuleShow = true;
}
inputIntentModuleClose($event: any): void {
this.intentModuleShow = false;
this.editIntentTableList={}
if ($event.cancel) {
return;
}
this.getIntentManagementData()
}
intentReportModuleClose($event: any): void {
this.intentReportDetailShow = false
if ($event.cancel) {
return;
}
}
viewReport(data,i): void{
this.reportData=[]
this.intentInfo={
intentId:'',
intentName:'',
reportTime: ''
};
this.intentInfo['intentId']=data['intentId']
this.intentInfo['intentName']=data['intentName']
this.myhttp.getIntentReportData(data.intentId).subscribe(
(data) => {
this.reportData=data.result_body.fulfillmentInfos
this.intentInfo['reportTime']=data.result_body.reportTime
this.intentReportDetailShow = true
},
(err) => {
this.message.error('Failed to obtain Report data');
}
)
}
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()
if(data.result_header.result_code===200){
this.message.success('Deleted successfully');
}else{
this.message.error(data.result_header.result_message);
}
}, (err) => {
this.message.error('Deletion failed');
});
}
}
|