Преглед на файлове

HUE-4866 [notebook] Test getting document as snippet source

Romain Rigaux преди 9 години
родител
ревизия
ffc916e6a8

+ 2 - 2
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -638,8 +638,8 @@
               itemTemplate: 'doc-search-autocomp-item'
             }, valueUpdate: 'afterkeydown'">
             <span class="inactive-action">
-                <i class="fa fa-sort"></i>
-              </span>
+              <i class="fa fa-sort"></i>
+            </span>
           </div>
           <a href="#" data-bind="attr: { href: associatedDocument().absoluteUrl() }" target="_blank" title="${ _('Open') }">
             <i class="fa fa-external-link-square"></i>

+ 3 - 0
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -421,6 +421,9 @@ var EditorViewModel = (function() {
 
     self.statementType = ko.observable(typeof snippet.statementType != "undefined" && snippet.statementType != null ? snippet.statementType : 'text');
     self.statementTypes = ko.observableArray(['text', 'file']); // Maybe computed later for Spark
+    if (! vm.editorMode()) {
+      self.statementTypes.push('document');	
+    }
     self.statementPath = ko.observable(typeof snippet.statementPath != "undefined" && snippet.statementPath != null ? snippet.statementPath : '');
     self.statementPath.subscribe(function(newVal) {
       $.post("/notebook/api/statement_from_file", {

+ 15 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1592,7 +1592,21 @@ ${ hueIcons.symbols() }
   <div class="row-fluid" style="margin-bottom: 5px">
 
     <div class="editor span12" data-bind="css: {'single-snippet-editor ace-container-resizable' : $root.editorMode() }, clickForAceFocus: ace">
-      <!-- ko if: statementType() != 'text' -->
+      <!-- ko if: statementType() == 'file' -->
+        <div class="control-group">
+          <label class="control-label">${_('Query File')}</label>
+          <div class="controls">
+            <input type="text" class="input-xxlarge filechooser-input" data-bind="value: statementPath, valueUpdate: 'afterkeydown', filechooser: statementPath" placeholder="${ _('Path to file, e.g. /user/hue/sample.sql, s3a://hue/sample.sql') }"/>
+            <!-- ko if: statementPath() -->
+              <a data-bind="attr: {href: '/filebrowser/view=' + statementPath() }" target="_blank" title="${ _('Open in new tab') }">
+                <i class="fa fa-external-link-square"></i>
+              </a>
+            <!-- /ko -->
+          </div>
+      </div>
+      <!-- /ko -->
+
+      <!-- ko if: statementType() == 'document' -->
         <div class="control-group">
           <label class="control-label">${_('Query File')}</label>
           <div class="controls">