Repository: ambari Updated Branches: refs/heads/trunk ebdc22e73 -> 321ffed24
AMBARI-9092 Add warning on repo URL change if the version is current / installed. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/321ffed2 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/321ffed2 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/321ffed2 Branch: refs/heads/trunk Commit: 321ffed2478bf5f4bcdb3d8b147428b62124f982 Parents: ebdc22e Author: aBabiichuk <[email protected]> Authored: Mon Jan 12 18:35:06 2015 +0200 Committer: aBabiichuk <[email protected]> Committed: Mon Jan 12 18:35:06 2015 +0200 ---------------------------------------------------------------------- .../stackVersions/StackVersionsEditCtrl.js | 43 +++++++++++++++++--- .../app/scripts/services/ConfirmationModal.js | 4 +- .../app/views/modals/ConfirmationModal.html | 4 +- 3 files changed, 43 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/321ffed2/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js index 734650f..38a1109 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsEditCtrl.js @@ -27,6 +27,14 @@ angular.module('ambariAdminConsole') $scope.versionName = response.versionName; $scope.stackVersion = response.stackVersion; $scope.updateObj = response.updateObj; + //save default values of repos to check if they were changed + $scope.defaulfOSRepos = {}; + response.updateObj.operating_systems.forEach(function(os) { + $scope.defaulfOSRepos[os.OperatingSystems.os_type] = { + defaultBaseUrl: os.repositories[0].Repositories.base_url, + defaultUtilsUrl: os.repositories[1].Repositories.base_url + }; + }); $scope.repoVersionFullName = response.repoVersionFullName; angular.forEach(response.osList, function (os) { os.selected = true; @@ -34,21 +42,25 @@ angular.module('ambariAdminConsole') $scope.osList = response.osList; // if user reach here from UI click, repo status should be cached // otherwise re-fetch repo status from cluster end point. - var repoStatus = Cluster.repoStatusCache[$scope.id]; - if (!repoStatus) { + $scope.repoStatus = Cluster.repoStatusCache[$scope.id]; + if (!$scope.repoStatus) { $scope.fetchClusters() .then(function () { return $scope.fetchRepoClusterStatus(); }) .then(function () { - $scope.deleteEnabled = ($scope.repoStatus == 'current' || $scope.repoStatus == 'installed')? false : true; + $scope.deleteEnabled = $scope.isDeletable(); }); } else { - $scope.deleteEnabled = (repoStatus == 'current' || repoStatus == 'installed')? false : true; + $scope.deleteEnabled = $scope.isDeletable(); } $scope.addMissingOSList(); }); - } + }; + + $scope.isDeletable = function() { + return !($scope.repoStatus == 'current' || $scope.repoStatus == 'installed'); + }; $scope.addMissingOSList = function() { Stack.getSupportedOSList($scope.stackName, $scope.stackVersion) @@ -90,17 +102,38 @@ angular.module('ambariAdminConsole') }); } + $scope.defaulfOSRepos = {}; + $scope.skipValidation = false; $scope.save = function () { $scope.editVersionDisabled = true; delete $scope.updateObj.href; $scope.updateObj.operating_systems = []; + var updateRepoUrl = false; angular.forEach($scope.osList, function (os) { + var savedUrls = $scope.defaulfOSRepos[os.OperatingSystems.os_type]; if (os.selected) { + var currentRepos = os.repositories; + if (currentRepos[0].Repositories.base_url != savedUrls.defaultBaseUrl + || currentRepos[1].Repositories.base_url != savedUrls.defaultUtilsUrl) { + updateRepoUrl = true; + } $scope.updateObj.operating_systems.push(os); + } else if (savedUrls) { + updateRepoUrl = true; } }); + if (updateRepoUrl && !$scope.deleteEnabled) { + ConfirmationModal.show('Confirm Base URL Change', 'You are about to change repository Base URLs that are already in use. Please confirm that you intend to make this change and that the new Base URLs point to the same exact Stack version and build', "Confirm Change").then(function() { + $scope.updateRepoVersions(); + }); + } else { + $scope.updateRepoVersions(); + } + }; + + $scope.updateRepoVersions = function () { Stack.updateRepo($scope.stackName, $scope.stackVersion, $scope.id, $scope.updateObj).then(function () { Alert.success('Edited version <a href="#/stackVersions/' + $scope.stackName + '/' + $scope.versionName + '/edit">' + $scope.repoVersionFullName + '</a>'); $location.path('/stackVersions'); http://git-wip-us.apache.org/repos/asf/ambari/blob/321ffed2/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js index a26f1df..34d0264 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/ConfirmationModal.js @@ -21,7 +21,7 @@ angular.module('ambariAdminConsole') .factory('ConfirmationModal', ['$modal', '$q', function($modal, $q) { return { - show: function(header, body) { + show: function(header, body, confirmText, cancelText) { var deferred = $q.defer(); var modalInstance = $modal.open({ @@ -29,6 +29,8 @@ angular.module('ambariAdminConsole') controller: ['$scope', '$modalInstance', function($scope, $modalInstance) { $scope.header = header; $scope.body = body; + $scope.confirmText = confirmText || "Ok"; + $scope.cancelText = cancelText || "Cancel"; $scope.ok = function() { $modalInstance.close(); http://git-wip-us.apache.org/repos/asf/ambari/blob/321ffed2/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html index 5953d11..0b81caf 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/ConfirmationModal.html @@ -22,6 +22,6 @@ {{body}} </div> <div class="modal-footer"> - <button class="btn btn-default" ng-click="cancel()">Cancel</button> - <button class="btn btn-primary" ng-click="ok()">OK</button> + <button class="btn btn-default" ng-click="cancel()">{{cancelText}}</button> + <button class="btn btn-primary" ng-click="ok()">{{confirmText}}</button> </div> \ No newline at end of file
