Add screens for media, the audit log and statistics

This commit is contained in:
Matthijs Iriks committed 2026-12-04 04:06:39 +01:00
1 parent 0caa196908
commit 1c9ccadf4e
10 files changed
+478 -6

No files matched your search

+171
View File
@@ -0,0 +1,171 @@
<script setup lang="ts">
import { reactive } from 'vue';
import { api, boot, useForm } from '../api';
import Link from '../components/Link.vue';
import { t } from '../i18n';
import { flash, navigate, reload } from '../state';
interface Entry {
id: number; at: string; event: string; summary: string; subject: { type: string; label: string; url: string | null } | null;
details: Record<string, any>; who: string | null; email: string | null; ip: string | null; browser: string | null;
banned: boolean; never_banned: boolean;
}
interface Ban { id: number; ip: string; reason: string | null; automatic: boolean; whole_site: boolean; by: string | null; hits: number; expires_at: string | null; active: boolean }
const props = defineProps<{
entries: Entry[]; pagination: { page: number; pages: number; total: number };
filters: { show: string; user: number | null; ip: string; q: string };
accounts: { id: number; name: string }[];
summary: { logins: number; failed: number; refused: number; banned: number };
bans: Ban[]; notes: { ip: string; group: string | null; note: string; by: string | null }[];
settings: { auto_ban: boolean; max_failures: number; window_minutes: number; ban_minutes: number; keep_days: number };
max_keep_days: number; can_manage: boolean; my_ip: string; never_banned: string[]; whole_site_bans: boolean;
}>();
const tabs = ['all', 'logins', 'failed', 'actions', 'viewed', 'refused', 'bans'];
const search = reactive({ q: props.filters.q, ip: props.filters.ip, user: props.filters.user ?? '' });
const when = (iso: string) => new Date(iso).toLocaleString();
function go(extra: Record<string, string | number>): void {
const query = new URLSearchParams();
const merged: Record<string, string | number> = { show: props.filters.show, q: search.q, ip: search.ip, user: search.user, ...extra };
for (const [key, value] of Object.entries(merged)) {
value !== '' && value !== 'all' && value !== 1 && query.set(key, String(value));
}
void navigate(`${boot.base}/audit${query.size ? '?' + query : ''}`);
}
const ban = useForm({ ip: '', minutes: 1440, reason: '', whole_site: false });
async function banIp(ip?: string): Promise<void> {
if (ip) {
ban.values.ip = ip;
}
const done = await ban.send<{ message: string }>('post', `${boot.base}/audit/bans`);
if (done) {
flash(done.message);
ban.values.ip = ban.values.reason = '';
await reload();
}
}
async function lift(item: Ban): Promise<void> {
flash((await api.delete(`${boot.base}/audit/bans/${item.id}`)).message);
await reload();
}
const rules = useForm({ ...props.settings });
async function saveRules(): Promise<void> {
if (await rules.send('put', `${boot.base}/audit/settings`)) {
flash(t('Saved.'));
await reload();
}
}
const note = useForm({ ip: '', group: '', note: '' });
async function saveNote(): Promise<void> {
if (await note.send('put', `${boot.base}/audit/notes`)) {
flash(t('Saved.'));
note.values.ip = note.values.group = note.values.note = '';
await reload();
}
}
const expires = (item: Ban) => (item.expires_at ? when(item.expires_at) : t('until lifted'));
</script>
<template>
<h1 class="font-display mb-6 text-2xl font-bold">{{ t('Audit log') }}</h1>
<div class="mb-6 grid grid-cols-2 gap-3 md:grid-cols-4">
<div v-for="(value, key) in summary" :key="key" class="m-card p-4">
<p class="text-2xl font-bold">{{ value }}</p>
<p class="m-help">{{ t(key === 'banned' ? 'Addresses banned' : key === 'logins' ? 'Logins (24 h)' : key === 'failed' ? 'Failed logins (24 h)' : 'Refused (24 h)') }}</p>
</div>
</div>
<nav class="mb-4 flex flex-wrap gap-2">
<button v-for="tab in tabs" :key="tab" type="button" class="m-btn" :class="filters.show === tab ? 'm-btn-primary' : 'm-btn-secondary'" @click="go({ show: tab, page: 1 })">{{ t(tab) }}</button>
</nav>
<form class="mb-4 flex flex-wrap gap-2" @submit.prevent="go({ page: 1 })">
<input v-model="search.q" class="m-input max-w-xs" :placeholder="t('Search')" :aria-label="t('Search')" />
<input v-model="search.ip" class="m-input max-w-[12rem]" placeholder="IP" aria-label="IP" />
<select v-model="search.user" class="m-input max-w-[12rem]" :aria-label="t('Account')">
<option value="">{{ t('Everyone') }}</option>
<option v-for="account in accounts" :key="account.id" :value="account.id">{{ account.name }}</option>
</select>
<button type="submit" class="m-btn m-btn-secondary">{{ t('Filter') }}</button>
</form>
<p v-if="!entries.length" class="m-card p-5 text-sm text-muted">{{ t('Nothing here yet.') }}</p>
<ul v-else class="m-card divide-y divide-line">
<li v-for="entry in entries" :key="entry.id" class="flex flex-wrap items-start justify-between gap-3 p-4 text-sm">
<div class="min-w-0">
<p class="font-semibold">{{ entry.summary }}
<template v-if="entry.subject">
· <Link v-if="entry.subject.url" :href="entry.subject.url" class="underline">{{ entry.subject.label }}</Link><span v-else>{{ entry.subject.label }}</span>
</template>
</p>
<p class="text-xs text-muted">{{ when(entry.at) }} · {{ entry.who ?? entry.email ?? t('Someone') }} · {{ entry.ip }} · {{ entry.browser }}</p>
</div>
<span class="flex gap-2">
<span v-if="entry.banned" class="m-badge">{{ t('banned') }}</span>
<button v-if="can_manage && entry.ip && !entry.banned && !entry.never_banned && entry.ip !== my_ip" type="button" class="m-btn m-btn-danger" @click="banIp(entry.ip)">{{ t('Ban') }}</button>
</span>
</li>
</ul>
<nav v-if="pagination.pages > 1" class="mt-4 flex items-center gap-2">
<button v-if="pagination.page > 1" type="button" class="m-btn m-btn-secondary" @click="go({ page: pagination.page - 1 })">{{ t('Previous') }}</button>
<span class="text-sm text-muted">{{ pagination.page }} / {{ pagination.pages }}</span>
<button v-if="pagination.page < pagination.pages" type="button" class="m-btn m-btn-secondary" @click="go({ page: pagination.page + 1 })">{{ t('Next') }}</button>
</nav>
<h2 class="font-display mb-3 mt-10 text-xl font-bold">{{ t('Bans') }}</h2>
<form v-if="can_manage" class="m-card mb-4 flex max-w-3xl flex-wrap items-end gap-3 p-4" @submit.prevent="banIp()">
<div><label class="m-label" for="b-ip">IP</label><input id="b-ip" v-model="ban.values.ip" required class="m-input" /></div>
<div><label class="m-label" for="b-min">{{ t('Minutes (0 = until lifted)') }}</label><input id="b-min" v-model.number="ban.values.minutes" type="number" min="0" class="m-input w-32" /></div>
<div class="min-w-[10rem] flex-1"><label class="m-label" for="b-why">{{ t('Reason') }}</label><input id="b-why" v-model="ban.values.reason" maxlength="200" class="m-input" /></div>
<label v-if="whole_site_bans" class="flex items-center gap-2 text-sm"><input v-model="ban.values.whole_site" type="checkbox" /> {{ t('Whole site') }}</label>
<button type="submit" class="m-btn m-btn-danger">{{ t('Ban') }}</button>
<p v-if="ban.errors.ip" class="m-error w-full">{{ ban.errors.ip }}</p>
</form>
<p v-if="!bans.length" class="text-sm text-muted">{{ t('No bans.') }}</p>
<ul v-else class="m-card divide-y divide-line">
<li v-for="item in bans" :key="item.id" class="flex flex-wrap items-center justify-between gap-3 p-4 text-sm" :class="item.active ? '' : 'opacity-50'">
<div>
<p class="font-semibold">{{ item.ip }} <span v-if="item.automatic" class="m-badge">{{ t('automatic') }}</span> <span v-if="item.whole_site" class="m-badge">{{ t('whole site') }}</span></p>
<p class="text-xs text-muted">{{ item.reason }} · {{ expires(item) }} · {{ item.hits }} {{ t('hits') }}</p>
</div>
<button v-if="can_manage && item.active" type="button" class="m-btn m-btn-secondary" @click="lift(item)">{{ t('Lift') }}</button>
</li>
</ul>
<template v-if="can_manage">
<h2 class="font-display mb-3 mt-10 text-xl font-bold">{{ t('Rules') }}</h2>
<form class="m-card grid max-w-3xl gap-4 p-5 sm:grid-cols-2" @submit.prevent="saveRules">
<label class="flex items-center gap-2 text-sm sm:col-span-2"><input v-model="rules.values.auto_ban" type="checkbox" /> {{ t('Ban an address by itself after too many failed logins') }}</label>
<div><label class="m-label" for="r-max">{{ t('Failed logins') }}</label><input id="r-max" v-model.number="rules.values.max_failures" type="number" min="3" max="100" class="m-input" /></div>
<div><label class="m-label" for="r-win">{{ t('Within minutes') }}</label><input id="r-win" v-model.number="rules.values.window_minutes" type="number" min="1" max="1440" class="m-input" /></div>
<div><label class="m-label" for="r-ban">{{ t('Ban for minutes (0 = until lifted)') }}</label><input id="r-ban" v-model.number="rules.values.ban_minutes" type="number" min="0" class="m-input" /></div>
<div><label class="m-label" for="r-keep">{{ t('Keep the log (days)') }}</label><input id="r-keep" v-model.number="rules.values.keep_days" type="number" min="7" :max="max_keep_days" class="m-input" /><p class="m-help">≤ {{ max_keep_days }}</p></div>
<div class="sm:col-span-2"><button type="submit" class="m-btn m-btn-primary" :disabled="rules.busy">{{ t('Save') }}</button></div>
<template v-for="(message, field) in rules.errors" :key="field"><p class="m-error sm:col-span-2">{{ message }}</p></template>
</form>
<h2 class="font-display mb-3 mt-10 text-xl font-bold">{{ t('Notes about addresses') }}</h2>
<form class="m-card mb-4 flex max-w-3xl flex-wrap items-end gap-3 p-4" @submit.prevent="saveNote">
<div><label class="m-label" for="n-ip">IP</label><input id="n-ip" v-model="note.values.ip" required class="m-input" /></div>
<div><label class="m-label" for="n-group">{{ t('Group') }}</label><input id="n-group" v-model="note.values.group" maxlength="60" class="m-input" /></div>
<div class="min-w-[10rem] flex-1"><label class="m-label" for="n-note">{{ t('Note') }}</label><input id="n-note" v-model="note.values.note" maxlength="2000" class="m-input" /></div>
<button type="submit" class="m-btn m-btn-secondary">{{ t('Save') }}</button>
<p v-if="note.errors.ip" class="m-error w-full">{{ note.errors.ip }}</p>
</form>
<ul v-if="notes.length" class="m-card divide-y divide-line text-sm">
<li v-for="item in notes" :key="item.ip" class="p-3"><b>{{ item.ip }}</b> <span v-if="item.group" class="m-badge">{{ item.group }}</span> {{ item.note }}</li>
</ul>
</template>
</template>
+119
View File
@@ -0,0 +1,119 @@
<script setup lang="ts">
import { ref } from 'vue';
import { ApiError, api, boot, upload, useForm } from '../api';
import { t } from '../i18n';
import { flash, reload } from '../state';
interface Item {
id: number; name: string; filename: string; url: string; mime_type: string; is_image: boolean; size: number;
width: number | null; height: number | null; alt: string | null; uploaded_by: string | null; usage_count: number;
}
defineProps<{
items: Item[]; max_file_mb: number; extensions: string[];
storage: { used: number; limit: number; left: number };
}>();
const can = (permission: string) => boot.permissions.includes(permission);
const busy = ref(false);
const selected = ref<Item | null>(null);
const form = useForm({ name: '', alt: '' });
const size = (bytes: number) => (bytes > 1e6 ? `${(bytes / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(bytes / 1e3))} kB`);
function choose(item: Item): void {
selected.value = item;
form.errors = {};
form.values.name = item.name;
form.values.alt = item.alt ?? '';
}
async function send(event: Event): Promise<void> {
const input = event.target as HTMLInputElement;
busy.value = true;
try {
for (const file of Array.from(input.files ?? [])) {
const data = new FormData();
data.append('file', file);
await upload(`${boot.base}/media`, data);
}
flash(t('Uploaded.'));
await reload();
} catch (error) {
flash(error instanceof ApiError ? (Object.values(error.errors)[0] ?? error.message) : t('Something went wrong. Try again.'), true);
} finally {
busy.value = false;
input.value = '';
}
}
async function save(): Promise<void> {
if (selected.value && (await form.send('put', `${boot.base}/media/${selected.value.id}`))) {
flash(t('Saved.'));
selected.value = null;
await reload();
}
}
async function remove(item: Item): Promise<void> {
const warning = item.usage_count > 0 ? t('This file is in use. Delete it anyway?') : t('Are you sure?');
if (window.confirm(warning)) {
await api.delete(`${boot.base}/media/${item.id}`);
selected.value = null;
flash(t('Deleted.'));
await reload();
}
}
</script>
<template>
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
<h1 class="font-display text-2xl font-bold">{{ t('Media') }}</h1>
<label v-if="can('media.upload')" class="m-btn m-btn-primary cursor-pointer" :class="busy ? 'opacity-50' : ''">
{{ busy ? t('Uploading…') : t('Upload') }}
<input type="file" multiple class="sr-only" :accept="extensions.map((e) => '.' + e).join(',')" :disabled="busy" @change="send" />
</label>
</div>
<div class="mb-6 max-w-md" :title="`${size(storage.used)} / ${size(storage.limit)}`">
<div class="h-2 overflow-hidden rounded-full bg-panel-2">
<div class="h-full bg-brand" :style="{ width: Math.min(100, (storage.used / Math.max(1, storage.limit)) * 100) + '%' }" />
</div>
<p class="m-help">{{ size(storage.used) }} / {{ size(storage.limit) }} · {{ t('Largest file') }}: {{ max_file_mb }} MB</p>
</div>
<form v-if="selected" class="m-card mb-6 flex max-w-3xl flex-wrap gap-5 p-5" @submit.prevent="save">
<img v-if="selected.is_image" :src="selected.url" :alt="selected.alt ?? ''" class="h-32 w-32 rounded-lg object-cover" />
<div class="min-w-0 flex-1 space-y-3">
<div>
<label class="m-label" for="m-name">{{ t('Name') }}</label>
<input id="m-name" v-model="form.values.name" required maxlength="250" class="m-input" :disabled="!can('media.edit')" />
<p v-if="form.errors.name" class="m-error">{{ form.errors.name }}</p>
</div>
<div v-if="selected.is_image">
<label class="m-label" for="m-alt">{{ t('Alternative text') }}</label>
<input id="m-alt" v-model="form.values.alt" maxlength="500" class="m-input" :disabled="!can('media.edit')" />
</div>
<p class="m-help">
{{ selected.mime_type }} · {{ size(selected.size) }}<span v-if="selected.width"> · {{ selected.width }}×{{ selected.height }}</span>
· {{ t('Used') }}: {{ selected.usage_count }}<span v-if="selected.uploaded_by"> · {{ selected.uploaded_by }}</span>
</p>
<p class="m-help break-all">{{ selected.url }}</p>
<div class="flex gap-2">
<button v-if="can('media.edit')" type="submit" class="m-btn m-btn-primary" :disabled="form.busy">{{ t('Save') }}</button>
<button v-if="can('media.delete')" type="button" class="m-btn m-btn-danger" @click="remove(selected)">{{ t('Delete') }}</button>
<button type="button" class="m-btn m-btn-secondary" @click="selected = null">{{ t('Cancel') }}</button>
</div>
</div>
</form>
<p v-if="!items.length" class="m-card p-5 text-sm text-muted">{{ t('No files yet.') }}</p>
<div v-else class="grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
<button v-for="item in items" :key="item.id" type="button" class="m-card overflow-hidden text-left transition hover:border-brand" :class="selected?.id === item.id ? 'border-brand' : ''" @click="choose(item)">
<img v-if="item.is_image" :src="item.url" :alt="item.alt ?? ''" loading="lazy" class="aspect-square w-full object-cover" />
<span v-else class="grid aspect-square w-full place-items-center text-xs text-muted">{{ item.mime_type }}</span>
<span class="block truncate px-2 py-1.5 text-xs">{{ item.name }}</span>
</button>
</div>
</template>
+8 -1
View File
@@ -1,6 +1,8 @@
<script setup lang="ts">
import { boot, useForm } from '../api';
import { ref } from 'vue';
import Link from '../components/Link.vue';
import MediaPicker from '../components/MediaPicker.vue';
import { t } from '../i18n';
import { flash, navigate } from '../state';
@@ -12,6 +14,7 @@ const form = useForm({
cover_image: post?.cover_image ?? '', category: post?.category ?? '', tags: (post?.tags ?? []) as string[],
is_featured: post?.is_featured ?? false, is_published: post?.is_published ?? false, published_at: post?.published_at ?? '',
});
const picking = ref(false);
// Tags are typed as one comma separated line.
let tagLine = (post?.tags ?? []).join(', ');
@@ -64,7 +67,10 @@ async function submit(): Promise<void> {
<div class="grid gap-5 sm:grid-cols-2">
<div>
<label for="cover" class="m-label">{{ t('Cover image') }}</label>
<input id="cover" v-model="form.values.cover_image" maxlength="2048" class="m-input" />
<div class="flex gap-2">
<input id="cover" v-model="form.values.cover_image" maxlength="2048" class="m-input" />
<button v-if="boot.permissions.includes('media.view')" type="button" class="m-btn m-btn-secondary shrink-0" @click="picking = true">{{ t('Choose') }}</button>
</div>
</div>
<div>
<label for="tags" class="m-label">{{ t('Tags (comma separated)') }}</label>
@@ -82,4 +88,5 @@ async function submit(): Promise<void> {
</div>
<button type="submit" class="m-btn m-btn-primary" :disabled="form.busy">{{ form.busy ? t('Saving…') : t('Save') }}</button>
</form>
<MediaPicker v-if="picking" @pick="(url) => { form.values.cover_image = url; picking = false; }" @close="picking = false" />
</template>
+103
View File
@@ -0,0 +1,103 @@
<script setup lang="ts">
import { computed } from 'vue';
import { boot } from '../api';
import Link from '../components/Link.vue';
import { t } from '../i18n';
import { state } from '../state';
type Totals = { visitors: number; visits: number; page_views: number; average_seconds: number; bounce_rate: number };
type Row = { name: string; visits: number; channel?: string };
const props = defineProps<{
range: { key: string; label: string; from: string; to: string; compared_to: string | null };
ranges: { key: string; label: string }[]; exports: Record<string, string>;
totals: Totals; previous: Totals | null;
series: { key: string; label: string; visitors: number; visits: number; page_views: number; bot_hits: number }[];
pages: { path: string; title: string | null; views: number; average_seconds: number }[];
posts: { title: string; slug: string; views: number; average_seconds: number }[];
channels: Row[]; sources: Row[]; countries: Row[]; devices: Row[]; browsers: Row[]; systems: Row[];
heatmap: { day: string; hours: number[] }[];
bots: { total: number; previous: number | null; names: { name: string; kind: string; hits: number }[]; kinds: { name: string; hits: number }[]; pages: { path: string; hits: number }[] };
}>();
const tiles = computed(() => [
['Visitors', 'visitors'], ['Visits', 'visits'], ['Page views', 'page_views'], ['Average time', 'average_seconds'], ['Bounce rate', 'bounce_rate'],
] as const);
const value = (key: keyof Totals, n: number) => (key === 'average_seconds' ? `${Math.floor(n / 60)}:${String(n % 60).padStart(2, '0')}` : key === 'bounce_rate' ? `${n}%` : n.toLocaleString());
const change = (key: keyof Totals) => {
const before = props.previous?.[key];
return before ? Math.round(((props.totals[key] - before) / before) * 100) : null;
};
const top = computed(() => Math.max(1, ...props.series.map((s) => s.visits)));
const heat = computed(() => Math.max(1, ...props.heatmap.flatMap((row) => row.hours)));
const lists = computed(() => [
['Channels', props.channels], ['Sources', props.sources], ['Countries', props.countries], ['Devices', props.devices], ['Browsers', props.browsers], ['Systems', props.systems],
] as const);
const rangeLink = (key: string) => `${boot.base}/statistics?range=${key}`;
const csv = (sheet: string) => `${boot.base}/statistics/export?sheet=${sheet}&range=${new URLSearchParams(state.path.split('?')[1] ?? '').get('range') ?? props.range.key}`;
</script>
<template>
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
<h1 class="font-display text-2xl font-bold">{{ t('Statistics') }}</h1>
<p class="text-sm text-muted">{{ range.from }} → {{ range.to }}<span v-if="range.compared_to"> · {{ t('compared with') }} {{ range.compared_to }}</span></p>
</div>
<nav class="mb-6 flex flex-wrap gap-2">
<Link v-for="item in ranges" :key="item.key" :href="rangeLink(item.key)" class="m-btn" :class="range.key === item.key ? 'm-btn-primary' : 'm-btn-secondary'">{{ item.label }}</Link>
</nav>
<div class="mb-6 grid grid-cols-2 gap-3 md:grid-cols-5">
<div v-for="[label, key] in tiles" :key="key" class="m-card p-4">
<p class="text-2xl font-bold">{{ value(key, totals[key]) }}</p>
<p class="m-help">{{ t(label) }}<span v-if="change(key) !== null" :class="(change(key) ?? 0) >= 0 ? 'text-emerald-500' : 'text-red-500'"> {{ (change(key) ?? 0) > 0 ? '+' : '' }}{{ change(key) }}%</span></p>
</div>
</div>
<section class="m-card mb-6 p-4">
<h2 class="mb-3 font-semibold">{{ t('Visits') }}</h2>
<div class="flex h-40 items-end gap-px" role="img" :aria-label="t('Visits')">
<div v-for="point in series" :key="point.key" class="min-w-px flex-1 rounded-t bg-brand" :style="{ height: Math.max(2, (point.visits / top) * 100) + '%' }" :title="`${point.label}: ${point.visits}`" />
</div>
</section>
<div class="mb-6 grid gap-6 md:grid-cols-2">
<section class="m-card p-4">
<h2 class="mb-3 font-semibold">{{ t('Pages') }}</h2>
<p v-if="!pages.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
<ul class="divide-y divide-line text-sm"><li v-for="row in pages" :key="row.path" class="flex justify-between gap-3 py-1.5"><span class="truncate">{{ row.title ?? row.path }}</span><span class="text-muted">{{ row.views }}</span></li></ul>
</section>
<section class="m-card p-4">
<h2 class="mb-3 font-semibold">{{ t('Posts') }}</h2>
<p v-if="!posts.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
<ul class="divide-y divide-line text-sm"><li v-for="row in posts" :key="row.slug" class="flex justify-between gap-3 py-1.5"><span class="truncate">{{ row.title }}</span><span class="text-muted">{{ row.views }}</span></li></ul>
</section>
<section v-for="[title, rows] in lists" :key="title" class="m-card p-4">
<h2 class="mb-3 font-semibold">{{ t(title) }}</h2>
<p v-if="!rows.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
<ul class="divide-y divide-line text-sm"><li v-for="row in rows" :key="row.name + (row.channel ?? '')" class="flex justify-between gap-3 py-1.5"><span class="truncate">{{ row.name || t('Direct') }}</span><span class="text-muted">{{ row.visits }}</span></li></ul>
</section>
</div>
<section class="m-card mb-6 overflow-x-auto p-4">
<h2 class="mb-3 font-semibold">{{ t('When people visit') }}</h2>
<div class="space-y-0.5 text-xs">
<div v-for="row in heatmap" :key="row.day" class="flex items-center gap-0.5">
<span class="w-9 shrink-0 text-muted">{{ row.day }}</span>
<span v-for="(n, hour) in row.hours" :key="hour" class="block h-5 min-w-3 flex-1 rounded-sm border border-line" :title="`${row.day} ${hour}:00 · ${n}`" :style="{ background: `color-mix(in srgb, var(--m-brand) ${Math.round((n / heat) * 100)}%, var(--m-panel-2))` }" />
</div>
</div>
</section>
<section class="m-card mb-6 p-4">
<h2 class="mb-3 font-semibold">{{ t('Programs') }} <span class="text-sm font-normal text-muted">· {{ bots.total }}</span></h2>
<p v-if="!bots.names.length" class="text-sm text-muted">{{ t('Nothing here yet.') }}</p>
<ul class="divide-y divide-line text-sm"><li v-for="row in bots.names" :key="row.name" class="flex justify-between gap-3 py-1.5"><span>{{ row.name }} <span class="text-xs text-muted">{{ row.kind }}</span></span><span class="text-muted">{{ row.hits }}</span></li></ul>
</section>
<p class="flex flex-wrap items-center gap-2 text-sm">
<span class="text-muted">{{ t('Download') }}:</span>
<a v-for="(label, sheet) in exports" :key="sheet" :href="csv(String(sheet))" class="m-btn m-btn-secondary">{{ label }} (CSV)</a>
</p>
</template>