[pve-devel] help with ExtJS4

Dietmar Maurer dietmar at proxmox.com
Thu Jun 30 06:02:18 CEST 2011


> Thanks for your assistance.  I am making progress in learning the code with your
> help.  Can you explain a little about how the PVE.Utils.API2Request function
> works and how the url attribute is used to execute the proper commands. 

A great way to explore and test the API is the 'pvesh' command. for example:

# pvesh

entering PVE shell - type 'help' for help
pve:/> ls
Dr--- access
Dr--- cluster
Dr--- nodes
Dr-c- storage
pve:/> cd access
pve:/access> ls
-rw-- acl
Dr-c- domains
Dr-c- groups
Dr-c- roles
---c- ticket
Dr-c- users
pve:/access> cd users
pve:/access/users> ls
-rw-d alex at pve
-rw-d carol at pve
-rw-d root at pam
pve:/access/users> help
help [path] [--verbose]
cd [path]
ls [path]

create /access/users -userid <string> [OPTIONS]
set /access/users/{userid}  [OPTIONS]
get /access/users/{userid} 
delete /access/users/{userid}

...

So the correct url is:

                 url: '/access/users/' + userid,


NOTE: create = POST, set = PUT, get = GET, delete =DELETE

Does that help?

>  This is
> what I have so far for deleting the user and it is not functioning.
> 
>             {
>                 text: 'Delete',
>                 handler: function() {
>                     var sm = me.getSelectionModel();
>                     var rec = sm.getSelection()[0];
>                     if (!rec)
>                         return;
> 
>                     var userid = rec.data.userid;
> 
>                     var msg = 'Are you sure you want to permanently delete the user: ' +
> userid;
>                     Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
>                         if (btn !== 'yes')
>                             return;
>                         PVE.Utils.API2Request({
>                           url: '/user/' + userid,
>                           method: 'DELETE',
>                           callback: function() {
>                             me.setLoading(false);
>                             reload();
>                           },
>                           failure: function (response, opts) {
>                             Ext.Msg.alert('Error',response.htmlStatus);
>                           },
>                         });
>                     });
>                 }
>             }
> 
> I appreciate all your help.
> 



More information about the pve-devel mailing list