2021-10-04 13:03:26 +10:30
|
|
|
{{ define "content" }}
|
|
|
|
|
2021-11-06 22:56:27 +10:30
|
|
|
<main role="main" x-data="uploads()" x-init="get_uploads();" class="inner DAU">
|
2021-06-08 22:20:11 +09:30
|
|
|
<h1 class="DAU-heading">Uploads</h1>
|
|
|
|
<p class="lead">Discord-auto-upload uploads</p>
|
|
|
|
|
2021-11-06 22:56:27 +10:30
|
|
|
<h2>Pending uploads</h2>
|
|
|
|
|
2021-06-08 22:20:11 +09:30
|
|
|
<table class="table table-condensed table-dark">
|
|
|
|
<thead>
|
2021-11-06 22:56:27 +10:30
|
|
|
<tr>
|
|
|
|
<th>filename</th>
|
|
|
|
<th>actions</th>
|
2021-11-07 13:25:18 +10:30
|
|
|
<th> </th>
|
2021-11-06 22:56:27 +10:30
|
|
|
</tr>
|
2021-06-08 22:20:11 +09:30
|
|
|
</thead>
|
2021-11-06 22:56:27 +10:30
|
|
|
<tbody>
|
|
|
|
<template x-for="ul in pending">
|
|
|
|
<tr>
|
|
|
|
<td x-text="ul.original_file"></td>
|
|
|
|
<td>
|
|
|
|
<button @click="start_upload(ul.id)" type="button" class="btn btn-primary">upload</button>
|
|
|
|
<button @click="skip_upload(ul.id)" type="button" class="btn btn-primary">reject</button>
|
|
|
|
</td>
|
2021-11-08 09:11:46 +10:30
|
|
|
<td>
|
2021-12-29 21:47:57 +10:30
|
|
|
<a x-bind:href="'/editor.html?id='+ul.id"><img x-bind:src="'/rest/image/'+ul.id+'/thumb'"></a>
|
|
|
|
<a x-show="ul.markedup_file" x-bind:href="'/editor.html?id='+ul.id"><img x-bind:src="'/rest/image/'+ul.id+'/markedup_thumb'"></a>
|
2021-11-08 09:11:46 +10:30
|
|
|
</td>
|
2021-11-06 22:56:27 +10:30
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<h2>Current uploads</h2>
|
|
|
|
|
|
|
|
<table class="table table-condensed table-dark">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>filename</th>
|
2022-12-05 22:01:52 +10:30
|
|
|
<th>state</th>
|
2021-11-07 13:25:18 +10:30
|
|
|
<th> </th>
|
2021-11-06 22:56:27 +10:30
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
|
|
|
|
<template x-for="ul in uploads">
|
|
|
|
<tr>
|
|
|
|
<td x-text="ul.original_file"></td>
|
2022-12-05 22:01:52 +10:30
|
|
|
<td>
|
|
|
|
<span x-text="ul.state"></span>
|
|
|
|
<div x-if="ul.state_reason">(<span x-text="ul.state_reason"></span>)</div>
|
|
|
|
</td>
|
|
|
|
|
2021-11-08 09:11:46 +10:30
|
|
|
<td>
|
|
|
|
<img :src="'/rest/image/'+ul.id+'/thumb'">
|
|
|
|
</td>
|
2021-11-06 22:56:27 +10:30
|
|
|
</tr>
|
|
|
|
</template>
|
2021-06-08 22:20:11 +09:30
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2021-11-06 22:56:27 +10:30
|
|
|
|
|
|
|
<h2>Completed uploads</h2>
|
|
|
|
|
|
|
|
<table class="table table-condensed table-dark">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>filename</th>
|
|
|
|
<th>state</th>
|
2021-11-07 13:25:18 +10:30
|
|
|
<th> </th>
|
2021-11-06 22:56:27 +10:30
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
|
|
|
|
<template x-for="ul in finished">
|
|
|
|
<tr>
|
|
|
|
<td x-text="ul.original_file"></td>
|
2022-12-05 22:01:52 +10:30
|
|
|
<td>
|
|
|
|
<span x-text="ul.state"></span>
|
|
|
|
<div x-if="ul.state_reason">(<span x-text="ul.state_reason"></span>)</div>
|
|
|
|
</td>
|
2021-11-08 09:11:46 +10:30
|
|
|
<td>
|
|
|
|
<img :src="'/rest/image/'+ul.id+'/thumb'">
|
|
|
|
</td>
|
2021-11-06 22:56:27 +10:30
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
2021-06-08 22:20:11 +09:30
|
|
|
</main>
|
|
|
|
|
2021-10-04 13:03:26 +10:30
|
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ define "js" }}
|
2021-06-08 22:20:11 +09:30
|
|
|
<script>
|
2021-11-06 22:56:27 +10:30
|
|
|
function uploads() {
|
|
|
|
return {
|
|
|
|
pending: [], uploads: [], finished: [],
|
|
|
|
start_upload(id) {
|
|
|
|
console.log(id);
|
|
|
|
fetch('/rest/upload/'+id+'/start', {method: 'POST'})
|
|
|
|
.then(response => response.json()) // convert to json
|
|
|
|
.then(json => {
|
|
|
|
console.log(json);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
skip_upload(id) {
|
|
|
|
console.log(id);
|
|
|
|
fetch('/rest/upload/'+id+'/skip', {method: 'POST'})
|
|
|
|
.then(response => response.json()) // convert to json
|
|
|
|
.then(json => {
|
|
|
|
console.log(json);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
get_uploads() {
|
|
|
|
fetch('/rest/uploads')
|
|
|
|
.then(response => response.json()) // convert to json
|
|
|
|
.then(json => {
|
|
|
|
this.pending = [];
|
|
|
|
this.uploads = [];
|
|
|
|
this.finished = [];
|
|
|
|
json.forEach(ul => {
|
|
|
|
if (ul.state == 'Pending') {
|
|
|
|
this.pending.push(ul);
|
|
|
|
}
|
|
|
|
else if (ul.state == 'Complete' || ul.state == 'Failed' || ul.state == 'Skipped') {
|
|
|
|
this.finished.push(ul)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.uploads.push(ul);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.config = json;
|
|
|
|
console.log(json);
|
|
|
|
let self = this;
|
|
|
|
setTimeout(function() { self.get_uploads(); } , 1000);
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-06-08 22:20:11 +09:30
|
|
|
|
|
|
|
</script>
|
2021-10-04 13:03:26 +10:30
|
|
|
{{ end }}
|