Commit 1ba832b3f0b7526486f6830469962906473ce15e
1 parent
2ce7949d
Exists in
master
ยิง api ทุก 10 นาที กับ ทำคอมเม้น
Showing
5 changed files
with
32 additions
and
12 deletions
Show diff stats
src/app/app.module.ts
... | ... | @@ -13,10 +13,12 @@ import { CommonService } from './services/common/common.service'; |
13 | 13 | import { AppComponent } from './app.component'; |
14 | 14 | import { LayoutComponent } from './layout/layout.component'; |
15 | 15 | import { DashboardComponent } from './dashboard/dashboard.component'; |
16 | +import { ShortPipe } from './dashboard/short'; | |
16 | 17 | |
17 | 18 | @NgModule({ |
18 | 19 | declarations: [ |
19 | 20 | AppComponent, |
21 | + ShortPipe, | |
20 | 22 | LayoutComponent, |
21 | 23 | DashboardComponent |
22 | 24 | ], | ... | ... |
src/app/dashboard/dashboard.component.html
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | [ngStyle] = "{'background-color': getColorDay(item.days.toFixed(0))}"> |
9 | 9 | <!-- <div [ngStyle]="{'background-color':item.days === '366.0098' ? 'green' : 'red' }"></<div> --> |
10 | 10 | <!-- <div class="avater">{{(item.days).toFixed(0)}} D</div> --> |
11 | - <div class="avater" [ngStyle]="{'background-color': getColorDay(item.days.toFixed(0))}" style="font-size: 26px; text-align: center; font-weight: bold;" >{{(item.days).toFixed(0)}}D</div> | |
11 | + <div class="avater" [ngStyle]="{'background-color': getColorDay(item.days.toFixed(0))}" style="font-size: 25px; text-align: center; font-weight: bold;" >{{item.days.toFixed(0)}}D</div> | |
12 | 12 | <div class="visual"> |
13 | 13 | <i class="fa fa-comments"></i> |
14 | 14 | </div> |
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <span data-counter="counterup" data-value="">{{item.custgroupName}}</span> |
20 | 20 | </div> |
21 | 21 | <div class="desc" style=" color: black;">{{item.team}}</div><br> |
22 | - <div class="desc" style="text-align: left; text-align: bottom; color: black;">{{item.COMMENT | slice:0:20 }} ....</div> | |
22 | + <div class="desc" style="text-align: left; text-align: bottom; color: black;">{{item.COMMENT | short}}</div> | |
23 | 23 | <!-- <div class="desc" style="text-align: left; text-align: bottom; color: black;">{{(item.COMMENT > 20)? | (item.COMMENT | slice:0:20) + '....':(item.COMMENT)}}</div> --> |
24 | 24 | </div> |
25 | 25 | </a> | ... | ... |
src/app/dashboard/dashboard.component.scss
src/app/dashboard/dashboard.component.ts
... | ... | @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; |
2 | 2 | import { ActivatedRoute, Router } from '@angular/router'; |
3 | 3 | import { ApiService } from '../services/api.service'; |
4 | 4 | import { CommonService } from '../services/common/common.service'; |
5 | +import { async } from 'rxjs/internal/scheduler/async'; | |
5 | 6 | |
6 | 7 | @Component({ |
7 | 8 | selector: 'app-dashboard', |
... | ... | @@ -36,13 +37,21 @@ export class DashboardComponent implements OnInit { |
36 | 37 | ) { } |
37 | 38 | |
38 | 39 | async ngOnInit() { |
39 | - const data = { | |
40 | - // tslint:disable-next-line:max-line-length | |
41 | - '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', | |
42 | - 'params': ['vtiger_crmentity'] | |
43 | - }; | |
40 | + | |
41 | + setInterval(async() => { | |
42 | + await this.getData(); | |
43 | + }, 600000); | |
44 | + | |
45 | + } | |
46 | + | |
47 | + async getData() { | |
44 | 48 | try { |
45 | - const response = await this._apiService.post('dynamic', data); | |
49 | + const data = { | |
50 | + // tslint:disable-next-line:max-line-length | |
51 | + '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', | |
52 | + 'params': ['vtiger_crmentity'] | |
53 | + }; | |
54 | + let response = await this._apiService.post('dynamic', data); | |
46 | 55 | if (response !== null) { |
47 | 56 | this.resultData = response; |
48 | 57 | this.resultData.link = decodeURIComponent(decodeURIComponent(this.resultData.link)); |
... | ... | @@ -59,7 +68,8 @@ export class DashboardComponent implements OnInit { |
59 | 68 | console.log(error); |
60 | 69 | } |
61 | 70 | } |
62 | - } | |
71 | + | |
72 | +} | |
63 | 73 | |
64 | 74 | // getColor(color) { |
65 | 75 | // console.log(color) | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +import { PipeTransform, Pipe } from "@angular/core"; | |
2 | + | |
3 | +@Pipe ({ | |
4 | + name: 'short' | |
5 | +}) | |
6 | +export class ShortPipe implements PipeTransform { | |
7 | + transform(value: string): string { | |
8 | + return value.substr(0, 30) + ' ...'; | |
9 | + } | |
10 | +} | |
0 | 11 | \ No newline at end of file | ... | ... |