Working Graphs Tab Redirection
This commit is contained in:
parent
ab6ff1c994
commit
44f96b6071
2 changed files with 29 additions and 8 deletions
|
@ -1,8 +0,0 @@
|
||||||
import { redirect } from '@sveltejs/kit';
|
|
||||||
|
|
||||||
export function load({ url }: { url: URL }) {
|
|
||||||
if (url.pathname == '/graphs') {
|
|
||||||
throw redirect(302, '/graphs/tab');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,35 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import SubNav from './SubNav.svelte';
|
import SubNav from './SubNav.svelte';
|
||||||
import '../styles.css';
|
import '../styles.css';
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
|
import { page } from "$app/stores";
|
||||||
|
import GraphsTabStore from '$lib/stores/GraphsTab';
|
||||||
|
|
||||||
|
let graphsTab = "tab";
|
||||||
|
// Tab Detection
|
||||||
|
GraphsTabStore.subscribe(tab => {
|
||||||
|
graphsTab = tab;
|
||||||
|
if (typeof localStorage !== 'undefined') {
|
||||||
|
localStorage.setItem('graphsTab', graphsTab);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
page.subscribe((tab) => {
|
||||||
|
if (tab && tab.route && tab.route.id) {
|
||||||
|
let currentTab;
|
||||||
|
const tmp = tab.route.id.split("/").at(-1);
|
||||||
|
if (typeof tmp === "string") {
|
||||||
|
currentTab = tmp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentTab = "graphs";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentTab == "graphs") {
|
||||||
|
goto('/graphs/' + graphsTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue