[pve-devel] applied: [PATCH v2 docs 1/2] apiviewer: add api endpoint deeplink ability

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Dec 11 16:07:14 CET 2019


On 12/11/19 12:58 PM, Tim Marx wrote:
> use #/<endpoint> to deeplink to a specific endpoint
> 
> Signed-off-by: Tim Marx <t.marx at proxmox.com>
> ---
> changes v2:
> * update hash part on treenode selection
> * deepLink should work on subsequent url changes
> 

applied, thanks! Did small followup, see inline:

>  api-viewer/PVEAPI.js | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/api-viewer/PVEAPI.js b/api-viewer/PVEAPI.js
> index d0da407..dd36fff 100644
> --- a/api-viewer/PVEAPI.js
> +++ b/api-viewer/PVEAPI.js
> @@ -368,6 +368,7 @@ Ext.onReady(function() {
>  		    return;
>  		var rec = selections[0];
>  		render_docu(rec.data);
> +		location.hash = '#' + rec.data.path;
>  	    }
>  	}
>      });
> @@ -389,4 +390,18 @@ Ext.onReady(function() {
>  	]
>      });
> 
> +    var deepLink = function() {
> +	var path = window.location.hash.substring(1);

added a .replace(/\/\s*$/, '') to trim trailing slashes, to make paths
like /access/ work, my firefox autocompletes to trailing slash, so I run
into this fast.

> +	var endpoint = store.findNode('path', path);
> +
> +	if (endpoint) {
> +	    tree.getSelectionModel().select(endpoint);
> +	    tree.expandPath(endpoint.getPath());
> +	    render_docu(endpoint.data);
> +	}
> +    }
> +    window.onhashchange = deepLink;
> +
> +    deepLink();
> +
>  });
> --
> 2.20.1




More information about the pve-devel mailing list