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 --- .../action/mapping/project.controller.map.js | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100755 old/moon_gui/static/app/project/action/mapping/project.controller.map.js (limited to 'old/moon_gui/static/app/project/action/mapping/project.controller.map.js') 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); + + } + + } + + } + +})(); -- cgit 1.2.3-korg