ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-8720 Admin > Stack Versions tweaks. (ababiichuk)
Date Tue, 16 Dec 2014 14:37:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f85260bed -> 523b0ca6c


AMBARI-8720 Admin > Stack Versions tweaks. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 523b0ca6cff89b08fc2c2eaa80eb823e43f613db
Parents: f85260b
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Tue Dec 16 15:27:27 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Tue Dec 16 16:14:01 2014 +0200

----------------------------------------------------------------------
 .../data/stack_versions/repo_versions_all.json  | 41 ++++++++++++++
 .../stack_versions/repo_versions_controller.js  | 21 ++++----
 .../stack_versions/stack_versions_controller.js |  7 ++-
 ambari-web/app/messages.js                      |  3 ++
 ambari-web/app/styles/application.less          |  3 ++
 .../stack_versions/os_for_repo_versions.hbs     | 28 ++++++++++
 .../main/admin/stack_versions/repo_versions.hbs |  9 +---
 .../admin/stack_versions/stack_versions.hbs     |  9 +---
 ambari-web/app/views.js                         |  1 +
 .../app/views/main/admin/stack_versions/menu.js | 21 ++++++--
 .../admin/stack_versions/operating_systems.js   | 56 ++++++++++++++++++++
 .../admin/stack_versions/repo_version_view.js   | 13 +----
 .../repo_versions_controller_test.js            |  7 ++-
 .../stack_versions_controller_test.js           |  3 ++
 14 files changed, 174 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/assets/data/stack_versions/repo_versions_all.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/stack_versions/repo_versions_all.json b/ambari-web/app/assets/data/stack_versions/repo_versions_all.json
index a96993c..28c25aa 100644
--- a/ambari-web/app/assets/data/stack_versions/repo_versions_all.json
+++ b/ambari-web/app/assets/data/stack_versions/repo_versions_all.json
@@ -442,6 +442,47 @@
               }
             }
           ]
