Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul admin UI #8

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions frontend/src/entrypoints/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ function ingestStatsGraph(elem: HTMLElement) {
const chart = echarts.init(elem);

const opts = {
title: {
left: "center",
text: "Ingested Media",
},
tooltip: {
trigger: "axis",
},
Expand Down
24 changes: 16 additions & 8 deletions frontend/src/ts/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getRelativeTime(toDate: Date, fromDate = new Date()): string {
if (Math.abs(elapsed) > units[unit] || unit === "second") {
return rtf.format(
Math.round(elapsed / units[unit]),
unit as Intl.RelativeTimeFormatUnit
unit as Intl.RelativeTimeFormatUnit,
);
}
}
Expand Down Expand Up @@ -79,10 +79,9 @@ document
const fileName = document.querySelector(input.dataset.fileNameLabel);

if (fileName) {
const displayedName =
input.files?.length === 1
? input.files[0].name
: `${input.files?.length} Files Selected`;
const displayedName = input.files?.length === 1
? input.files[0].name
: `${input.files?.length} Files Selected`;
fileName.textContent = displayedName;
}

Expand All @@ -109,7 +108,7 @@ document
return "Archive is uploading";
};

const fileInput = <HTMLInputElement>(
const fileInput = <HTMLInputElement> (
chunkUploader.querySelector('input[type="file"]')
);
if (!fileInput) return;
Expand All @@ -129,7 +128,7 @@ document
window.onbeforeunload = null;
console.log(`Completed uploading chunks to ${collectionId}`);

let collectionIDElement = <HTMLInputElement>(
let collectionIDElement = <HTMLInputElement> (
chunkUploader.querySelector('input[name="collection_id"]')
);
if (collectionIDElement) {
Expand All @@ -152,7 +151,7 @@ document

async function performChunkedUpload(
file: File,
progressBar: HTMLProgressElement | null
progressBar: HTMLProgressElement | null,
) {
const CHUNK_SIZE = 1024 * 1024 * 10;

Expand Down Expand Up @@ -212,3 +211,12 @@ document.querySelectorAll<HTMLInputElement>(".hover-reveal").forEach((elem) => {
elem.type = "password";
});
});

const numberFormatter = new Intl.NumberFormat(undefined, {
style: "decimal",
});

document.querySelectorAll(".human-number").forEach((elem) => {
const value = parseInt(elem.textContent?.trim() || "0", 10);
elem.textContent = numberFormatter.format(value);
});
12 changes: 12 additions & 0 deletions queries/admin/flist_stats.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SELECT
COALESCE(
(
SELECT
count(*)
FROM
flist_file
WHERE
discovered_at > current_timestamp - interval '24 hours'
),
0
) "recent_posts!";
50 changes: 50 additions & 0 deletions queries/admin/overview.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
SELECT
COALESCE(
(
SELECT
count(*)
FROM
user_account
),
0
) "total_users!",
COALESCE(
(
SELECT
count(*)
FROM
linked_account
),
0
) "linked_accounts!",
COALESCE(
(
SELECT
count(DISTINCT user_id)
FROM
user_session
WHERE
last_used > current_timestamp - interval '24 hours'
),
0
) "recent_users!",
COALESCE(
(
SELECT
sum(content_size)::bigint
FROM
owned_media_item
),
0
) "total_filesize!",
COALESCE(
(
SELECT
count(*)
FROM
owned_media_item
WHERE
last_modified > current_timestamp - interval '24 hours'
),
0
) "recent_media!";
12 changes: 12 additions & 0 deletions queries/admin/reddit_stats.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SELECT
COALESCE(
(
SELECT
count(*)
FROM
reddit_post
WHERE
posted_at > current_timestamp - interval '24 hours'
),
0
) "recent_posts!";
78 changes: 78 additions & 0 deletions sqlx-data.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading