Browse Source

HDFS-14198. Upload and Create button doesn't get enabled after getting reset. Contributed by Ayush Saxena.

Surendra Singh Lilhore 6 năm trước cách đây
mục cha
commit
9aeaaa0479

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html

@@ -184,11 +184,11 @@
       <div class="col-xs-2 col-md-2">
         <button type="button" class="btn btn-default" data-toggle="modal"
           aria-label="New Directory" data-target="#btn-create-directory"
-          title="Create Directory">
+          title="Create Directory" id="btn-create-dir">
             <span class="glyphicon glyphicon-folder-open"></span>
         </button>
         <button type="button" class="btn btn-default" data-toggle="modal"
-          data-target="#modal-upload-file" title="Upload Files">
+          data-target="#modal-upload-file" title="Upload Files" id="btn-upload-files">
             <span class="glyphicon glyphicon-cloud-upload"></span>
         </button>
         <button class="btn btn-default dropdown-toggle" type="button"

+ 28 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js

@@ -405,6 +405,34 @@
     });
   })
 
+  $('#btn-upload-files').click(function() {
+        $('#modal-upload-file-button').prop('disabled', true).button('reset');
+        $('#modal-upload-file-input').val(null);
+      });
+
+  $('#btn-create-dir').click(function() {
+        $('#btn-create-directory-send').prop('disabled', true).button('reset');
+        $('#new_directory').val(null);
+      });
+
+  $('#modal-upload-file-input').change(function() {
+      if($('#modal-upload-file-input').prop('files').length >0) {
+         $('#modal-upload-file-button').prop('disabled', false);
+        }
+      else {
+        $('#modal-upload-file-button').prop('disabled', true);
+        }
+      });
+
+  $('#new_directory').on('keyup keypress blur change',function() {
+      if($('#new_directory').val() == '' ||  $('#new_directory').val() == null) {
+         $('#btn-create-directory-send').prop('disabled', true);
+        }
+      else {
+         $('#btn-create-directory-send').prop('disabled', false);
+        }
+      });
+
   $('#modal-upload-file-button').click(function() {
     $(this).prop('disabled', true);
     $(this).button('complete');