Browse Source

Polishing of the recent UI changes

Fix 'None' description when saving a Beeswax query with empty description.
Add PopupException when Filebrowser 'move' operation fails.
Removed filechooser for 'rename' file operation.
Romain Rigaux 13 years ago
parent
commit
052aeed641

+ 2 - 3
apps/beeswax/src/beeswax/forms.py

@@ -67,12 +67,11 @@ class SaveForm(forms.Form):
       raise forms.ValidationError('Please enter a name')
     return self.cleaned_data
 
-  def set_data(self, name, desc=None):
+  def set_data(self, name, desc=''):
     """Set the name and desc programmatically"""
     data2 = self.data.copy()
     data2[self.add_prefix('name')] = name
-    if desc:
-      data2[self.add_prefix('desc')] = desc
+    data2[self.add_prefix('desc')] = desc
     self.data = data2
 
 

+ 34 - 41
apps/beeswax/src/beeswax/templates/execute.mako

@@ -23,53 +23,46 @@
 <%namespace name="util" file="util.mako" />
 
 <%def name="query()">
-		<h1>Hive Query</h1>
-		<fieldset>
-			% if design and not design.is_auto and design.name:
-		          <legend>${design.name}</legend>
-		          % if design.desc:
-		            <p>${design.desc}</p>
-		          % endif
-
-		      % else:
-		        <legend>Query</legend>
-		      % endif
-
-          <div class="clearfix">
-            <div class="input">
-              	<textarea class="span9" rows="9" placeholder="Example: SELECT * FROM tablename" name="${form.query["query"].html_name | n}" id="queryField">${extract_field_data(form.query["query"]) or ''}</textarea>
-				<div id="validationResults">
-				% if len(form.query["query"].errors):
-					${unicode(form.query["query"].errors) | n}
-				 % endif
-				</div>
-            </div>
-          </div>
-        </fieldset>
-
-
-
-		<div class="actions">
-			<a id="executeQuery" class="btn primary">Execute</a>
-			% if design and not design.is_auto and design.name:
-            <a id="saveQuery" class="btn">Save</a>
-          	% endif
-          	<a id="saveQueryAs" class="btn">Save as...</a>
-
-			<a id="explainQuery" class="btn">Explain</a>
-			&nbsp; or <a href="${ url('beeswax.views.execute_query') }">create a new query</a>
-		</div>
-
-
-
-
+	<h1>Hive Query</h1>
+	<fieldset>
+		% if design and not design.is_auto and design.name:
+	          <legend>${design.name}</legend>
+	          % if design.desc:
+	            <p>${design.desc}</p>
+	          % endif
+
+	      % else:
+	        <legend>Query</legend>
+	      % endif
+
+      <div class="clearfix">
+        <div class="input">
+            <textarea class="span9" rows="9" placeholder="Example: SELECT * FROM tablename" name="${form.query["query"].html_name | n}" id="queryField">${extract_field_data(form.query["query"]) or ''}</textarea>
+			<div id="validationResults">
+			% if len(form.query["query"].errors):
+				${unicode(form.query["query"].errors) | n}
+			 % endif
+			</div>
+        </div>
+      </div>
+    </fieldset>
+
+	<div class="actions">
+		<a id="executeQuery" class="btn primary">Execute</a>
+		% if design and not design.is_auto and design.name:
+        <a id="saveQuery" class="btn">Save</a>
+        % endif
+        <a id="saveQueryAs" class="btn">Save as...</a>
+        <a id="explainQuery" class="btn">Explain</a>
+		&nbsp; or create a &nbsp;<a class="btn" href="${ url('beeswax.views.execute_query') }">New query</a>
+	</div>
 </%def>
 
 
 ${commonheader("Hive Query", "beeswax", "100px")}
 ${layout.menubar(section='query')}
-<div class="container-fluid">
 
+<div class="container-fluid">
 	<div class="row-fluid">
 		<div class="span3">
 			<div class="well sidebar-nav">

+ 4 - 0
apps/beeswax/src/beeswax/views.py

@@ -35,6 +35,8 @@ from desktop.lib.django_util import copy_query_dict, format_preserving_redirect,
 from desktop.lib.django_util import login_notrequired, get_desktop_uri_prefix
 from desktop.lib.django_util import render_injected, PopupWithJframe, PopupException
 
+from hadoop.fs.exceptions import WebHdfsException
+
 import beeswax.forms
 import beeswax.design
 import beeswax.report
@@ -1022,6 +1024,8 @@ def save_results(request, id):
           except BeeswaxException, bex:
             LOG.exception(bex)
             error_msg, log = expand_exception(bex)
+      except WebHdfsException, ex:
+        raise PopupException('The table could not be saved.', detail=ex)
       except IOError, ex:
         LOG.exception(ex)
         error_msg = str(ex)

+ 6 - 29
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -118,7 +118,7 @@ from django.utils.encoding import smart_str
 							<li><a href="${url('filebrowser.views.download', path=urlencode(path))}" target="_blank">Download File</a></li>
 							% endif
 							<li><a class="rename" file-to-rename="${path}">Rename</a></li>
