2014-09-01 13:05:51 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2017-05-19 11:21:02 -04:00
|
|
|
App.controller 'RenameProjectModalController', ($scope, $modalInstance, $timeout, project, queuedHttp) ->
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope.inputs =
|
2017-05-19 11:21:02 -04:00
|
|
|
projectName: project.name
|
|
|
|
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
|
|
|
error: false
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.rename = () ->
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = true
|
|
|
|
$scope.state.error = false
|
|
|
|
$scope
|
|
|
|
.renameProject(project, $scope.inputs.projectName)
|
2017-06-20 06:49:55 -04:00
|
|
|
.then () ->
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close()
|
2017-06-20 11:27:05 -04:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 11:27:05 -04:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 11:21:02 -04:00
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
App.controller 'CloneProjectModalController', ($scope, $modalInstance, $timeout, project) ->
|
|
|
|
$scope.inputs =
|
|
|
|
projectName: project.name + " (Copy)"
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
2017-05-19 11:21:02 -04:00
|
|
|
error: false
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.clone = () ->
|
|
|
|
$scope.state.inflight = true
|
|
|
|
$scope
|
|
|
|
.cloneProject(project, $scope.inputs.projectName)
|
2017-06-20 06:49:55 -04:00
|
|
|
.then () ->
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope.state.inflight = false
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close()
|
2017-06-20 11:27:05 -04:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 11:27:05 -04:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 11:21:02 -04:00
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
App.controller 'NewProjectModalController', ($scope, $modalInstance, $timeout, template) ->
|
|
|
|
$scope.inputs =
|
|
|
|
projectName: ""
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
2017-05-19 11:21:02 -04:00
|
|
|
error: false
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.create = () ->
|
|
|
|
$scope.state.inflight = true
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.error = false
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope
|
|
|
|
.createProject($scope.inputs.projectName, template)
|
2017-06-20 11:27:05 -04:00
|
|
|
.then (response) ->
|
|
|
|
{ data } = response
|
2017-05-19 11:21:02 -04:00
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close(data.project_id)
|
2017-06-20 11:27:05 -04:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2014-09-01 13:05:51 -04:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 11:27:05 -04:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 11:21:02 -04:00
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
App.controller 'DeleteProjectsModalController', ($scope, $modalInstance, $timeout, projects) ->
|
|
|
|
$scope.projectsToDelete = projects.filter (project) -> project.accessLevel == "owner"
|
|
|
|
$scope.projectsToLeave = projects.filter (project) -> project.accessLevel != "owner"
|
|
|
|
|
|
|
|
if $scope.projectsToLeave.length > 0 and $scope.projectsToDelete.length > 0
|
2016-03-22 08:12:11 -04:00
|
|
|
$scope.action = "delete-and-leave"
|
2014-09-01 13:05:51 -04:00
|
|
|
else if $scope.projectsToLeave.length == 0 and $scope.projectsToDelete.length > 0
|
2016-03-22 08:12:11 -04:00
|
|
|
$scope.action = "delete"
|
2014-09-01 13:05:51 -04:00
|
|
|
else
|
2016-03-22 08:12:11 -04:00
|
|
|
$scope.action = "leave"
|
2014-09-01 13:05:51 -04:00
|
|
|
|
|
|
|
$scope.delete = () ->
|
|
|
|
$modalInstance.close()
|
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
|
|
|
|
App.controller 'UploadProjectModalController', ($scope, $modalInstance, $timeout) ->
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
$scope.onComplete = (error, name, response) ->
|
|
|
|
if response.project_id?
|
2016-01-28 10:11:57 -05:00
|
|
|
window.location = '/project/' + response.project_id
|
2017-11-27 08:46:08 -05:00
|
|
|
|
|
|
|
App.controller 'V1ImportModalController', ($scope, $modalInstance, project) ->
|
|
|
|
console.log('V1ImportModalController', project)
|