Semaphore/public/js/controllers/dashboard.js

30 lines
784 B
JavaScript
Raw Normal View History

2016-04-02 14:40:07 +02:00
define(['controllers/projects/edit'], function () {
app.registerController('DashboardCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $modal) {
$scope.projects = [];
$scope.refresh = function () {
$http.get('/projects').success(function (projects) {
$scope.projects = projects;
});
$http.get('/events').success(function (events) {
$scope.events = events;
});
}
2016-04-02 14:40:07 +02:00
$scope.addProject = function () {
$modal.open({
templateUrl: '/tpl/projects/add.html'
}).result.then(function (project) {
$http.post('/projects', project)
.success(function () {
$scope.refresh();
2016-04-02 14:40:07 +02:00
}).error(function (data, status) {
swal('Error', 'Could not create project: ' + status, 'error');
});
});
}
$scope.refresh();
2016-04-02 14:40:07 +02:00
}]);
});