From 345c96f99aa98d5e90a46fa3f175ec0a2e6d4f36 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sat, 9 Jul 2022 11:49:39 +1000 Subject: Fix links-to-node failing on load Was setting SERVER_URL incorrectly Also changed server API to include 'excl' param --- src/App.vue | 2 +- src/components/SearchModal.vue | 3 ++- src/components/TileInfoModal.vue | 2 +- src/lib.ts | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/App.vue b/src/App.vue index 77de7ca..784b15d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -865,7 +865,7 @@ export default defineComponent({ let urlParams = new URLSearchParams({type: 'node', tree: this.uiOpts.tree}); if (nodeName != null){ urlParams.append('name', nodeName); - urlParams.append('toroot', this.activeRoot.name); + urlParams.append('toroot', '1'); } let responseObj: {[x: string]: TolNode} = await this.loadFromServer(urlParams); if (responseObj == null){ diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue index 990312a..9dc8f9b 100644 --- a/src/components/SearchModal.vue +++ b/src/components/SearchModal.vue @@ -206,7 +206,8 @@ export default defineComponent({ let urlParams = new URLSearchParams({ type: 'node', name: tolNodeName, - toroot: this.activeRoot.name, + toroot: '1', + excl: this.activeRoot.name, tree: this.uiOpts.tree, }); this.$emit('net-wait'); // Allows the parent component to show a loading-indicator diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index e5ea77b..a70215d 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -240,7 +240,7 @@ export default defineComponent({ onLinkIconClick(evt: Event){ // Copy link to clipboard let url = new URL(window.location.href); - url.search = 'node=' + encodeURIComponent(this.nodeName); + url.search = new URLSearchParams({node: this.nodeName}); navigator.clipboard.writeText(url.toString()); // Show visual indicator this.linkCopied = true; diff --git a/src/lib.ts b/src/lib.ts index 0422389..9afe199 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -7,7 +7,7 @@ import {LayoutOptions} from './layout'; import {getBreakpoint, Breakpoint, getScrollBarWidth, onTouchDevice} from './util'; // For server requests -const SERVER_URL = window.location.href + 'data' +const SERVER_URL = (new URL(window.location.href)).origin + '/data' export async function queryServer(params: URLSearchParams){ // Construct URL let url = new URL(SERVER_URL); @@ -18,7 +18,7 @@ export async function queryServer(params: URLSearchParams){ let response = await fetch(url.toString()); responseObj = await response.json(); } catch (error){ - console.log(`Error with querying ${url}: ${error}`); + console.log(`Error with querying ${url.toString()}: ${error}`); return null; } return responseObj; -- cgit v1.2.3