Skip to content

Commit 530f74c

Browse files
committed
Added support for postgresql and timeline feature
1 parent 38e55de commit 530f74c

19 files changed

+1222
-33
lines changed

appinfo/database.xml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,143 @@
361361
</table>
362362

363363

364+
<table>
365+
<name>*dbprefix*timetracker_timeline_entry</name>
366+
367+
<declaration>
368+
<field>
369+
<name>id</name>
370+
<type>integer</type>
371+
<default>0</default>
372+
<notnull>true</notnull>
373+
<autoincrement>1</autoincrement>
374+
<length>4</length>
375+
</field>
376+
<field>
377+
<name>timeline_id</name>
378+
<type>integer</type>
379+
<length>4</length>
380+
</field>
381+
<field>
382+
<name>user_uid</name>
383+
<type>text</type>
384+
<notnull>true</notnull>
385+
<length>128</length>
386+
</field>
387+
<field>
388+
<name>name</name>
389+
<type>text</type>
390+
<notnull>true</notnull>
391+
<length>64</length>
392+
</field>
393+
<field>
394+
<name>project_name</name>
395+
<type>text</type>
396+
<notnull>true</notnull>
397+
<length>64</length>
398+
</field>
399+
<field>
400+
<name>client_name</name>
401+
<type>text</type>
402+
<notnull>true</notnull>
403+
<length>64</length>
404+
</field>
405+
<field>
406+
<name>time_interval</name>
407+
<type>text</type>
408+
<notnull>true</notnull>
409+
<length>64</length>
410+
</field>
411+
<field>
412+
<name>total_duration</name>
413+
<type>text</type>
414+
<notnull>true</notnull>
415+
<length>64</length>
416+
</field>
417+
<field>
418+
<name>created_at</name>
419+
<type>integer</type>
420+
<notnull>true</notnull>
421+
<length>4</length>
422+
</field>
423+
</declaration>
424+
</table>
425+
426+
427+
<table>
428+
<name>*dbprefix*timetracker_timeline</name>
429+
430+
<declaration>
431+
<field>
432+
<name>id</name>
433+
<type>integer</type>
434+
<default>0</default>
435+
<notnull>true</notnull>
436+
<autoincrement>1</autoincrement>
437+
<length>4</length>
438+
</field>
439+
<field>
440+
<name>status</name>
441+
<type>text</type>
442+
<notnull>true</notnull>
443+
<length>64</length>
444+
</field>
445+
<field>
446+
<name>user_uid</name>
447+
<type>text</type>
448+
<notnull>true</notnull>
449+
<length>128</length>
450+
</field>
451+
<field>
452+
<name>group1</name>
453+
<type>text</type>
454+
<notnull>false</notnull>
455+
<length>64</length>
456+
</field>
457+
<field>
458+
<name>group2</name>
459+
<type>text</type>
460+
<notnull>false</notnull>
461+
<length>64</length>
462+
</field>
463+
<field>
464+
<name>time_group</name>
465+
<type>text</type>
466+
<notnull>false</notnull>
467+
<length>64</length>
468+
</field>
469+
<field>
470+
<name>filter_projects</name>
471+
<type>text</type>
472+
<notnull>false</notnull>
473+
<length>64</length>
474+
</field>
475+
<field>
476+
<name>filter_clients</name>
477+
<type>text</type>
478+
<notnull>false</notnull>
479+
<length>64</length>
480+
</field>
481+
<field>
482+
<name>time_interval</name>
483+
<type>text</type>
484+
<notnull>false</notnull>
485+
<length>64</length>
486+
</field>
487+
<field>
488+
<name>total_duration</name>
489+
<type>text</type>
490+
<notnull>true</notnull>
491+
<length>64</length>
492+
</field>
493+
<field>
494+
<name>created_at</name>
495+
<type>integer</type>
496+
<notnull>true</notnull>
497+
<length>4</length>
498+
</field>
499+
</declaration>
500+
</table>
501+
502+
364503
</database>

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>Time Tracker</name>
66
<summary>Time Tracker App</summary>
77
<description><![CDATA[Time Tracker App]]></description>
8-
<version>0.0.27</version>
8+
<version>0.0.29</version>
99
<licence>agpl</licence>
1010
<author mail="[email protected]" >MTier Ltd.</author>
1111
<namespace>TimeTracker</namespace>

