ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject git commit: AMBARI-5375 Views: Dynamic Views menu (query views from server). (ababiichuk)
Date Mon, 07 Apr 2014 16:04:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e2b0e2ae7 -> 9c7dc7785


AMBARI-5375 Views: Dynamic Views menu (query views from server). (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 9c7dc7785e7a13f2c7bf47f535ad5689cdbf8af7
Parents: e2b0e2a
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Mon Apr 7 19:01:54 2014 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Mon Apr 7 19:01:54 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers.js                   |  2 +-
 .../controllers/global/cluster_controller.js    | 36 ++++++++++++++++
 ambari-web/app/controllers/main/views.js        | 23 ----------
 .../app/controllers/main/views_controller.js    | 32 ++++++++++++++
 ambari-web/app/templates/main/menu_item.hbs     | 36 +++++++++-------
 ambari-web/app/utils/ajax.js                    |  8 ++++
 ambari-web/app/views.js                         |  2 +-
 ambari-web/app/views/main/menu.js               |  7 +++-
 ambari-web/app/views/main/views.js              | 44 --------------------
 ambari-web/app/views/main/views_view.js         | 34 +++++++++++++++
 10 files changed, 140 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/controllers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js
index 598279b..75348ae 100644
--- a/ambari-web/app/controllers.js
+++ b/ambari-web/app/controllers.js
@@ -117,7 +117,7 @@ require('controllers/main/mirroring/edit_dataset_controller');
 require('controllers/main/mirroring/datasets_controller');
 require('controllers/main/mirroring/jobs_controller');
 require('controllers/main/mirroring/manage_clusters_controller');
-require('controllers/main/views');
+require('controllers/main/views_controller');
 require('controllers/wizard/slave_component_groups_controller');
 require('controllers/wizard/step0_controller');
 require('controllers/wizard/step1_controller');

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 2109248..7a1304f 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -24,6 +24,7 @@ App.ClusterController = Em.Controller.extend({
   isLoaded:false,
   ambariProperties: null,
   ambariVersion: null,
+  ambariViews: [],
   clusterDataLoadedPercent: 'width:0', // 0 to 1
   /**
    * Whether we need to update statuses automatically or not
@@ -279,6 +280,7 @@ App.ClusterController = Em.Controller.extend({
   loadClusterData:function () {
     var self = this;
     this.loadAmbariProperties();
+    this.loadAmbariViews();
     if (!this.get('clusterName')) {
       return;
     }
@@ -382,6 +384,40 @@ App.ClusterController = Em.Controller.extend({
     }, callback)
   },
 
+  loadAmbariViews: function() {
+    App.ajax.send({
+      name: 'views.info',
+      sender: this,
+      success: 'loadAmbariViewsSuccess'
+    });
+  },
+
+  loadAmbariViewsSuccess: function(data) {
+    this.set('ambariViews',[]);
+    data.items.forEach(function(item){
+      App.ajax.send({
+        name: 'views.instances',
+        data: {
+          viewName: item.ViewInfo.view_name
+        },
+        sender: this,
+        success: 'loadViewInstancesSuccess'
+      });
+    }, this)
+  },
+
+  loadViewInstancesSuccess: function(data) {
+    data.instances.forEach(function(instance){
+      var view = Em.Object.create({
+        label: data.ViewInfo.label,
+        viewName: instance.ViewInstanceInfo.view_name,
+        instanceName: instance.ViewInstanceInfo.instance_name,
+        href: "/views/" + instance.ViewInstanceInfo.view_name + "/" + instance.ViewInstanceInfo.instance_name
+      });
+      this.get('ambariViews').push(view);
+    }, this);
+  },
+
   loadAmbariProperties: function() {
     App.ajax.send({
       name: 'ambari.service',

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/controllers/main/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/views.js b/ambari-web/app/controllers/main/views.js
deleted file mode 100644
index ce10081..0000000
--- a/ambari-web/app/controllers/main/views.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * 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.MainViewsController = Em.Controller.extend({
-  name:'mainViewsController'
-})
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/controllers/main/views_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/views_controller.js b/ambari-web/app/controllers/main/views_controller.js
new file mode 100644
index 0000000..242d989
--- /dev/null
+++ b/ambari-web/app/controllers/main/views_controller.js
@@ -0,0 +1,32 @@
+/**
+ * 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.MainViewsController = Em.Controller.extend({
+  name:'mainViewsController',
+
+  selectedView: null,
+
+  setView: function(event) {
+    if(event.context){
+      this.set('selectedView', event.context);
+      App.router.transitionTo('views');
+    }
+  }
+})
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/templates/main/menu_item.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/menu_item.hbs b/ambari-web/app/templates/main/menu_item.hbs
index f185886..5031e76 100644
--- a/ambari-web/app/templates/main/menu_item.hbs
+++ b/ambari-web/app/templates/main/menu_item.hbs
@@ -15,17 +15,25 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
-
-<a href="#/main/{{unbound view.content.routing}}">
-  {{unbound view.content.label}}
-  {{#if view.alertsCount}}
-    <span class="label label-important alerts-count">
-      {{view.alertsCount}}
-    </span>
-  {{/if}}
-  <!--{{#if view.hostDetailsOperationsCount}}-->
-    <!--<span class="label operations-count" {{action "showBackgroundOperationsPopup"
target="App.router.mainHostDetailsController"}}>-->
-      <!--{{view.hostDetailsOperationsCount}}-->
-    <!--</span>-->
-  <!--{{/if}}-->
-</a>
+{{#if view.content.isView}}
+    <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{view.content.label}}<b
class="caret pull-right"></b></a>
+    <ul class="dropdown-menu pull-right">
+      {{#each v in view.content.views}}
+          <li><a href="#" class="align-right" {{action "setView" v target="App.router.mainViewsController"}}>{{v.label}}</a></li>
+      {{/each}}
+    </ul>
+{{else}}
+    <a href="#/main/{{unbound view.content.routing}}">
+      {{unbound view.content.label}}
+      {{#if view.alertsCount}}
+          <span class="label label-important alerts-count">
+            {{view.alertsCount}}
+          </span>
+      {{/if}}
+        <!--{{#if view.hostDetailsOperationsCount}}-->
+        <!--<span class="label operations-count" {{action "showBackgroundOperationsPopup"
target="App.router.mainHostDetailsController"}}>-->
+        <!--{{view.hostDetailsOperationsCount}}-->
+        <!--</span>-->
+        <!--{{/if}}-->
+    </a>
+{{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index 339a27c..4f25d93 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -1756,6 +1756,14 @@ var urls = {
     'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
     'mock': '/data/jobs/tezDagVertex.json',
     'apiPrefix': ''
+  },
+  'views.info': {
+    'real': '/views',
+    'mock':''
+  },
+  'views.instances': {
+    'real': '/views/{viewName}',
+    'mock':''
   }
 };
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 2988e33..c08dd10 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -236,7 +236,7 @@ require('views/main/mirroring/datasets_view');
 require('views/main/mirroring/jobs_view');
 require('views/main/mirroring/manage_clusters_view');
 
-require('views/main/views');
+require('views/main/views_view');
 
 require('views/installer');
 require('views/wizard/controls_view');

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/views/main/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/menu.js b/ambari-web/app/views/main/menu.js
index b59c2da..c2a4e21 100644
--- a/ambari-web/app/views/main/menu.js
+++ b/ambari-web/app/views/main/menu.js
@@ -25,6 +25,11 @@ var App = require('app');
 App.MainMenuView = Em.CollectionView.extend({
   tagName:'ul',
   classNames:['nav'],
+
+  views: function() {
+    return App.router.get('clusterController.ambariViews');
+  }.property('App.ClusterController.ambariViews'),
+
   content:function(){
     var result = [
       { label:Em.I18n.t('menu.item.dashboard'), routing:'dashboard', active:'active'},
@@ -49,7 +54,7 @@ App.MainMenuView = Em.CollectionView.extend({
     }
 
     if (App.supports.views) {
-      result.push({ label:Em.I18n.t('menu.item.views'), routing:'views'});
+      result.push({ label:Em.I18n.t('menu.item.views'), routing:'views', isView:true, views:
this.get('views')});
     }
     return result;
   }.property(),

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/views/main/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/views.js b/ambari-web/app/views/main/views.js
deleted file mode 100644
index e009486..0000000
--- a/ambari-web/app/views/main/views.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.MainViewsView = Em.View.extend({
-
-  tagName: "iframe",
-
-  classNames: ["views_sizes"],
-
-  attributeBindings: ['src','seamless'],
-
-  seamless: "seamless",
-
-  src: function() {
-    return window.location.origin + this.get('views')[1].link;
-  }.property("views"),
-
-  views: [{
-      name: "filebrowser",
-      link: "/views/FILE_BROWSER/FILEBROWSER_1/#/?path=/"
-    },
-    {
-      name: "pig",
-      link: "/views/PIG/PIG_1/"
-  }]
-
-});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7dc778/ambari-web/app/views/main/views_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/views_view.js b/ambari-web/app/views/main/views_view.js
new file mode 100644
index 0000000..dac54c0
--- /dev/null
+++ b/ambari-web/app/views/main/views_view.js
@@ -0,0 +1,34 @@
+/**
+ * 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.MainViewsView = Em.View.extend({
+
+  tagName: "iframe",
+
+  classNames: ["views_sizes"],
+
+  attributeBindings: ['src','seamless'],
+
+  seamless: "seamless",
+
+  src: function() {
+    return window.location.origin + this.get('controller.selectedView.href');
+  }.property('controller.selectedView')
+});
\ No newline at end of file


Mime
View raw message