-							<li><a  onclick="openChownWindow('${path}','${file['stats']['user']}','${file['stats']['group']}','${current_request_path}')">Change Owner / Group</a></li>
+							<li><a onclick="openChownWindow('${path}','${file['stats']['user']}','${file['stats']['group']}','${current_request_path}')">Change Owner / Group</a></li>
 							<li><a onclick="openChmodWindow('${path}','${stringformat(file['stats']['mode'], "o")}','${current_request_path}')">Change Permissions</a></li>
 							<li><a onclick="openMoveModal('${path}','${stringformat(file['stats']['mode'], "o")}', '${current_request_path}')">Move</a></li>
 				    	</ul>
@@ -156,11 +156,7 @@ from django.utils.encoding import smart_str
         <h3>Renaming: <span id="renameFileName">file name</span></h3>
     </div>
     <div class="modal-body">
-		<label>New name <input id="newNameInput" name="dest_path" value="" type="text" class="input-xlarge pathChooser"/></label>
-		<br/>
-		<div id="fileChooserModal" class="smallModal well hide">
-			<a href="#" class="close" data-dismiss="modal">&times;</a>
-		</div>
+		<label>New name <input id="newNameInput" name="dest_path" value="" type="text" class="input-xlarge"/></label>
     </div>
     <div class="modal-footer">
         <div id="renameNameRequiredAlert" class="hide" style="position: absolute; left: 10;">
@@ -192,13 +188,10 @@ from django.utils.encoding import smart_str
         </form>
 
     </div>
-    <div class="modal-footer">
-
-    </div>
+    <div class="modal-footer"></div>
     </form>
 </div>
 
-
 <!-- create directory modal -->
 <div id="createDirectoryModal" class="modal hide fade">
     <form id="createDirectoryForm" action="/filebrowser/mkdir?next=${current_request_path}" method="POST" enctype="multipart/form-data" class="form-inline form-padding-fix">
@@ -252,7 +245,6 @@ from django.utils.encoding import smart_str
     }
 
     function openChmodWindow(path, mode, next){
-
         $.ajax({
             url: "/filebrowser/chmod",
             data: {"path":path, "mode":mode, "next" : next},
@@ -272,7 +264,6 @@ from django.utils.encoding import smart_str
     }
 
     function openMoveModal(src_path, mode, next){
-
         $.ajax({
             url: "/filebrowser/move",
             data: {"src_path":src_path, "mode":mode, "next" : next},
@@ -415,9 +406,11 @@ from django.utils.encoding import smart_str
                 show: true
             });
         });
+
         $("#cancelCreateDirectoryBtn").click(function(){
             $("#createDirectoryModal").modal("hide");
         });
+
         $("#createDirectoryForm").submit(function(){
             if ($.trim($("#newDirectoryNameInput").val())==""){
                 $("#directoryNameRequiredAlert").show();
@@ -426,28 +419,12 @@ from django.utils.encoding import smart_str
             }
             return true;
         });
+
         $("#newDirectoryNameInput").focus(function(){
             $("#newDirectoryNameInput").removeClass("fieldError");
             $("#directoryNameRequiredAlert").hide();
         });
-		$(".pathChooser").click(function(){
-			var self = this;
-			$("#fileChooserModal").jHueFileChooser({
-				onFileChoose: function(filePath) {
-					$(self).val(filePath);
-				},
-				onFolderChange: function(folderPath){
-					$(self).val(folderPath);
-				},
-				createFolder: false,
-				uploadFile: false
-			});
-			$("#fileChooserModal").slideDown();
-		});
-
 	});
-
-
 </script>
 
 </%def>

+ 1 - 0
apps/filebrowser/src/filebrowser/templates/move.mako

@@ -38,6 +38,7 @@
         <a class="btn" onclick="$('#moveModal').modal('hide');">Cancel</a>
     </div>
 </form>
+
 <script type="text/javascript" charset="utf-8">
 	$(".pathChooser").click(function(){
 		var self = this;

+ 2 - 2
apps/jobsub/src/jobsub/templates/edit_design.mako

@@ -89,8 +89,8 @@ ${layout.menubar(section='designs')}
                   </thead>
                   <tbody data-bind="foreach: properties">
                     <tr>
-                      <td><input class="span2 required propKey" data-bind="value: name, uniqueName: false" /></td>
-                      <td><input class="span3 required pathChooserKo" data-bind="fileChooser: $data, value: value, uniqueName: false" /></td>
+                      <td><input class="span3 required propKey" data-bind="value: name, uniqueName: false" /></td>
+                      <td><input class="span4 required pathChooserKo" data-bind="fileChooser: $data, value: value, uniqueName: false" /></td>
                       <td><a class="btn btn-small" href="#" data-bind="click: $root.removeProp">Delete</a></td>
                     </tr>
                   </tbody>