Repository: hadoop
Updated Branches:
  refs/heads/trunk 28bd13801 -> cea0972fa


HDFS-7779. Support changing ownership, group and replication in HDFS Web UI. 
Contributed by Ravi Prakash.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/cea0972f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/cea0972f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/cea0972f

Branch: refs/heads/trunk
Commit: cea0972fa13c4c3f6d6a12179f7e65552d1ae873
Parents: 28bd138
Author: Haohui Mai <whe...@apache.org>
Authored: Tue Jan 5 13:43:32 2016 -0800
Committer: Haohui Mai <whe...@apache.org>
Committed: Tue Jan 5 13:44:16 2016 -0800

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 ++
 .../src/main/webapps/hdfs/explorer.html         |  8 ++++--
 .../src/main/webapps/hdfs/explorer.js           | 30 ++++++++++++++++++++
 3 files changed, 38 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/cea0972f/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt 
b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 207ef91..364f685 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -1794,6 +1794,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-9552. Document types of permission checks performed for HDFS
     operations. (cnauroth)
 
+    HDFS-7779. Support changing ownership, group and replication in HDFS Web
+    UI. (Ravi Prakash via wheat9)
+
   OPTIMIZATIONS
 
     HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

http://git-wip-us.apache.org/repos/asf/hadoop/blob/cea0972f/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html
index fb4397f..3fcacf9 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.html
@@ -20,6 +20,7 @@
   <head>
     <meta http-equiv="X-UA-Compatible" content="IE=9" />
     <link rel="stylesheet" type="text/css" 
href="/static/bootstrap-3.0.2/css/bootstrap.min.css" />
+    <link rel="stylesheet" type="text/css" 
href="/static/bootstrap-3.0.2/css/bootstrap-editable.css"/>
     <link rel="stylesheet" type="text/css" href="/static/hadoop.css" />
     <title>Browsing HDFS</title>
   </head>
@@ -231,11 +232,11 @@
               {type|helper_to_directory}{permission|helper_to_permission}
               {aclBit|helper_to_acl_bit}
               </span></td>
-            <td>{owner}</td>
-            <td>{group}</td>
+            <td><span class="explorer-owner-links">{owner}</span></td>
+            <td><span class="explorer-group-links">{group}</span></td>
             <td>{length|fmt_bytes}</td>
             <td>{#helper_date_tostring value="{modificationTime}"/}</td>
-            <td>{replication}</td>
+            <td><span 
class="explorer-replication-links">{replication}</span></td>
             <td>{blockSize|fmt_bytes}</td>
             <td><a inode-type="{type}" 
class="explorer-browse-links">{pathSuffix}</a></td>
             <td><span class="glyphicon glyphicon-trash"></span></td>
@@ -262,6 +263,7 @@
     </script>
     <script type="text/javascript" src="/static/jquery-1.10.2.min.js">
     </script><script type="text/javascript" 
src="/static/bootstrap-3.0.2/js/bootstrap.min.js">
+    </script><script type="text/javascript" 
src="/static/bootstrap-3.0.2/js/bootstrap-editable.min.js">
     </script><script type="text/javascript" 
src="/static/dust-full-2.0.0.min.js">
     </script><script type="text/javascript" 
src="/static/dust-helpers-1.1.1.min.js">
     </script><script type="text/javascript" src="/static/dfs-dust.js">

http://git-wip-us.apache.org/repos/asf/hadoop/blob/cea0972f/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js
index 2931723..0c68209 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/explorer.js
@@ -211,6 +211,32 @@
     }).error(network_error_handler(url));
   }
 
+  /**Use X-editable to make fields editable with a nice UI.
+   * elementType is the class of element(s) you want to make editable
+   * op is the WebHDFS operation that will be triggered
+   * parameter is (currently the 1) parameter which will be passed along with
+   *   the value entered by the user
+   */
+  function makeEditable(elementType, op, parameter) {
+    $(elementType).each(function(index, value) {
+      $(this).editable({
+        url: function(params) {
+          var inode_name = $(this).closest('tr').attr('inode-path');
+          var absolute_file_path = append_path(current_directory, inode_name);
+          var url = '/webhdfs/v1' + encode_path(absolute_file_path) + '?op=' +
+            op + '&' + parameter + '=' + encodeURIComponent(params.value);
+
+          return $.ajax(url, { type: 'PUT', })
+            .error(network_error_handler(url))
+            .success(function() {
+                browse_directory(current_directory);
+             });
+        },
+        error: function(response, newValue) {return "";}
+      });
+    });
+  }
+
   function browse_directory(dir) {
     var HELPERS = {
       'helper_date_tostring' : function (chunk, ctx, bodies, params) {
@@ -252,6 +278,10 @@
           view_perm_details($(this), filename, abs_path, perms);
         });
 
+        makeEditable('.explorer-owner-links', 'SETOWNER', 'owner');
+        makeEditable('.explorer-group-links', 'SETOWNER', 'group');
+        makeEditable('.explorer-replication-links', 'SETREPLICATION', 
'replication');
+
         $('.explorer-entry .glyphicon-trash').click(function() {
           var inode_name = $(this).closest('tr').attr('inode-path');
           var absolute_file_path = append_path(current_directory, inode_name);

Reply via email to