Files
fnx_web/svelte/src/user_home/ActivityLog.svelte

145 lines
2.8 KiB
Svelte
Raw Normal View History

2022-02-01 18:43:52 +01:00
<script>
import { onMount } from "svelte";
import { formatDate } from "util/Formatting";
import LoadingIndicator from "util/LoadingIndicator.svelte";
2022-02-01 18:43:52 +01:00
let loading = false
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
month_str = year + "-" + ("00"+(month)).slice(-2)
2022-02-01 18:43:52 +01:00
try {
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
}
}
data = await resp.json()
2022-02-01 18:43:52 +01:00
} catch (err) {
alert(err)
} finally {
loading = false
}
};
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(() => {
let now = new Date()
year = now.getFullYear()
month = now.getMonth()+1
2022-02-01 18:43:52 +01:00
load_activity()
})
</script>
2022-04-26 15:23:57 +02:00
<LoadingIndicator loading={loading}/>
2022-02-01 18:43:52 +01:00
<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>
<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}
<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>
2024-05-17 16:32:53 +02:00
{:else if row.event === "filesystem_node_blocked"}
<a href="/d/{row.file_id}">{row.file_name}</a>
2022-04-03 22:54:55 +02:00
{:else}
{row.file_name}
{/if}
</td>
<td>
2024-05-17 16:32:53 +02:00
{#if row.event === "file_instance_blocked" || row.event === "filesystem_node_blocked"}
2022-04-03 22:54:55 +02:00
Blocked for abuse
{:else if row.event === "file_instance_expired"}
Expired
2022-09-27 10:31:59 +02:00
{:else if row.event === "file_instance_lost"}
File has been lost
2022-04-03 22:54:55 +02:00
{/if}
</td>
</tr>
2022-04-03 22:54:55 +02:00
{/each}
</tbody>
</table>
{#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>
{/if}
2022-02-01 18:43:52 +01:00
</section>
<style>
.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>