2022-02-01 18:43:52 +01:00
|
|
|
<script>
|
|
|
|
import { onMount } from "svelte";
|
2022-03-28 12:33:13 +02:00
|
|
|
import { formatDate } from "../util/Formatting.svelte";
|
2022-02-01 18:43:52 +01:00
|
|
|
import Spinner from "../util/Spinner.svelte";
|
|
|
|
|
|
|
|
let loading = false
|
2022-03-28 12:33:13 +02:00
|
|
|
|
|
|
|
let year = 0
|
|
|
|
let month = 0
|
|
|
|
let month_str = ""
|
|
|
|
let data = []
|
2022-02-01 18:43:52 +01:00
|
|
|
|
|
|
|
const load_activity = async () => {
|
|
|
|
loading = true
|
2022-03-28 12:33:13 +02:00
|
|
|
month_str = year + "-" + ("00"+(month)).slice(-2)
|
2022-02-01 18:43:52 +01:00
|
|
|
try {
|
2022-03-28 12:33:13 +02:00
|
|
|
const resp = await fetch(window.api_endpoint+"/user/activity/" + month_str)
|
|
|
|
if(resp.status >= 400) {
|
|
|
|
let json = await resp.json()
|
|
|
|
if (json.value === "authentication_failed") {
|
|
|
|
window.location = "/login"
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
throw new Error(json.message)
|
2022-02-01 18:43:52 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-28 12:33:13 +02:00
|
|
|
|
|
|
|
data = await resp.json()
|
2022-02-01 18:43:52 +01:00
|
|
|
} catch (err) {
|
|
|
|
alert(err)
|
|
|
|
} finally {
|
|
|
|
loading = false
|
|
|
|
}
|
|
|
|
};
|
2022-03-28 12:33:13 +02:00
|
|
|
const last_month = () => {
|
|
|
|
month--
|
|
|
|
if (month === 0) {
|
|
|
|
month = 12
|
|
|
|
year--
|
|
|
|
}
|
|
|
|
|
|
|
|
load_activity()
|
|
|
|
}
|
|
|
|
const next_month = () => {
|
|
|
|
month++
|
|
|
|
if (month === 13) {
|
|
|
|
month = 1
|
|
|
|
year++
|
|
|
|
}
|
|
|
|
|
|
|
|
load_activity()
|
|
|
|
}
|
2022-02-01 18:43:52 +01:00
|
|
|
onMount(() => {
|
2022-03-28 12:33:13 +02:00
|
|
|
let now = new Date()
|
|
|
|
year = now.getFullYear()
|
|
|
|
month = now.getMonth()+1
|
|
|
|
|
2022-02-01 18:43:52 +01:00
|
|
|
load_activity()
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if loading}
|
|
|
|
<div class="spinner_container">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<section>
|
|
|
|
<h2>Account activity log</h2>
|
|
|
|
<p>
|
|
|
|
Here you can see files that have recently expired or have been blocked
|
|
|
|
for breaking the content policy.
|
|
|
|
</p>
|
|
|
|
|
2022-03-28 12:33:13 +02:00
|
|
|
<h3>{month_str}</h3>
|
|
|
|
<div class="toolbar">
|
|
|
|
<button on:click={last_month}>
|
|
|
|
<i class="icon">chevron_left</i>
|
|
|
|
Previous month
|
|
|
|
</button>
|
|
|
|
<div class="toolbar_spacer"></div>
|
|
|
|
<button on:click={next_month}>
|
|
|
|
Next month
|
|
|
|
<i class="icon">chevron_right</i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2022-04-03 22:54:55 +02:00
|
|
|
<table style="text-align: left;">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td>Time</td>
|
|
|
|
<td>File name</td>
|
|
|
|
<td>Event</td>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{#each data as row}
|
2022-03-28 12:33:13 +02:00
|
|
|
<tr>
|
2022-04-03 22:54:55 +02:00
|
|
|
<td>
|
|
|
|
{formatDate(row.time, true, true, false)}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{#if row.event === "file_instance_blocked"}
|
|
|
|
<a href="/u/{row.file_id}">{row.file_name}</a>
|
|
|
|
{:else}
|
|
|
|
{row.file_name}
|
|
|
|
{/if}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{#if row.event === "file_instance_blocked"}
|
|
|
|
Blocked for abuse
|
|
|
|
{:else if row.event === "file_instance_expired"}
|
|
|
|
Expired
|
|
|
|
{/if}
|
|
|
|
</td>
|
2022-03-28 12:33:13 +02:00
|
|
|
</tr>
|
2022-04-03 22:54:55 +02:00
|
|
|
{/each}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2022-03-28 12:33:13 +02:00
|
|
|
|
|
|
|
{#if data.length > 100}
|
|
|
|
<div class="toolbar">
|
|
|
|
<button on:click={last_month}>
|
|
|
|
<i class="icon">chevron_left</i>
|
|
|
|
Previous month
|
|
|
|
</button>
|
|
|
|
<div class="toolbar_spacer"></div>
|
|
|
|
<button on:click={next_month}>
|
|
|
|
Next month
|
|
|
|
<i class="icon">chevron_right</i>
|
|
|
|
</button>
|
2022-02-01 18:43:52 +01:00
|
|
|
</div>
|
2022-03-28 12:33:13 +02:00
|
|
|
{/if}
|
2022-02-01 18:43:52 +01:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.spinner_container {
|
|
|
|
position: absolute;
|
|
|
|
top: 10px;
|
|
|
|
left: 10px;
|
|
|
|
height: 100px;
|
|
|
|
width: 100px;
|
|
|
|
z-index: 1000;
|
|
|
|
}
|
2022-03-28 12:33:13 +02:00
|
|
|
.toolbar {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
.toolbar > * { flex: 0 0 auto; }
|
|
|
|
.toolbar_spacer { flex: 1 1 auto; }
|
2022-02-01 18:43:52 +01:00
|
|
|
</style>
|