2016-12-21 11:12:35 +01:00
|
|
|
define(['controllers/projects/taskRunner'], function() {
|
|
|
|
app.registerController('ProjectDashboardCtrl', ['$scope', '$http', 'Project', '$uibModal', '$rootScope', function($scope, $http, Project, $modal, $rootScope) {
|
|
|
|
$http.get(Project.getURL() + '/events').success(function(events) {
|
|
|
|
$scope.events = events;
|
2016-04-17 02:20:23 +02:00
|
|
|
|
2016-12-21 11:12:35 +01:00
|
|
|
events.forEach(function(evt) {
|
|
|
|
evt.createdFormatted = moment(evt.created).format('DD/M/YY HH:MM')
|
|
|
|
})
|
|
|
|
});
|
2016-04-17 02:20:23 +02:00
|
|
|
|
2016-12-21 11:12:35 +01:00
|
|
|
$scope.reload = function() {
|
|
|
|
$http.get(Project.getURL() + '/tasks').success(function(tasks) {
|
|
|
|
$scope.tasks = tasks;
|
2016-04-17 02:20:23 +02:00
|
|
|
|
2016-12-21 11:12:35 +01:00
|
|
|
$scope.tasks.forEach(function(t) {
|
|
|
|
if (t.created) {
|
|
|
|
t.createdFormatted = moment(t.created).format('DD/M/YY HH:MM')
|
|
|
|
}
|
|
|
|
if (t.start) {
|
|
|
|
t.startFormatted = moment(t.start).format('DD/M/YY HH:MM:ss')
|
|
|
|
}
|
|
|
|
if (t.end) {
|
|
|
|
t.endFormatted = moment(t.end).format('DD/M/YY HH:MM:ss')
|
|
|
|
}
|
2016-04-17 02:20:23 +02:00
|
|
|
|
2016-12-21 11:12:35 +01:00
|
|
|
if (!t.start || !t.end) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-17 02:20:23 +02:00
|
|
|
|
2016-12-21 11:12:35 +01:00
|
|
|
t.duration = moment(t.start).diff(moment(t.end), 'minutes');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$scope.reload();
|
|
|
|
|
|
|
|
$scope.openTask = function(task) {
|
|
|
|
var scope = $rootScope.$new();
|
|
|
|
scope.task = task;
|
|
|
|
scope.project = Project;
|
|
|
|
|
|
|
|
$modal.open({
|
|
|
|
templateUrl: '/tpl/projects/taskModal.html',
|
|
|
|
controller: 'TaskCtrl',
|
|
|
|
scope: scope,
|
|
|
|
size: 'lg'
|
|
|
|
}).result.then(function() {
|
|
|
|
$scope.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}]);
|
2016-04-02 14:40:07 +02:00
|
|
|
});
|