appinfo/routes.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
['name' => 'projects#index', 'url' => '/projects', 'verb' => 'GET'],
1818
['name' => 'dashboard#index', 'url' => '/dashboard', 'verb' => 'GET'],
1919
['name' => 'reports#index', 'url' => '/reports', 'verb' => 'GET'],
20+
['name' => 'timelines#index', 'url' => '/timelines', 'verb' => 'GET'],
21+
['name' => 'timelinesAdmin#index', 'url' => '/timelines-admin', 'verb' => 'GET'],
22+
2023
['name' => 'tags#index', 'url' => '/tags', 'verb' => 'GET'],
2124

2225
['name' => 'ajax#start_timer', 'url' => '/ajax/start-timer/{name}', 'verb' => 'POST'],
@@ -45,5 +48,10 @@
4548
['name' => 'ajax#delete_tag', 'url' => '/ajax/delete-tag/{id}', 'verb' => 'POST'],
4649

4750
['name' => 'ajax#get_report', 'url' => '/ajax/report', 'verb' => 'GET'],
51+
['name' => 'ajax#post_timeline', 'url' => '/ajax/timeline', 'verb' => 'POST'],
52+
['name' => 'ajax#get_timelines', 'url' => '/ajax/timelines', 'verb' => 'GET'],
53+
['name' => 'ajax#get_timelines_admin', 'url' => '/ajax/timelines-admin', 'verb' => 'GET'],
54+
['name' => 'ajax#download_timeline', 'url' => '/ajax/download-timeline/{id}', 'verb' => 'GET'],
55+
['name' => 'ajax#edit_timeline', 'url' => '/ajax/edit-timeline/{id}', 'verb' => 'POST'],
4856
]
4957
];

