Procházet zdrojové kódy

[security] Fixed tree actions for Hive

Enrico Berti před 11 roky
rodič
revize
3f77f23

+ 4 - 4
apps/security/src/security/templates/hive.mako

@@ -84,11 +84,9 @@ ${ layout.menubar(section='hive') }
             </br>
             <input type="checkbox" checked> All
             </br>
-            <select data-bind="options: $root.selectableHadoopGroups" size="10" multiple="true"></select>
+            <select data-bind="options: $root.selectableHadoopGroups" size="10" multiple="true" style="width: 100%"></select>
           </li>          
-          <li class="nav-header"><i class="fa fa-group"></i> ${ _('Server') }
-            <input type="text" data-bind="value: $root.assist.server" class="input-small" />
-          </li>
+
         </ul>
       </div>
     </div>
@@ -273,6 +271,8 @@ ${ layout.menubar(section='hive') }
 
 ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assist.togglePath', itemSelected='$root.assist.path() == path()',iconModifier=treeIcons) }
 
+##${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assist.togglePath', itemSelected='$root.assist.path() == path()', iconModifier=treeIcons, styleModifier='aclBit', styleModifierPullRight=aclBitPullRight, anchorProperty='path', showMore='$root.assist.loadMore', strikedProperty='striked') }
+
 <script src="/static/ext/js/knockout-min.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/knockout.mapping-2.3.2.js" type="text/javascript" charset="utf-8"></script>
 <script src="/static/ext/js/routie-0.3.0.min.js" type="text/javascript" charset="utf-8"></script>

+ 56 - 25
apps/security/static/js/hive.ko.js

@@ -320,6 +320,60 @@ var Assist = function (vm) {
     self.loadData(self.growingTree());
   }
 
+  self.collapseTree = function () {
+    self.updateTreeProperty(self.growingTree(), "isExpanded", false);
+    self.updatePathProperty(self.growingTree(), "__HUEROOT__", "isExpanded", true);
+    self.loadData(self.growingTree());
+  }
+
+  self.collapseOthers = function () {
+    self.updateTreeProperty(self.growingTree(), "isExpanded", false);
+    self.updatePathProperty(self.growingTree(), "__HUEROOT__", "isExpanded", true);
+
+    var _path = self.path();
+    var _crumb = "";
+    for (var i = 0; i < _path.length; i++) {
+      if ((_path[i] === "." && _crumb != "")) {
+        self.updatePathProperty(self.growingTree(), _crumb, "isExpanded", true);
+      }
+      _crumb += _path[i];
+    }
+
+    self.updatePathProperty(self.growingTree(), _path, "isExpanded", true);
+
+    self.loadData(self.growingTree());
+  }
+
+  self.expandTree = function () {
+    self.updateTreeProperty(self.growingTree(), "isExpanded", true);
+    self.loadData(self.growingTree());
+  }
+
+  self.refreshTree = function (force) {
+    self.growingTree(jQuery.extend(true, {}, self.initialGrowingTree));
+    Object.keys(self.treeAdditionalData).forEach(function (path) {
+      if (typeof force == "boolean" && force) {
+        self.fetchPath(path);
+      } else {
+        if (self.treeAdditionalData[path].loaded) {
+          self.fetchPath(path);
+        }
+      }
+    });
+  }
+
+  self.rebuildTree = function (leaf, paths) {
+    paths.push(leaf.path);
+    if (leaf.nodes.length > 0) {
+      leaf.nodes.forEach(function (node) {
+        if (node.isDir){
+          self.rebuildTree(node, paths);
+        }
+      });
+    }
+    return paths;
+  }
+
   self.setPath = function (obj, toggle) {
     if (self.getTreeAdditionalDataForPath(obj.path()).loaded || (!obj.isExpanded() && !self.getTreeAdditionalDataForPath(obj.path()).loaded)) {
       if (typeof toggle == "boolean" && toggle) {
@@ -370,31 +424,6 @@ var Assist = function (vm) {
     return leaf;
   }
 
-  self.collapseTree = function () {
-    self.updateTreeProperty(self.growingTree(), "isExpanded", false);
-    self.updatePathProperty(self.growingTree(), "/", "isExpanded", true);
-    self.loadData(self.growingTree());
-  }
-
-  self.collapseOthers = function () {
-    self.updateTreeProperty(self.growingTree(), "isExpanded", false);
-    self.updatePathProperty(self.growingTree(), "/", "isExpanded", true);
-
-    var _path = self.path();
-    var _crumb = "";
-    for (var i = 0; i < _path.length; i++) {
-      if ((_path[i] === "/" && _crumb != "")) {
-        self.updatePathProperty(self.growingTree(), _crumb, "isExpanded", true);
-      }
-      _crumb += _path[i];
-    }
-
-    self.updatePathProperty(self.growingTree(), _path, "isExpanded", true);
-
-    self.loadData(self.growingTree());
-  }
-
-
   self.fetchHivePath = function () {
     if (self.path().split(".").length < 3) {
       var _path = self.path().replace('.', '/');
@@ -417,6 +446,8 @@ var Assist = function (vm) {
             self.addColumns(data.columns);
           }
 
+          self.getTreeAdditionalDataForPath(self.path()).loaded = true;
+
           vm.list_sentry_privileges_by_authorizable();
         },
         cache: false