You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/02/20 23:41:19 UTC

svn commit: r1448450 - in /incubator/ambari/trunk: ./ ambari-web/app/ ambari-web/app/assets/data/clusters/ ambari-web/app/controllers/global/ ambari-web/app/controllers/main/admin/ ambari-web/app/routes/ ambari-web/app/styles/ ambari-web/app/templates/...

Author: yusaku
Date: Wed Feb 20 22:41:18 2013
New Revision: 1448450

URL: http://svn.apache.org/r1448450
Log:
AMBARI-1459. Add Admin > Cluster page. (yusaku)

Added:
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js
    incubator/ambari/trunk/ambari-web/app/templates/main/admin/cluster.hbs
    incubator/ambari/trunk/ambari-web/app/views/main/admin/cluster.js
Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/app.js
    incubator/ambari/trunk/ambari-web/app/assets/data/clusters/info.json
    incubator/ambari/trunk/ambari-web/app/controllers.js
    incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js
    incubator/ambari/trunk/ambari-web/app/routes/main.js
    incubator/ambari/trunk/ambari-web/app/styles/application.less
    incubator/ambari/trunk/ambari-web/app/views.js
    incubator/ambari/trunk/ambari-web/app/views/main/admin/menu.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Wed Feb 20 22:41:18 2013
@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1459. Add Admin > Cluster page. (yusaku)
+
  AMBARI-1454. Service page: add "Reassign <Master Component>" action items
  to "Maintenance" pulldown. (yusaku)
 