js/timelines-admin.js

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
(function() {
2+
3+
4+
function timeConverter(UNIX_timestamp){
5+
var a = new Date(UNIX_timestamp * 1000);
6+
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
7+
var year = a.getFullYear();
8+
var month = months[a.getMonth()];
9+
var date = a.getDate();
10+
var hour = a.getHours();
11+
var min = a.getMinutes();
12+
var sec = a.getSeconds();
13+
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
14+
return time;
15+
}
16+
17+
$( function() {
18+
19+
var group1 = "project";
20+
var group2 = "user";
21+
var group3 = "day";
22+
var filterProjectId = "";
23+
var filterClientId = "";
24+
25+
26+
$(document).ready(function() {
27+
$("#dialog-confirm").dialog({
28+
autoOpen: false,
29+
modal: true
30+
});
31+
32+
33+
34+
function editTimeline(dialogTimelineEditForm){
35+
target = dialogTimelineEditForm.target;
36+
form = dialogTimelineEditForm.find( "form" );
37+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/edit-timeline/'+target.getData().id);
38+
var jqxhr = $.post( baseUrl, {status:form.find("#status").val()},function() {
39+
getTimelines();
40+
$(dialogTimelineEditForm).dialog("close");
41+
})
42+
.done(function(data, status, jqXHR) {
43+
var response = data;
44+
if ('Error' in response){
45+
alert(response.Error);
46+
}
47+
})
48+
.fail(function() {
49+
alert( "error" );
50+
});
51+
52+
}
53+
54+
dialogTimelineEditForm = $( "#dialog-timeline-edit-form" ).dialog({
55+
autoOpen: false,
56+
height: 400,
57+
width: 350,
58+
modal: true,
59+
create: function( event, ui ) {
60+
61+
},
62+
buttons: {
63+
"Edit timeline": { text:'Edit timeline',
64+
click:function(){
65+
editTimeline(dialogTimelineEditForm);
66+
}, class:'primary'},
67+
Cancel: function() {
68+
dialogTimelineEditForm.dialog( "close" );
69+
}
70+
},
71+
close: function() {
72+
73+
74+
}
75+
});
76+
77+
78+
79+
getTimelines();
80+
81+
function getTimelines(){
82+
83+
var editIcon = function(cell, formatterParams){ //plain text value
84+
return "<i class='fa fa-edit'></i>";
85+
};
86+
function pad(n, width, z) {
87+
z = z || '0';
88+
n = n + '';
89+
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
90+
}
91+
92+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/timelines-admin');
93+
var table = new Tabulator("#timelines", {
94+
ajaxURL:baseUrl,
95+
layout:"fitColumns",
96+
// rowClick:function(e, row){
97+
// e.preventDefault();
98+
// dialogTimelineEditForm.target = row;
99+
// debugger;
100+
// dialogTimelineEditForm.find('#status').val(row.getData().status);
101+
// dialogTimelineEditForm.dialog("open");
102+
// return false;
103+
// },
104+
columns:[
105+
//{title:"Id", field:"id", width:100}, //column has a fixed width of 100px;
106+
{title:"#", field:"", formatter:"rownum"},
107+
{title:"Id", field:"id", widthGrow:1}, //column will be allocated 1/5 of the remaining space
108+
{title:"User", field:"userUid", widthGrow:1}, //column will be allocated 1/5 of the remaining space
109+
{title:"Status", field:"status", widthGrow:1}, //column will be allocated 1/5 of the remaining space
110+
111+
//{title:"User", field:"userUid", widthGrow:1}, //column will be allocated 1/5 of the remaining space
112+
//{title:"Project", field:"projectName", widthGrow:1}, //column will be allocated 1/5 of the remaining space
113+
//{title:"Client", field:"clientName", widthGrow:1}, //column will be allocated 1/5 of the remaining space
114+
{title:"When", field:"timeInterval", widthGrow:1}, //column will be allocated 1/5 of the remaining space
115+
{title:"Total Duration", field:"totalDuration",formatter:function(cell, formatterParams, onRendered){
116+
//cell - the cell component
117+
//formatterParams - parameters set for the column
118+
//onRendered - function to call when the formatter has been rendered
119+
var duration = cell.getValue();
120+
var s = Math.floor( (duration) % 60 );
121+
var m = Math.floor( (duration/60) % 60 );
122+
var h = Math.floor( (duration/(60*60)));
123+
124+
return pad(h,2) + ':' + pad(m,2) + ':' + pad(s,2);
125+
126+
},}, //column will be allocated 1/5 of the remaining space
127+
{title:"created At", field:"createdAt",formatter:function(cell, formatterParams, onRendered){
128+
//cell - the cell component
129+
//formatterParams - parameters set for the column
130+
//onRendered - function to call when the formatter has been rendered
131+
var unix = cell.getValue();
132+
133+
return timeConverter(unix);
134+
135+
},}, //column will be allocated 1/5 of the remaining space
136+
{title:"Download", field:"", formatter:"rownum",formatter:function(cell, formatterParams, onRendered){
137+
//cell - the cell component
138+
//formatterParams - parameters set for the column
139+
//onRendered - function to call when the formatter has been rendered
140+
//debugger;
141+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/download-timeline/'+cell.getRow().getData()["id"]);
142+
143+
return '<a href="'+baseUrl+'">'+"Download"+'</a>';
144+
145+
}},
146+
147+
{formatter:editIcon, width:40, align:"center", cellClick:function(e, cell){
148+
149+
dialogTimelineEditForm.target = cell.getRow();
150+
//debugger;
151+
dialogTimelineEditForm.find('#status').val(cell.getRow().getData().status);
152+
dialogTimelineEditForm.dialog("open");
153+
return false;
154+
155+
}},
156+
157+
],
158+
ajaxResponse:function(url, params, response){
159+
160+
return response.Timelines; //return the tableData property of a response json object
161+
},
162+
});
163+
164+
}
165+
});
166+
167+
168+
} );
169+
}());

0 commit comments

Comments
 (0)