2014-09-01 17:05:51 +00:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2017-05-19 15:21:02 +00:00
|
|
|
App.controller 'RenameProjectModalController', ($scope, $modalInstance, $timeout, project, queuedHttp) ->
|
2014-09-01 17:05:51 +00:00
|
|
|
$scope.inputs =
|
2017-05-19 15:21:02 +00:00
|
|
|
projectName: project.name
|
|
|
|
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
|
|
|
error: false
|
2014-09-01 17:05:51 +00:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.rename = () ->
|
2017-05-19 15:21:02 +00:00
|
|
|
$scope.state.inflight = true
|
|
|
|
$scope.state.error = false
|
|
|
|
$scope
|
|
|
|
.renameProject(project, $scope.inputs.projectName)
|
2017-06-20 10:49:55 +00:00
|
|
|
.then () ->
|
2017-05-19 15:21:02 +00:00
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close()
|
2017-06-20 15:27:05 +00:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2017-05-19 15:21:02 +00:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 15:27:05 +00:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 15:21:02 +00:00
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 17:05:51 +00: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 15:21:02 +00:00
|
|
|
error: false
|
2014-09-01 17:05:51 +00:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.clone = () ->
|
|
|
|
$scope.state.inflight = true
|
|
|
|
$scope
|
|
|
|
.cloneProject(project, $scope.inputs.projectName)
|
2017-06-20 10:49:55 +00:00
|
|
|
.then () ->
|
2014-09-01 17:05:51 +00:00
|
|
|
$scope.state.inflight = false
|
2017-05-19 15:21:02 +00:00
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close()
|
2017-06-20 15:27:05 +00:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2017-05-19 15:21:02 +00:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 15:27:05 +00:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 15:21:02 +00:00
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 17:05:51 +00:00
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
App.controller 'NewProjectModalController', ($scope, $modalInstance, $timeout, template) ->
|
|
|
|
$scope.inputs =
|
|
|
|
projectName: ""
|
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
2017-05-19 15:21:02 +00:00
|
|
|
error: false
|
2014-09-01 17:05:51 +00:00
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 200
|
|
|
|
|
|
|
|
$scope.create = () ->
|
|
|
|
$scope.state.inflight = true
|
2017-05-19 15:21:02 +00:00
|
|
|
$scope.state.error = false
|
2014-09-01 17:05:51 +00:00
|
|
|
$scope
|
|
|
|
.createProject($scope.inputs.projectName, template)
|
2017-06-20 15:27:05 +00:00
|
|
|
.then (response) ->
|
|
|
|
{ data } = response
|
2017-05-19 15:21:02 +00:00
|
|
|
$scope.state.inflight = false
|
|
|
|
$scope.state.error = false
|
|
|
|
$modalInstance.close(data.project_id)
|
2017-06-20 15:27:05 +00:00
|
|
|
.catch (response) ->
|
|
|
|
{ data, status } = response
|
2014-09-01 17:05:51 +00:00
|
|
|
$scope.state.inflight = false
|
2017-06-20 15:27:05 +00:00
|
|
|
if status == 400
|
|
|
|
$scope.state.error = { message: data }
|
2017-05-19 15:21:02 +00:00
|
|
|
else
|
|
|
|
$scope.state.error = true
|
2014-09-01 17:05:51 +00: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 12:12:11 +00:00
|
|
|
$scope.action = "delete-and-leave"
|
2014-09-01 17:05:51 +00:00
|
|
|
else if $scope.projectsToLeave.length == 0 and $scope.projectsToDelete.length > 0
|
2016-03-22 12:12:11 +00:00
|
|
|
$scope.action = "delete"
|
2014-09-01 17:05:51 +00:00
|
|
|
else
|
2016-03-22 12:12:11 +00:00
|
|
|
$scope.action = "leave"
|
2014-09-01 17:05:51 +00: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 15:11:57 +00:00
|
|
|
window.location = '/project/' + response.project_id
|
2017-11-27 13:46:08 +00:00
|
|
|
|
|
|
|
App.controller 'V1ImportModalController', ($scope, $modalInstance, project) ->
|
2017-11-28 11:31:31 +00:00
|
|
|
$scope.project = project
|
|
|
|
$scope.step = 1
|
|
|
|
|
|
|
|
$scope.dismiss = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
|
|
|
|
|
|
|
$scope.moveToConfirmation = () ->
|
|
|
|
$scope.step = 2
|