From 7bb53c64da2dcf88894bfd31503accdd81498f3d Mon Sep 17 00:00:00 2001 From: Thomas Duval Date: Wed, 3 Jun 2020 10:06:52 +0200 Subject: Update to new version 5.4 Signed-off-by: Thomas Duval Change-Id: Idcd868133d75928a1ffd74d749ce98503e0555ea --- .../project/action/mapping/project-map.tpl.html | 62 ++++++ .../project/action/mapping/project-unmap.tpl.html | 33 ++++ .../action/mapping/project.controller.map.js | 107 ++++++++++ .../action/mapping/project.controller.unmap.js | 74 +++++++ .../static/app/project/action/project-add.tpl.html | 89 +++++++++ .../app/project/action/project-delete.tpl.html | 45 +++++ .../app/project/action/project-view.tpl.html | 194 ++++++++++++++++++ .../app/project/action/project.controller.add.js | 78 ++++++++ .../project/action/project.controller.delete.js | 134 +++++++++++++ .../app/project/action/project.controller.view.js | 216 +++++++++++++++++++++ 10 files changed, 1032 insertions(+) create mode 100755 old/moon_gui/static/app/project/action/mapping/project-map.tpl.html create mode 100755 old/moon_gui/static/app/project/action/mapping/project-unmap.tpl.html create mode 100755 old/moon_gui/static/app/project/action/mapping/project.controller.map.js create mode 100755 old/moon_gui/static/app/project/action/mapping/project.controller.unmap.js create mode 100755 old/moon_gui/static/app/project/action/project-add.tpl.html create mode 100755 old/moon_gui/static/app/project/action/project-delete.tpl.html create mode 100755 old/moon_gui/static/app/project/action/project-view.tpl.html create mode 100755 old/moon_gui/static/app/project/action/project.controller.add.js create mode 100755 old/moon_gui/static/app/project/action/project.controller.delete.js create mode 100755 old/moon_gui/static/app/project/action/project.controller.view.js (limited to 'old/moon_gui/static/app/project/action') 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 @@ + 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 @@ + \ 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 + */ + +(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 + */ + +(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 @@ + 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 @@ + \ 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 @@ + 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 + */ + +(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 + */ + +(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 + */ + +(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); + // }); + // + // } + // + // } + // + } + +})(); -- cgit 1.2.3-korg