Przeglądaj źródła

HUE-1176 [jb] Automatically display YARN and/or Oozie jobs if app configured

Romain Rigaux 8 lat temu
rodzic
commit
f214da3c31

+ 16 - 5
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -80,11 +80,15 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
                 ${ _('Job Browser') }
               </a>
             </li>
-            <li data-bind="css: {'active': interface() === 'jobs'}"><a class="pointer" data-bind="click: function(){ selectInterface('jobs'); }">${ _('Jobs') }</a></li>
-            <li data-bind="css: {'active': interface() === 'workflows'}"><a class="pointer" data-bind="click: function(){ selectInterface('workflows'); }">${ _('Workflows') }</a></li>
-            <li data-bind="css: {'active': interface() === 'schedules'}"><a class="pointer" data-bind="click: function(){ selectInterface('schedules'); }">${ _('Schedules') }</a></li>
-            <li data-bind="css: {'active': interface() === 'bundles'}"><a class="pointer" data-bind="click: function(){ selectInterface('bundles'); }">${ _('Bundles') }</a></li>
-            <li data-bind="css: {'active': interface() === 'slas'}"><a class="pointer" data-bind="click: function(){ selectInterface('slas'); }">${ _('SLAs') }</a></li>
+            <!-- ko if: appConfig() && appConfig()['browser'] && appConfig()['browser']['interpreter_names'].indexOf('yarn') != -1 -->
+              <li data-bind="css: {'active': interface() === 'jobs'}"><a class="pointer" data-bind="click: function(){ selectInterface('jobs'); }">${ _('Jobs') }</a></li>
+            <!-- /ko -->
+            <!-- ko if: appConfig() && appConfig()['scheduler'] && appConfig()['scheduler']['interpreters'].length > 0 -->
+              <li data-bind="css: {'active': interface() === 'workflows'}"><a class="pointer" data-bind="click: function(){ selectInterface('workflows'); }">${ _('Workflows') }</a></li>
+              <li data-bind="css: {'active': interface() === 'schedules'}"><a class="pointer" data-bind="click: function(){ selectInterface('schedules'); }">${ _('Schedules') }</a></li>
+              <li data-bind="css: {'active': interface() === 'bundles'}"><a class="pointer" data-bind="click: function(){ selectInterface('bundles'); }">${ _('Bundles') }</a></li>
+              <li data-bind="css: {'active': interface() === 'slas'}"><a class="pointer" data-bind="click: function(){ selectInterface('slas'); }">${ _('SLAs') }</a></li>
+            <!-- /ko -->
             </ul>
           % if not hiveserver2_impersonation_enabled:
             <div class="pull-right label label-warning" style="margin-top: 16px">${ _("Hive jobs are running as the 'hive' user") }</div>
@@ -1363,6 +1367,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       self.assistAvailable = ko.observable(true);
       self.isLeftPanelVisible = ko.observable();
       self.apiHelper.withTotalStorage('assist', 'assist_panel_visible', self.isLeftPanelVisible, true);
+      self.appConfig = ko.observable();
 
       self.slasLoadedOnce = false;
       self.slasLoading = ko.observable(true);
@@ -1461,6 +1466,10 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       viewModel.job().fetchJob();
     });
 
+   huePubSub.subscribe('cluster.config.set.config', function (clusterConfig) {
+     viewModel.appConfig(clusterConfig && clusterConfig['app_config']);
+   });
+
     $(document).ready(function () {
       viewModel = new JobBrowserViewModel(RunningCoordinatorModel);
       % if not is_mini:
@@ -1469,6 +1478,8 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       ko.applyBindings(viewModel, $('#jobbrowserMiniComponents')[0]);
       % endif
 
+      huePubSub.publish('cluster.config.get.config');
+
       var loadHash = function () {
         if (window.location.pathname.indexOf('jobbrowser') > -1 || $('#jobbrowserMiniComponents').is(':visible')) {
           var h = window.location.hash;

+ 7 - 1
desktop/core/src/desktop/api2.py

@@ -72,7 +72,13 @@ def get_config(request):
     'status': 0,
     'app_config': app_config,
     'main_button_action': app_config['editor']['interpreters'][1],
-    'button_actions': [app_config['editor'], app_config['dashboard'], app_config['scheduler']],
+    'button_actions': [
+      app for app in [
+        app_config.get('editor'),
+        app_config.get('dashboard'),
+        app_config.get('scheduler')
+      ] if app is not None
+    ],
   })
 
 

+ 10 - 8
desktop/core/src/desktop/models.py

@@ -43,6 +43,7 @@ from settings import HUE_DESKTOP_VERSION
 
 from aws.conf import is_enabled as is_s3_enabled, has_s3_access
 from dashboard.conf import IS_ENABLED as IS_DASHBOARD_ENABLED
+from hadoop.cluster import get_default_yarncluster
 from notebook.conf import SHOW_NOTEBOOKS, get_ordered_interpreters
 
 from desktop import appmanager
@@ -1597,12 +1598,13 @@ class ClusterConfig():
       })
 
     if 'jobbrowser' in self.apps:
-      interpreters.append({
-        'type': 'jobs',
-        'displayName': _('Jobs'),
-        'tooltip': _('Jobs'),
-        'page': '/jobbrowser/'
-      })
+      if get_default_yarncluster():
+        interpreters.append({
+          'type': 'yarn',
+          'displayName': _('Jobs'),
+          'tooltip': _('Jobs'),
+          'page': '/jobbrowser/'
+        })
 
     if 'hbase' in self.apps:
       interpreters.append({
@@ -1693,13 +1695,13 @@ class ClusterConfig():
 
 
   def get_apps(self):
-    apps = OrderedDict([
+    apps = OrderedDict([app for app in [
       ('editor', self._get_editor()),
       ('dashboard', self._get_dashboard()),
       ('browser', self._get_browser()),
       ('scheduler', self._get_scheduler()),
       ('sdkapps', self._get_sdk_apps()),
-    ])
+    ] if app[1]])
 
     return apps
 

+ 11 - 11
desktop/core/src/desktop/templates/assist.mako

@@ -1429,17 +1429,17 @@ from notebook.conf import get_ordered_interpreters
 
             if (appConfig['editor']) {
               panels.push(
-                      new AssistInnerPanel({
-                        panelData: new AssistDbPanel($.extend({
-                          apiHelper: self.apiHelper,
-                          i18n: i18n
-                        }, params.sql)),
-                        apiHelper: self.apiHelper,
-                        name: '${ _("SQL") }',
-                        type: 'sql',
-                        icon: 'fa-database',
-                        minHeight: 75
-                      })
+                new AssistInnerPanel({
+                  panelData: new AssistDbPanel($.extend({
+                    apiHelper: self.apiHelper,
+                    i18n: i18n
+                  }, params.sql)),
+                  apiHelper: self.apiHelper,
+                  name: '${ _("SQL") }',
+                  type: 'sql',
+                  icon: 'fa-database',
+                  minHeight: 75
+                })
               );
             }