Jelajahi Sumber

HUE-5868 [jb] Make the new job browser embeddable without a nav bar

Enrico Berti 8 tahun lalu
induk
melakukan
29cf9ff70b

+ 4 - 0
Gruntfile.js

@@ -41,6 +41,8 @@ module.exports = function(grunt) {
           'desktop/libs/notebook/src/notebook/static/notebook/css/notebook-layout.css': 'desktop/libs/notebook/src/notebook/static/notebook/less/notebook-layout.less',
           'apps/oozie/src/oozie/static/oozie/css/workflow-editor.css': 'apps/oozie/src/oozie/static/oozie/less/workflow-editor.less',
           'apps/filebrowser/src/filebrowser/static/filebrowser/css/display.css': 'apps/filebrowser/src/filebrowser/static/filebrowser/less/display.less',
+          'apps/jobbrowser/src/jobbrowser/static/jobbrowser/css/jobbrowser.css': 'apps/jobbrowser/src/jobbrowser/static/jobbrowser/less/jobbrowser.less',
+          'apps/jobbrowser/src/jobbrowser/static/jobbrowser/css/jobbrowser-embeddable.css': 'apps/jobbrowser/src/jobbrowser/static/jobbrowser/less/jobbrowser-embeddable.less',
         }
       }
     },
@@ -57,6 +59,8 @@ module.exports = function(grunt) {
           'apps/oozie/src/oozie/static/oozie/less/**/*.less',
           'apps/filebrowser/src/filebrowser/static/filebrowser/less/*.less',
           'apps/filebrowser/src/filebrowser/static/filebrowser/less/**/*.less',
+          'apps/jobbrowser/src/jobbrowser/static/jobbrowser/less/*.less',
+          'apps/jobbrowser/src/jobbrowser/static/jobbrowser/less/**/*.less',
         ],
         tasks: ['less']
       }

+ 17 - 0
apps/jobbrowser/src/jobbrowser/static/jobbrowser/css/jobbrowser-embeddable.css

@@ -0,0 +1,17 @@
+/*!
+Licensed to Cloudera, Inc. under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  Cloudera, Inc. 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.
+ */#jobbrowserComponents .content-panel-inner{padding:10px}#jobbrowserComponents .tab-content{padding:10px;border:none !important}#jobbrowserComponents .hueBreadcrumbBar{padding:0}#jobbrowserComponents .hueBreadcrumbBar li{padding:12px}#jobbrowserComponents .hueBreadcrumbBar li:first-child{padding-left:0;padding-right:0}#jobbrowserComponents .hueBreadcrumbBar a{color:#338BB8 !important;display:inline !important}#jobbrowserComponents .divider{color:#CCC;padding-right:12px}#jobbrowserComponents .app-icon{vertical-align:text-top}

+ 15 - 38
apps/jobbrowser/src/jobbrowser/static/jobbrowser/css/jobbrowser.css

@@ -1,40 +1,17 @@
-/*
- Licensed to Cloudera, Inc. under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  Cloudera, Inc. 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
+/*!
+Licensed to Cloudera, Inc. under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  Cloudera, Inc. 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
+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.
-*/
-
-.retired {
-  display: inline;
-  margin-right: 10px;
-  margin-top: 4px;
-}
-
-.retired input {
-  float: none !important;
-  margin-right: 3px;
-  margin-top: -4px;
-}
-
-#jobsTable tbody tr {
-  height: 45px;
-}
-
-#noJobs {
-  margin-top: 40px;
-  margin-bottom: 40px;
-  padding: 20px;
-  display: none;
-}
+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.
+ */.retired{display:inline;margin-right:10px;margin-top:4px}.retired input{float:none !important;margin-right:3px;margin-top:-4px}#jobsTable tbody tr{height:45px}#noJobs{margin-top:40px;margin-bottom:40px;padding:20px;display:none}

+ 54 - 0
apps/jobbrowser/src/jobbrowser/static/jobbrowser/less/jobbrowser-embeddable.less

