Sfoglia il codice sorgente

[security] Autocomplete group or user names for each HDFS ACL

Romain Rigaux 11 anni fa
parent
commit
f670b56

+ 3 - 6
apps/security/src/security/templates/hdfs.mako

@@ -92,10 +92,7 @@ ${ layout.menubar(section='hdfs') }
     <input type="radio" value="user" data-bind="checked: type, attr: { name: 'aclType' + $index() + (isDefault() ? 'isDefault' : 'notDefault') }"/> ${ _('user') }
     <input type="radio" value="mask" data-bind="checked: type, attr: { name: 'aclType' + $index() + (isDefault() ? 'isDefault' : 'notDefault') }"/> ${ _('mask') }
     <input type="radio" value="other" data-bind="checked: type, attr: { name: 'aclType' + $index() + (isDefault() ? 'isDefault' : 'notDefault') }"/> ${ _('other') }
-
-    <input type="text" data-bind="value: name, valueUpdate:'afterkeydown'" class="input-small" placeholder="${ _('name...') }"/>
-    ##<select data-bind="options: $root.availableHadoopGroups, value: name, optionsCaption: '', valueUpdate:'afterkeydown'" class="input-small" placeholder="${ _('name...') }"/>
-
+    <input type="text" data-bind="value: name, valueUpdate: 'afterkeydown', css: { 'user-list': type() == 'user', 'group-list': type() == 'group' }" class="input-small" placeholder="${ _('name...') }"/>
     <input type="checkbox" title="r, ${ _('Read') }" data-bind="checked: r"/>
     <input type="checkbox" title="w, ${ _('Write') }" data-bind="checked: w"/>
     <input type="checkbox" title="x, ${ _('Execute') }" data-bind="checked: x"/>
@@ -119,8 +116,8 @@ ${ layout.menubar(section='hdfs') }
             </a>
             <i class="fa fa-compress"></i>
             <i class="fa fa-refresh"></i>
-              ${ _('View as') }
-              <input type="text" class="doas-input input-small" data-bind="value: $root.doAs">
+            ${ _('View as') }
+            <input type="text" class="user-list input-small" data-bind="value: $root.doAs">
           </div>
           ${ _('HDFS ACLs') }
         </h1>

+ 10 - 2
apps/security/static/js/hdfs.ko.js

@@ -29,6 +29,7 @@ function parseAcl(acl) {
 
   acl.type.subscribe(function () {
     acl.status('modified');
+    updateTypeAheads(viewModel);
   });
   acl.name.subscribe(function () {
     acl.status('modified');
@@ -50,6 +51,12 @@ function printAcl(acl) {
   return (acl.isDefault() ? 'default:' : '') + acl.type() + ':' + acl.name() + ':' + (acl.r() ? 'r' : '-') + (acl.w() ? 'w' : '-') + (acl.x() ? 'x' : '-');
 }
 
+function updateTypeAheads(vm) { 
+  $(".group-list").typeahead({'source': vm.availableHadoopGroups()});
+  $(".user-list").typeahead({'source': vm.availableHadoopUsers()});
+}
+
+
 var Assist = function (vm, assist) {
   var self = this;
 
@@ -121,6 +128,7 @@ var Assist = function (vm, assist) {
     var newAcl = parseAcl('group::---');
     newAcl.status('new');
     self.acls.push(newAcl);
+    updateTypeAheads(vm);
   };
 
   self.addDefaultAcl = function () {
@@ -330,12 +338,12 @@ var HdfsViewModel = function (initial) {
       $.each(data.users, function (i, user) {
         self.availableHadoopUsers.push(user.username);
       });
-      
-      $(".doas-input").typeahead({'source': self.availableHadoopUsers()});
 
       $.each(data.groups, function (i, group) {
         self.availableHadoopGroups.push(group.name);
       });
+      
+      updateTypeAheads(self);
     });
   }
 };