浏览代码

HUE-5862 [fb] Remove smiley and message on empty files

Enrico Berti 8 年之前
父节点
当前提交
62ee8e2df0

+ 7 - 2
Gruntfile.js

@@ -39,7 +39,8 @@ module.exports = function(grunt) {
           'apps/metastore/src/metastore/static/metastore/css/metastore.css': 'apps/metastore/src/metastore/static/metastore/less/metastore.less',
           'desktop/libs/notebook/src/notebook/static/notebook/css/notebook.css': 'desktop/libs/notebook/src/notebook/static/notebook/less/notebook.less',
           '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/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',
         }
       }
     },
@@ -51,7 +52,11 @@ module.exports = function(grunt) {
           'apps/metastore/src/metastore/static/metastore/less/*.less',
           'apps/metastore/src/metastore/static/metastore/less/**/*.less',
           'desktop/libs/notebook/src/notebook/static/notebook/less/*.less',
-          'desktop/libs/notebook/src/notebook/static/notebook/less/**/*.less'
+          'desktop/libs/notebook/src/notebook/static/notebook/less/**/*.less',
+          'apps/oozie/src/oozie/static/oozie/less/*.less',
+          'apps/oozie/src/oozie/static/oozie/less/**/*.less',
+          'apps/filebrowser/src/filebrowser/static/filebrowser/less/*.less',
+          'apps/filebrowser/src/filebrowser/static/filebrowser/less/**/*.less',
         ],
         tasks: ['less']
       }

+ 17 - 67
apps/filebrowser/src/filebrowser/static/filebrowser/css/display.css

@@ -1,67 +1,17 @@
-#fileviewer .card-body {
-  padding: 0;
-  margin: 0;
-}
-
-#fileviewer .hueBreadcrumbBar {
-  margin: 0;
-}
-
-#fileArea {
-  overflow: auto;
-  background-color: #F5F5F5;
-  position: relative;
-  font-size: 12px;
-}
-
-#fileArea.loading {
-  opacity: .7;
-}
-
-#loader {
-  position: fixed;
-  margin-top: 40px;
-  width: 140px;
-  height: 140px;
-  line-height: 140px;
-  -webkit-border-radius: 20px;
-  -moz-border-radius: 20px;
-  border-radius: 20px;
-  font-size: 50px;
-  text-align: center;
-}
-
-.binary {
-  font-family: "Courier New", Courier, monospace;
-}
-
-pre {
-  border: none;
-}
-
-pre a {
-  color: #444;
-  cursor: default;
-  white-space: inherit;
-}
-
-pre a:hover {
-  color: #444;
-  text-decoration: none;
-}
-
-.pagination-input-form {
-  position: relative;
-  right: 1em;
-  top: -10px;
-}
-
-.pagination-input {
-  text-align: center;
-  width: 40px;
-}
-
-dd {
-  margin-left: 0;
-  margin-bottom: 6px;
-}
+/*!
+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.
+ */#fileviewerComponents .card-body{padding:0;margin:0}#fileviewerComponents .hueBreadcrumbBar{margin:0;padding-bottom:0}#fileviewerComponents #fileArea{overflow:auto;background-color:#F5F5F5;position:relative;font-size:12px}#fileviewerComponents #fileArea.loading{opacity:.7}#fileviewerComponents #loader{position:fixed;margin-top:40px;width:140px;height:140px;line-height:140px;-webkit-border-radius:20px;-moz-border-radius:20px;border-radius:20px;font-size:50px;text-align:center}#fileviewerComponents .binary{font-family:"Courier New",Courier,monospace}#fileviewerComponents pre{border:none}#fileviewerComponents pre a{color:#444;cursor:default;white-space:inherit}#fileviewerComponents pre a:hover{color:#444;text-decoration:none}#fileviewerComponents .pagination-input-form{position:relative;right:1em;top:-10px}#fileviewerComponents .pagination-input{text-align:center;width:40px}#fileviewerComponents dd{margin-left:0;margin-bottom:6px}

+ 87 - 0
apps/filebrowser/src/filebrowser/static/filebrowser/less/display.less