@@ -0,0 +1,54 @@
+/*
+ Licensed to Cloudera, Inc. under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  Cloudera, Inc. 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.
+*/
+
+#jobbrowserComponents {
+  .content-panel-inner {
+    padding: 10px;
+  }
+  .tab-content {
+    padding: 10px;
+    border: none !important;
+  }
+
+  .hueBreadcrumbBar {
+    padding: 0;
+  }
+
+  .hueBreadcrumbBar li {
+    padding: 12px;
+  }
+
+  .hueBreadcrumbBar li:first-child {
+    padding-left: 0;
+    padding-right: 0;
+  }
+
+  .hueBreadcrumbBar a {
+    color: #338BB8 !important;
+    display: inline !important;
+  }
+
+  .divider {
+    color: #CCC;
+    padding-right: 12px;
+  }
+
+  .app-icon {
+    vertical-align: text-top;
+  }
+}

+ 40 - 0
apps/jobbrowser/src/jobbrowser/static/jobbrowser/less/jobbrowser.less

@@ -0,0 +1,40 @@
+/*
+ Licensed to Cloudera, Inc. under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  Cloudera, Inc. 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.
+*/
+
+.retired {
+  display: inline;
+  margin-right: 10px;
+  margin-top: 4px;
+}
+
+.retired input {
+  float: none !important;
+  margin-right: 3px;
+  margin-top: -4px;
+}
+
+#jobsTable tbody tr {
+  height: 45px;
+}
+
+#noJobs {
+  margin-top: 40px;
+  margin-bottom: 40px;
+  padding: 20px;
+  display: none;
+}

+ 3 - 37
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -41,6 +41,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 % endif
 </style>
 % endif
+<link rel="stylesheet" href="${ static('jobbrowser/css/jobbrowser-embeddable.css') }">
 
 <script src="${ static('oozie/js/dashboard-utils.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/ext/js/jquery/plugins/jquery.basictable.min.js') }"></script>
@@ -64,43 +65,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 % endif
 
 
-<style type="text/css">
-  #jobbrowserComponents .content-panel-inner {
-    padding: 10px;
-  }
-  #jobbrowserComponents .tab-content {
-    padding: 10px;
-    border: none!important;
-  }
-
-  #jobbrowserComponents .hueBreadcrumbBar {
-    padding: 0;
-  }
-
-  #jobbrowserComponents .hueBreadcrumbBar li {
-    padding: 12px;
-  }
-
-  #jobbrowserComponents .hueBreadcrumbBar li:first-child {
-    padding-left: 0;
-    padding-right: 0;
-  }
-
-  #jobbrowserComponents .hueBreadcrumbBar a {
-    color: #338BB8 !important;
-    display: inline !important;
-  }
-
-  #jobbrowserComponents .divider {
-    color: #CCC;
-    padding-right: 12px;
-  }
-
-  #jobbrowserComponents .app-icon {
-    vertical-align: text-top;
-  }
-</style>
-
+% if not is_mini:
 <div class="navbar navbar-inverse navbar-fixed-top">
     <div class="navbar-inner">
       <div class="container-fluid">
@@ -124,6 +89,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
       </div>
     </div>
 </div>
+% endif
 
 <div class="main-content">
   <div class="vertical-full container-fluid" data-bind="style: { 'padding-left' : $root.isLeftPanelVisible() ? '0' : '20px' }">

+ 1 - 0
apps/jobbrowser/src/jobbrowser/views.py

@@ -105,6 +105,7 @@ def get_job(request, job_id):
 def apps(request):
   return render('job_browser.mako', request, {
     'is_embeddable': request.GET.get('is_embeddable', False),
+    'is_mini': request.GET.get('is_mini', False),
     'hiveserver2_impersonation_enabled': hiveserver2_impersonation_enabled()
   })
 

File diff ditekan karena terlalu besar
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


+ 14 - 0
desktop/core/src/desktop/static/desktop/less/hue.less

@@ -928,4 +928,18 @@ a:visited {
 
 .context-panel .tab-pane {
   height: 100%;
+}
+
+#mini_jobbrowser {
+  overflow-y: auto;
+  max-height: 350px;
+  table, thead, tbody, th, td, tr {
+    display: block;
+  }
+  thead tr {
+    display: none;
+  }
+  input.search-query {
+    width: 70px;
+  }
 }

