From d182202fc6001983541504ed323d68479086317e Mon Sep 17 00:00:00 2001 From: WuKong Date: Sat, 22 Apr 2017 13:25:07 +0200 Subject: add moonv4 Change-Id: I247af788d0b0fb961fbc85416486b241eb1d807c Signed-off-by: WuKong --- .../action/mapping/project.controller.unmap.js | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 moonv4/moon_gui/static/app/project/action/mapping/project.controller.unmap.js (limited to 'moonv4/moon_gui/static/app/project/action/mapping/project.controller.unmap.js') diff --git a/moonv4/moon_gui/static/app/project/action/mapping/project.controller.unmap.js b/moonv4/moon_gui/static/app/project/action/mapping/project.controller.unmap.js new file mode 100644 index 00000000..911b30ff --- /dev/null +++ b/moonv4/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); + + } + + } + + } + +})(); -- cgit 1.2.3-korg