Pārlūkot izejas kodu

[beeswax] Save table as a file opens output directory

Open Filebrowser page on the output directory.
Removed deprecated PopupWithJframe.
Romain Rigaux 13 gadi atpakaļ
vecāks
revīzija
1644919c9c

+ 0 - 2
apps/beeswax/src/beeswax/templates/execute.mako

@@ -421,8 +421,6 @@ ${layout.menubar(section='query')}
 			$(".query").val($("#queryField").val());
 			$("#advancedSettingsForm").submit();
 		}
-
-
 	});
 </script>
 

+ 1 - 3
apps/beeswax/src/beeswax/templates/index.mako

@@ -58,9 +58,7 @@ ${layout.menubar(section='tables')}
         <h3>Install samples</h3>
     </div>
     <div class="modal-body">
-      <div id="installSamplesMessage" class="alert">
-
-      </div>
+      <div id="installSamplesMessage" class="alert"></div>
     </div>
     <div class="modal-footer">
         <a href="#" id="installSamplesBtn" class="btn primary">Yes</a>

+ 0 - 2
apps/beeswax/src/beeswax/templates/save_results.mako

@@ -47,7 +47,6 @@ ${layout.menubar(section='history')}
 
 <script type="text/javascript" charset="utf-8">
 	$(document).ready(function(){
-
 		$("input[name='save_target']").change(function(){
 			$("#fieldRequired").addClass("hidden");
 			$("input[name='target_dir']").removeClass("fieldError");
@@ -82,7 +81,6 @@ ${layout.menubar(section='history')}
 			}
 			return true;
 		});
-
 	});
 </script>
 ${commonfooter()}

+ 30 - 33
apps/beeswax/src/beeswax/templates/watch_results.mako

@@ -112,9 +112,7 @@ ${layout.menubar(section='query')}
 		          % endif
 				</div>
 				<div class="tab-pane" id="query">
-
 						<pre>${query.query | h}</pre>
-
 				</div>
 				<div class="tab-pane" id="log">
 					<pre>${log | h}</pre>
@@ -128,42 +126,42 @@ ${layout.menubar(section='query')}
 %if can_save:
 <div id="saveAs" class="modal hide fade">
 	<form id="saveForm" action="${url('beeswax.views.save_results', query.id) }" method="POST" class="form form-inline form-padding-fix">
-    <div class="modal-header">
-        <a href="#" class="close" data-dismiss="modal">&times;</a>
-        <h3>Save Query Results</h3>
-    </div>
-    <div class="modal-body">
-		<label class="radio">
-			<input id="id_save_target_0" type="radio" name="save_target" value="to a new table" checked="checked"/>
-			&nbsp;In a new table
-		</label>
-		${comps.field(save_form['target_table'], notitle=True, placeholder="Table Name")}
-		<br/>
-		<label class="radio">
-			<input id="id_save_target_1" type="radio" name="save_target" value="to HDFS directory">
-			&nbsp;In an HDFS directory
-		</label>
-		${comps.field(save_form['target_dir'], notitle=True, hidden=True, placeholder="Results location", klass="pathChooser")}
-		<br/><br/>
-		<div id="fileChooserModal" class="smallModal well hide">
-			<a href="#" class="close" data-dismiss="modal">&times;</a>
-		</div>
-
-    </div>
-    <div class="modal-footer">
-		<div id="fieldRequired" class="hide" style="position: absolute; left: 10;">
-			<span class="label label-important">Sorry, name is required.</span>
-        </div>
-        <input type="submit" class="btn primary" value="Save" name="save" />
-		<button class="btn" data-dismiss="modal">Cancel</button>
-    </div>
+	    <div class="modal-header">
+	        <a href="#" class="close" data-dismiss="modal">&times;</a>
+	        <h3>Save Query Results</h3>
+	    </div>
+	    <div class="modal-body">
+			<label class="radio">
+				<input id="id_save_target_0" type="radio" name="save_target" value="to a new table" checked="checked"/>
+				&nbsp;In a new table
+			</label>
+			${comps.field(save_form['target_table'], notitle=True, placeholder="Table Name")}
+			<br/>
+			<label class="radio">
+				<input id="id_save_target_1" type="radio" name="save_target" value="to HDFS directory">
+				&nbsp;In an HDFS directory
+			</label>
+			${comps.field(save_form['target_dir'], notitle=True, hidden=True, placeholder="Results location", klass="pathChooser")}
+			<br/>
+			<br/>
+			<div id="fileChooserModal" class="smallModal well hide">
+				<a href="#" class="close" data-dismiss="modal">&times;</a>
+			</div>
+	    </div>
+	    <div class="modal-footer">
+			<div id="fieldRequired" class="hide" style="position: absolute; left: 10;">
+				<span class="label label-important">Sorry, name is required.</span>
+	        </div>
+	        <input type="submit" class="btn primary" value="Save" name="save" />
+			<button class="btn" data-dismiss="modal">Cancel</button>
+	    </div>
+    </form>
 </div>
 %endif
 
 
 <script type="text/javascript" charset="utf-8">
 	$(document).ready(function(){
-
 		$(".resultTable").dataTable({
 			"bPaginate": false,
 		    "bLengthChange": false,
@@ -217,7 +215,6 @@ ${layout.menubar(section='query')}
 			});
 			$("#fileChooserModal").slideDown();
 		});
