diff --git a/svelte/src/user_home/Router.svelte b/svelte/src/user_home/Router.svelte
index 7ce3a71..2ccb073 100644
--- a/svelte/src/user_home/Router.svelte
+++ b/svelte/src/user_home/Router.svelte
@@ -3,6 +3,7 @@ import { onMount } from "svelte";
import Home from "./Home.svelte";
import AccountSettings from "./AccountSettings.svelte";
import APIKeys from "./APIKeys.svelte";
+import Transactions from "./Transactions.svelte";
let page = ""
@@ -14,21 +15,28 @@ let navigate = (path, title) => {
)
}
-onMount(() => {
+let get_page = () => {
let newpage = window.location.pathname.substring(window.location.pathname.lastIndexOf("/")+1)
if (newpage === "user") {
- newpage = ""
+ newpage = "home"
}
+
page = newpage
+}
+
+onMount(() => {
+ get_page()
})
+
+
- {#if page === ""}
-
+ {#if page === "home"}
+
{:else if page === "settings"}
-
+
{:else if page === "api_keys"}
-
+
+ {:else if page === "transactions"}
+
{/if}
-
-
diff --git a/svelte/src/user_home/Transactions.svelte b/svelte/src/user_home/Transactions.svelte
new file mode 100644
index 0000000..abfd884
--- /dev/null
+++ b/svelte/src/user_home/Transactions.svelte
@@ -0,0 +1,220 @@
+
+
+
+ {#if loading}
+
+
+
+ {/if}
+
+
Manage subscription
+
+ Current account balance: {formatEuros(window.user.balance_micro_eur, 4)}
+
+
+ {#if result !== ""}
+
+ {result}
+
+ {/if}
+
+
+ {#if window.user.subscription.id !== "prepaid"}
+ Prepaid subscription is not active.
+ {update_subscription("prepaid")}}>
+ attach_money
+ Enable prepaid subscription
+
+ {:else}
+ Prepaid subscription is active.
+ Deactivating your subscription may cause your files to expire
+ sooner than expected!
+ {update_subscription("none")}}>
+ money_off
+ Disable prepaid subscription
+
+ {/if}
+
+
+ When your prepaid subscription is active you will be charged:
+
+
+
+ €4 per TB per month for storage. The amount is charged per day
+ 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.
+
+
+ €2 per TB of bandwidth, charged every day based on the usage of
+ the previous day
+
+
+ €2 per month for the subscription itself, because prepaid has
+ the same perks as the Pro subscription (No advertisements, no
+ bandwidth limit, video player, etc)
+
+
+
+
Transaction log
+
+ Here is a log of all transactions on your account balance.
+
+
+ {#each months as month}
+
{month.month}
+
+ Subscription charge: {formatEuros(month.total_subscription_charge, 4)}
+ Storage charge: {formatEuros(month.total_storage_charge, 4)}
+ Bandwidth charge: {formatEuros(month.total_bandwidth_charge, 4)}
+ Total charge: {formatEuros(month.total_deducted, 4)}
+ Deposited: {formatEuros(month.total_deposited, 4)}
+
+
+
+ {/each}
+
+
+
+
diff --git a/svelte/src/util/Formatting.svelte b/svelte/src/util/Formatting.svelte
index 7feafea..9088382 100644
--- a/svelte/src/util/Formatting.svelte
+++ b/svelte/src/util/Formatting.svelte
@@ -15,17 +15,17 @@ export const formatThousands = (x) => {
export const formatDataVolume = (amt, precision) => {
if (precision < 3) { precision = 3; }
- if (amt >= 1e18) {
+ if (amt >= 1e18-1e15) {
return (amt/1e18).toPrecision(precision) + " EB";
- }else if (amt >= 1e15) {
+ }else if (amt >= 1e15-1e12) {
return (amt/1e15).toPrecision(precision) + " PB";
- }else if (amt >= 1e12) {
+ }else if (amt >= 1e12-1e9) {
return (amt/1e12).toPrecision(precision) + " TB";
- } else if (amt >= 1e9) {
+ } else if (amt >= 1e9-1e6) {
return (amt/1e9).toPrecision(precision) + " GB";
- } else if (amt >= 1e6) {
+ } else if (amt >= 1e6-1e3) {
return (amt/1e6).toPrecision(precision) + " MB";
- } else if (amt >= 1e3) {
+ } else if (amt >= 1e3-1) {
return (amt/1e3).toPrecision(precision) + " kB";
}
return amt + " B"
@@ -58,4 +58,8 @@ export const formatDate = (date, hours, minutes, seconds) => {
if (seconds) { dateStr += ":"+("00"+date.getMinutes()).slice(-2) }
return dateStr
}
+
+export const formatEuros = (amt, precision) => {
+ return "€ "+ (amt / 1000000).toFixed(precision)
+}
diff --git a/webcontroller/web_controller.go b/webcontroller/web_controller.go
index dc69a66..e7becd6 100644
--- a/webcontroller/web_controller.go
+++ b/webcontroller/web_controller.go
@@ -175,8 +175,10 @@ func New(
// User account settings
{GET, "user" /* */, wc.serveTemplate("user_home", handlerOpts{Auth: true})},
+ {GET, "user/home" /* */, wc.serveTemplate("user_home", handlerOpts{Auth: true})},
{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/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})},
@@ -194,6 +196,7 @@ func New(
{GET, "admin/abuse_reporters" /**/, wc.serveTemplate("admin", handlerOpts{Auth: true})},
{GET, "admin/abuse_reports" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
{GET, "admin/ip_bans" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
+ {GET, "admin/subscriptions" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
{GET, "admin/globals" /* */, wc.serveForm(wc.adminGlobalsForm, handlerOpts{Auth: true})},
{PST, "admin/globals" /* */, wc.serveForm(wc.adminGlobalsForm, handlerOpts{Auth: true})},