فهرست منبع

HUE-8330 [cluster] Display multi cluster configs

Romain 6 سال پیش
والد
کامیت
2f0b401ab7

+ 2 - 0
desktop/core/src/desktop/api2.py

@@ -71,6 +71,7 @@ def api_error_handler(func):
 @api_error_handler
 def get_config(request):
   config = get_cluster_config(request.user)
+  config['clusters'] = get_clusters(request.user).values()
   config['status'] = 0
 
   return JsonResponse(config)
@@ -185,6 +186,7 @@ def get_context_computes(request, interface):
   return JsonResponse(response)
 
 
+# Deprecated
 @api_error_handler
 def get_context_clusters(request, interface):
   response = {}

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

@@ -1780,6 +1780,9 @@ def get_clusters(user):
 def has_multi_cluster():
   return bool(CLUSTERS.get())
 
+def has_multi_clusters():
+  return len(CLUSTERS.get()) > 1
+
 
 CLUSTERS = UnspecifiedConfigSection(
   "clusters",

+ 4 - 4
desktop/core/src/desktop/js/ko/components/ko.contextSelector.js

@@ -28,7 +28,7 @@ const TEMPLATE = `
   <!-- ko if: loadingContext -->
   <i class="fa fa-spinner fa-spin muted"></i>
   <!-- /ko -->
-  
+
   <div class="inline-block" style="display: none;" data-bind="visible: !loadingContext()">
     <!-- ko if: window.HAS_MULTI_CLUSTER -->
     <!-- ko if: availableClusters().length > 0 && !hideClusters -->
@@ -44,7 +44,7 @@ const TEMPLATE = `
       'No clusters found'
     )}</span>
     <!-- /ko -->
-  
+
     <!-- ko if: availableComputes().length > 0 && !hideComputes -->
     <!-- ko ifnot: hideLabels --><span class="editor-header-title">${I18n(
       'Compute'
@@ -58,7 +58,7 @@ const TEMPLATE = `
       'No computes found'
     )}</span>
     <!-- /ko -->
-  
+
     <!-- ko if: availableNamespaces().length > 0 && !hideNamespaces -->
     <!-- ko ifnot: hideLabels --><span class="editor-header-title">${I18n(
       'Namespace'
@@ -73,7 +73,7 @@ const TEMPLATE = `
     )}</span>
     <!-- /ko -->
     <!-- /ko -->
-  
+
     <!-- ko if: availableDatabases().length > 0 && !hideDatabases-->
     <!-- ko ifnot: hideLabels --><span class="editor-header-title">${I18n(
       'Database'

+ 5 - 0
desktop/core/src/desktop/js/topNavViewModel.js

@@ -57,6 +57,7 @@ class TopNavViewModel {
     self.quickCreateActions = ko.observableArray();
 
     self.hasJobBrowser = ko.observable(true);
+    self.clusters = ko.observableArray();
 
     huePubSub.subscribe('cluster.config.set.config', clusterConfig => {
       if (clusterConfig && clusterConfig['main_button_action']) {
@@ -121,6 +122,10 @@ class TopNavViewModel {
         self.quickCreateActions([]);
       }
 
+      if (clusterConfig && clusterConfig['clusters']) {
+        self.clusters(clusterConfig['clusters']);
+      }
+
       self.hasJobBrowser(
         clusterConfig &&
           clusterConfig['app_config'] &&

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

@@ -18,7 +18,7 @@
   from django.utils.translation import ugettext as _
 
   from desktop import conf
-  from desktop.conf import IS_EMBEDDED, DEV_EMBEDDED, IS_MULTICLUSTER_ONLY, has_multi_cluster
+  from desktop.conf import IS_EMBEDDED, DEV_EMBEDDED, IS_MULTICLUSTER_ONLY, has_multi_cluster, has_multi_clusters
   from desktop.views import _ko, commonshare, login_modal
   from desktop.lib.i18n import smart_unicode
   from desktop.models import PREFERENCE_IS_WELCOME_TOUR_SEEN, ANALYTIC_DB, hue_version
@@ -199,7 +199,7 @@ ${ hueIcons.symbols() }
           </a>
 
           <a class="brand" data-bind="hueLink: '/home/'" href="javascript: void(0);" title="${_('Documents')}">
-              <svg style="height: 24px; width: 120px;"><use xlink:href="#hi-logo"></use></svg>
+            <svg style="height: 24px; width: 120px;"><use xlink:href="#hi-logo"></use></svg>
           </a>
           % endif
         % endif
@@ -259,6 +259,10 @@ ${ hueIcons.symbols() }
           % if IS_MULTICLUSTER_ONLY.get():
             ##<!-- ko component: { name: 'hue-app-switcher', params: { onPrem: ko.observable(false) } } --><!-- /ko -->
           % endif
+          % if has_multi_clusters():
+            <select data-bind="options: clusters, optionsText: 'name', value: 'id'" class="input-medium pull-right">
+            </select>
+          % endif
 
           <%
             view_profile = user.has_hue_permission(action="access_view:useradmin:edit_user", app="useradmin") or is_admin(user)