-
 	});
 </script>
 

+ 1 - 2
apps/beeswax/src/beeswax/tests.py

@@ -640,8 +640,7 @@ for x in sys.stdin:
     resp = _make_query(self.client, hql, wait=True, local=False, max=180.0)
     resp = save_and_verify(resp, TARGET_DIR_ROOT + '/2')
     # Results has a link to the FB
-    assert_true('Query results stored in' in resp.content)
-    assert_true('filebrowser' in resp.content)
+    assert_true('/filebrowser/view' in resp.content)
 
     # Not supported. Partition tables
     hql = "SELECT * FROM test_partitions"

+ 2 - 6
apps/beeswax/src/beeswax/views.py

@@ -33,7 +33,7 @@ from desktop.lib import django_mako
 from desktop.lib.paginator import Paginator
 from desktop.lib.django_util import copy_query_dict, format_preserving_redirect, render
 from desktop.lib.django_util import login_notrequired, get_desktop_uri_prefix
-from desktop.lib.django_util import render_injected, PopupWithJframe, PopupException
+from desktop.lib.django_util import render_injected, PopupException
 
 from hadoop.fs.exceptions import WebHdfsException
 
@@ -1009,11 +1009,7 @@ def save_results(request, id):
           request.fs.rename_star(result_meta.table_dir, target_dir)
           LOG.debug("Moved results from %s to %s" % (result_meta.table_dir, target_dir))
           query_history.save_state(models.QueryHistory.STATE.expired)
-          fb_url = location_to_url(request, target_dir, strict=False)
-          popup = PopupWithJframe('Query results stored in %s' % (target_dir,),
-                                  launch_app_name='FileBrowser',
-                                  launch_app_url=fb_url)
-          return render_injected(list_query_history(request), popup)
+          return HttpResponse(urlresolvers.reverse('filebrowser.views.view', kwargs={'path': target_dir}))
         elif form.cleaned_data['save_target'] == form.SAVE_TYPE_TBL:
           # To new table
           try:

+ 0 - 20
desktop/core/src/desktop/lib/django_util.py

@@ -357,26 +357,6 @@ class PopupException(Exception):
       data['request'] = request
     return render("popup_error.mako", request, data)
 
-
-class PopupWithJframe(object):
-  """A popup container, intended to be rendered with a regular HttpResponse."""
-  def __init__(self, message, launch_app_name=None, launch_app_url=None):
-    """
-    PopupWithJframe(message, launch_app_name=None, launch_app_url=None)
-
-    It can simply display a message. It can also show a link to launch an app.
-    """
-    self.message = message
-    self.app = launch_app_name
-    self.app_url = launch_app_url
-
-  def html(self):
-    return django_mako.render_to_string('popup_with_jframe.mako', {
-      'msg': self.message,
-      'app': self.app,
-      'app_url': self.app_url,
-    })
-
 class TruncatingModel(models.Model):
   """
   Abstract class which truncates Text and Char fields to their configured

+ 0 - 27
desktop/core/src/desktop/templates/popup_with_jframe.mako

@@ -1,27 +0,0 @@
-## 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.
-<div class="alert_popup jframe_renders">
-  <div class="jframe_padded">
-    ${msg}
-    % if app:
-      % if app_url:
-        <li><a href="${app_url}" target="${app}">link</a></li>
-      % else:
-        <li><a target="${app}">link</a></li>
-      % endif
-    % endif
-  </div>
-</div>