+        },
+        {
+          "href" : "http://162.216.149.241:8080/api/v1/stacks/HDP/versions/2.2/repository_versions/9/operating_systems/redhat6",
+          "OperatingSystems" : {
+            "os_type" : "suse11",
+            "repository_version_id" : 9,
+            "stack_name" : "HDP",
+            "stack_version" : "2.2"
+          },
+          "repositories" : [
+            {
+              "href" : "http://162.216.149.241:8080/api/v1/stacks/HDP/versions/2.2/repository_versions/9/operating_systems/redhat6/repositories/HDP-2.2",
+              "Repositories" : {
+                "base_url" : "http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos5/2.x/updates/2.2.0.0",
+                "default_base_url" : "",
+                "latest_base_url" : "",
+                "mirrors_list" : "",
+                "os_type" : "redhat6",
+                "repo_id" : "HDP-2.2",
+                "repo_name" : "HDP",
+                "repository_version_id" : 9,
+                "stack_name" : "HDP",
+                "stack_version" : "2.2"
+              }
+            },
+            {
+              "href" : "http://162.216.149.241:8080/api/v1/stacks/HDP/versions/2.2/repository_versions/9/operating_systems/redhat6/repositories/HDP-UTILS-1.1.0.20",
+              "Repositories" : {
+                "base_url" : "http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos5/2.x/updates/2.2.0.0",
+                "default_base_url" : "",
+                "latest_base_url" : "",
+                "mirrors_list" : "",
+                "os_type" : "redhat6",
+                "repo_id" : "HDP-UTILS-1.1.0.20",
+                "repo_name" : "HDP-UTILS",
+                "repository_version_id" : 9,
+                "stack_name" : "HDP",
+                "stack_version" : "2.2"
+              }
+            }
+          ]
         }
       ]
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
b/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
index 002bcbe..2e4a3c8 100644
--- a/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_versions/repo_versions_controller.js
@@ -54,9 +54,12 @@ App.RepoVersionsController = Em.ArrayController.extend({
     this.set('dataIsLoaded', false);
     var dfd = $.Deferred();
     var self = this;
-    this.loadRepoVersionsToModel().done(function () {
-      self.set('dataIsLoaded', true);
-      dfd.resolve();
+
+    App.get('router.mainStackVersionsController').loadStackVersionsToModel().done(function
() {
+      self.loadRepoVersionsToModel().done(function () {
+        self.set('dataIsLoaded', true);
+        dfd.resolve();
+      });
     });
     return dfd.promise();
   },
@@ -69,15 +72,11 @@ App.RepoVersionsController = Em.ArrayController.extend({
    */
   loadRepoVersionsToModel: function () {
     var dfd = $.Deferred();
-    var self = this;
-    App.get('router.mainStackVersionsController').loadStackVersionsToModel().done(function
() {
-      App.HttpClient.get(self.getUrl(), App.repoVersionMapper, {
-        complete: function () {
-          dfd.resolve();
-        }
-      });
+    App.HttpClient.get(this.getUrl(), App.repoVersionMapper, {
+      complete: function () {
+        dfd.resolve();
+      }
     });
-
     return dfd.promise();
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/controllers/main/admin/stack_versions/stack_versions_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_versions/stack_versions_controller.js
b/ambari-web/app/controllers/main/admin/stack_versions/stack_versions_controller.js
index 6d294ee..1cc8bdc 100644
--- a/ambari-web/app/controllers/main/admin/stack_versions/stack_versions_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_versions/stack_versions_controller.js
@@ -72,8 +72,11 @@ App.MainStackVersionsController = Em.ArrayController.extend({
     var dfd = $.Deferred();
     var self = this;
     this.loadStackVersionsToModel().done(function () {
-      self.set('dataIsLoaded', true);
-      dfd.resolve();
+      App.get('router.repoVersionsController').loadRepoVersionsToModel().done(function()
{
+        self.set('dataIsLoaded', true);
+        dfd.resolve();
+      });
+
     });
     return dfd.promise();
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 83eacf6..9dbcb75 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1299,6 +1299,9 @@ Em.I18n.translations = {
   'admin.stackVersions.hosts.popup.title': "{0} Version is {1} on {2} hosts:",
   'admin.stackVersions.hosts.popup.primary': "Go to Hosts",
 
+  'admin.stackVersions.updateTab.title.available': "Updates Available ({0})",
+  'admin.stackVersions.updateTab.title.not.available': "No Updates Available",
+
   'admin.stackUpgrade.title': "Stack and upgrade",
   'admin.stackUpgrade.hostsOnline': "{0}/{1} hosts online",
   'admin.stackUpgrade.state.available': "Upgrade Available",

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 162dff2..abf5630 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -5016,6 +5016,9 @@ ul.inline li {
     color: #999;
     cursor: default;
   }
+  .black {
+    color: black;
+  }
 }
 
 #stack_versions, #repository_versions {

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/templates/main/admin/stack_versions/os_for_repo_versions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_versions/os_for_repo_versions.hbs b/ambari-web/app/templates/main/admin/stack_versions/os_for_repo_versions.hbs
new file mode 100644
index 0000000..44c2b38
--- /dev/null
+++ b/ambari-web/app/templates/main/admin/stack_versions/os_for_repo_versions.hbs
@@ -0,0 +1,28 @@
+{{!
+* 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.
+}}
+<span {{bindAttr class="view.hasMoreOs::not-active-link"}} >
+  <a href="#" {{bindAttr class="view.hasMoreOs:os-expander :black"}} {{action toggleOs
target="view"}}>
+    <span {{bindAttr class="view.isOsCollapsed:icon-caret-right:icon-caret-down view.hasMoreOs::hide"}}></span>
+    {{view.osText}}
+  </a>
+  {{#if view.hasMoreOs}}
+    <div id="stack-{{view.content.repositoryVersion}}" class="operating-systems">
+      {{{view.labels}}}
+    </div>
+  {{/if}}
+</span>

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs b/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
index a49b813..4b1d6cf 100644
--- a/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
+++ b/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
@@ -44,14 +44,7 @@
               <span>{{view.content.displayName}}</span>
             </td>
             <td class="os-types">
-              <a href="#" class="os-expander" {{action toggleOs target="view"}}>
-                <span {{bindAttr class="view.isOsCollapsed:icon-caret-right:icon-caret-down"}}></span>
-                {{view.content.operatingSystems.length}} {{pluralize view.content.operatingSystems.length
singular="t:common.os" plural="t:common.oss"}}
-              </a>
-
-              <div id="stack-{{view.content.repositoryVersion}}" class="operating-systems">
-                {{{view.labels}}}
-              </div>
+              {{view App.OperatingSystemsView contentBinding="view.content"}}
             </td>
             <td class="repo-version-install">
               <a href="#" class="btn btn-success" {{action installRepoVersion view.content
target="controller"}}>{{t common.install}}</a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs b/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
index facc623..ac6822d 100644
--- a/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
+++ b/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
@@ -46,14 +46,7 @@
               <a href="#/main/admin/versions/{{unbound view.content.id}}">{{view.content.repositoryVersion.displayName}}</a>
             </td>
             <td class="os-types">
-              <a href="#" class="os-expander" {{action toggleOs target="view"}}>
-                <span {{bindAttr class="view.isOsCollapsed:icon-caret-right:icon-caret-down"}}></span>
-                {{view.content.repositoryVersion.operatingSystems.length}} {{pluralize view.content.repositoryVersion.operatingSystems.length
singular="t:common.os" plural="t:common.oss"}}
-              </a>
-
-              <div id="stack-{{view.content.name}}" class="operating-systems">
-                {{{view.labels}}}
-              </div>
+              {{view App.OperatingSystemsView contentBinding="view.content.repositoryVersion"}}
             </td>
             <td class="installed-hosts-count">
               <span  {{bindAttr class="view.content.noInstalledHosts:not-active-link"}}>

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index efb354a..cf384d9 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -110,6 +110,7 @@ require('views/main/admin/stack_upgrade/upgrade_group_view');
 require('views/main/admin/stack_upgrade/upgrade_task_view');
 require('views/main/admin/stack_and_upgrade_view');
 require('views/main/admin/stack_versions/menu');
+require('views/main/admin/stack_versions/operating_systems');
 require('views/main/admin/stack_versions/repo_version_view');
 require('views/main/admin/stack_versions/stack_version_view');
 require('views/main/admin/stack_versions/stack_version_details_view');

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/views/main/admin/stack_versions/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_versions/menu.js b/ambari-web/app/views/main/admin/stack_versions/menu.js
index 7117a1a..e4567cf 100644
--- a/ambari-web/app/views/main/admin/stack_versions/menu.js
+++ b/ambari-web/app/views/main/admin/stack_versions/menu.js
@@ -23,8 +23,8 @@ App.StackVersionMenuView = Em.CollectionView.extend({
   classNames: ["nav", "nav-tabs"],
   content:function(){
     var menuItems = [
-      { label: 'Installed', routing:'versions', url:"versions", active:"active"},
-      { label: 'Updates', routing:'updates', url:"versions/updates"}
+      { label: Em.I18n.t('common.installed'), routing:'versions', url:"versions", active:"active"},
+      { label: Em.I18n.t('admin.stackVersions.updateTab.title.not.available'), routing:'updates',
url:"versions/updates"}
     ];
     return menuItems;
   }.property(),
@@ -46,6 +46,21 @@ App.StackVersionMenuView = Em.CollectionView.extend({
   itemViewClass: Em.View.extend({
     classNameBindings: ["active"],
     active: "",
-    template: Ember.Handlebars.compile('<a href="#/main/admin/{{unbound view.content.url}}">
{{unbound view.content.label}}</a>')
+    newRepoCount: function() {
+      return App.RepositoryVersion.find().filterProperty('stackVersion', null).get('length');
+    }.property('controller.dataIsLoaded'),
+    label: function() {
+      if (this.get('content.routing') == 'updates') {
+        if (this.get('newRepoCount') > 0) {
+          this.set("active", "");
+          return  Em.I18n.t('admin.stackVersions.updateTab.title.available').format(this.get('newRepoCount'))
+        } else {
+          this.set("active", 'not-active-link');
+        }
+      }
+      return this.get('content.label')
+    }.property('view.content.label', 'newRepoCount'),
+
+    template: Ember.Handlebars.compile('<a href="#/main/admin/{{unbound view.content.url}}">
{{view.label}}</a>')
   })
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/views/main/admin/stack_versions/operating_systems.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_versions/operating_systems.js b/ambari-web/app/views/main/admin/stack_versions/operating_systems.js
new file mode 100644
index 0000000..03cef25
--- /dev/null
+++ b/ambari-web/app/views/main/admin/stack_versions/operating_systems.js
@@ -0,0 +1,56 @@
+/** 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.
+ */
+
+var App = require('app');
+
+App.OperatingSystemsView = Em.View.extend({
+
+  templateName: require('templates/main/admin/stack_versions/os_for_repo_versions'),
+
+  didInsertElement: function () {
+    this.set('isOsCollapsed', true);
+  },
+
+  toggleOs: function(event) {
+    if (this.get('hasMoreOs')) {
+      this.set('isOsCollapsed', !this.get('isOsCollapsed'));
+      this.$('.operating-systems').toggle();
+    }
+  },
+
+  hasMoreOs: function() {
+    return this.get('content.operatingSystems.length') > 1;
+  }.property('content.operatingSystems.length'),
+
+  osText: function() {
+    switch (this.get('content.operatingSystems.length')) {
+      case 0:
+        return Em.I18n.t("none");
+        break;
+      case 1:
+        return this.get('content.operatingSystems').getEach('osType');
+        break;
+      default :
+        return this.get('content.operatingSystems.length') + Em.I18n.t("common.oss");
+    }
+  }.property('content.operatingSystems.length'),
+
+  labels: function() {
+    return this.get('content.operatingSystems') &&
+      this.get('content.operatingSystems').getEach('osType').join("<br/>");
+  }.property('content.operatingSystems.length')
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/app/views/main/admin/stack_versions/repo_version_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_versions/repo_version_view.js b/ambari-web/app/views/main/admin/stack_versions/repo_version_view.js
index 1031c9e..9d874ec 100644
--- a/ambari-web/app/views/main/admin/stack_versions/repo_version_view.js
+++ b/ambari-web/app/views/main/admin/stack_versions/repo_version_view.js
@@ -127,18 +127,7 @@ App.RepoVersionsView = App.TableView.extend({
     tagName: 'tr',
     didInsertElement: function () {
       App.tooltip(this.$("[rel='Tooltip']"));
-      this.set('isOsCollapsed', true);
-    },
-
-    toggleOs: function(event) {
-      this.set('isOsCollapsed', !this.get('isOsCollapsed'));
-      this.$('.operating-systems').toggle();
-    },
-
-    labels: function() {
-      return this.get('content.operatingSystems') &&
-        this.get('content.operatingSystems').getEach('osType').join("<br/>");
-    }.property('content.operatingSystems.length')
+    }
   })
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
b/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
index 1fef683..19678bc 100644
--- a/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_version/repo_versions_controller_test.js
@@ -52,24 +52,23 @@ describe('App.RepoVersionsController', function () {
   describe('#load', function () {
     it('loads data by running loadRepoVersionsToModel', function () {
       sinon.stub(repoVersionsController, 'loadRepoVersionsToModel').returns({done: Em.K});
+      sinon.stub(App.get('router.mainStackVersionsController'), 'loadStackVersionsToModel',
function() { return $.Deferred().resolve()});
       repoVersionsController.load();
       expect(repoVersionsController.loadRepoVersionsToModel.calledOnce).to.be.true;
+      expect(App.get('router.mainStackVersionsController').loadStackVersionsToModel.calledOnce).to.be.true;
       repoVersionsController.loadRepoVersionsToModel.restore();
+      App.get('router.mainStackVersionsController').loadStackVersionsToModel.restore();
     });
   });
   describe('#loadRepoVersionsToModel()', function () {
     it('loads data to model', function () {
       sinon.stub(App.HttpClient, 'get', Em.K);
       sinon.stub(repoVersionsController, 'getUrl', Em.K);
-      sinon.stub(App.get('router.mainStackVersionsController'), 'loadStackVersionsToModel',
function() { return $.Deferred().resolve()});
 
       repoVersionsController.loadRepoVersionsToModel();
       expect(App.HttpClient.get.calledOnce).to.be.true;
       expect(repoVersionsController.getUrl.calledOnce).to.be.true;
-      expect(App.get('router.mainStackVersionsController').loadStackVersionsToModel.calledOnce).to.be.true;
-
 
-      App.get('router.mainStackVersionsController').loadStackVersionsToModel.restore();
       repoVersionsController.getUrl.restore();
       App.HttpClient.get.restore();
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/523b0ca6/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
b/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
index b05c40c..9eb4f92 100644
--- a/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_version/stack_versions_controller_test.js
@@ -30,11 +30,14 @@ describe('App.MainStackVersionsController', function () {
   describe('#load()', function () {
     it('loads data to model by running loadStackVersionsToModel', function () {
       sinon.stub(controller, 'loadStackVersionsToModel').returns({done: Em.K});
+      sinon.stub(App.get('router.repoVersionsController'), 'loadRepoVersionsToModel').returns({done:
Em.K});
 
       controller.load();
       expect(controller.loadStackVersionsToModel.calledOnce).to.be.true;
+      expect(App.get('router.repoVersionsController').loadRepoVersionsToModel.calledOnce).to.be.true;
 
       controller.loadConfigVersionsToModel.restore();
+      App.get('router.repoVersionsController').loadRepoVersionsToModel.restore();
     });
   });
 


Mime
View raw message