diff --git a/svelte/src/admin_panel/HostMetrics.svelte b/svelte/src/admin_panel/HostMetrics.svelte
index 2560cf1..ad7b819 100644
--- a/svelte/src/admin_panel/HostMetrics.svelte
+++ b/svelte/src/admin_panel/HostMetrics.svelte
@@ -1,14 +1,18 @@
{#if loaded}
@@ -111,10 +206,10 @@ onMount(async () => {
{#each group.graphs as graph (graph.metric)}
{/each}
diff --git a/svelte/src/admin_panel/HostMetricsGraph.svelte b/svelte/src/admin_panel/HostMetricsGraph.svelte
index 26f638b..9139336 100644
--- a/svelte/src/admin_panel/HostMetricsGraph.svelte
+++ b/svelte/src/admin_panel/HostMetricsGraph.svelte
@@ -1,121 +1,77 @@
diff --git a/svelte/src/admin_panel/HostMetricsLib.ts b/svelte/src/admin_panel/HostMetricsLib.ts
index 8da8e9a..1c41df0 100644
--- a/svelte/src/admin_panel/HostMetricsLib.ts
+++ b/svelte/src/admin_panel/HostMetricsLib.ts
@@ -1,8 +1,26 @@
import { loading_finish, loading_start } from "lib/Loading";
-import { get_endpoint } from "lib/PixeldrainAPI";
+import { check_response, get_endpoint } from "lib/PixeldrainAPI";
import hsl2rgb from "pure-color/convert/hsl2rgb";
import rgb2hex from "pure-color/convert/rgb2hex";
+export type HostMetrics = {
+ timestamps: string[]
+ // First key is the requested metric, second key is the host ID
+ metrics: { [key: string]: { [key: string]: number[] } }
+}
+
+export const get_host_metrics = async (start: Date, end: Date, metrics: string[], interval: number): Promise => {
+ return await check_response(
+ await fetch(
+ get_endpoint() + "/admin/host_metrics" +
+ "?start=" + start.toISOString() +
+ "&end=" + end.toISOString() +
+ "&metrics=" + metrics.join(",") +
+ "&interval=" + interval
+ )
+ ) as HostMetrics
+};
+
let host_colours: { [key: string]: string } = {}
export const host_colour = (id: string): string => {
let host_count: number = Object.keys(host_colours).length
@@ -12,11 +30,18 @@ export const host_colour = (id: string): string => {
return host_colours[id]
}
- const colour_interval = 360 / (host_count + 1)
+ // Divide the colour wheel by the number of hosts we need to colour. We cap
+ // the steps at 24 hue, which allows for 15 colours
+ const colour_interval = Math.max(360 / (host_count + 1), 24)
var i = 0
for (const host of Object.keys(host_colours).sort()) {
- host_colours[host] = rgb2hex(hsl2rgb([i * colour_interval, 100, 70]))
+ const hue = (i * colour_interval) % 360
+
+ // Lightness decreases with 10 for each cycle of the colour wheel
+ const lightness = 80 - (Math.floor((i * colour_interval) / 360) * 10)
+
+ host_colours[host] = rgb2hex(hsl2rgb([hue, 100, lightness]))
i++
}
diff --git a/svelte/src/lib/AdminAPI.ts b/svelte/src/lib/AdminAPI.ts
index a9e2d06..a55b701 100644
--- a/svelte/src/lib/AdminAPI.ts
+++ b/svelte/src/lib/AdminAPI.ts
@@ -27,20 +27,3 @@ export const get_admin_invoices = async (year: number, month: number) => {
)
) as Invoice[]
};
-
-export type HostMetrics = {
- timestamps: string[]
- host_amounts: { [key: string]: number[] }
-}
-
-export const get_host_metrics = async (start: Date, end: Date, metric: string, interval: number): Promise => {
- return await check_response(
- await fetch(
- get_endpoint() + "/admin/host_metrics" +
- "?start=" + start.toISOString() +
- "&end=" + end.toISOString() +
- "&metric=" + metric +
- "&interval=" + interval
- )
- ) as HostMetrics
-};
diff --git a/svelte/src/lib/PixeldrainAPI.ts b/svelte/src/lib/PixeldrainAPI.ts
index bf34adf..5b2cf75 100644
--- a/svelte/src/lib/PixeldrainAPI.ts
+++ b/svelte/src/lib/PixeldrainAPI.ts
@@ -15,6 +15,7 @@ export type User = {
subscription: Subscription,
storage_space_used: number,
filesystem_storage_used: number,
+ filesystem_node_count: number,
is_admin: boolean,
balance_micro_eur: number,
hotlinking_enabled: boolean,
@@ -138,7 +139,7 @@ export const logout_user = async (redirect_path: string) => {
{ method: "DELETE" },
))
- document.cookie = "pd_auth_key=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
+ // document.cookie = "pd_auth_key=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
window.location.pathname = redirect_path
}