diff options
Diffstat (limited to 'old/moon_gui/static/app/project/action')
10 files changed, 1032 insertions, 0 deletions
diff --git a/old/moon_gui/static/app/project/action/mapping/project-map.tpl.html b/old/moon_gui/static/app/project/action/mapping/project-map.tpl.html new file mode 100755 index 00000000..5ffd98e2 --- /dev/null +++ b/old/moon_gui/static/app/project/action/mapping/project-map.tpl.html @@ -0,0 +1,62 @@ +<div ng-controller="ProjectMapController as map" class="modal" tabindex="-1" data-role="modalMappingProject"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.project.map.title" data-translate-values="{projectName: map.project.name}"></h4> + </div> + + <div class="modal-body"> + + <form class="form-horizontal" role="form" name="map.form"> + + <div class="form-group" ng-class="{'has-error': map.form.pdp.$dirty && (map.form.pdp.$invalid || !map.selectedPDP)}"> + + <label class="col-sm-3 control-label" data-translate="moon.project.map.form.pdp">PDP</label> + + <div class="col-sm-6"> + + <ui-select ng-model="map.selectedPDP" name="pdp" required> + <ui-select-match placeholder="(None)" ng-bind="$select.selected.name"></ui-select-match> + <ui-select-choices repeat="pdp in map.pdps"> + <div ng-bind="pdp.name" ng-value="pdp"></div> + </ui-select-choices> + </ui-select> + + <img ng-if="map.pdpsLoading" src="assets/img/ajax-loader.gif" /> + + <div class="help-block" ng-show="map.form.pdp.$dirty && (map.form.pdp.$invalid || !map.selectedPDP)"> + <small class="error" ng-show="map.form.pdp.$error.required" data-translate="moon.project.map.check.pdp.required">PDP is required</small> + </div> + + </div> + + </div> + + </form> + + </div> + + <div class="modal-footer"> + <div class="btn-toolbar" style="float: right;"> + <a href="" ng-click="$hide()" class="btn btn-default"> + <span data-translate="moon.project.map.action.cancel">Cancel</span> + </a> + <a href="" ng-disabled="map.mappingLoading" ng-click="map.map()" class="btn btn-warning"> + <span class="glyphicon glyphicon-link"></span> + <span data-translate="moon.project.map.action.map">Map</span> + </a> + + <img ng-if="map.mappingLoading" src="assets/img/ajax-loader.gif" /> + + </div> + </div> + + </div> + + </div> + +</div> diff --git a/old/moon_gui/static/app/project/action/mapping/project-unmap.tpl.html b/old/moon_gui/static/app/project/action/mapping/project-unmap.tpl.html new file mode 100755 index 00000000..5cc5c6dd --- /dev/null +++ b/old/moon_gui/static/app/project/action/mapping/project-unmap.tpl.html @@ -0,0 +1,33 @@ +<div ng-controller="ProjectUnMapController as unmap" class="modal" tabindex="-1" data-role="modalUnmapProject"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.project.unmap.title"></h4> + </div> + + <div class="modal-body"> + <span data-translate="moon.project.unmap.content" data-translate-values="{ projectName: unmap.project.name, pdpName: unmap.project.mapping.authz.pdp.name }"></span> + </div> + + <div class="modal-footer"> + <div class="btn-toolbar" style="float: right;"> + <a href="" ng-click="$hide()" class="btn btn-default"> + <span data-translate="moon.project.unmap.action.cancel">Cancel</span> + </a> + <a href="" ng-disabled="unmap.unMappingLoading" ng-click="unmap.unmap()" class="btn btn-warning"> + <span class="glyphicon glyphicon-transfer"></span> + <span data-translate="moon.project.unmap.action.unmap">Unmap</span> + </a> + <img ng-if="unmap.unMappingLoading" src="assets/img/ajax-loader.gif" /> + </div> + </div> + + </div> + + </div> + +</div>
\ No newline at end of file diff --git a/old/moon_gui/static/app/project/action/mapping/project.controller.map.js b/old/moon_gui/static/app/project/action/mapping/project.controller.map.js new file mode 100755 index 00000000..afa2bfc0 --- /dev/null +++ b/old/moon_gui/static/app/project/action/mapping/project.controller.map.js @@ -0,0 +1,107 @@ +/** + * @author arnaud marhin<arnaud.marhin@orange.com> + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ProjectMapController', ProjectMapController); + + ProjectMapController.$inject = ['$scope', '$translate', 'alertService', 'formService', 'pdpService']; + + function ProjectMapController($scope, $translate, alertService, formService, pdpService) { + + var map = this; + + /* + * + */ + + map.form = {}; + + map.project = $scope.project; + + map.pdps = []; + + map.pdpsLoading = true; + + map.selectedPDP = null; + + map.map = mapProject; + + activate(); + + function activate(){ + + resolvePDPs(); + + } + + /* + * + */ + + function resolvePDPs() { + + pdpService.findAllWithCallBack(resolveMappedProjects); + + } + + function resolveMappedProjects(pdps) { + + map.pdps = _.filter(pdps, function(pdp){ + return _.isNull(pdp.keystone_project_id); + }); + + map.pdpsLoading = false; + + } + + function mapProject() { + + if(formService.isInvalid(map.form)) { + + formService.checkFieldsValidity(map.form); + + } else { + + map.mappingLoading = true; + + pdpService.map( map.selectedPDP, map.project.id, mapSuccess, mapError); + + } + + function mapSuccess(data) { + + map.project.pdp = map.selectedPDP; + + $translate('moon.project.map.success', { projectName: map.project.name, pdpName: map.selectedPDP.name }).then(function (translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + map.mappingLoading = false; + + $scope.$emit('event:projectMappedSuccess', map.project); + + } + + function mapError(response) { + + $translate('moon.project.map.error', { projectName: map.project.name, pdpName: map.selectedPDP.name }).then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + map.mappingLoading = false; + + $scope.$emit('event:projectMappedError', map.project); + + } + + } + + } + +})(); diff --git a/old/moon_gui/static/app/project/action/mapping/project.controller.unmap.js b/old/moon_gui/static/app/project/action/mapping/project.controller.unmap.js new file mode 100755 index 00000000..911b30ff --- /dev/null +++ b/old/moon_gui/static/app/project/action/mapping/project.controller.unmap.js @@ -0,0 +1,74 @@ +/** + * @author arnaud marhin<arnaud.marhin@orange.com> + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ProjectUnMapController', ProjectUnMapController); + + ProjectUnMapController.$inject = ['$scope', '$translate', 'alertService', 'pdpService']; + + function ProjectUnMapController($scope, $translate, alertService, pdpService) { + + var unmap = this; + + /* + * + */ + + unmap.project = $scope.project; + unmap.unMappingLoading = false; + + unmap.unmap = unMapProject; + + /* + * + */ + + function unMapProject() { + + + unmap.unMappingLoading = true; + + var pdpName = unmap.project.pdp.name; + + pdpService.unMap(unmap.project.pdp, unMapSuccess, unMapError); + + function unMapSuccess(data) { + + $translate('moon.project.unmap.success', { projectName: unmap.project.name, pdpName: pdpName }) + .then(function (translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + unmap.unMappingLoading = false; + + delete unmap.project.mapping; + delete unmap.project.pdp; + + $scope.$emit('event:projectUnmappedSuccess', unmap.project); + + } + + function unMapError(reason) { + + $translate('moon.project.unmap.error', { projectName: unmap.project.name, pdpName: pdpName }) + .then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + unmap.unMappingLoading = false; + + $scope.$emit('event:projectUnmappedError', unmap.project); + + } + + } + + } + +})(); diff --git a/old/moon_gui/static/app/project/action/project-add.tpl.html b/old/moon_gui/static/app/project/action/project-add.tpl.html new file mode 100755 index 00000000..a90dcfa1 --- /dev/null +++ b/old/moon_gui/static/app/project/action/project-add.tpl.html @@ -0,0 +1,89 @@ +<div ng-controller="ProjectAddController as add" class="modal" tabindex="-1" data-role="modalAddProject"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.project.add.title"></h4> + </div> + + <div class="modal-body"> + + <form class="form-horizontal" role="form" name="add.form"> + + <div class="form-group" ng-class="{'has-error': add.form.name.$invalid && add.form.name.$dirty}"> + + <label for="name" class="col-sm-3 control-label" data-translate="moon.project.add.form.name">Name</label> + + <div class="col-sm-6"> + + <input name="name" id="name" class="form-control" type="text" data-ng-model="add.project.project.name" required /> + + <div class="help-block" ng-show="add.form.name.$dirty && add.form.name.$invalid"> + <small class="error" ng-show="add.form.name.$error.required" data-translate="moon.project.add.check.name.required">Name is required</small> + </div> + + </div> + </div> + + <div class="form-group"> + <label for="description" class="col-sm-3 control-label" data-translate="moon.project.add.form.description">Description</label> + <div class="col-sm-6"> + <textarea id="description" name="description" class="form-control" data-ng-model="add.project.project.description"></textarea> + </div> + </div> + + <div class="form-group"> + <label for="enabled" class="col-sm-3 control-label" data-translate="moon.project.add.form.enabled">Enabled</label> + <div class="col-sm-6"> + <div class="radio"> + <input type="checkbox" id="enabled" name="enabled" class="js-switch" data-ng-model="add.project.project.enabled" ui-switch /> + </div> + </div> + </div> + + <div class="form-group" ng-class="{'has-error': add.form.domain.$invalid && add.form.domain.$dirty}"> + + <label for="domain" class="col-sm-3 control-label" data-translate="moon.project.add.form.domain">Domain</label> + + <div class="col-sm-6"> + + <input name="domain" id="domain" type="text" class="form-control" data-ng-model="add.project.project.domain" required /> + + <div class="help-block" ng-show="add.form.domain.$dirty && add.form.domain.$invalid"> + <small class="error" ng-show="add.form.domain.$error.required" data-translate="moon.project.add.check.domain.required">Domain is required</small> + </div> + + </div> + + </div> + + </form> + + </div> + + <div class="modal-footer"> + + <div class="btn-toolbar" style="float: right;"> + + <a href="" ng-click="$hide()" class="btn btn-default"> + <span data-translate="moon.project.add.action.cancel">Cancel</span> + </a> + + <a href="" ng-disabled="add.loading" ng-click="add.create()" class="btn btn-warning"> + <span class="glyphicon glyphicon-save"></span> + <span data-translate="moon.project.add.action.create">Create</span> + </a> + <img ng-if="add.loading" src="assets/img/ajax-loader.gif" /> + + </div> + + </div> + + </div> + + </div> + +</div> diff --git a/old/moon_gui/static/app/project/action/project-delete.tpl.html b/old/moon_gui/static/app/project/action/project-delete.tpl.html new file mode 100755 index 00000000..96b4f2e3 --- /dev/null +++ b/old/moon_gui/static/app/project/action/project-delete.tpl.html @@ -0,0 +1,45 @@ +<div ng-controller="ProjectDeleteController as del" class="modal" tabindex="-1" data-role="modalDeleteProject"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.project.remove.title"></h4> + </div> + + <div class="modal-body"> + <p><span data-translate="moon.project.remove.content.query" data-translate-values="{ projectName: del.project.name }"></span></p> + + <p ng-if="del.loadingPDP"><img src="assets/img/ajax-loader.gif" /></p> + + <div ng-if="!del.loadingPDP"> + <p ng-if="!del.isProjectMapped()"><span data-translate="moon.project.remove.content.isNotMapped">This Project is not map with any PDP</span></p> + <p ng-if="del.isProjectMapped()"> + <span data-translate="moon.project.remove.content.isMapped" data-translate-values="{ pdpName: del.project.pdp.name }"></span> + </p> + </div> + + </div> + + <div class="modal-footer"> + <div class="btn-toolbar" style="float: right;"> + + <a href="" ng-click="$hide()" class="btn btn-default"> + <span data-translate="moon.project.remove.action.cancel">Cancel</span> + </a> + <a href="" ng-disabled="del.loading || del.loadingPDP" ng-click="del.remove()" class="btn btn-warning"> + <span class="glyphicon glyphicon-trash"></span> + <span data-translate="moon.project.remove.action.delete">Delete</span> + </a> + <img ng-if="del.loading" src="assets/img/ajax-loader.gif" /> + + </div> + </div> + + </div> + + </div> + +</div>
\ No newline at end of file diff --git a/old/moon_gui/static/app/project/action/project-view.tpl.html b/old/moon_gui/static/app/project/action/project-view.tpl.html new file mode 100755 index 00000000..3228c915 --- /dev/null +++ b/old/moon_gui/static/app/project/action/project-view.tpl.html @@ -0,0 +1,194 @@ +<div ng-controller="ProjectViewController as view" class="modal" tabindex="-1" data-role="modalViewProject"> + + <div class="modal-dialog"> + + <div class="modal-content"> + + <div class="modal-header"> + <button type="button" class="close" ng-click="$hide()">×</button> + <h4 class="modal-title" data-translate="moon.project.view.title" data-translate-values="{projectName: view.project.name}"></h4> + </div> + <div class="modal-body"> + <dl class="dl-horizontal"> + <dt>Id</dt> + <dd ng-bind="view.project.id"></dd> + <dt>Name</dt> + <dd ng-bind="view.project.name"></dd> + <dt>Is_domain</dt> + <dd ng-bind="view.project.is_domain"></dd> + <dt>Link</dt> + <dd ng-bind="view.project.links.self"></dd> + <dt>enabled</dt> + <dd ng-bind="view.project.enabled"></dd> + <dt>Parent id</dt> + <dd ng-bind="view.project.parent_id"></dd> + <dt>Domain id</dt> + <dd ng-bind="view.project.domain_id"></dd> + <dt>Description</dt> + <dd ng-bind="view.project.description"></dd> + </dl> + </div> + + <!--<div class="modal-body">--> + <!----> + <!--<!– objects –>--> + <!----> + <!--<div class="row">--> + <!--<div class="col-md-12">--> + <!--<h1 class="pull-left" data-translate="moon.project.view.object.title">Objects</h1>--> + <!--</div>--> + <!--</div>--> + <!----> + <!--<div class="row top05">--> + <!--<div class="col-md-3"><label data-translate="moon.project.view.object.name">Name</label></div>--> + <!--<div class="col-md-7"><label data-translate="moon.project.view.object.description">Description</label></div>--> + <!--<div class="col-md-2"><label data-translate="moon.project.view.object.enabled">Enabled</label></div>--> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="view.objectsLoading">--> + <!--<div class="col-md-12"><img src="assets/img/ajax-loader.gif" /> <em data-translate="moon.project.view.object.loading">Loading Objects</em></div>--> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="!view.objectsLoading && !view.hasObjects()">--> + <!--<div class="col-md-12" data-translate="moon.project.view.object.notFound">Objects not found</div>--> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="!view.objectsLoading && view.hasObjects()" ng-repeat="object in view.objects">--> + <!--<div class="col-md-3">{{object.name}}</div> --> + <!--<div class="col-md-7">{{object.description}}</div>--> + <!--<div class="col-md-2">--> + <!--<span ng-if="object.enabled" class="glyphicon glyphicon-ok"></span>--> + <!--</div>--> + <!--</div>--> + <!----> + <!--<!– subjects –>--> + <!----> + <!--<div class="row top10">--> + <!--<div class="col-md-12">--> + <!--<h1 class="pull-left" data-translate="moon.project.view.subject.title">Subjects</h1>--> + <!--</div>--> + <!--</div>--> + <!----> + <!--<div class="row top05">--> + <!--<div class="col-md-3"><label data-translate="moon.project.view.subject.name">Name</label></div>--> + <!--<div class="col-md-3"><label data-translate="moon.project.view.subject.domain">Domain</label></div>--> + <!--<div class="col-md-4"><label data-translate="moon.project.view.subject.mail">Mail</label></div>--> + <!--<div class="col-md-2"><label data-translate="moon.project.view.subject.enabled">Enabled</label></div>--> + <!--</div>--> + <!----> + <!--<div class="row">--> + <!--<div class="col-md-3">--> + <!--<ui-select ng-model="view.selectedSubject" on-select="view.resolveRoles($item); view.resolveGroups($item)">--> + <!--<ui-select-match placeholder="(None)">{{$select.selected.name}}</ui-select-match>--> + <!--<ui-select-choices repeat="subject in view.subjects">--> + <!--<div ng-value="subject">{{subject.name}}</div>--> + <!--</ui-select-choices>--> + <!--</ui-select>--> + <!--<img ng-if="view.subjectsLoading" src="assets/img/ajax-loader.gif" />--> + <!--</div> --> + <!--<div class="col-md-3">{{view.selectedSubject.domain}}</div>--> + <!--<div class="col-md-4">{{view.selectedSubject.mail}}</div>--> + <!--<div class="col-md-2">--> + <!--<div ng-if="view.selectedSubject != null">--> + <!--<span ng-if="view.selectedSubject.enabled" class="glyphicon glyphicon-ok"></span>--> + <!--</div>--> + <!--</div>--> + <!--</div>--> + <!----> + <!--<!– roles –>--> + <!----> + <!--<div ng-if="view.hasSelectedSubject()">--> + <!----> + <!--<div class="row top10">--> + <!--<div class="col-md-12">--> + <!--<h1 class="pull-left" data-translate="moon.project.view.role.title">Roles</h1>--> + <!--</div>--> + <!--</div>--> + <!----> + <!--<div class="row top05">--> + <!----> + <!--<div class="col-md-3"><label data-translate="moon.project.view.role.value">Value</label></div>--> + <!--<div class="col-md-5"><label data-translate="moon.project.view.role.description">Description</label></div>--> + <!--<div class="col-md-2"><label data-translate="moon.project.view.role.assigned">Assigned</label></div>--> + <!--<div class="col-md-2"><label data-translate="moon.project.view.role.enabled">Enabled</label></div>--> + <!----> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="view.rolesLoading">--> + <!--<div class="col-md-12"><img src="assets/img/ajax-loader.gif" /> <em data-translate="moon.project.view.role.loading">Loading Roles</em></div>--> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="!view.rolesLoading && !view.hasRoles()">--> + <!--<div class="col-md-12" data-translate="moon.project.view.role.notFound">Roles not found</div>--> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="!view.rolesLoading && view.hasRoles()" ng-repeat="role in view.roles">--> + <!----> + <!--<div class="col-md-3" ng-bind="role.value"></div>--> + <!--<div class="col-md-5" ng-bind="role.description"></div>--> + <!--<div class="col-md-2">--> + <!--<span ng-if="view.isRoleAssigned(role)" class="glyphicon glyphicon-ok"></span>--> + <!--</div>--> + <!--<div class="col-md-2">--> + <!--<span ng-if="role.enabled" class="glyphicon glyphicon-ok"></span>--> + <!--</div>--> + <!----> + <!--</div>--> + <!----> + <!--</div>--> + <!----> + <!--<!– groups –>--> + <!----> + <!--<div ng-if="view.hasSelectedSubject()">--> + <!----> + <!--<div class="row top10">--> + <!--<div class="col-md-12">--> + <!--<h1 class="pull-left" data-translate="moon.project.view.group.title">Groups</h1>--> + <!--</div>--> + <!--</div>--> + <!----> + <!--<div class="row top05">--> + <!----> + <!--<div class="col-md-3"><label data-translate="moon.project.view.group.value">Value</label></div>--> + <!--<div class="col-md-5"><label data-translate="moon.project.view.group.description">Description</label></div>--> + <!--<div class="col-md-2"><label data-translate="moon.project.view.group.assigned">Assigned</label></div>--> + <!--<div class="col-md-2"><label data-translate="moon.project.view.group.enabled">Enabled</label></div>--> + <!----> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="view.groupsLoading">--> + <!--<div class="col-md-12"><img src="assets/img/ajax-loader.gif" /> <em data-translate="moon.project.view.group.loading">Loading Groups</em></div>--> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="!view.groupsLoading && !view.hasGroups()">--> + <!--<div class="col-md-12" data-translate="moon.project.view.group.notFound">Groups not found</div>--> + <!--</div>--> + <!----> + <!--<div class="row" ng-if="!view.groupsLoading && view.hasGroups()" ng-repeat="group in view.groups">--> + <!----> + <!--<div class="col-md-3">{{group.value}}</div>--> + <!--<div class="col-md-5">{{group.description}}</div>--> + <!--<div class="col-md-2">--> + <!--<span ng-if="view.isGroupAssigned(group)" class="glyphicon glyphicon-ok"></span>--> + <!--</div>--> + <!--<div class="col-md-2">--> + <!--<span ng-if="group.enabled" class="glyphicon glyphicon-ok"></span>--> + <!--</div>--> + <!----> + <!--</div>--> + <!----> + <!--</div>--> + <!----> + <!--</div>--> + <!----> + <div class="modal-footer top10"> + <div class="btn-toolbar" style="float: right;"> + <button ng-click="$hide()" class="btn btn-default" data-translate="moon.project.view.action.close">Close</button> + </div> + </div> + + </div> + + </div> + +</div> diff --git a/old/moon_gui/static/app/project/action/project.controller.add.js b/old/moon_gui/static/app/project/action/project.controller.add.js new file mode 100755 index 00000000..4d12b75d --- /dev/null +++ b/old/moon_gui/static/app/project/action/project.controller.add.js @@ -0,0 +1,78 @@ +/** + * @author arnaud marhin<arnaud.marhin@orange.com> + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ProjectAddController', ProjectAddController); + + ProjectAddController.$inject = ['$scope', '$translate', 'alertService', 'formService', 'projectService', 'DEFAULT_CST']; + + function ProjectAddController($scope, $translate, alertService, formService, projectService, DEFAULT_CST) { + + var add = this; + + /* + * + */ + + add.form = {}; + + add.loading = false; + + //@todo: verify if enable argument is understood serrver-side + add.project = { project: {name: null, description: null, enabled: true, domain: DEFAULT_CST.DOMAIN.DEFAULT} }; + add.create= createProject; + + /* + * ---- create + */ + + function createProject() { + + if(formService.isInvalid(add.form)) { + + formService.checkFieldsValidity(add.form); + + } else { + + add.loading = true; + + projectService.data.projects.create({}, add.project, createSuccess, createError); + + } + + function createSuccess(data) { + + var created = data.project; + $translate('moon.project.add.success', { projectName: created.name }).then(function (translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + add.loading = false; + + $scope.$emit('event:projectCreatedSuccess', created); + + } + + function createError(reason) { + + $translate('moon.project.add.error', { projectName: add.project.project.name }).then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + add.loading = false; + + $scope.$emit('event:projectCreatedError', add.project); + + } + + } + + } + +})(); diff --git a/old/moon_gui/static/app/project/action/project.controller.delete.js b/old/moon_gui/static/app/project/action/project.controller.delete.js new file mode 100755 index 00000000..4f18f8e6 --- /dev/null +++ b/old/moon_gui/static/app/project/action/project.controller.delete.js @@ -0,0 +1,134 @@ +/** + * @author arnaud marhin<arnaud.marhin@orange.com> + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ProjectDeleteController', ProjectDeleteController); + + ProjectDeleteController.$inject = ['$scope', '$translate', 'alertService', 'projectService', 'pdpService']; + + function ProjectDeleteController($scope, $translate, alertService, projectService, pdpService) { + + var del = this; + + /* + * + */ + + del.project = $scope.project; + del.loading = false; + del.loadingPDP = true; + del.remove = deleteProjectAndMapping; + del.isProjectMapped = isProjectMapped; + del.pdps = []; + + activate(); + + /** + * + */ + + function activate(){ + + resolvePDPs(); + + } + + function resolvePDPs() { + + pdpService.findAllWithCallBack(function(data){ + + del.pdps = data; + + pdpService.mapPdpsToProject(del.project, del.pdps); + + del.loadingPDP = false; + + }); + + } + + function isProjectMapped(){ + return _.has(del.project, 'pdp'); + } + + /* + * ---- delete + */ + + + function deleteProjectAndMapping() { + + del.loading = true; + + + if(isProjectMapped() ) { + + removeMapping(deleteProject); + + }else{ + deleteProject(); + } + + } + + function removeMapping(callbackSuccess){ + + + var pdpName = unmap.project.pdp.name; + + pdpService.unMap(unmap.project, callbackSuccess, deleteMappingError); + + + function deleteMappingError(reason) { + + $translate('moon.project.remove.mapping.remove.error', { pdpName: pdpName} ).then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + del.loading = false; + + $scope.$emit('event:projectDeletedError', del.project); + + } + + + } + + function deleteProject(){ + + projectService.data.projects.remove({project_id: del.project.id}, deleteSuccess, deleteError); + + function deleteSuccess(data) { + + $translate('moon.project.remove.success', { projectName: del.project.name }).then(function (translatedValue) { + alertService.alertSuccess(translatedValue); + }); + + del.loading = false; + + $scope.$emit('event:projectDeletedSuccess', del.project); + + } + + function deleteError(reason) { + + $translate('moon.project.remove.error', { projectName: del.project.name, errorCode: reason.data.error.code, message : reason.data.error.message } ).then(function (translatedValue) { + alertService.alertError(translatedValue); + }); + + del.loading = false; + + $scope.$emit('event:projectDeletedError', del.project); + + } + + } + } + +})(); diff --git a/old/moon_gui/static/app/project/action/project.controller.view.js b/old/moon_gui/static/app/project/action/project.controller.view.js new file mode 100755 index 00000000..fe98a507 --- /dev/null +++ b/old/moon_gui/static/app/project/action/project.controller.view.js @@ -0,0 +1,216 @@ +/** + * @author arnaud marhin<arnaud.marhin@orange.com> + */ + +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('ProjectViewController', ProjectViewController); + + ProjectViewController.$inject = ['$q', '$scope', '$translate', 'alertService', 'projectService']; + + function ProjectViewController($q, $scope, $translate, alertService, projectService) { + + var view = this; + + /* + * + */ + + view.project = $scope.project; + + // view.subjects = []; + // view.subjectsLoading = true; + // view.selectedSubject = null; + // view.hasSubjects = hasSubjects; + // view.hasSelectedSubject = hasSelectedSubject; + // + // view.objects = []; + // view.objectsLoading = true; + // view.hasObjects = hasObjects; + // + // view.roles = []; + // view.groups = []; + // view.roleAssignments = []; + // view.groupAssignments = []; + // + // view.hasRoles = hasRoles; + // view.hasGroups = hasGroups; + // + // view.isRoleAssigned = isRoleAssigned; + // view.isGroupAssigned = isGroupAssigned; + // + // view.resolveRoles = resolveRoles; + // view.resolveGroups = resolveGroups; + // + // //resolveObjects(); + // //resolveSubjects(); + // + // /* + // * ---- objects + // */ + // + // function resolveObjects() { + // + // projectService.data.object.query({project_uuid: view.project.id}).$promise.then(resolveSuccess, resolveError); + // + // function resolveSuccess(data) { + // + // view.objectsLoading = false; + // view.objects = data.objects; + // + // } + // + // function resolveError(reason) { + // + // view.objectsLoading = false; + // + // $translate('moon.project.view.object.error').then(function (translatedValue) { + // alertService.alertError(translatedValue); + // }); + // + // } + // + // } + // + // function hasObjects() { + // return view.objects.length > 0; + // } + // + // /* + // * ---- subjects + // */ + // + // function resolveSubjects() { + // + // projectService.data.subject.query({project_uuid: view.project.uuid}).$promise.then(resolveSuccess, resolveError); + // + // function resolveSuccess(data) { + // + // view.subjectsLoading = false; + // view.subjects = data.users; + // + // } + // + // function resolveError(reason) { + // + // view.subjectsLoading = false; + // + // $translate('moon.project.view.subject.error').then(function (translatedValue) { + // alertService.alertError(translatedValue); + // }); + // + // } + // + // } + // + // function hasSubjects() { + // return view.subjects.lenght > 0; + // } + // + // function hasSelectedSubject() { + // return view.selectedSubject != null; + // } + // + // /* + // * ---- role + // */ + // + // function isRoleAssigned(role) { + // + // return _(view.roleAssignment.attributes).find(function(role_uuid) { + // return role.uuid === role_uuid; + // }).length !== 0; + // + // } + // + // function hasRoles() { + // return view.roles.length > 0; + // } + // + // function resolveRoles(subject) { + // + // view.rolesLoading = true; + // + // view.roles = []; + // view.roleAssignment = null; + // + // var promises = { roles: projectService.data.subjectRole.get({project_uuid: view.project.uuid, user_uuid: subject.uuid}).$promise, + // roleAssigment: projectService.data.roleAssigment.get({project_uuid: view.project.uuid, user_uuid: subject.uuid}).$promise }; + // + // $q.all(promises).then(resolveSuccess, resolveError); + // + // function resolveSuccess(data) { + // + // view.rolesLoading = false; + // view.roles = data.roles.roles; + // view.roleAssignment = _.first(data.roleAssigment.role_assignments); + // + // } + // + // function resolveError(reason) { + // + // view.rolesLoading = false; + // + // $translate('moon.project.view.role.error').then(function (translatedValue) { + // alertService.alertError(translatedValue); + // }); + // + // } + // + // } + // + // /* + // * ---- group + // */ + // + // function isGroupAssigned(group) { + // + // return _($scope.view.groupAssignment.attributes).find(function(group_uuid) { + // return group.uuid === group_uuid; + // }).length !== 0; + // + // } + // + // function hasGroups() { + // return view.groups.length > 0; + // } + // + // function resolveGroups(subject) { + // + // view.groupsLoading = true; + // + // view.groups = []; + // view.groupAssignment = null; + // + // var promises = { groups: projectService.data.subjectGroup.get({project_uuid: view.project.uuid, user_uuid: subject.uuid}).$promise, + // groupAssignment: projectService.data.groupAssigment.get({project_uuid: view.project.uuid, user_uuid: subject.uuid}).$promise }; + // + // $q.all(promises).then(resolveSuccess, resolveError); + // + // function resolveSuccess(data) { + // + // view.groupsLoading = false; + // view.groups = data.groups.groups; + // view.groupAssignment = _.first(data.groupAssignment.group_assignments); + // + // } + // + // function resolveError(reason) { + // + // view.groupsLoading = false; + // + // $translate('moon.project.view.group.error').then(function (translatedValue) { + // alertService.alertError(translatedValue); + // }); + // + // } + // + // } + // + } + +})(); |