Semaphore/public/js/controllers/projects/edit.js
Matej Kramny b4cab16fda Improved UI
- Fixes #94
- Fixes admin permissions (needed to manipulate users)
2016-06-17 13:16:46 -07:00

30 lines
930 B
JavaScript

define(function () {
app.registerController('ProjectEditCtrl', ['$scope', '$http', 'Project', '$state', function ($scope, $http, Project, $state) {
$scope.projectName = Project.name;
$scope.save = function (name) {
$http.put(Project.getURL(), { name: name }).success(function () {
swal('Saved', 'Project settings saved.', 'success');
}).error(function () {
swal('Error', 'Project settings were not saved', 'error');
});
}
$scope.deleteProject = function () {
swal({
title: 'Delete Project?',
text: 'All data related to this project will be deleted.',
type: 'warning',
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Yes, DELETE'
}, function () {
$http.delete(Project.getURL()).success(function () {
$state.go('dashboard');
}).error(function () {
swal('error', 'could not delete project!', 'error');
});
});
}
}]);
});