ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiw...@apache.org
Subject [1/4] ambari git commit: AMBARI-14795. Register Version: add ability to load new version definition file.
Date Thu, 04 Feb 2016 21:56:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-dev-patch-upgrade c72dc41db -> 0f9da4282


AMBARI-14795. Register Version: add ability to load new version definition file.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e4d03b5b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e4d03b5b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e4d03b5b

Branch: refs/heads/branch-dev-patch-upgrade
Commit: e4d03b5b5879aff474abdbb3a9d571215383a6c4
Parents: c72dc41
Author: Xi Wang <xiwang@apache.org>
Authored: Fri Jan 22 17:24:01 2016 -0800
Committer: Xi Wang <xiwang@apache.org>
Committed: Wed Feb 3 13:55:05 2016 -0800

----------------------------------------------------------------------
 .../app/assets/data/version/version.json        |  38 ++++++-
 .../stackVersions/StackVersionsCreateCtrl.js    | 100 +++++++++++++++++++
 .../ui/admin-web/app/scripts/i18n.config.js     |   4 +
 .../ui/admin-web/app/scripts/services/Stack.js  |  38 +++++++
 .../resources/ui/admin-web/app/styles/main.css  |  16 ++-
 .../views/stackVersions/stackVersionPage.html   |  31 ++++++
 6 files changed, 225 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e4d03b5b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json
b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json
index 7c604f1..b5b3601 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/assets/data/version/version.json
@@ -14,7 +14,43 @@
             "id" : 15,
             "repository_version" : "2.2.0.1-901",
             "stack_name" : "HDP",
-            "stack_version" : "2.2"
+            "stack_version" : "2.2",
+            "release": {
+              "type": "PATCH",
+              "stack_id": "HDP-2.2",
+              "version": "2.2.0.1",
+              "build": "901",
+              "compatible_with": "2.2.0.1-[1-9]",
+              "release_notes": "http://someurl"
+            },
+            "services": [
+              {
+                "name": "HDFS",
+                "versions": [
+                  {
+                    "version": "2.1.1",
+                    "version_id": "10",
+                    "components": [ "NAMENODE"]
+                  }
+                ]
+              },
+              {
+                "name": "HIVE",
+                "versions": [
+                  {
+                    "version": "1.2.1"
+                  }
+                ]
+              },
+              {
+                "name": "ZOOKEEPER",
+                "versions": [
+                  {
+                    "version": "3.4.5"
+                  }
+                ]
+              }
+            ]
           },
           "operating_systems" : [
             {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4d03b5b/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 a817d88..40aa103 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
@@ -151,4 +151,104 @@ angular.module('ambariAdminConsole')
     $location.path('/stackVersions');
   };
 
+  // two options to upload version definition file
+  $scope.option1 = {
+    index: 1,
+    displayName: 'Upload Version Definition File',
+    url: 'files://',
+    selected: true,
+    hasError: true
+  };
+  $scope.option2 = {
+    index: 2,
+    displayName: 'Version Definition File URL',
+    url: 'https://',
+    selected: false,
+    hasError: false
+  };
+  $scope.selectedOption = 1;
+
+  /**
+   * User can select ONLY one option to upload version definition file
+   */
+  $scope.toggleOptionSelect = function () {
+    $scope.option1.selected = $scope.selectedOption == $scope.option1.index;
+    $scope.option2.selected = $scope.selectedOption == $scope.option2.index;
+    $scope.option1.hasError = false;
+    $scope.option2.hasError = false;
+  };
+  $scope.clearOptionsError = function () {
+    $scope.option1.hasError = false;
+    $scope.option2.hasError = false;
+  };
+  $scope.readInfoButtonDisabled = function () {
+    return $scope.option1.selected ? !$scope.option1.url : !$scope.option2.url;
+  };
+
+  $scope.onFileSelect = function(){
+    return {
+      link: function($scope,el){
+        el.bind("change", function(e){
+          $scope.file = (e.srcElement || e.target).files[0];
+          $scope.getFile();
+        })
+      }
+    }
+  };
+
+//  $scope.uploadFile = function(){
+//    var file = $scope.myFile;
+//    console.log('file is ' );
+//    console.dir(file);
+//    var uploadUrl = "/fileUpload";
+//    fileUpload.uploadFileToUrl(file, uploadUrl);
+//  };
+
+  /**
+   * Load selected file to current page content
+   */
+  $scope.readVersionInfo = function(){
+    if ($scope.option2.selected) {
+      var url = $scope.option2.url;
+    }
+    /// POST url first then get the version definition info
+    return Stack.getLatestRepo('HDP').then(function (response) {
+      $scope.id = response.id;
+      $scope.isPatch = response.type == 'PATCH';
+      $scope.stackNameVersion = response.stackNameVersion;
+      $scope.displayName = response.displayName;
+      $scope.version = response.version;
+      $scope.actualVersion = response.actualVersion;
+      $scope.services = response.services;
+      //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;
+      });
+      $scope.selectedOS = response.osList.length;
+      $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.
+      $scope.repoStatus = Cluster.repoStatusCache[$scope.id];
+      if (!$scope.repoStatus) {
+        $scope.fetchClusters()
+          .then(function () {
+            return $scope.fetchRepoClusterStatus();
+          })
+          .then(function () {
+            $scope.deleteEnabled = $scope.isDeletable();
+          });
+      } else {
+        $scope.deleteEnabled = $scope.isDeletable();
+      }
+      $scope.addMissingOSList();
+    });
+  };
 }]);

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4d03b5b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
index 086bc13..21622b5 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
@@ -293,6 +293,10 @@ angular.module('ambariAdminConsole')
       'current': 'Current',
       'inUse': 'In Use',
       'installed': 'Installed',
