2021-09-21 21:39:28 +02:00
|
|
|
<script>
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
import Home from "./Home.svelte";
|
|
|
|
import AccountSettings from "./AccountSettings.svelte";
|
2021-09-21 22:47:38 +02:00
|
|
|
import APIKeys from "./APIKeys.svelte";
|
2021-11-16 13:58:00 +01:00
|
|
|
import Transactions from "./Transactions.svelte";
|
2021-11-16 21:11:59 +01:00
|
|
|
import Subscription from "./Subscription.svelte";
|
2021-09-21 21:39:28 +02:00
|
|
|
|
|
|
|
let page = ""
|
|
|
|
|
|
|
|
let navigate = (path, title) => {
|
|
|
|
page = path
|
|
|
|
window.document.title = title+" ~ pixeldrain"
|
|
|
|
window.history.pushState(
|
|
|
|
{}, window.document.title, "/user/"+path
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-11-16 13:58:00 +01:00
|
|
|
let get_page = () => {
|
2021-09-21 21:39:28 +02:00
|
|
|
let newpage = window.location.pathname.substring(window.location.pathname.lastIndexOf("/")+1)
|
|
|
|
if (newpage === "user") {
|
2021-11-16 13:58:00 +01:00
|
|
|
newpage = "home"
|
2021-09-21 21:39:28 +02:00
|
|
|
}
|
2021-11-16 13:58:00 +01:00
|
|
|
|
2021-09-21 21:39:28 +02:00
|
|
|
page = newpage
|
2021-11-16 13:58:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
get_page()
|
2021-09-21 21:39:28 +02:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
2021-11-16 13:58:00 +01:00
|
|
|
<svelte:window on:popstate={get_page} />
|
|
|
|
|
2021-09-21 21:39:28 +02:00
|
|
|
<div>
|
2021-09-21 23:12:55 +02:00
|
|
|
<div class="tab_bar">
|
2021-09-23 20:38:17 +02:00
|
|
|
<a class="button"
|
2021-09-21 23:12:55 +02:00
|
|
|
href="/user"
|
2021-11-16 13:58:00 +01:00
|
|
|
class:button_highlight={page === "home"}
|
|
|
|
on:click|preventDefault={() => {navigate("home", "My home")}}>
|
2021-09-21 23:12:55 +02:00
|
|
|
<i class="icon">home</i>
|
|
|
|
My home
|
|
|
|
</a>
|
2021-09-23 20:38:17 +02:00
|
|
|
<a class="button"
|
2021-09-21 23:12:55 +02:00
|
|
|
href="/user/settings"
|
|
|
|
class:button_highlight={page === "settings"}
|
|
|
|
on:click|preventDefault={() => {navigate("settings", "Account settings")}}>
|
|
|
|
<i class="icon">settings</i>
|
|
|
|
Account settings
|
|
|
|
</a>
|
2021-09-23 20:38:17 +02:00
|
|
|
<a class="button"
|
2021-09-21 23:12:55 +02:00
|
|
|
href="/user/api_keys"
|
|
|
|
class:button_highlight={page === "api_keys"}
|
|
|
|
on:click|preventDefault={() => {navigate("api_keys", "API keys")}}>
|
|
|
|
<i class="icon">vpn_key</i>
|
|
|
|
API keys
|
|
|
|
</a>
|
2021-11-16 13:58:00 +01:00
|
|
|
{#if window.user.balance_micro_eur !== 0}
|
|
|
|
<a class="button"
|
|
|
|
href="/user/transactions"
|
|
|
|
class:button_highlight={page === "transactions"}
|
|
|
|
on:click|preventDefault={() => {navigate("transactions", "Transactions")}}>
|
|
|
|
<i class="icon">receipt_long</i>
|
|
|
|
Transactions
|
|
|
|
</a>
|
2021-11-16 21:11:59 +01:00
|
|
|
<a class="button"
|
|
|
|
href="/user/subscription"
|
|
|
|
class:button_highlight={page === "subscription"}
|
|
|
|
on:click|preventDefault={() => {navigate("subscription", "Subscription")}}>
|
|
|
|
<i class="icon">shopping_cart</i>
|
|
|
|
Subscription
|
|
|
|
</a>
|
2021-11-16 13:58:00 +01:00
|
|
|
{/if}
|
2021-09-21 23:12:55 +02:00
|
|
|
</div>
|
2021-09-21 21:39:28 +02:00
|
|
|
|
2021-11-16 13:58:00 +01:00
|
|
|
{#if page === "home"}
|
|
|
|
<Home></Home>
|
2021-09-21 21:39:28 +02:00
|
|
|
{:else if page === "settings"}
|
2021-11-16 13:58:00 +01:00
|
|
|
<AccountSettings></AccountSettings>
|
2021-09-21 22:47:38 +02:00
|
|
|
{:else if page === "api_keys"}
|
2021-11-16 13:58:00 +01:00
|
|
|
<APIKeys></APIKeys>
|
|
|
|
{:else if page === "transactions"}
|
|
|
|
<Transactions></Transactions>
|
2021-11-16 21:11:59 +01:00
|
|
|
{:else if page === "subscription"}
|
|
|
|
<Subscription></Subscription>
|
2021-09-21 21:39:28 +02:00
|
|
|
{/if}
|
|
|
|
</div>
|