Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Implemented cost field in workitem and display it in dashboard and re…
…ports
  • Loading branch information
Harm Akkerman committed Jun 1, 2022
commit 5396c96fc509981e0499b8ada7c77b9da333483d
10 changes: 6 additions & 4 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* it's instantiated in there
*/


return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
Expand All @@ -18,9 +18,9 @@
['name' => 'dashboard#index', 'url' => '/dashboard', 'verb' => 'GET'],
['name' => 'reports#index', 'url' => '/reports', 'verb' => 'GET'],
['name' => 'timelines#index', 'url' => '/timelines', 'verb' => 'GET'],

['name' => 'timelinesAdmin#index', 'url' => '/timelines-admin', 'verb' => 'GET'],

['name' => 'tags#index', 'url' => '/tags', 'verb' => 'GET'],
['name' => 'goals#index', 'url' => '/goals', 'verb' => 'GET'],

Expand All @@ -31,8 +31,10 @@
['name' => 'ajax#update_work_interval', 'url' => '/ajax/update-work-interval/{id}', 'verb' => 'POST'],
['name' => 'ajax#add_work_interval', 'url' => '/ajax/add-work-interval/{name}', 'verb' => 'POST'],
['name' => 'ajax#delete_work_interval', 'url' => '/ajax/delete-work-interval/{id}', 'verb' => 'POST'],
['name' => 'ajax#add_cost', 'url' => '/ajax/add-cost/{id}', 'verb' => 'POST'],


['name' => 'ajax#get_clients', 'url' => '/ajax/clients', 'verb' => 'GET'],
['name' => 'ajax#get_clients', 'url' => '/ajax/clients', 'verb' => 'GET'],
['name' => 'ajax#add_client', 'url' => '/ajax/add-client/{name}', 'verb' => 'POST'],
['name' => 'ajax#edit_client', 'url' => '/ajax/edit-client/{id}', 'verb' => 'POST'],
['name' => 'ajax#delete_client', 'url' => '/ajax/delete-client/{id}', 'verb' => 'POST'],
Expand Down
482 changes: 274 additions & 208 deletions js/src/dashboard.js

Large diffs are not rendered by default.

55 changes: 30 additions & 25 deletions js/src/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var dtf = require("./dateformat.js");
'The Month Before Last': [moment().subtract(2, 'month').startOf('month'), moment().subtract(2, 'month').endOf('month')],
'This Year': [moment().startOf('year'), moment().endOf('year')],
'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')],

},
locale: {
format: dtf.dformat(),
Expand All @@ -68,15 +68,15 @@ var dtf = require("./dateformat.js");
$("#group1").select2();
$("#group2").select2();
$("#group3").select2();
$('#group1').on("select2:select select2:unselect", function(e) {
$('#group1').on("select2:select select2:unselect", function(e) {
group1 = e.params.data.id;
getReport();
});
$('#group2').on("select2:select select2:unselect", function(e) {
$('#group2').on("select2:select select2:unselect", function(e) {
group2 = e.params.data.id;
getReport();
});
$('#group3').on("select2:select select2:unselect", function(e) {
$('#group3').on("select2:select select2:unselect", function(e) {
group3 = e.params.data.id;
getReport();
});
Expand All @@ -96,15 +96,15 @@ var dtf = require("./dateformat.js");
);
return $state;
},
ajax: {
ajax: {
tags: true,
url: OC.generateUrl('/apps/timetracker/ajax/projects'),

dataType: 'json',
delay: 250,

processResults: function (data, page) { //json parse
return {
return {
results: $.map(data.Projects,function(val, i){
return { id: val.id, text:val.name, color: val.color};
}),
Expand All @@ -114,13 +114,13 @@ var dtf = require("./dateformat.js");
};
},
cache: false,

},
});

$('#filter-project').on("select2:select select2:unselect", function(e) {
$('#filter-project').on("select2:select select2:unselect", function(e) {


filterProjectId = ($(e.target).val() != null)? $(e.target).val() : "";
getReport();
});
Expand All @@ -133,14 +133,14 @@ var dtf = require("./dateformat.js");
escapeMarkup : function(markup) { return markup; },
placeholder: "Select client",
allowClear: true,
ajax: {
ajax: {
tags: true,
url: OC.generateUrl('/apps/timetracker/ajax/clients'),

dataType: 'json',
delay: 250,
processResults: function (data, page) { //json parse
return {
return {
results: $.map(data.Clients,function(val, i){
return { id: val.id, text:val.name};
}),
Expand All @@ -150,23 +150,23 @@ var dtf = require("./dateformat.js");
};
},
cache: false,

},
});

$('#filter-client').on("select2:select select2:unselect", function(e) {

$('#filter-client').on("select2:select select2:unselect", function(e) {


filterClientId = ($(e.target).val() != null)? $(e.target).val() : "";
getReport();
});


$('input.select2-input').attr('autocomplete', "xxxxxxxxxxx");



function getReport(){
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/report?name=&from='+start.unix()+'&to='+end.unix()+'&group1='+group1+'&group2='+group2+'&timegroup='+group3+'&filterProjectId='+filterProjectId+'&filterClientId='+filterClientId);
function pad(n, width, z) {
Expand Down Expand Up @@ -203,6 +203,10 @@ var dtf = require("./dateformat.js");
var nullCheckAccessor = function(value, data, type, params, column){
return value ? value : '';
}

var money = function(value, data, type, params, component) {
return value / 100;
}
var table = new Tabulator("#report", {
ajaxURL:baseUrl,
layout:"fitColumns",
Expand All @@ -229,6 +233,7 @@ var dtf = require("./dateformat.js");
return moment.unix(t).format(dtf.dtformat());
}
}},
{title:"Cost", field:"cost", mutator:money, accessorDownload: nullCheckAccessor, widthGrow:1, bottomCalc: "sum", formatter: "money", bottomCalcFormatter: "money"}, //column will be allocated 1/5 of the remaining space
{title:"Total Duration", field:"totalDuration",accessorDownload:totalDurationAccessor,formatter:function(cell, formatterParams, onRendered){
//cell - the cell component
//formatterParams - parameters set for the column
Expand All @@ -238,7 +243,7 @@ var dtf = require("./dateformat.js");
var m = Math.floor( (duration/60) % 60 );
var h = Math.floor( (duration/(60*60)));
return pad(h,2) + ':' + pad(m,2) + ':' + pad(s,2);

},bottomCalc:"sum", bottomCalcParams:{
precision:1,
},bottomCalcFormatter:function(cell, formatterParams, onRendered){
Expand All @@ -263,11 +268,11 @@ var dtf = require("./dateformat.js");
var time = cell.getRow().getData().time;
var duration = cell.getRow().getData().totalDuration;
return moment.unix(parseInt(time) + parseInt(duration)).format(dtf.dtformat());

}},
],
ajaxResponse:function(url, params, response){

return response.items; //return the tableData property of a response json object
},
});
Expand Down
Loading