فهرست منبع

HUE-6245 [cloud] Start ko-ifying the multi cluster dropdown and list dataeng clusters

Romain Rigaux 8 سال پیش
والد
کامیت
76f8a3b
2فایلهای تغییر یافته به همراه76 افزوده شده و 3 حذف شده
  1. 2 3
      desktop/core/src/desktop/conf.py
  2. 74 0
      desktop/core/src/desktop/templates/hue.mako

+ 2 - 3
desktop/core/src/desktop/conf.py

@@ -33,7 +33,6 @@ from desktop.lib.conf import Config, ConfigSection, UnspecifiedConfigSection,\
                              coerce_password_from_script, coerce_string
 from desktop.lib.i18n import force_unicode
 from desktop.lib.paths import get_desktop_root
-import string
 
 
 LOG = logging.getLogger(__name__)
@@ -1341,7 +1340,7 @@ def get_clusters():
     engines = CLUSTERS.get()
     return dict([
       (i, {
-        'analytics': engines[i].ANALYTICS.get(),
+        'analytics': engines[i].TYPE.get(),
         'nesting': engines[i].NESTING.get()
       }) for i in engines]
     )
@@ -1357,7 +1356,7 @@ CLUSTERS = UnspecifiedConfigSection(
           "type",
           help=_("Type of cluster, e.g. local ini, CM API, Dataeng, Arcus, BigQuery, Presto."),
           default='local',
-          type=string,
+          type=str,
       ),
       PRODUCT_SECRET=Config(
         key="product_secret",

+ 74 - 0
desktop/core/src/desktop/templates/hue.mako

@@ -194,6 +194,7 @@ ${ hueIcons.symbols() }
       </div>
 
       <div class="top-nav-right">
+      
         % if user.is_authenticated() and section != 'login':
         <div class="dropdown navbar-dropdown pull-right">
           <%
@@ -225,7 +226,44 @@ ${ hueIcons.symbols() }
         <!-- ko if: hasJobBrowser -->
           <!-- ko component: { name: 'hue-job-browser-links', params: { onePageViewModel: onePageViewModel }} --><!-- /ko -->
         <!-- /ko -->
+        
+        <div class="compose-action btn-group">
+          <button class="btn" data-bind="text: cluster.cluster"></button>
+          <button class="btn dropdown-toggle" data-toggle="dropdown">
+            <span class="caret"></span>
+          </button>
+
+          <ul class="dropdown-menu">
+            <li class="dropdown-submenu">
+              <a data-rel="navigator-tooltip" href="javascript: void(0)" data-bind="click: function(){ page('/editor'); onePageViewModel.changeEditorType('hive', true); }">
+                <i class="fa fa-fw fa-send inline-block"></i> ${ _('Data Eng') }
+              </a>
+              <ul class="dropdown-menu">
+               <li><a data-rel="navigator-tooltip" href="#"><span class="dropdown-no-icon"><i class="fa fa-fw fa-plus inline-block"></i></span></a></li>
+                <!-- ko foreach: cluster.clusters()[3]['clusters'] -->
+                  <li>
+                    <a  href="javascript: void(0)">
+                      <span class="dropdown-no-icon" data-bind="text: $data"></span>
+                    </a>
+                  </li>
+                <!-- /ko -->
+              </ul>
+            </li>
+            <li><a href="javascript: void(0)" data-bind="click: function(){ page('/dashboard/new_search') }"><i class="fa fa-fw fa-th-large"></i> ${ _('Team') }</a></li>
+            <li><a href="javascript: void(0)" data-bind="click: function(){ page('/dashboard/new_search') }"><i class="fa fa-fw fa-square"></i> ${ _('Athena') }</a></li>
+            <li class="dropdown-submenu">
+              <a data-rel="navigator-tooltip" href="javascript: void(0)" data-bind="click: function(){ page('/editor'); onePageViewModel.changeEditorType('hive', true); }">
+                <i class="fa fa-fw fa-th-large inline-block"></i> ${ _('Nightly') }
+              </a>
+              <ul class="dropdown-menu">
+              <li><a  href="javascript: void(0)"><span class="dropdown-no-icon">Cluster 1</span></a></li>
+              <li><a  href="javascript: void(0)"><span class="dropdown-no-icon">Cluster 2</span></a></li>
+              </ul>
+            </li>
+          </ul>
+        </div>
       </div>
+
     </div>
   </nav>
 
@@ -1031,6 +1069,8 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
       return sidePanelViewModel;
     })();
 
+
+
     var topNavViewModel = (function (onePageViewModel) {
 
       // TODO: Extract to common module (shared with nav search autocomplete)
@@ -1130,6 +1170,40 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           self.hasJobBrowser(clusterConfig && clusterConfig['app_config'] && clusterConfig['app_config']['browser']);
         });
 
+        var ClusterPanelViewModel = function() {
+          var self = this;
+          self.apiHelper = ApiHelper.getInstance();
+  
+          self.cluster = ko.observable('Ro\'s Cluster');
+          self.clusters = ko.observableArray([
+            {'name': 'Ro\'s Cluster', 'type': 'ini'},
+            {'name': 'Team', 'type': 'ini', 'clusters': ko.observableArray()},
+            {'name': 'Nightly', 'type': 'cm', 'clusters': ko.observableArray()},
+            {'name': 'DataEng', 'type': 'dataeng', 'clusters': ko.observableArray()},
+            {'name': 'Athena', 'type': 'athena'}
+          ]);
+  
+          self.contextPanelVisible = ko.observable(false);
+          
+          $.post("/jobbrowser/api/jobs", {
+            interface: ko.mapping.toJSON('dataeng-clusters'),
+            filters: ko.mapping.toJSON([]),
+          }, function (data) {
+            if (data.status == 0) {
+              var apps = [];
+              if (data && data.apps) {
+                data.apps.forEach(function (job) {
+                  apps.push(job.id);
+                });
+              }
+              self.clusters()[3]['clusters'](apps);
+            } else {
+              $(document).trigger("error", data.message);
+            }
+          });
+        }
+        self.cluster = new ClusterPanelViewModel();
+
         self.searchAutocompleteSource = function (request, callback) {
           // TODO: Extract complete contents to common module (shared with nav search autocomplete)
           var facetMatch = request.term.match(/([a-z]+):\s*(\S+)?$/i);