+ 41 - 32
desktop/core/src/desktop/templates/responsive.mako

@@ -290,6 +290,7 @@ ${ hueIcons.symbols() }
         </div>
         <div class="jobs-panel" data-bind="visible: jobsPanelVisible" style="display: none;">
           <span style="font-size: 15px; font-weight: 300">${_('Jobs')} | ${_('Workflows')} | ${_('Schedules')}</span>
+          <div id="mini_jobbrowser"></div>
         </div>
       % endif
     </div>
@@ -540,16 +541,6 @@ ${ assist.assistPanel() }
 <iframe id="zoomDetectFrame" style="width: 250px; display: none" ></iframe>
 
 <script type="text/javascript">
-  (function () {
-    var proxiedKORegister = ko.components.register;
-    var LOADED_COMPONENTS = [];
-    ko.components.register = function () {
-      if (LOADED_COMPONENTS.indexOf(arguments[0]) === -1) {
-        LOADED_COMPONENTS.push(arguments[0]);
-        return proxiedKORegister.apply(this, arguments);
-      }
-    };
-  })();
 
   $(document).ready(function () {
     var options = {
@@ -697,6 +688,32 @@ ${ assist.assistPanel() }
           }
         });
 
+        function processHeaders(response){
+          var r = $('<span>').html(response);
+          r.find('link').each(function () {
+            $(this).attr('href', $(this).attr('href') + '?' + Math.random())
+          });
+          // load just CSS and JS files that are not loaded before
+          r.find('script[src]').each(function () {
+            var jsFile = $(this).attr('src').split('?')[0];
+            if (LOADED_JS.indexOf(jsFile) === -1) {
+              LOADED_JS.push(jsFile);
+              $(this).clone().appendTo($('head'));
+            }
+            $(this).remove();
+          });
+          r.find('link[href]').each(function () {
+            var cssFile = $(this).attr('href').split('?')[0];
+            if (LOADED_CSS.indexOf(cssFile) === -1) {
+              LOADED_CSS.push(cssFile);
+              $(this).clone().appendTo($('head'));
+            }
+            $(this).remove();
+          });
+          r.unwrap('<span>');
+          return r;
+        }
+
         self.currentApp.subscribe(function (newVal) {
           hueUtils.changeURLParameter('app', newVal);
           if (newVal !== 'editor') {
@@ -712,28 +729,7 @@ ${ assist.assistPanel() }
               dataType: 'html',
               success: function (response) {
                 self.extraEmbeddableURLParams('');
-                var r = $('<span>').html(response);
-                r.find('link').each(function () {
-                  $(this).attr('href', $(this).attr('href') + '?' + Math.random())
-                });
-                // load just CSS and JS files that are not loaded before
-                r.find('script[src]').each(function () {
-                  var jsFile = $(this).attr('src').split('?')[0];
-                  if (LOADED_JS.indexOf(jsFile) === -1) {
-                    LOADED_JS.push(jsFile);
-                    $(this).clone().appendTo($('head'));
-                  }
-                  $(this).remove();
-                });
-                r.find('link[href]').each(function () {
-                  var cssFile = $(this).attr('href').split('?')[0];
-                  if (LOADED_CSS.indexOf(cssFile) === -1) {
-                    LOADED_CSS.push(cssFile);
-                    $(this).clone().appendTo($('head'));
-                  }
-                  $(this).remove();
-                });
-                r.unwrap('<span>');
+                var r = processHeaders(response);
                 if (self.SKIP_CACHE.indexOf(newVal) === -1) {
                   self.embeddable_cache[newVal] = r;
                 }
@@ -791,6 +787,19 @@ ${ assist.assistPanel() }
           self.currentApp(name);
         });
 
+        // load the mini jobbrowser
+        $.ajax({
+          url: '/jobbrowser/apps?is_embeddable=true&is_mini=true',
+          beforeSend: function (xhr) {
+            xhr.setRequestHeader('X-Requested-With', 'Hue');
+          },
+          dataType: 'html',
+          success: function (response) {
+            var r = processHeaders(response);
+            $('#mini_jobbrowser').html(r);
+          }
+        });
+
       };
 
       var onePageViewModel = new OnePageViewModel();

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini