Repository: ambari Updated Branches: refs/heads/branch-2.2 8df64c479 -> 782526f8a
AMBARI-13216: Add a Add button to Repo management UI (mithmatt via bhuvnesh2703) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/782526f8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/782526f8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/782526f8 Branch: refs/heads/branch-2.2 Commit: 782526f8a6428b2194e0c2593640793d15caacdf Parents: 8df64c4 Author: Bhuvnesh Chaudhary <[email protected]> Authored: Fri Mar 4 10:32:39 2016 -0800 Committer: Bhuvnesh Chaudhary <[email protected]> Committed: Fri Mar 4 10:32:39 2016 -0800 ---------------------------------------------------------------------- .../main/resources/ui/admin-web/app/index.html | 1 + .../app/scripts/controllers/mainCtrl.js | 9 +- .../stackVersions/StackVersionsCreateCtrl.js | 10 ++- .../stackVersions/StackVersionsEditCtrl.js | 10 ++- .../app/scripts/services/AddRepositoryModal.js | 95 ++++++++++++++++++++ .../resources/ui/admin-web/app/styles/main.css | 3 + .../app/views/modals/AddRepositoryModal.html | 63 +++++++++++++ .../views/stackVersions/stackVersionPage.html | 12 ++- ambari-web/app/config.js | 3 +- 9 files changed, 199 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-admin/src/main/resources/ui/admin-web/app/index.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/index.html b/ambari-admin/src/main/resources/ui/admin-web/app/index.html index fe049ac..4522f7f 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/index.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/index.html @@ -156,6 +156,7 @@ <script src="scripts/services/GetDifference.js"></script> <script src="scripts/services/UnsavedDialog.js"></script> <script src="scripts/services/Stack.js"></script> + <script src="scripts/services/AddRepositoryModal.js"></script> <!-- endbuild --> </body> </html> http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js index 1213d0d..90643a0 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js @@ -18,7 +18,7 @@ 'use strict'; angular.module('ambariAdminConsole') -.controller('MainCtrl',['$scope','$rootScope','$window','Auth', 'Alert', '$modal', 'Cluster', 'View', function($scope, $rootScope, $window, Auth, Alert, $modal, Cluster, View) { +.controller('MainCtrl',['$scope','$rootScope','$window','Auth', 'Alert', '$modal', 'Cluster', 'View', '$http', 'Settings', function($scope, $rootScope, $window, Auth, Alert, $modal, Cluster, View, $http, Settings) { $scope.signOut = function() { Auth.signout().finally(function() { $window.location.pathname = ''; @@ -26,6 +26,13 @@ angular.module('ambariAdminConsole') }; $scope.ambariVersion = null; + $rootScope.supports = {}; + + $http.get(Settings.baseUrl + "/persist/user-pref-" + Auth.getCurrentUser() + "-supports") + .then(function(data, status, headers) { + $rootScope.supports = data.data ? data.data : {}; + }); + $scope.about = function() { var ambariVersion = $scope.ambariVersion; http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js index 97a7696..9a524bd 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/stackVersions/StackVersionsCreateCtrl.js @@ -18,7 +18,7 @@ 'use strict'; angular.module('ambariAdminConsole') -.controller('StackVersionsCreateCtrl', ['$scope', 'Stack', '$routeParams', '$location', 'Alert', function($scope, Stack, $routeParams, $location, Alert) { +.controller('StackVersionsCreateCtrl', ['$scope', 'Stack', '$routeParams', '$location', 'Alert', 'AddRepositoryModal', function($scope, Stack, $routeParams, $location, Alert, AddRepositoryModal) { $scope.createController = true; $scope.osList = []; $scope.skipValidation = false; @@ -153,4 +153,12 @@ angular.module('ambariAdminConsole') $location.path('/stackVersions'); }; + /** + * TODO create parent controller for StackVersionsEditCtrl and StackVersionsCreateCtrl and + * move this method to it + */ + $scope.addRepository = function() { + AddRepositoryModal.show($scope.osList, $scope.stackName, $scope.stackVersion, $scope.id); + }; + }]); http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/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 dcd79df..4d3f339 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 @@ -18,7 +18,7 @@ 'use strict'; angular.module('ambariAdminConsole') -.controller('StackVersionsEditCtrl', ['$scope', '$location', 'Cluster', 'Stack', '$routeParams', 'ConfirmationModal', 'Alert', function($scope, $location, Cluster, Stack, $routeParams, ConfirmationModal, Alert) { +.controller('StackVersionsEditCtrl', ['$scope', '$location', 'Cluster', 'Stack', '$routeParams', 'ConfirmationModal', 'Alert', 'AddRepositoryModal', function($scope, $location, Cluster, Stack, $routeParams, ConfirmationModal, Alert, AddRepositoryModal) { $scope.editController = true; $scope.osList = []; $scope.skipValidation = false; @@ -248,4 +248,12 @@ angular.module('ambariAdminConsole') $location.path('/stackVersions'); }; + /** + * TODO create parent controller for StackVersionsEditCtrl and StackVersionsCreateCtrl and + * move this method to it + */ + $scope.addRepository = function() { + AddRepositoryModal.show($scope.osList, $scope.stackName, $scope.stackVersion, $scope.id); + }; + }]); http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/AddRepositoryModal.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/AddRepositoryModal.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/AddRepositoryModal.js new file mode 100644 index 0000000..d4238c8 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/AddRepositoryModal.js @@ -0,0 +1,95 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +angular.module('ambariAdminConsole') + .factory('AddRepositoryModal', ['$modal', '$q', function($modal, $q) { + return { + show: function(osList, stackName, stackVersion, repositoryVersionId) { + var deferred = $q.defer(); + var modalInstance = $modal.open({ + templateUrl: 'views/modals/AddRepositoryModal.html', + controller: ['$scope', '$modalInstance', function($scope, $modalInstance) { + $scope.osTypes = osList.map(function(os) { + return os.OperatingSystems.os_type; + }); + $scope.repo = { + selectedOS: $scope.osTypes[0] + }; + + // Check if repository with the same repoId exists among repositories for the selectedOS + var repoExists = function(existingRepos, repoId) { + for(var i = existingRepos.length - 1; i >= 0; --i) { + if (existingRepos[i].Repositories.repo_id === repoId) { + return true; + } + } + return false; + }; + + $scope.add = function(newRepo) { + var repositoriesForOS; + + // Get existing list of repositories for selectedOS + for(var i = osList.length - 1; i >= 0; --i) { + if (osList[i].OperatingSystems.os_type === newRepo.selectedOS) { + osList[i].repositories = osList[i].repositories || []; + repositoriesForOS = osList[i].repositories; + break; + } + } + + // If repo with the same id exists for the selectedOS, show an alert and do not take any action + $scope.showAlert = repoExists(repositoriesForOS, newRepo.id); + if($scope.showAlert) { + return; + } + + // If no duplicate repository is found on the selectedOS, add the new repository + repositoriesForOS.push({ + Repositories: { + repo_id: newRepo.id, + repo_name: newRepo.name, + os_type: newRepo.selectedOS, + base_url: newRepo.baseUrl, + stack_name: stackName, + stack_version: stackVersion, + repository_version_id: repositoryVersionId + } + }); + + $modalInstance.close(); + deferred.resolve(); + }; + + $scope.cancel = function() { + $modalInstance.dismiss(); + deferred.reject(); + }; + }] + }); + modalInstance.result.then(function() { + // Gets triggered on close + }, function() { + // Gets triggered on dismiss + deferred.reject(); + }); + return deferred.promise; + } + }; + }]); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css index ff963ee..4e4bc3c 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css +++ b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css @@ -1330,4 +1330,7 @@ accordion .panel-group .panel{ padding-left: 20px; margin-top: 10px; margin-bottom: 10px; +} +.pull-up { + margin-top: -2px; } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/AddRepositoryModal.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/AddRepositoryModal.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/AddRepositoryModal.html new file mode 100644 index 0000000..c53a908 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/AddRepositoryModal.html @@ -0,0 +1,63 @@ +<!-- +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +--> +<div class="modal-header" xmlns="http://www.w3.org/1999/html"> + <h3 class="modal-title">Add Repository</h3> +</div> +<form class="form-horizontal" name="addRepoForm" novalidate> + <div class="modal-body"> + <div class="alert alert-warning hide-soft" ng-class="{'visible' : showAlert}" role="alert"> + A repository with the same Repo ID already exists for {{repo.selectedOS}}! + </div> + <div class="form-group"> + <div class="col-sm-3"> + <label class="control-label">OS</label> + </div> + <div class="col-sm-4"> + <select class="form-control" ng-options="os for os in osTypes" ng-model="repo.selectedOS"></select> + </div> + </div> + <div class="form-group"> + <div class="col-sm-3"> + <label class="control-label">Repo ID</label> + </div> + <div class="col-sm-9"> + <input name="repoId" type="text" class="form-control" ng-model="repo.id" ng-required="required"> + </div> + </div> + <div class="form-group"> + <div class="col-sm-3"> + <label class="control-label">Repo Name</label> + </div> + <div class="col-sm-9"> + <input name="repoName" type="text" class="form-control" ng-model="repo.name" ng-required="required"> + </div> + </div> + <div class="form-group"> + <div class="col-sm-3"> + <label class="control-label">Base URL</label> + </div> + <div class="col-sm-9"> + <input name="repoUrl" type="text" class="form-control" ng-model="repo.baseUrl" ng-required="required"> + </div> + </div> + </div> + <div class="modal-footer"> + <button class="btn btn-default" ng-click="cancel()">Cancel</button> + <button class="btn btn-primary" ng-disabled="addRepoForm.$invalid" ng-click="add(repo)" >Add</button> + </div> +</form> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html index 0c6ca84..98fc442 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/stackVersions/stackVersionPage.html @@ -59,9 +59,15 @@ </div> </div> <div class="panel panel-default"> - <div class="panel-heading"> - <h3 class="panel-title">Repositories</h3> - </div> + <div class="panel-heading"> + <h3 class="panel-title"> + Repositories + <button ng-show="supports.addingNewRepository" class="btn btn-primary pull-right btn-xs pull-up" ng-click="addRepository()"> + <span class="glyphicon glyphicon-plus"></span> + Add Repository + </button> + </h3> + </div> <div class="panel-body "> <div class="alert alert-info" role="alert"> Provide Base URLs for the Operating Systems you are configuring. Uncheck all other Operating Systems. http://git-wip-us.apache.org/repos/asf/ambari/blob/782526f8/ambari-web/app/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js index 098a0dc..5b6b179 100644 --- a/ambari-web/app/config.js +++ b/ambari-web/app/config.js @@ -78,7 +78,8 @@ App.supports = { showPageLoadTime: false, skipComponentStartAfterInstall: false, storeKDCCredentials: true, - preInstallChecks: false + preInstallChecks: false, + addingNewRepository: false }; if (App.enableExperimental) {
