]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/dc/ACLView.js
ui: eslint: fix various spacing related issues
[pve-manager.git] / www / manager6 / dc / ACLView.js
index b011e506c0ff1528ae3ff4a1f21a711008fbe01b..3e66386bc4600075cffc27192ea187615811a0c0 100644 (file)
@@ -1,23 +1,22 @@
 Ext.define('PVE.dc.ACLAdd', {
-    extend: 'PVE.window.Edit',
+    extend: 'Proxmox.window.Edit',
     alias: ['widget.pveACLAdd'],
     url: '/access/acl',
     method: 'PUT',
     isAdd: true,
-    initComponent : function() {
-
+    initComponent: function() {
         var me = this;
 
        me.isCreate = true;
 
        var items = [
            {
-               xtype: me.path ? 'hiddenfield' : 'textfield',
+               xtype: me.path ? 'hiddenfield' : 'pvePermPathSelector',
                name: 'path',
                value: me.path,
                allowBlank: false,
-               fieldLabel: gettext('Path')
-           }
+               fieldLabel: gettext('Path'),
+           },
        ];
 
        if (me.aclType === 'group') {
@@ -25,47 +24,54 @@ Ext.define('PVE.dc.ACLAdd', {
            items.push({
                xtype: 'pveGroupSelector',
                name: 'groups',
-               fieldLabel: gettext('Group')
+               fieldLabel: gettext('Group'),
            });
        } else if (me.aclType === 'user') {
            me.subject = gettext("User Permission");
            items.push({
                xtype: 'pveUserSelector',
                name: 'users',
-               fieldLabel: gettext('User')
+               fieldLabel: gettext('User'),
+           });
+       } else if (me.aclType === 'token') {
+           me.subject = gettext("API Token Permission");
+           items.push({
+               xtype: 'pveTokenSelector',
+               name: 'tokens',
+               fieldLabel: gettext('API Token'),
            });
        } else {
            throw "unknown ACL type";
        }
 
        items.push({
-           xtype: 'pveRoleSelector',
+           xtype: 'pmxRoleSelector',
            name: 'roles',
            value: 'NoAccess',
-           fieldLabel: gettext('Role')
+           fieldLabel: gettext('Role'),
        });
 
        if (!me.path) {
            items.push({
-               xtype: 'pvecheckbox',
+               xtype: 'proxmoxcheckbox',
                name: 'propagate',
                checked: true,
                uncheckedValue: 0,
-               fieldLabel: gettext('Propagate')
+               fieldLabel: gettext('Propagate'),
            });
        }
 
-       var ipanel = Ext.create('PVE.panel.InputPanel', {
+       var ipanel = Ext.create('Proxmox.panel.InputPanel', {
            items: items,
-           onlineHelp: 'pveum_permission_management'
+           onlineHelp: 'pveum_permission_management',
        });
 
        Ext.apply(me, {
-           items: [ ipanel ]
+           items: [ipanel],
        });
 
        me.callParent();
-    }
+    },
 });
 
 Ext.define('PVE.dc.ACLView', {
@@ -81,28 +87,28 @@ Ext.define('PVE.dc.ACLView', {
     // use fixed path
     path: undefined,
 
-    initComponent : function() {
+    initComponent: function() {
        var me = this;
 
-       var store = Ext.create('Ext.data.Store',{
+       var store = Ext.create('Ext.data.Store', {
            model: 'pve-acl',
            proxy: {
-                type: 'pve',
-               url: "/api2/json/access/acl"
+                type: 'proxmox',
+               url: "/api2/json/access/acl",
            },
            sorters: {
                property: 'path',
-               order: 'DESC'
-           }
+               order: 'DESC',
+           },
        });
 
        if (me.path) {
-           store.addFilter(Ext.create('Ext.util.Filter',{
+           store.addFilter(Ext.create('Ext.util.Filter', {
                filterFn: function(item) {
                    if (item.data.path === me.path) {
                        return true;
                    }
-               }
+               },
            }));
        }
 
@@ -111,23 +117,23 @@ Ext.define('PVE.dc.ACLView', {
                return '@' + ugid;
            }
 
-           return ugid;
+           return Ext.String.htmlEncode(ugid);
        };
 
        var columns = [
            {
-               header: gettext('User') + '/' + gettext('Group'),
+               header: gettext('User') + '/' + gettext('Group') + '/' + gettext('API Token'),
                flex: 1,
                sortable: true,
                renderer: render_ugid,
-               dataIndex: 'ugid'
+               dataIndex: 'ugid',
            },
            {
                header: gettext('Role'),
                flex: 1,
                sortable: true,
-               dataIndex: 'roleid'
-           }
+               dataIndex: 'roleid',
+           },
        ];
 
        if (!me.path) {
@@ -135,13 +141,13 @@ Ext.define('PVE.dc.ACLView', {
                header: gettext('Path'),
                flex: 1,
                sortable: true,
-               dataIndex: 'path'
+               dataIndex: 'path',
            });
            columns.push({
                header: gettext('Propagate'),
                width: 80,
                sortable: true,
-               dataIndex: 'propagate'
+               dataIndex: 'propagate',
            });
        }
 
@@ -160,17 +166,19 @@ Ext.define('PVE.dc.ACLView', {
                var params = {
                    'delete': 1,
                    path: rec.data.path,
-                   roles: rec.data.roleid
+                   roles: rec.data.roleid,
                };
                if (rec.data.type === 'group') {
                    params.groups = rec.data.ugid;
                } else if (rec.data.type === 'user') {
                    params.users = rec.data.ugid;
+               } else if (rec.data.type === 'token') {
+                   params.tokens = rec.data.ugid;
                } else {
                    throw 'unknown data type';
                }
 
-               PVE.Utils.API2Request({
+               Proxmox.Utils.API2Request({
                    url: '/access/acl',
                    params: params,
                    method: 'PUT',
@@ -178,14 +186,14 @@ Ext.define('PVE.dc.ACLView', {
                    callback: function() {
                        reload();
                    },
-                   failure: function (response, opts) {
+                   failure: function(response, opts) {
                        Ext.Msg.alert(gettext('Error'), response.htmlStatus);
-                   }
+                   },
                });
-           }
+           },
        });
 
-       PVE.Utils.monStoreErrors(me, store);
+       Proxmox.Utils.monStoreErrors(me, store);
 
        Ext.apply(me, {
            store: store,
@@ -200,53 +208,63 @@ Ext.define('PVE.dc.ACLView', {
                                text: gettext('Group Permission'),
                                iconCls: 'fa fa-fw fa-group',
                                handler: function() {
-                                   var win = Ext.create('PVE.dc.ACLAdd',{
+                                   var win = Ext.create('PVE.dc.ACLAdd', {
                                        aclType: 'group',
-                                       path: me.path
+                                       path: me.path,
                                    });
                                    win.on('destroy', reload);
                                    win.show();
-                               }
+                               },
                            },
                            {
                                text: gettext('User Permission'),
                                iconCls: 'fa fa-fw fa-user',
                                handler: function() {
-                                   var win = Ext.create('PVE.dc.ACLAdd',{
+                                   var win = Ext.create('PVE.dc.ACLAdd', {
                                        aclType: 'user',
-                                       path: me.path
+                                       path: me.path,
                                    });
                                    win.on('destroy', reload);
                                    win.show();
-                               }
-                           }
-                       ]
-                   }
+                               },
+                           },
+                           {
+                               text: gettext('API Token Permission'),
+                               iconCls: 'fa fa-fw fa-user-o',
+                               handler: function() {
+                                   var win = Ext.create('PVE.dc.ACLAdd', {
+                                       aclType: 'token',
+                                       path: me.path,
+                                   });
+                                   win.on('destroy', reload);
+                                   win.show();
+                               },
+                           },
+                       ],
+                   },
                },
-               remove_btn
+               remove_btn,
            ],
            viewConfig: {
-               trackOver: false
+               trackOver: false,
            },
            columns: columns,
            listeners: {
-               activate: reload
-           }
+               activate: reload,
+           },
        });
 
        me.callParent();
-    }
+    },
 }, function() {
-
     Ext.define('pve-acl', {
        extend: 'Ext.data.Model',
        fields: [
            'path', 'type', 'ugid', 'roleid',
            {
                name: 'propagate',
-               type: 'boolean'
-           }
-       ]
+               type: 'boolean',
+           },
+       ],
     });
-
 });