Преглед изворни кода

[security] Added shield icon to Hive items with privileges

Enrico Berti пре 11 година
родитељ
комит
6fcac69
2 измењених фајлова са 16 додато и 1 уклоњено
  1. 9 1
      apps/security/src/security/templates/hive.mako
  2. 7 0
      apps/security/static/js/hive.ko.js

+ 9 - 1
apps/security/src/security/templates/hive.mako

@@ -411,7 +411,15 @@ ${ layout.menubar(section='hive') }
   'fa-columns': isColumn()
 </%def>
 
-${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assist.togglePath', itemSelected='$root.assist.path() == path()', iconModifier=treeIcons, anchorProperty='path', itemChecked='isChecked') }
+<%def name="withPrivilegesPullRight()">
+  <div class="pull-right">
+    <i class="fa fa-shield" data-bind="visible: withPrivileges()" style="color: #338bb8" title="${ _('Has some privileges') }"></i>
+  </div>
+</%def>
+
+
+${ tree.import_templates(itemClick='$root.assist.setPath', iconClick='$root.assist.togglePath', itemSelected='$root.assist.path() == path()', styleModifier='withPrivileges', iconModifier=treeIcons, anchorProperty='path', itemChecked='isChecked', styleModifierPullRight=withPrivilegesPullRight) }
+
 
 <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>

+ 7 - 0
apps/security/static/js/hive.ko.js

@@ -318,6 +318,7 @@ var Assist = function (vm, initial) {
         var _item = {
           path: db,
           name: db,
+          withPrivileges: false,
           isDb: true,
           isTable: false,
           isColumn: false,
@@ -353,6 +354,7 @@ var Assist = function (vm, initial) {
         var _item = {
           path: _path,
           name: table,
+          withPrivileges: false,
           isDb: false,
           isTable: true,
           isColumn: false,
@@ -394,6 +396,7 @@ var Assist = function (vm, initial) {
         var _item = {
           path: _path,
           name: column,
+          withPrivileges: false,
           isDb: false,
           isTable: false,
           isColumn: true,
@@ -872,6 +875,9 @@ var HiveViewModel = function (initial) {
         success: function (data) {
           var _privileges = [];
           $.each(data.privileges, function (index, item) {
+            if (item.table != ""){
+              self.assist.updatePathProperty(self.assist.growingTree(), item.database + "." + item.table, "withPrivileges", true);
+            }
             var _role = null;
             self.assist.roles().forEach(function (role) {
               if (role.name() == item.roleName) {
@@ -887,6 +893,7 @@ var HiveViewModel = function (initial) {
           });
           self.assist.privileges(_privileges);
           self.isLoadingPrivileges(false);
+          self.assist.loadData(self.assist.growingTree());
         }
       }).fail(function (xhr, textStatus, errorThrown) {
         $(document).trigger("error", xhr.responseText);