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 = [];
|
|
|
|
|
|
|
|
$http.get('/projects').success(function (projects) {
|
|
|
|
$scope.projects = projects;
|
2016-04-16 21:42:57 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$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 () {
|
|
|
|
}).error(function (data, status) {
|
|
|
|
swal('Error', 'Could not create project: ' + status, 'error');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
});
|