Modified: incubator/ambari/trunk/ambari-web/app/app.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/app.js?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/app.js (original)
+++ incubator/ambari/trunk/ambari-web/app/app.js Wed Feb 20 22:41:18 2013
@@ -36,8 +36,14 @@ module.exports = Em.Application.create({
    * return url prefix with number value of version of HDP stack
    */
   stackVersionURL:function(){
-    return '/stacks/HDP/version/' + App.defaultStackVersion.replace(/HDP-/g, '');
-  }.property()
+    var stackVersion = this.get('currentStackVersion') || this.get('defaultStackVersion');
+    return '/stacks/HDP/version/' + stackVersion.replace(/HDP-/g, '');
+  }.property('currentStackVersion'),
+  clusterName: null,
+  currentStackVersion: null,
+  ready: function(){
+    this.set('currentStackVersion', this.get('defaultStackVersion'));
+  }
 });
 
 /**

Modified: incubator/ambari/trunk/ambari-web/app/assets/data/clusters/info.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/assets/data/clusters/info.json?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/assets/data/clusters/info.json (original)
+++ incubator/ambari/trunk/ambari-web/app/assets/data/clusters/info.json Wed Feb 20 22:41:18 2013
@@ -4,7 +4,8 @@
     {
       "href" : "http://ambari:9998/clusters/mycluster",
       "Clusters" : {
-        "cluster_name" : "mycluster"
+        "cluster_name" : "mycluster",
+        "version" : "HDP-1.2.2"
       }
     }
   ]

Modified: incubator/ambari/trunk/ambari-web/app/controllers.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers.js?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers.js Wed Feb 20 22:41:18 2013
@@ -26,6 +26,7 @@ require('controllers/installer');
 require('controllers/global/background_operations_controller');
 require('controllers/main');
 require('controllers/main/admin');
+require('controllers/main/admin/cluster');
 require('controllers/main/admin/user');
 require('controllers/main/admin/user/edit');
 require('controllers/main/admin/user/create');

Modified: incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/global/cluster_controller.js Wed Feb 20 22:41:18 2013
@@ -64,6 +64,10 @@ App.ClusterController = Em.Controller.ex
       timeout:App.timeout,
       success:function (data) {
         self.set('cluster', data.items[0]);
+        App.set('clusterName', data.items[0].Clusters.cluster_name);
+        if(data.items[0].Clusters.version){
+          App.set('currentStackVersion', data.items[0].Clusters.version);
+        }
       },
       error:function (request, ajaxOptions, error) {
         console.log('failed on loading cluster name');

Added: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js?rev=1448450&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js (added)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/cluster.js Wed Feb 20 22:41:18 2013
@@ -0,0 +1,112 @@
+/**
+ * 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.MainAdminClusterController = Em.Controller.extend({
+  name:'mainAdminClusterController',
+  services: [],
+  installedServices: function(){
+    return App.Service.find().mapProperty('serviceName');
+  }.property(),
+  currentVersion: function(){
+    return App.get('currentStackVersion');
+  }.property('App.currentStackVersion'),
+  upgradeVersion: '',
+  /**
+   * get the newest version of HDP from server
+   * and update if it newer than current
+   */
+  updateUpgradeVersion: function(){
+    var url = App.formatUrl(
+      App.apiPrefix + "/stacks",
+      {},
+      '/data/wizard/stack/stacks.json'
+    );
+    var result = this.get('upgradeVersion') || App.defaultStackVersion;
+    $.ajax({
+      type: "GET",
+      url: url,
+      async: false,
+      dataType: 'json',
+      timeout: App.timeout,
+      success: function (data) {
+        result = result.replace(/HDP-/, '');
+        data.filterProperty('name', 'HDP').mapProperty('version').forEach(function(version){
+          result = (result < version) ? version : result;
+        });
+        result = 'HDP-' + result;
+      },
+      error: function (request, ajaxOptions, error) {
+        console.log('Error message is: ' + request.responseText);
+      },
+      statusCode: require('data/statusCodes')
+    });
+    if(result && result !== this.get('upgradeVersion')){
+      this.set('upgradeVersion', result);
+    }
+  },
+  /**
+   * load services info(versions, description)
+   */
+  loadServicesFromServer: function () {
+    var displayOrderConfig = require('data/services');
+    var result = [];
+    var method = 'GET';
+    var url = App.formatUrl(
+      App.apiPrefix + App.get('stackVersionURL'),
+      {},
+      '/data/wizard/stack/hdp/version/1.2.0.json'
+    );
+    var self = this;
+    $.ajax({
+      type: method,
+      url: url,
+      async: false,
+      dataType: 'text',
+      timeout: App.timeout,
+      success: function (data) {
+        var jsonData = jQuery.parseJSON(data);
+
+        // loop through all the service components
+        for (var i = 0; i < displayOrderConfig.length; i++) {
+          var entry = jsonData.services.findProperty("name", displayOrderConfig[i].serviceName);
+          if(self.get('installedServices').contains(entry.name)){
+            var myService = Em.Object.create({
+              serviceName: entry.name,
+              displayName: displayOrderConfig[i].displayName,
+              isDisabled: i === 0,
+              isSelected: true,
+              isInstalled: false,
+              isHidden: displayOrderConfig[i].isHidden,
+              description: entry.comment,
+              version: entry.version,
+              newVersion: '1.3.0'
+            });
+            result.push(myService);
+          }
+        }
+      },
+      error: function (request, ajaxOptions, error) {
+        console.log('Error message is: ' + request.responseText);
+      },
+      statusCode: require('data/statusCodes')
+    });
+    this.set('services', result);
+  }.observes('upgradeVersion')
+});
\ No newline at end of file

Modified: incubator/ambari/trunk/ambari-web/app/routes/main.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/main.js?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/main.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/main.js Wed Feb 20 22:41:18 2013
@@ -222,6 +222,14 @@ module.exports = Em.Route.extend({
       })
     }),
 
