feat(frontend,backend): storage panel with weight rows and trash, heavy media streams by url in the viewer
This commit is contained in:
1 parent
f2c245707a
commit
55634984fd
19 files changed
+1822
-24
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import type { StorageGroupName } from "#lib/api/types.js";
|
||||
import { plural } from "#lib/format/shares.js";
|
||||
|
||||
const DAY_MS = 86_400_000;
|
||||
const EXTENSION_LIMIT = 4;
|
||||
|
||||
export const GROUP_LABELS: Record<StorageGroupName, string> = {
|
||||
audio: "Аудио",
|
||||
file: "Файлы",
|
||||
other: "Фото и прочее",
|
||||
video: "Видео",
|
||||
voice: "Кружки и голосовые",
|
||||
};
|
||||
|
||||
const KIND_GROUPS: Record<string, StorageGroupName> = {
|
||||
audio: "audio",
|
||||
document: "file",
|
||||
video: "video",
|
||||
video_note: "voice",
|
||||
voice: "voice",
|
||||
};
|
||||
|
||||
export function groupOf(kind: string): StorageGroupName {
|
||||
return KIND_GROUPS[kind] ?? "other";
|
||||
}
|
||||
|
||||
export function filesLabel(count: number): string {
|
||||
return `${count.toLocaleString("ru-RU")} ${plural(count, "файл", "файла", "файлов")}`;
|
||||
}
|
||||
|
||||
export function messagesLabel(count: number): string {
|
||||
return `в ${count} ${plural(count, "сообщении", "сообщениях", "сообщениях")}`;
|
||||
}
|
||||
|
||||
export function fileExtension(fileName: string): string {
|
||||
const tail = fileName.includes(".") ? (fileName.split(".").pop() ?? "") : "";
|
||||
return tail.length > 0 && tail.length <= EXTENSION_LIMIT
|
||||
? tail.toUpperCase()
|
||||
: "";
|
||||
}
|
||||
|
||||
export function purgeLabel(iso: string): string {
|
||||
const days = Math.ceil((new Date(iso).getTime() - Date.now()) / DAY_MS);
|
||||
if (days <= 0) {
|
||||
return "Удалится сегодня";
|
||||
}
|
||||
if (days === 1) {
|
||||
return "Удалится завтра";
|
||||
}
|
||||
return `Удалится через ${days} дн.`;
|
||||
}
|
||||
Reference in new issue
Block a user