Add date picker and different report types
This commit is contained in:
@@ -502,7 +502,8 @@ textarea,
|
|||||||
input[type="text"],
|
input[type="text"],
|
||||||
input[type="password"],
|
input[type="password"],
|
||||||
input[type="email"],
|
input[type="email"],
|
||||||
input[type="number"]{
|
input[type="number"],
|
||||||
|
input[type="date"]{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 3px; /* Same as button, to make them align nicely */
|
margin: 3px; /* Same as button, to make them align nicely */
|
||||||
border: none;
|
border: none;
|
||||||
@@ -521,11 +522,13 @@ input[type="text"]:active,
|
|||||||
input[type="password"]:active,
|
input[type="password"]:active,
|
||||||
input[type="email"]:active,
|
input[type="email"]:active,
|
||||||
input[type="number"]:active,
|
input[type="number"]:active,
|
||||||
|
input[type="date"]:active,
|
||||||
textarea:focus,
|
textarea:focus,
|
||||||
input[type="text"]:focus,
|
input[type="text"]:focus,
|
||||||
input[type="password"]:focus,
|
input[type="password"]:focus,
|
||||||
input[type="email"]:focus,
|
input[type="email"]:focus,
|
||||||
input[type="number"]:focus{
|
input[type="number"]:focus,
|
||||||
|
input[type="date"]:focus{
|
||||||
box-shadow: var(--highlight_border), inset 3px 3px 6px -3px var(--shadow_color);
|
box-shadow: var(--highlight_border), inset 3px 3px 6px -3px var(--shadow_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
Block files
|
Block files
|
||||||
</a>
|
</a>
|
||||||
<a class="button" href="/admin/abuse_reports">
|
<a class="button" href="/admin/abuse_reports">
|
||||||
<i class="icon">report</i>
|
<i class="icon">flag</i>
|
||||||
User abuse reports
|
User abuse reports
|
||||||
</a>
|
</a>
|
||||||
<a class="button" href="/admin/abuse_reporters">
|
<a class="button" href="/admin/abuse_reporters">
|
||||||
|
@@ -7,17 +7,11 @@ let dispatch = createEventDispatcher()
|
|||||||
export let report
|
export let report
|
||||||
let expandable
|
let expandable
|
||||||
|
|
||||||
let grant = () => {
|
let set_status = async (action, report_type) => {
|
||||||
set_status("grant")
|
|
||||||
}
|
|
||||||
let reject = () => {
|
|
||||||
set_status("reject")
|
|
||||||
}
|
|
||||||
let set_status = async (action) => {
|
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append("action", action)
|
form.append("action", action)
|
||||||
if (action === "grant") {
|
if (action === "grant") {
|
||||||
form.append("type", report.type)
|
form.append("type", report_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -44,7 +38,9 @@ let set_status = async (action) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="title">{report.file.name}</div>
|
<div class="title">{report.file.name}</div>
|
||||||
<div class="stats">Type<br/>{report.type}</div>
|
<div class="stats">Type<br/>
|
||||||
|
{report.file.abuse_type === "" ? report.type : report.file.abuse_type}
|
||||||
|
</div>
|
||||||
{#if report.status !== "pending"}
|
{#if report.status !== "pending"}
|
||||||
<div class="stats">Status<br/>{report.status}</div>
|
<div class="stats">Status<br/>{report.status}</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -53,12 +49,24 @@ let set_status = async (action) => {
|
|||||||
<div class="stats">DL<br/>{Math.round(report.file.bandwidth_used / report.file.size)}</div>
|
<div class="stats">DL<br/>{Math.round(report.file.bandwidth_used / report.file.size)}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<div style="text-align: center;">
|
<div class="toolbar">
|
||||||
|
<div style="flex: 1 1 auto">
|
||||||
<a class="button" target="_blank" href={"/u/"+report.file.id}>
|
<a class="button" target="_blank" href={"/u/"+report.file.id}>
|
||||||
<i class="icon">open_in_new</i> Open file
|
<i class="icon">open_in_new</i> Open file
|
||||||
</a>
|
</a>
|
||||||
<button on:click={grant}><i class="icon">done</i> Grant (block file)</button>
|
<button class="button_highlight" on:click={() => {set_status("grant", report.type)}}>
|
||||||
<button on:click={reject}><i class="icon">delete</i> Ignore reports</button>
|
<i class="icon">done</i> Block ({report.type})
|
||||||
|
</button>
|
||||||
|
<button class="button_red" on:click={() => {set_status("reject", "")}}>
|
||||||
|
<i class="icon">delete</i> Ignore
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div style="flex: 0 1 auto">
|
||||||
|
<button on:click={() => {set_status("grant", "terrorism")}}>terrorism</button>
|
||||||
|
<button on:click={() => {set_status("grant", "gore")}}>gore</button>
|
||||||
|
<button on:click={() => {set_status("grant", "child_abuse")}}>child_abuse</button>
|
||||||
|
<button on:click={() => {set_status("grant", "malware")}}>malware</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -83,6 +91,7 @@ let set_status = async (action) => {
|
|||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
line-height: 1.2em;
|
||||||
}
|
}
|
||||||
.icon_cell {
|
.icon_cell {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
@@ -96,13 +105,16 @@ let set_status = async (action) => {
|
|||||||
.stats {
|
.stats {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
padding: 3px 4px;
|
padding: 3px 4px;
|
||||||
line-height: 1.2em;
|
|
||||||
border-left: 1px solid var(--layer_3_color_border);
|
border-left: 1px solid var(--layer_3_color_border);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.details {
|
.details {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
.toolbar {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
.file_icon {
|
.file_icon {
|
||||||
width:48px;
|
width:48px;
|
||||||
height:48px;
|
height:48px;
|
||||||
|
@@ -6,25 +6,26 @@ import AbuseReport from "./AbuseReport.svelte";
|
|||||||
let loading = true
|
let loading = true
|
||||||
let reports = []
|
let reports = []
|
||||||
|
|
||||||
|
let startPicker
|
||||||
|
let endPicker
|
||||||
|
|
||||||
|
|
||||||
const get_reports = async () => {
|
const get_reports = async () => {
|
||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
let today = new Date()
|
|
||||||
let start = new Date()
|
|
||||||
start.setMonth(start.getMonth() - 1)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(
|
const resp = await fetch(
|
||||||
window.api_endpoint+
|
window.api_endpoint+
|
||||||
"/admin/abuse_report?start="+
|
"/admin/abuse_report"+
|
||||||
start.toISOString()+
|
"?start="+(new Date(startPicker.value)).toISOString()+
|
||||||
"&end="+today.toISOString()
|
"&end="+(new Date(endPicker.value)).toISOString()
|
||||||
);
|
);
|
||||||
if(resp.status >= 400) {
|
if(resp.status >= 400) {
|
||||||
throw new Error(resp.text());
|
throw new Error(resp.text());
|
||||||
}
|
}
|
||||||
reports = await resp.json();
|
reports = await resp.json();
|
||||||
|
|
||||||
|
// Sort files from new to old
|
||||||
reports.sort((a, b) => {
|
reports.sort((a, b) => {
|
||||||
if (a.first_report_time > b.first_report_time) {
|
if (a.first_report_time > b.first_report_time) {
|
||||||
return -1
|
return -1
|
||||||
@@ -34,6 +35,8 @@ const get_reports = async () => {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Sort individual reports from old to new
|
||||||
reports.forEach(v => {
|
reports.forEach(v => {
|
||||||
v.reports.sort((a, b) => {
|
v.reports.sort((a, b) => {
|
||||||
if (a.time > b.time) {
|
if (a.time > b.time) {
|
||||||
@@ -52,7 +55,16 @@ const get_reports = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(get_reports);
|
onMount(() => {
|
||||||
|
let start = new Date()
|
||||||
|
start.setMonth(start.getMonth() - 1)
|
||||||
|
let end = new Date()
|
||||||
|
|
||||||
|
startPicker.valueAsNumber = start.getTime()
|
||||||
|
endPicker.valueAsNumber = end.getTime()
|
||||||
|
|
||||||
|
get_reports()
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -68,11 +80,13 @@ onMount(get_reports);
|
|||||||
<i class="icon">arrow_back</i> Return to admin panel
|
<i class="icon">arrow_back</i> Return to admin panel
|
||||||
</a>
|
</a>
|
||||||
<div class="toolbar_spacer"></div>
|
<div class="toolbar_spacer"></div>
|
||||||
|
<div>
|
||||||
|
Start: <input type="date" bind:this={startPicker}/>
|
||||||
|
End: <input type="date" bind:this={endPicker}/>
|
||||||
|
</div>
|
||||||
<button on:click={get_reports}><i class="icon">refresh</i></button>
|
<button on:click={get_reports}><i class="icon">refresh</i></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<h2>Pending</h2>
|
<h2>Pending</h2>
|
||||||
{#each reports as report}
|
{#each reports as report}
|
||||||
{#if report.status === "pending"}
|
{#if report.status === "pending"}
|
||||||
|
Reference in New Issue
Block a user