Parcourir la source

[security] Select2 now accept a new Hive action too

Enrico Berti il y a 11 ans
Parent
commit
a75786d

+ 3 - 5
apps/security/src/security/templates/hive.mako

@@ -39,7 +39,7 @@ ${ layout.menubar(section='hive') }
     <input type="text" data-bind="value: $data.URI" placeholder="URI">
 
     ## <input type="text" class="input-small" data-bind="value: $data.action" placeholder="action">
-    <select data-bind="options: $data.availableActions, select2: { update: $data.action, type: 'user'}" style="width: 100px"></select>
+    <select data-bind="options: $root.availableActions, select2: { update: $data.action, type: 'action'}" style="width: 100px"></select>
     
     <div>
       <label class="checkbox inline-block">
@@ -50,13 +50,14 @@ ${ layout.menubar(section='hive') }
 
     <span data-bind="visible: showAdvanced">
       <input type="text" data-bind="value: $data.server" placeholder="serverName">
-      <select data-bind="options: availablePrivileges, value: privilegeScope"></select>
+      <select data-bind="options: $root.availablePrivileges, value: privilegeScope"></select>
     </span>
     
     <a href="javascript:void(0)"><i class="fa fa-minus" data-bind="click: remove"></i></a>
   <!-- /ko -->
   
   <!-- ko ifnot: editing() -->
+  lala
     <span data-bind="text: properties.name"></span>
     <span data-bind="text: properties.timestamp"></span>
     <a data-bind="attr: { href: '/metastore/' + properties.database() }" target="_blank"><span data-bind="text: properties.database"></span></a>
@@ -313,9 +314,7 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
         }
       });
 
-
       function showMainSection(mainSection) {
-        console.log("show", mainSection)
         if ($("#" + mainSection).is(":hidden")) {
           $(".mainSection").hide();
           $("#" + mainSection).show();
@@ -344,7 +343,6 @@ ${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assi
         viewModel.assist.path(window.location.hash.substr(1));
       };
 
-
     });
 </script>
 

+ 6 - 0
apps/security/static/js/common.ko.js

@@ -29,6 +29,9 @@ ko.bindingHandlers.select2 = {
           name: options.update
         });
       }
+      if (options.type == "action" && viewModel.availableActions().indexOf(options.update) == -1) {
+        viewModel.availableActions.push(options.update);
+      }
     }
     $(element)
         .select2(options)
@@ -52,6 +55,9 @@ ko.bindingHandlers.select2 = {
                   name: _newVal
                 });
               }
+              if (_type == "action") {
+                viewModel.availableActions.push(_newVal);
+              }
               $(element).select2("val", _newVal, true);
               $(element).select2("close");
             }

+ 3 - 4
apps/security/static/js/hive.ko.js

@@ -84,9 +84,6 @@ var Privilege = function (vm, privilege) {
       }
   });  
   
-  self.availablePrivileges = ko.observableArray(['SERVER', 'DATABASE', 'TABLE']);
-  self.availableActions = ko.observableArray(['SELECT', 'INSERT', 'ALL', '']);
-
   self.remove = function (privilege) {
     privilege.status('deleted');
   }
@@ -519,6 +516,9 @@ var Assist = function (vm) {
 var HiveViewModel = function (initial) {
   var self = this;
 
+  self.availablePrivileges = ko.observableArray(['SERVER', 'DATABASE', 'TABLE']);
+  self.availableActions = ko.observableArray(['SELECT', 'INSERT', 'ALL', '']);
+
   // Models
   self.roles = ko.observableArray();
   self.availableHadoopGroups = ko.mapping.fromJS(initial.hadoop_groups);
@@ -534,7 +534,6 @@ var HiveViewModel = function (initial) {
     self.assist.fetchHivePath();
   });
   self.availableHadoopUsers = ko.observableArray();
-  self.availableHadoopGroups = ko.observableArray();
 
   self.selectableHadoopUsers = ko.computed(function () {
     var _users = ko.utils.arrayMap(self.availableHadoopUsers(), function (user) {