Commit 0f3b076061524380bfc3bbc4733365665cee697d
1 parent
1ba832b3
Exists in
master
แก้ยิง api
Showing
1 changed file
with
23 additions
and
1 deletions
Show diff stats
src/app/dashboard/dashboard.component.ts
@@ -37,7 +37,29 @@ export class DashboardComponent implements OnInit { | @@ -37,7 +37,29 @@ export class DashboardComponent implements OnInit { | ||
37 | ) { } | 37 | ) { } |
38 | 38 | ||
39 | async ngOnInit() { | 39 | async ngOnInit() { |
40 | - | 40 | + try { |
41 | + const data = { | ||
42 | + // tslint:disable-next-line:max-line-length | ||
43 | + 'query': 'SELECT vtiger_account.accountname AS custgroupName , vtiger_troubletickets.ticketid AS id , IF( vtiger_groups.groupname is not null , vtiger_groups.groupname , vu.user_name) as team , vtiger_troubletickets.title , vtiger_troubletickets. STATUS , vtiger_troubletickets.priority , CONCAT( \'http%3A%2F%2Fvtiger.sourcecode.co.th%2Findex.php%3Faction%3DDetailView%26module%3DHelpDesk%26parenttab%3DSupport%26record%3D\' , vtiger_troubletickets.ticketid) AS link ,( SELECT xx.comments FROM vtiger_ticketcomments xx WHERE xx.ticketid = vtiger_troubletickets.ticketid ORDER BY xx.createdtime DESC LIMIT 1) AS COMMENT , CASE vtiger_troubletickets. STATUS WHEN \'Closed\' THEN( unix_timestamp(vtiger_crmentity.modifiedtime) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 ELSE( unix_timestamp(now()) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 END AS days , concat( vtiger_ticketcf.cf_568 , \' (\' , vtiger_cf_568.day_amount , \')\') AS type , IFNULL(( SELECT \'Wait for response by\' FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = \'Wait for response\' ORDER BY updatetime DESC LIMIT 0 , 1) , \'Created by\') userType , IFNULL(( SELECT concat(\'\' , assigned_by , \'\') FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = \'Wait for response\' ORDER BY updatetime DESC LIMIT 0 , 1) , vtiger_users.user_name) username , vtiger_crmentity.description , vtiger_crmentity.createdtime , vtiger_crmentity.modifiedtime , vtiger_cf_568.cf_568id FROM vtiger_crmentity JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smcreatorid JOIN vtiger_troubletickets ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid JOIN vtiger_account ON vtiger_account.accountid = vtiger_troubletickets.parent_id JOIN vtiger_ticketcf ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid JOIN vtiger_cf_568 ON vtiger_cf_568.cf_568 = vtiger_ticketcf.cf_568 LEFT OUTER JOIN vtiger_groups ON vtiger_crmentity.smownerid = vtiger_groups.groupid LEFT OUTER JOIN vtiger_users vu ON vtiger_crmentity.smownerid = vu.id WHERE 1 AND vtiger_crmentity.setype = \'HelpDesk\' AND vtiger_crmentity.deleted = 0 AND vtiger_ticketcf.cf_568 != \'\' AND vtiger_cf_568.cf_568id NOT IN(8 , 9 , 10) AND( LCASE(vtiger_cf_568.cf_568) = \'set (ติดตั้ง)\' AND LCASE(vtiger_troubletickets. STATUS) != \'closed\') GROUP BY vtiger_troubletickets.ticketid ORDER BY vtiger_crmentity.createdtime ASC LIMIT 0 , 100', | ||
44 | + 'params': ['vtiger_crmentity'] | ||
45 | + }; | ||
46 | + let response = await this._apiService.post('dynamic', data); | ||
47 | + if (response !== null) { | ||
48 | + this.resultData = response; | ||
49 | + this.resultData.link = decodeURIComponent(decodeURIComponent(this.resultData.link)); | ||
50 | + console.log('link: ', this.resultData.link); | ||
51 | + // tslint:disable-next-line:forin | ||
52 | + for (const i in this.resultData) { | ||
53 | + this.resultData[i].link = this._common.decodeURI(this.resultData[i].link); | ||
54 | + this.resultData[i].birth_date = this._common.convertDate(this.resultData[i].birth_date); | ||
55 | + } | ||
56 | + } else { | ||
57 | + this.resultData = []; | ||
58 | + } | ||
59 | + } catch (error) { | ||
60 | + console.log(error); | ||
61 | + } | ||
62 | + | ||
41 | setInterval(async() => { | 63 | setInterval(async() => { |
42 | await this.getData(); | 64 | await this.getData(); |
43 | }, 600000); | 65 | }, 600000); |