فهرست منبع

HUE-5357 [fb] Copy file form should submit via AJAX

Enrico Berti 9 سال پیش
والد
کامیت
c29ec5a

+ 13 - 0
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1352,7 +1352,20 @@ from django.utils.translation import ugettext as _
           show:true
         });
 
+        $('#copyForm').ajaxForm({
+          dataType:  'json',
+          success: function() {
+            $("#copyModal").modal('hide');
+            self.retrieveData();
+          },
+          error: function(xhr){
+            $.jHueNotify.error(xhr.responseText);
+            resetPrimaryButtonsStatus();
+          }
+        });
+
         $("#copyModal").on("shown", function(){
+          $("#copyDestination").val('');
           $("#copyModal .modal-footer div").show();
           $("#copyHdfsTree").remove();
           $("<div>").attr("id", "copyHdfsTree").appendTo($("#copyModal .modal-body"));

+ 10 - 1
desktop/core/src/desktop/templates/common_footer.mako

@@ -52,7 +52,16 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
     // global catch for ajax calls after the user has logged out
     var isLoginRequired = false;
     $(document).ajaxComplete(function (event, xhr, settings) {
-      if ((xhr.responseText === '/* login required */' || xhr.status === 403) && !isLoginRequired) {
+      var whiteListURLs = [
+        'filebrowser/copy?next='
+      ];
+      var whiteListed = false;
+      whiteListURLs.forEach(function(url){
+        if (settings.url.indexOf(url) > -1){
+          whiteListed = true;
+        }
+      });
+      if ((xhr.responseText === '/* login required */' || (xhr.status === 403 && !whiteListed)) && !isLoginRequired) {
         isLoginRequired = true;
         $('.blurred').removeClass('blurred');
         if ($('#login-modal').length > 0 && $('#login-modal').is(':hidden')) {