From 772bb40030a94fc4ec114cd27622895b66a8564c Mon Sep 17 00:00:00 2001 From: Fornax Date: Tue, 16 Nov 2021 21:11:59 +0100 Subject: [PATCH] Add subscription management page and currency widget --- res/include/style/layout.css | 4 - svelte/src/user_home/Home.svelte | 12 +- svelte/src/user_home/Router.svelte | 10 ++ svelte/src/user_home/Subscription.svelte | 186 +++++++++++++++++++++++ svelte/src/user_home/Transactions.svelte | 72 ++------- svelte/src/util/Euro.svelte | 20 +++ webcontroller/web_controller.go | 1 + 7 files changed, 238 insertions(+), 67 deletions(-) create mode 100644 svelte/src/user_home/Subscription.svelte create mode 100644 svelte/src/util/Euro.svelte diff --git a/res/include/style/layout.css b/res/include/style/layout.css index b987569..fd873bf 100644 --- a/res/include/style/layout.css +++ b/res/include/style/layout.css @@ -303,10 +303,6 @@ p, .indent { margin: 10px; } -li { - margin-bottom: 0.3em; -} - hr{ height: 1px; border: none; diff --git a/svelte/src/user_home/Home.svelte b/svelte/src/user_home/Home.svelte index ee5ea02..3228369 100644 --- a/svelte/src/user_home/Home.svelte +++ b/svelte/src/user_home/Home.svelte @@ -4,6 +4,7 @@ import { formatDataVolume, formatThousands } from "../util/Formatting.svelte"; import Chart from "../util/Chart.svelte"; import StorageProgressBar from "./StorageProgressBar.svelte"; import HotlinkProgressBar from "./HotlinkProgressBar.svelte"; +import Euro from "../util/Euro.svelte" let graph_view = null let graph_download = null @@ -128,11 +129,11 @@ onDestroy(() => { Max file size: {formatDataVolume(window.user.subscription.file_size_limit, 3)}
  • - Advertisements when viewing files: + Advertisements when you view files: {#if window.user.subscription.disable_ad_display}No{:else}Yes{/if}
  • - Advertisements on your uploaded files: + Advertisements when others view your files: {#if window.user.subscription.disable_ads_on_files}No{:else}Yes{/if}
  • {#if window.user.subscription.file_expiry_days > 0} @@ -142,6 +143,11 @@ onDestroy(() => { {/if} + {#if window.user.balance_micro_eur !== 0} +
  • + Current account balance: +
  • + {/if} {#if window.user.subscription.storage_space === -1} @@ -150,7 +156,7 @@ onDestroy(() => { {/if} - {#if window.user.subscription.storage_space === -1} + {#if window.user.subscription.direct_linking_bandwidth === -1} Hotlink bandwidth used in the last 30 days: {formatDataVolume(direct_link_bandwidth_used, 3)}
    {:else} diff --git a/svelte/src/user_home/Router.svelte b/svelte/src/user_home/Router.svelte index 2ccb073..9bb31fc 100644 --- a/svelte/src/user_home/Router.svelte +++ b/svelte/src/user_home/Router.svelte @@ -4,6 +4,7 @@ import Home from "./Home.svelte"; import AccountSettings from "./AccountSettings.svelte"; import APIKeys from "./APIKeys.svelte"; import Transactions from "./Transactions.svelte"; +import Subscription from "./Subscription.svelte"; let page = "" @@ -62,6 +63,13 @@ onMount(() => { receipt_long Transactions + {navigate("subscription", "Subscription")}}> + shopping_cart + Subscription + {/if} @@ -73,5 +81,7 @@ onMount(() => { {:else if page === "transactions"} + {:else if page === "subscription"} + {/if} diff --git a/svelte/src/user_home/Subscription.svelte b/svelte/src/user_home/Subscription.svelte new file mode 100644 index 0000000..4da37ad --- /dev/null +++ b/svelte/src/user_home/Subscription.svelte @@ -0,0 +1,186 @@ + + +
    + {#if loading} +
    + +
    + {/if} +
    +

    Manage subscription

    +

    + Current account balance: +

    +

    + When your prepaid subscription is active you will be charged daily + based on usage. Hotlink bandwidth is charged per TB based on the + usage of the previous day. The amount charged for storage each day + is your storage usage at the end of the day multiplied by the + storage price (€4 / TB) and divided by the average number of days in + a month (30.4375). So if you have exactly 1 TB on your account you + will be charged €0.131416838 per day. +

    +

    + The prepaid subscription will stay active for as long as you have + credit on your account. When you reach negative balance the + subscription will automatically end. You will need a positive + balance to activate the subscription again. +

    + + {#if result !== ""} +
    + {result} +
    + {/if} + +
    +
    +
    + Prepaid
    + {#if window.user.subscription.id === "prepaid"} + Currently active + {:else} + + {/if} +
    +
    +
      +
    • Base price of €2 per month
    • +
    • €4 per TB per month for storage
    • +
    • €2 per TB for hotlink bandwidth
    • +
    • No bandwidth limit, your files will download at the highest speed possible
    • +
    +
    +
    +
    +
    + Prepaid (just storage)
    + {#if window.user.subscription.id === "prepaid_storage"} + Currently active + {:else} + + {/if} +
    +
    +
      +
    • Base price of €0.10 per month
    • +
    • €4 per TB per month for storage
    • +
    • No hotlink bandwidth (rate limiting will be enabled when a file uses too much bandwidth)
    • +
    • You don't see ads, but people downloading your files do see ads
    • +
    +
    +
    +
    +
    + Free
    + {#if window.user.subscription.id === ""} + Currently active + {:else} + + {/if} +
    +
    +
      +
    • Standard free plan, files expire after 30 days.
    • +
    +
    +
    +
    +
    +
    + + diff --git a/svelte/src/user_home/Transactions.svelte b/svelte/src/user_home/Transactions.svelte index abfd884..7da2b51 100644 --- a/svelte/src/user_home/Transactions.svelte +++ b/svelte/src/user_home/Transactions.svelte @@ -1,7 +1,8 @@ + + + € + 0}> + {(amount / 1000000).toFixed(precision)} + + + + diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go index 4b7688c..6ccbd4c 100644 --- a/webcontroller/web_controller.go +++ b/webcontroller/web_controller.go @@ -179,6 +179,7 @@ func New( {GET, "user/settings" /* */, wc.serveTemplate("user_home", handlerOpts{Auth: true})}, {GET, "user/api_keys" /* */, wc.serveTemplate("user_home", handlerOpts{Auth: true})}, {GET, "user/transactions" /* */, wc.serveTemplate("user_home", handlerOpts{Auth: true})}, + {GET, "user/subscription" /* */, wc.serveTemplate("user_home", handlerOpts{Auth: true})}, {GET, "user/confirm_email" /* */, wc.serveEmailConfirm}, {GET, "user/password_reset_confirm" /**/, wc.serveForm(wc.passwordResetConfirmForm, handlerOpts{NoEmbed: true})}, {PST, "user/password_reset_confirm" /**/, wc.serveForm(wc.passwordResetConfirmForm, handlerOpts{NoEmbed: true})},