Эх сурвалжийг харах

HUE-8555 [jb] Refactor job browser preview to support multi cluster

Romain Rigaux 7 жил өмнө
parent
commit
703eed0b3e

+ 24 - 7
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -79,7 +79,21 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
   </a>
 % endif
 
-  % if not is_mini:
+
+% if is_mini:
+  <ul class="nav nav-pills">
+    <!-- ko foreach: availableInterfaces -->
+      <li data-bind="css: {'active': $parent.interface() === interface}, visible: condition()">
+        <a class="pointer" data-bind="click: function(){ $parent.selectInterface(interface); }, text: label"></a>
+      </li>
+    <!-- /ko -->
+  </ul>
+  <span class="pull-right">
+    <!-- ko if: availableComputes().length > 1 -->
+      <div data-bind="component: { name: 'hue-drop-down', params: { value: compute, entries: availableComputes, labelAttribute: 'name', searchable: true, linkTitle: '${ _ko('Active clusters') }' } }"></div>
+    <!-- /ko -->
+  </span>
+% else:    
   <div class="navbar hue-title-bar">
     <div class="navbar-inner">
       <div class="container-fluid">
@@ -116,7 +130,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       </div>
     </div>
   </div>
-  % endif
+% endif
 
 
   <script type="text/html" id="apps-list${ SUFFIX }">
@@ -2780,15 +2794,18 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         };
         var dataEngInterfaceCondition = function () {
           return self.compute() && self.compute()['type'].indexOf('altus-de') >= 0;
-        }
+        };
         var dataWarehouseInterfaceCondition = function () {
           return self.compute() && self.compute()['type'].indexOf('altus-dw') >= 0;
-        }
+        };
         var schedulerInterfaceCondition = function () {
           return '${ user.has_hue_permission(action="access", app="oozie") }' == 'True' && self.clusterType() != '${ ANALYTIC_DB }' && (!self.compute() || self.compute()['type'].indexOf('altus') == -1);
         };
+        var schedulerExtraInterfaceCondition = function () {
+          return '${ is_mini }' == 'False' && schedulerInterfaceCondition();
+        };
         var livyInterfaceCondition = function () {
-          return self.appConfig() && self.appConfig()['editor'] && self.appConfig()['editor']['interpreter_names'].indexOf('pyspark') != -1 && (!self.compute() || self.compute()['type'].indexOf('altus') == -1);
+          return '${ is_mini }' == 'False' && self.appConfig() && self.appConfig()['editor'] && self.appConfig()['editor']['interpreter_names'].indexOf('pyspark') != -1 && (!self.compute() || self.compute()['type'].indexOf('altus') == -1);
         };
         var queryInterfaceCondition = function () {
           return '${ ENABLE_QUERY_BROWSER.get() }' == 'True' && self.appConfig() && self.appConfig()['editor'] && self.appConfig()['editor']['interpreter_names'].indexOf('impala') != -1 && (!self.compute() || self.compute()['type'].indexOf('altus') == -1);
@@ -2802,8 +2819,8 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
           {'interface': 'queries', 'label': '${ _ko('Queries') }', 'condition': queryInterfaceCondition},
           {'interface': 'workflows', 'label': '${ _ko('Workflows') }', 'condition': schedulerInterfaceCondition},
           {'interface': 'schedules', 'label': '${ _ko('Schedules') }', 'condition': schedulerInterfaceCondition},
-          {'interface': 'bundles', 'label': '${ _ko('Bundles') }', 'condition': schedulerInterfaceCondition},
-          {'interface': 'slas', 'label': '${ _ko('SLAs') }', 'condition': schedulerInterfaceCondition},
+          {'interface': 'bundles', 'label': '${ _ko('Bundles') }', 'condition': schedulerExtraInterfaceCondition},
+          {'interface': 'slas', 'label': '${ _ko('SLAs') }', 'condition': schedulerExtraInterfaceCondition},
           {'interface': 'livy-sessions', 'label': '${ _ko('Livy') }', 'condition': livyInterfaceCondition},
         ];
 

+ 6 - 19
desktop/core/src/desktop/templates/hue.mako

@@ -286,22 +286,9 @@ ${ hueIcons.symbols() }
 
   <div id="jobsPanel" class="jobs-panel" style="display: none;">
     <a class="pointer inactive-action pull-right" onclick="huePubSub.publish('hide.jobs.panel')"><i class="fa fa-fw fa-times"></i></a>
-    <a class="pointer inactive-action pull-right" onclick="huePubSub.publish('mini.jb.expand'); huePubSub.publish('hide.jobs.panel')"><i class="fa fa-fw fa-expand" title="${ _('Open Job Browser') }"></i></a>
-    <ul class="nav nav-pills">
-      % if cluster != ANALYTIC_DB:
-      <li class="active" data-interface="jobs"><a href="javascript:void(0)" onclick="huePubSub.publish('mini.jb.navigate', 'jobs')">${_('Jobs')}</a></li>
-      % endif
-      % if 'jobbrowser' in apps:
-      <% from jobbrowser.conf import ENABLE_QUERY_BROWSER %>
-      % if ENABLE_QUERY_BROWSER.get():
-        <li data-interface="queries" class="${ 'active' if cluster == ANALYTIC_DB else '' }"><a href="javascript:void(0)" onclick="huePubSub.publish('mini.jb.navigate', 'queries')">${_('Queries')}</a></li>
-      % endif
-      % endif
-      % if cluster != ANALYTIC_DB:
-        <li data-interface="workflows"><a href="javascript:void(0)" onclick="huePubSub.publish('mini.jb.navigate', 'workflows')">${_('Workflows')}</a></li>
-        <li data-interface="schedules"><a href="javascript:void(0)" onclick="huePubSub.publish('mini.jb.navigate', 'schedules')">${_('Schedules')}</a></li>
-      % endif
-    </ul>
+    <a class="pointer inactive-action pull-right" onclick="huePubSub.publish('mini.jb.expand'); huePubSub.publish('hide.jobs.panel')" title="${ _('Open in Job Browser') }">
+      ${ _('Open') } <i class="fa fa-fw fa-expand"></i>
+    </a>
     <div id="mini_jobbrowser"></div>
   </div>
 
@@ -322,11 +309,11 @@ ${ hueIcons.symbols() }
         <div class="hue-sidebar-content">
           <!-- ko foreach: {data: items, as: 'item'} -->
           <!-- ko if: item.isCategory -->
-          <h4 class="hue-sidebar-category-item" data-bind="text: item.displayName"></h4>
-          <!-- ko template: {name: 'hue-tmpl-sidebar-link', foreach: item.children, as: 'item'} --><!-- /ko -->
+            <h4 class="hue-sidebar-category-item" data-bind="text: item.displayName"></h4>
+            <!-- ko template: {name: 'hue-tmpl-sidebar-link', foreach: item.children, as: 'item'} --><!-- /ko -->
           <!-- /ko -->
           <!-- ko ifnot: item.isCategory -->
-          <!-- ko template: { name: 'hue-tmpl-sidebar-link' } --><!-- /ko -->
+            <!-- ko template: { name: 'hue-tmpl-sidebar-link' } --><!-- /ko -->
           <!-- /ko -->
           <!-- /ko -->
         </div>