Эх сурвалжийг харах

[security] Improved HDFS tree refresh, added click on row to set the path, moved and i18n'ed the done messages

Enrico Berti 11 жил өмнө
parent
commit
45b0577

+ 16 - 0
apps/security/src/security/templates/hdfs.mako

@@ -274,6 +274,22 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
       }
     });
 
+    $(document).on("updated.acls", function() {
+      $(document).trigger("info", "${ _('The selected ACLs have been successfully updated.') }");
+    });
+
+    $(document).on("added.bulk.acls", function() {
+      $(document).trigger("info", "${ _('The current ACLs have been successfully added to the selected paths.') }");
+    });
+
+    $(document).on("deleted.bulk.acls", function() {
+      $(document).trigger("info", "${ _('All the ACLs have been successfully removed from the selected paths.') }");
+    });
+
+    $(document).on("syncd.bulk.acls", function() {
+      $(document).trigger("info", "${ _('All the ACLs have been successfully updated for the selected paths.') }");
+    });
+
     var _resizeTimeout = -1;
     $(window).resize(function(){
       window.clearTimeout(_resizeTimeout);

+ 21 - 11
apps/security/static/js/hdfs.ko.js

@@ -303,10 +303,16 @@ var Assist = function (vm, assist) {
     self.growingTree(jQuery.extend(true, {}, self.initialGrowingTree));
     Object.keys(self.treeAdditionalData).forEach(function (path) {
       if (typeof force == "boolean" && force) {
-        self.fetchPath(path);
+        self.fetchPath(path, function() {
+          self.updatePathProperty(self.growingTree(), path, "isExpanded", true);
+          self.loadData(self.growingTree());
+        });
       } else {
         if (self.treeAdditionalData[path].loaded) {
-          self.fetchPath(path);
+          self.fetchPath(path, function() {
+            self.updatePathProperty(self.growingTree(), path, "isExpanded", true);
+            self.loadData(self.growingTree());
+          });
         }
       }
     });
@@ -479,7 +485,7 @@ var Assist = function (vm, assist) {
           self.acls.remove(item);
         });
         self.refreshTree();
-        $(document).trigger("info", 'Done!');
+        $(document).trigger("updated.acls");
       }
     ).fail(function (xhr, textStatus, errorThrown) {
       $(document).trigger("error", JSON.parse(xhr.responseText).message);
@@ -501,7 +507,7 @@ var Assist = function (vm, assist) {
           self.acls.removeAll();
         }
         self.refreshTree();
-        $(document).trigger("info", 'Done!');
+        $(document).trigger("deleted.bulk.acls");
       }
     ).fail(function (xhr, textStatus, errorThrown) {
       $(document).trigger("error", JSON.parse(xhr.responseText).message);
@@ -521,7 +527,7 @@ var Assist = function (vm, assist) {
         'recursive': ko.mapping.toJSON(self.recursive()),
       }, function (data) {
         self.refreshTree();
-        $(document).trigger("info", 'Done!');
+        $(document).trigger("added.bulk.acls");
       }
     ).fail(function (xhr, textStatus, errorThrown) {
       $(document).trigger("error", JSON.parse(xhr.responseText).message);
@@ -541,7 +547,7 @@ var Assist = function (vm, assist) {
         'recursive': ko.mapping.toJSON(self.recursive()),
       }, function (data) {
         self.refreshTree();
-        $(document).trigger("info", 'Done!');
+        $(document).trigger("syncd.bulk.acls");
       }
     ).fail(function (xhr, textStatus, errorThrown) {
       $(document).trigger("error", JSON.parse(xhr.responseText).message);
@@ -583,12 +589,16 @@ var HdfsViewModel = function (initial) {
     $(document).one("loaded.parents", function(){
       self.assist.isLoadingTree(true);
       var _paths = self.assist.rebuildTree(self.assist.growingTree().nodes[0], []);
-      _paths.forEach(function(path, cnt){
-        self.assist.fetchPath(path, function(){
+      _paths.forEach(function(ipath, cnt){
+        self.assist.updatePathProperty(self.assist.growingTree(), ipath, "isExpanded", true);
+        self.assist.fetchPath(ipath, function(){
           if (cnt == _paths.length -1){
-            self.assist.fromRebuildTree = true;
-            self.assist.loadData(self.assist.growingTree());
-            self.assist.isLoadingTree(false);
+            self.assist.fetchPath(path, function(){
+              self.assist.updatePathProperty(self.assist.growingTree(), path, "isExpanded", true);
+              self.assist.fromRebuildTree = true;
+              self.assist.loadData(self.assist.growingTree());
+              self.assist.isLoadingTree(false);
+            });
           }
         });
       });

+ 48 - 37
desktop/core/src/desktop/templates/common_tree.mako

@@ -77,45 +77,56 @@
      css: { selected: ${itemSelected}}
     %endif
     ">
-      %if itemChecked:
-      <i data-bind="css: {'fa': true, 'fa-fw': true, 'fa-square-o': ! ${itemChecked}(), 'fa-check-square-o': ${itemChecked}()}, click: $root.assist.checkPath, style: { color: '#999999'}"></i>
-      %endif
-      <i data-bind="
-        %if iconClick:
-          click: ${iconClick},
-        %endif
-        css: {
-            'fa': true,
-            %if iconModifier:
-            ${iconModifier()}
-            %else:
-            'fa-file-o': true
+      <table style="width: 100%">
+        <tr>
+          %if itemChecked:
+          <td style="width: 16px">
+            <i data-bind="css: {'fa': true, 'fa-fw': true, 'fa-square-o': ! ${itemChecked}(), 'fa-check-square-o': ${itemChecked}()}, click: $root.assist.checkPath, style: { color: '#999999'}"></i>
+          </td>
+          %endif
+          <td style="width: 16px">
+            <i data-bind="
+              %if iconClick:
+                click: ${iconClick},
+              %endif
+              css: {
+                  'fa fa-fw': true,
+                  %if iconModifier:
+                  ${iconModifier()}
+                  %else:
+                  'fa-file-o': true
+                  %endif
+              },
+              %if styleModifier:
+                style: { color: ${styleModifier}() ? '#338bb8': '#999999'}
+              %else:
+                style: { color: '#999999'}
+              %endif
+              "></i>
+          </td>
+          <td class="pointer" data-bind="
+          %if itemClick:
+              click: ${itemClick},
             %endif
-        },
-        %if styleModifier:
-          style: { color: ${styleModifier}() ? '#338bb8': '#999999'}
-        %else:
-          style: { color: '#999999'}
-        %endif
-        "></i>
-      %if anchorProperty:
-        <a href="#" class="anchor" data-bind="attr: {href: ${anchorProperty}}"></a>
-      %endif
-      <strong><a style="display: inline-block" data-bind="text:name,
-      %if itemClick:
-        click: ${itemClick},
-      %endif
-      %if itemDblClick:
-        event : { dblclick: ${itemDblClick} },
-      %endif
-      %if strikedProperty:
-      css:{'striked': striked},
-      %endif
-      visible: true"></a></strong>
+            %if itemDblClick:
+              event : { dblclick: ${itemDblClick} },
+            %endif
+          visible: true">
+            %if anchorProperty:
+              <a href="#" class="anchor" data-bind="attr: {href: ${anchorProperty}}"></a>
+            %endif
+            <strong><a style="display: inline-block" data-bind="text:name,
+            %if strikedProperty:
+            css:{'striked': striked},
+            %endif
+            visible: true"></a></strong>
 
-      %if styleModifierPullRight:
-      ${styleModifierPullRight()}
-      %endif
+            %if styleModifierPullRight:
+            ${styleModifierPullRight()}
+            %endif
+          </td>
+        </tr>
+      </table>
     </div>
   </script>