@@ -0,0 +1,87 @@
+/*
+ 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.
+*/
+#fileviewerComponents {
+  .card-body {
+    padding: 0;
+    margin: 0;
+  }
+
+  .hueBreadcrumbBar {
+    margin: 0;
+    padding-bottom: 0;
+  }
+
+  #fileArea {
+    overflow: auto;
+    background-color: #F5F5F5;
+    position: relative;
+    font-size: 12px;
+    &.loading {
+      opacity: .7;
+    }
+  }
+
+  #loader {
+    position: fixed;
+    margin-top: 40px;
+    width: 140px;
+    height: 140px;
+    line-height: 140px;
+    -webkit-border-radius: 20px;
+    -moz-border-radius: 20px;
+    border-radius: 20px;
+    font-size: 50px;
+    text-align: center;
+  }
+
+  .binary {
+    font-family: "Courier New", Courier, monospace;
+  }
+
+  pre {
+    border: none;
+  }
+
+  pre a {
+    color: #444;
+    cursor: default;
+    white-space: inherit;
+  }
+
+  pre a:hover {
+    color: #444;
+    text-decoration: none;
+  }
+
+  .pagination-input-form {
+    position: relative;
+    right: 1em;
+    top: -10px;
+  }
+
+  .pagination-input {
+    text-align: center;
+    width: 40px;
+  }
+
+  dd {
+    margin-left: 0;
+    margin-bottom: 6px;
+  }
+}
+

+ 20 - 14
apps/filebrowser/src/filebrowser/templates/display.mako

@@ -124,9 +124,8 @@ ${ fb_components.menubar() }
           ${fb_components.breadcrumbs(path, breadcrumbs, is_embeddable=is_embeddable)}
         %endif
         <div class="card-body" style="padding: 0">
-            <!-- ko if: $root.file() && $root.file().stats.size() === 0 -->
+            <!-- ko if: $root.file() && $root.file().stats.size() === 0 && $root.isViewing() -->
             <div class="center empty-wrapper">
-              <i class="fa fa-frown-o"></i>
               <h1>${_('The current file is empty.')}</h1>
               <br/>
             </div>
@@ -146,7 +145,7 @@ ${ fb_components.menubar() }
               <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }"/><![endif]-->
             </div>
             <!-- ko if: $root.isViewing -->
-            <div id="fileArea" data-bind="css: {'loading': isLoading}">
+            <div id="fileArea" data-bind="css: {'loading': isLoading}, visible: $root.file() && $root.file().stats.size()">
               <pre></pre>
               <table class="binary">
                 <tbody>
@@ -185,16 +184,14 @@ ${ fb_components.menubar() }
     max_size: ${view['max_chunk_size']}
   });
 
-  function resizeText () {
-    var _fileArea = $("#fileArea");
-    if (_fileArea.height() > 0) {
-      _fileArea.height($(window).height() - _fileArea.offset().top - 26);
-      $("#loader").css("marginLeft", (_fileArea.width() - $("#loader").width()) / 2);
-    }
+  function resizeText() {
+    hueUtils.waitForRendered('#fileArea', function(el){ return el.height() > 0 }, function(){
+      $("#fileArea").height($(window).height() - $("#fileArea").offset().top - 26);
+    });
   }
 
-  function formatHex (number, padding) {
-    if ("undefined" != typeof number){
+  function formatHex(number, padding) {
+    if ("undefined" != typeof number) {
       var _filler = "";
       for (var i = 0; i < padding - 1; i++) {
         _filler += "0";
@@ -204,7 +201,7 @@ ${ fb_components.menubar() }
     return "";
   }
 
-  function renderPages () {
+  function renderPages() {
     var _html = "";
     for (var i = viewModel.page(); i <= viewModel.upperPage(); i++) {
       _html += "<a id='page" + i + "'><div class='fill-file-area'></div></a>";
@@ -294,10 +291,18 @@ ${ fb_components.menubar() }
     self.PAGES_PER_CHUNK = 50;
 
     self.isViewing = ko.observable(true);
+    self.isViewing.subscribe(function(val){
+      if (val){
+        window.setTimeout(resizeText, 0);
+      }
+    });
 
     self.base_url = ko.observable(params.base_url);
     self.compression = ko.observable(params.compression);
     self.mode = ko.observable(params.mode);
+    self.mode.subscribe(function(val){
+      window.setTimeout(resizeText, 0);
+    });
     self.begin = ko.observable(params.begin);
     self.end = ko.observable(params.end);
     self.length = ko.observable(params.length);
@@ -477,18 +482,19 @@ ${ fb_components.menubar() }
   $(document).ready(function () {
     ko.applyBindings(viewModel, $('#fileviewerComponents')[0]);
 
+    $("#loader").css("marginLeft", ($(".hueBreadcrumbBar").width() - $("#loader").width()) / 2);
+
     $(document).ajaxError(function () {
       $.jHueNotify.error("${_('There was an unexpected server error.')}");
     });
 
     setTimeout(function () {
+      resizeText();
       getContent(function () {
         viewModel.toggleDisables();
       });
     }, 100);
 
-    resizeText();
-
     var _resizeTimeout = -1;
 
     $(window).on("resize", function () {