2020-05-20 12:15:37 +02:00
Ext . define ( 'pmx-acls' , {
extend : 'Ext.data.Model' ,
fields : [
'path' , 'ugid' , 'ugid_type' , 'roleid' , 'propagate' ,
{
name : 'aclid' ,
calculate : function ( data ) {
2020-05-22 14:51:44 +02:00
return ` ${ data . path } for ${ data . ugid } - ${ data . roleid } ` ;
2020-05-20 12:15:37 +02:00
} ,
} ,
] ,
idProperty : 'aclid' ,
proxy : {
type : 'proxmox' ,
url : '/api2/json/access/acl' ,
} ,
} ) ;
Ext . define ( 'PBS.config.ACLView' , {
extend : 'Ext.grid.GridPanel' ,
alias : 'widget.pbsACLView' ,
stateful : true ,
stateId : 'grid-acls' ,
2020-05-20 13:26:41 +02:00
title : gettext ( 'Permissions' ) ,
2020-05-20 12:15:37 +02:00
aclPath : undefined ,
aclExact : undefined ,
controller : {
xclass : 'Ext.app.ViewController' ,
addACL : function ( ) {
let me = this ;
let view = me . getView ( ) ;
Ext . create ( 'PBS.window.ACLEdit' , {
path : view . aclPath ,
listeners : {
destroy : function ( ) {
me . reload ( ) ;
} ,
} ,
} ) . show ( ) ;
} ,
removeACL : function ( btn , event , rec ) {
let me = this ;
Proxmox . Utils . API2Request ( {
2020-09-25 18:29:42 +02:00
url : '/access/acl' ,
2020-05-20 12:15:37 +02:00
method : 'PUT' ,
params : {
'delete' : 1 ,
path : rec . data . path ,
role : rec . data . roleid ,
userid : rec . data . ugid ,
} ,
callback : function ( ) {
me . reload ( ) ;
} ,
2020-09-25 18:29:42 +02:00
failure : function ( response , opts ) {
2020-05-20 12:15:37 +02:00
Ext . Msg . alert ( gettext ( 'Error' ) , response . htmlStatus ) ;
} ,
} ) ;
} ,
reload : function ( ) { this . getView ( ) . getStore ( ) . rstore . load ( ) ; } ,
init : function ( view ) {
let proxy = view . getStore ( ) . rstore . getProxy ( ) ;
let params = { } ;
if ( view . aclPath !== undefined ) {
params . path = view . aclPath ;
}
if ( view . aclExact !== undefined ) {
params . exact = view . aclExact ;
}
proxy . setExtraParams ( params ) ;
2020-05-26 12:23:26 +02:00
Proxmox . Utils . monStoreErrors ( view , view . getStore ( ) . rstore ) ;
2020-05-20 12:15:37 +02:00
} ,
2020-05-26 18:58:19 +02:00
control : {
'#' : { // view
activate : function ( ) {
this . getView ( ) . getStore ( ) . rstore . startUpdate ( ) ;
} ,
deactivate : function ( ) {
this . getView ( ) . getStore ( ) . rstore . stopUpdate ( ) ;
} ,
} ,
} ,
2020-05-20 12:15:37 +02:00
} ,
store : {
type : 'diff' ,
autoDestroy : true ,
autoDestroyRstore : true ,
2020-05-22 14:51:44 +02:00
sorters : 'aclid' ,
2020-05-20 12:15:37 +02:00
rstore : {
type : 'update' ,
storeid : 'pmx-acls' ,
model : 'pmx-acls' ,
interval : 5000 ,
} ,
} ,
tbar : [
{
xtype : 'proxmoxButton' ,
text : gettext ( 'Add' ) ,
handler : 'addACL' ,
selModel : false ,
} ,
{
xtype : 'proxmoxStdRemoveButton' ,
handler : 'removeACL' ,
callback : 'reload' ,
} ,
] ,
columns : [
{
header : gettext ( 'Path' ) ,
width : 200 ,
sortable : true ,
renderer : Ext . String . htmlEncode ,
dataIndex : 'path' ,
} ,
{
header : gettext ( 'User/Group' ) ,
width : 100 ,
sortable : true ,
renderer : Ext . String . htmlEncode ,
dataIndex : 'ugid' ,
} ,
{
header : gettext ( 'Role' ) ,
width : 80 ,
sortable : true ,
dataIndex : 'roleid' ,
} ,
{
header : gettext ( 'Propagate' ) ,
width : 150 ,
sortable : true ,
renderer : Proxmox . Utils . format _boolean ,
dataIndex : 'propagate' ,
} ,
] ,
} ) ;