]> git.proxmox.com Git - pve2-api-doc.git/blobdiff - data/PVEAPI.js
add usage information
[pve2-api-doc.git] / data / PVEAPI.js
index 0ce315bddb88be9e7a77ef53d9ae7c814c963e5c..ff3cd447fde239547a2a3eb8368e0df8db937783 100644 (file)
@@ -1,9 +1,3 @@
-Ext.require([
-    'Ext.tree.*',
-    'Ext.data.*',
-    'Ext.window.MessageBox'
-]);
-
 // avoid errors when running without development tools
 if (!Ext.isDefined(Ext.global.console)) {   
     var console = { 
@@ -53,7 +47,7 @@ Ext.onReady(function() {
 
        metaData.style = 'white-space:pre-wrap;'
 
-       return  value;
+       return Ext.htmlEncode(value);
     };
 
     var render_type = function(value, metaData, record) {
@@ -89,14 +83,31 @@ Ext.onReady(function() {
 
        var items = [];
 
+       var clicmdhash = {
+           GET: 'get',
+           POST: 'create',
+           PUT: 'set',
+           DELETE: 'delete'
+       };
+
        Ext.Array.each(['GET', 'POST', 'PUT', 'DELETE'], function(method) {
            var info = md[method];
            if (info) {
 
+               var usage = "";
+
+               usage += "<table><tr><td>HTTP:&nbsp;&nbsp;&nbsp;</td><td>" + method + " /api2/json" + data.path + "</td></tr><tr><td>&nbsp</td></tr>";
+               usage += "<tr><td>CLI:</td><td>pvesh " + clicmdhash[method] + " " + data.path + "</td></tr></table>";
+
                var sections = [
                    {
                        title: 'Description',
-                       html: info.description,
+                       html: Ext.htmlEncode(info.description),
+                       bodyPadding: 10
+                   },
+                   {
+                       title: 'Usage',
+                       html: usage,
                        bodyPadding: 10
                    }
                ];
@@ -188,13 +199,15 @@ Ext.onReady(function() {
                    }
 
                    if (info.permissions.user) {
-                       if (info.permissions.user === 'world') {
-                           permhtml += "Accessible without any authententification.";
-                       } else if (info.permissions.user === 'all') {
-                           permhtml += "Accessible by all authententicated users.";
-                       } else {
-                           permhtml += 'Onyl accessible by user "' + 
-                               info.permissions.user + '"';
+                       if (!info.permissions.description) {
+                           if (info.permissions.user === 'world') {
+                               permhtml += "Accessible without any authententification.";
+                           } else if (info.permissions.user === 'all') {
+                               permhtml += "Accessible by all authententicated users.";
+                           } else {
+                               permhtml += 'Onyl accessible by user "' + 
+                                   info.permissions.user + '"';
+                           }
                        }
                    } else if (info.permissions.check) {
                        permhtml += "<pre>Check: " +