+      'uploadFile': 'Upload Version Definition File',
+      'enterURL': 'Version Definition File URL',
+      'readInfo': 'Read Version Info',
+      'browse': 'Browse',
       'installOn': 'Install on...',
       'register': 'Register Version',
       'deregister': 'Deregister Version',

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4d03b5b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
index ffed3cc..a28943c 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Stack.js
@@ -173,6 +173,44 @@ angular.module('ambariAdminConsole')
       return deferred.promise;
     },
 
+    getLatestRepo: function (stack_name) {
+      var url = Settings.baseUrl + '/stacks/' + stack_name + '/versions?' +
+        'fields=repository_versions/operating_systems/repositories/*' +
+        ',repository_versions/RepositoryVersions/*';
+      var deferred = $q.defer();
+      $http.get(url, {mock: 'version/version.json'})
+        .success(function (data) {
+          data = data.items[0];
+          var response = {
+            id : data.repository_versions[0].RepositoryVersions.id,
+            stackVersion : data.Versions.stack_version,
+            stackName: data.Versions.stack_name,
+            type: data.repository_versions[0].RepositoryVersions.release.type,
+            stackNameVersion: data.Versions.stack_name + '-' + data.Versions.stack_version,
/// HDP-2.3
+            actualVersion: data.repository_versions[0].RepositoryVersions.repository_version,
/// 2.3.4.0-3846
+            version: data.repository_versions[0].RepositoryVersions.release.version, ///
2.3.4.0
+            displayName: data.Versions.stack_name + '-' + data.repository_versions[0].RepositoryVersions.release.version,
//HDP-2.3.4.0
+            repoVersionFullName : data.Versions.stack_name + '-' + data.repository_versions[0].RepositoryVersions.repository_version,
+            osList: data.repository_versions[0].operating_systems,
+            updateObj: data.repository_versions[0]
+          };
+          var services = [];
+          angular.forEach(data.repository_versions[0].RepositoryVersions.services, function
(service) {
+            services.push({
+              name: service.name,
+              version: service.versions[0].version,
+              components: service.versions[0].components
+            });
+          });
+          response.services = services;
+          deferred.resolve(response);
+        })
+        .error(function (data) {
+          deferred.reject(data);
+        });
+      return deferred.promise;
+    },
+
     updateRepo: function (stackName, stackVersion, id, payload) {
       var url = Settings.baseUrl + '/stacks/' + stackName + '/versions/' + stackVersion +
'/repository_versions/' + id;
       var deferred = $q.defer();

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4d03b5b/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 cc57fa3..de3d526 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
@@ -1383,4 +1383,18 @@ thead.view-permission-header > tr > th {
 
 .test-ldap-icon.ng-hide-add-active, .test-ldap-icon.ng-hide-remove {
   display: inline-block!important;
-}
\ No newline at end of file
+}
+
+.register-version-options .read-info-button {
+  margin-bottom: 10px;
+}
+
+.register-version-options .option-radio-button {
+  padding-top: 5px;
+}
+
+.register-version-options .choose-file-input {
+  padding-top: 6px;
+  padding-bottom: 20px;
+}
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4d03b5b/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 9b7e032..e23aecb 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
@@ -29,6 +29,37 @@
   </div>
 </div>
 <hr>
+
+
+
+<div class="clearfix register-version-options">
+  <div class="col-sm-5 option-radio-button">
+    <label class="option-label">
+      <input type="radio" ng-model="selectedOption" value="{{option1.index}}" ng-change="toggleOptionSelect()">
{{'versions.uploadFile' | translate}}
+    </label>
+  </div>
+  <div class="col-sm-7">
+    <input type="file" class="choose-file-input" ng-file-select="onFileSelect($files)"/>
+  </div>
+</div>
+<div class="clearfix register-version-options border-bottom bottom-margin">
+  <div class="col-sm-5 option-radio-button">
+    <label class="option-label">
+      <input type="radio" ng-model="selectedOption" value="{{option2.index}}" ng-change="toggleOptionSelect()">
{{'versions.enterURL' | translate}}
+    </label>
+  </div>
+    <div class="col-sm-7">
+      <div class="form-group {{option2.name}}" ng-class="{'has-error': option2.url.hasError
}">
+        <div class=""><input type="text" class="form-control" ng-model="option2.url"
ng-change="clearOptionsError()" ng-disabled="!option2.selected"></div>
+      </div>
+    </div>
+    <div class="col-sm-12 read-info-button">
+    <button class="btn btn-primary pull-right" ng-click="readVersionInfo()"
+        ng-disabled="readInfoButtonDisabled()">{{'versions.readInfo' | translate}}</button>
+    </div>
+</div>
+
+
 <form class="form-horizontal register-version-form" role="form" name="repoRegForm" novalidate>
   <div class="panel panel-default" ng-if="createController">
     <div class="panel-heading">


Mime
View raw message