+    adminCluster:Em.Route.extend({
+      route:'/cluster',
+      connectOutlets:function (router) {
+        router.set('mainAdminController.category', "cluster");
+        router.get('mainAdminController').connectOutlet('mainAdminCluster');
+      }
+    }),
+
     adminAuthentication:Em.Route.extend({
       route:'/authentication',
       connectOutlets:function (router) {

Modified: incubator/ambari/trunk/ambari-web/app/styles/application.less
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/styles/application.less?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/styles/application.less (original)
+++ incubator/ambari/trunk/ambari-web/app/styles/application.less Wed Feb 20 22:41:18 2013
@@ -1631,6 +1631,19 @@ table.graphs {
 
 /*End Hosts*/
 
+/*Start Admin*/
+.admin-cluster {
+  .header {
+    margin-bottom: 20px;
+  }
+  a.inactive {
+    cursor: default;
+    color: #333333;
+    text-decoration: none;
+  }
+}
+/*End Admin*/
+
 /*assign masters*/
 
 .assign-masters {
@@ -2112,6 +2125,10 @@ ul.filter {
   text-align: right;
 }
 
+.text-center {
+  text-align: center;
+}
+
 .left {
   float: left;
 }

Added: incubator/ambari/trunk/ambari-web/app/templates/main/admin/cluster.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/admin/cluster.hbs?rev=1448450&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/admin/cluster.hbs (added)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/admin/cluster.hbs Wed Feb 20 22:41:18 2013
@@ -0,0 +1,49 @@
+{{!
+* 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="admin-cluster">
+    <div class="header">
+        <strong>{{t admin.cluster.stackVersion}}: {{currentVersion}}
+            (<a href="true" {{bindAttr class="view.isUpgradeAvailable::inactive"}}{{action "upgradeStack"}}>
+            {{#if view.isUpgradeAvailable}}{{t admin.cluster.upgradeAvailable}}: {{upgradeVersion}}
+            {{else}} {{t admin.cluster.upgradeUnavailable}}
+            {{/if}}
+            </a>)
+        </strong>
+    </div>
+    <table class="table table-bordered table-striped">
+        <thead>
+        <tr>
+            <th>{{t common.service}}</th>
+            <th>{{t common.version}}</th>
+            <th>{{t common.description}}</th>
+        </tr>
+        </thead>
+        <tbody>
+        {{#each service in services}}
+        {{#unless service.isHidden}}
+        <tr>
+            <td>{{service.displayName}}</td>
+            <td>{{service.version}}</td>
+            <td>{{service.description}}</td>
+        </tr>
+        {{/unless}}
+        {{/each}}
+        </tbody>
+    </table>
+</div>
\ No newline at end of file

Modified: incubator/ambari/trunk/ambari-web/app/views.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views.js?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views.js Wed Feb 20 22:41:18 2013
@@ -47,6 +47,7 @@ require('views/main/host/metrics/memory'
 require('views/main/host/metrics/network');
 require('views/main/host/metrics/processes');
 require('views/main/admin');
+require('views/main/admin/cluster');
 require('views/main/admin/advanced');
 require('views/main/admin/advanced/password');
 require('views/main/admin/audit');

Added: incubator/ambari/trunk/ambari-web/app/views/main/admin/cluster.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/admin/cluster.js?rev=1448450&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/admin/cluster.js (added)
+++ incubator/ambari/trunk/ambari-web/app/views/main/admin/cluster.js Wed Feb 20 22:41:18 2013
@@ -0,0 +1,30 @@
+/**
+ * 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.MainAdminClusterView = Em.View.extend({
+  templateName: require('templates/main/admin/cluster'),
+
+  isUpgradeAvailable: function(){
+    return this.get('controller.upgradeVersion').replace(/HDP-/, '') > this.get('controller.currentVersion').replace(/HDP-/, '');
+  }.property('controller.upgradeVersion', 'controller.currentVersion'),
+  didInsertElement: function(){
+    this.get('controller').updateUpgradeVersion();
+  }
+});
\ No newline at end of file

Modified: incubator/ambari/trunk/ambari-web/app/views/main/admin/menu.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/admin/menu.js?rev=1448450&r1=1448449&r2=1448450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/admin/menu.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/main/admin/menu.js Wed Feb 20 22:41:18 2013
@@ -23,7 +23,12 @@ App.MainAdminMenuView = Em.CollectionVie
     {
       route:'user',
       label:'Users'
-    }/*,
+    },
+    {
+      route:'cluster',
+      label:'Cluster'
+    }
+    /*,
     {
       route:'authentication',
       label:'Authentication'
@@ -61,6 +66,6 @@ App.MainAdminMenuView = Em.CollectionVie
   itemViewClass:Em.View.extend({
     classNameBindings:["active"],
     active:"",
-    template:Ember.Handlebars.compile('<a {{action adminNavigate view.content.route }} href="#"> {{unbound view.content.label}}</a>')
+    template:Ember.Handlebars.compile('<a class="text-center" {{action adminNavigate view.content.route }} href="#"> {{unbound view.content.label}}</a>')
   })
 });
\ No newline at end of file