diff --git a/src/lib/components/Popup.svelte b/src/lib/components/Popup.svelte index e64a2b7..4451b4e 100644 --- a/src/lib/components/Popup.svelte +++ b/src/lib/components/Popup.svelte @@ -49,6 +49,11 @@ return `/${release}${toTree}?path=${encodeURIComponent(path.path)}${platParam}${fromParam}${modelParam}` } + function launchQuery(path: any) { + const release = "release" in path ? `v${path.release}` : $page.data.release + return `/${release}/query?path=${encodeURIComponent(path.path)}` + } + function copyEffect() { const toggle = () => { document.getElementById("clip")?.classList.toggle("hidden") @@ -159,7 +164,10 @@ -
+
+ + JSON-RPC Query + Show in {"release" in popupDetail ? popupDetail.release : ''} {treePopup() ? 'Path' : 'Tree'} Browser
diff --git a/src/lib/components/functions.ts b/src/lib/components/functions.ts index beabd29..aef2abf 100644 --- a/src/lib/components/functions.ts +++ b/src/lib/components/functions.ts @@ -234,4 +234,13 @@ export function gnmiToModelPath(jsonInstancePath: string) { }) .join('/') .replace(/^/, '/') +} + +export function copyAnimation() { + const toggle = () => { + document.getElementById("clip")?.classList.toggle("hidden") + document.getElementById("copied")?.classList.toggle("hidden") + } + setTimeout(toggle, 1000) + toggle() } \ No newline at end of file diff --git a/src/routes/[release]/query/+page.svelte b/src/routes/[release]/query/+page.svelte new file mode 100644 index 0000000..fe1c58e --- /dev/null +++ b/src/routes/[release]/query/+page.svelte @@ -0,0 +1,119 @@ + + + + Nokia SR Linux {release} {model !== "nokia" ? modelTitle : ""} Yang Model | Query + + +
+ + +
+
+

JSON-RPC Query SR Linux

+
+
+
+ + +
+
+ + +
+
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+

Response:

+ +
+
{JSON.stringify(jsonRpcResponse, null, 2)}
+
+
+
+
diff --git a/src/routes/[release]/query/+page.ts b/src/routes/[release]/query/+page.ts new file mode 100644 index 0000000..aab9c5e --- /dev/null +++ b/src/routes/[release]/query/+page.ts @@ -0,0 +1,42 @@ +import { error } from '@sveltejs/kit' + +import yaml from 'js-yaml' +import rel from '$lib/releases.yaml?raw' +import type { Releases } from '$lib/structure' + +const releases = yaml.load(rel) as Releases +const validVersions = [...new Set(Object.keys(releases))] + +export async function load({ url, params }) { + const release = params.release + + if(!validVersions.includes(release)) { + throw error(404, "Unsupported release") + } + + const model = url.searchParams.get("model")?.trim() ?? "nokia" + if(model != "openconfig" && model != "nokia") { + throw error(404, "Unsupported model") + } + + const allModels = [{title: "Nokia", path: `/${release}`}] + if(releases[release].openconfig) { + allModels.push({title: "OpenConfig", path: `/${release}/?model=openconfig`}) + } + + let modelTitle = "Nokia" + if(model === "openconfig") { + if(releases[release].openconfig) { + modelTitle = "OpenConfig" + } else { + throw error(404, "Unsupported model") + } + } + + const urlPath = url.searchParams.get("path")?.trim() ?? "" + + return { + model, release, allModels, modelTitle, + urlPath: decodeURIComponent(urlPath) + } +} \ No newline at end of file