mirror of
https://github.com/bellingcat/auto-archiver-setup-tool.git
synced 2026-06-13 05:58:37 +03:00
improves URL search/archive UI/UX
This commit is contained in:
@@ -343,6 +343,7 @@ export default createStore({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// add permissions
|
// add permissions
|
||||||
|
// TODO: make sure this emailAdress is used according to the group
|
||||||
await gapi.client.drive.permissions.create({
|
await gapi.client.drive.permissions.create({
|
||||||
fileId: spreadsheetId,
|
fileId: spreadsheetId,
|
||||||
resource: {
|
resource: {
|
||||||
|
|||||||
@@ -52,7 +52,15 @@
|
|||||||
<a :href="item.url" target="_blank" rel="noopener noreferrer">{{ item.url }}</a>
|
<a :href="item.url" target="_blank" rel="noopener noreferrer">{{ item.url }}</a>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:item.created_at="{ item }">
|
<template v-slot:item.created_at="{ item }">
|
||||||
<time :datetime="item?.created_at">{{ item?.created_at }}</time>
|
<time :datetime="item?.created_at"
|
||||||
|
:title="$moment(item?.created_at).format(`MMMM Do YYYY, k:mm:ss`)">{{
|
||||||
|
$moment(item?.created_at).fromNow() }}</time>
|
||||||
|
</template>
|
||||||
|
<template v-slot:item.store_until="{ item }">
|
||||||
|
<time :datetime="item?.store_until"
|
||||||
|
:title="`this archive will be deleted on: ${$moment(item?.store_until).format(`MMMM Do YYYY, k:mm:ss`)}`"
|
||||||
|
:style="{ color: $moment().diff(item?.store_until, 'days') > -31 ? 'red' : 'inherit' }">{{
|
||||||
|
item?.store_until ? $moment(item?.store_until).fromNow() : "never" }}</time>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:item.size="{ item }">
|
<template v-slot:item.size="{ item }">
|
||||||
{{ ((item?.result?.metadata?.total_bytes || 0) / (1024 * 1024)).toFixed(2) }}
|
{{ ((item?.result?.metadata?.total_bytes || 0) / (1024 * 1024)).toFixed(2) }}
|
||||||
@@ -123,7 +131,8 @@ export default {
|
|||||||
headers: [
|
headers: [
|
||||||
{ title: "URL", value: "url" },
|
{ title: "URL", value: "url" },
|
||||||
{ title: "Result", value: "result" },
|
{ title: "Result", value: "result" },
|
||||||
{ title: "Archived At", value: "created_at" },
|
{ title: "Archived", value: "created_at" },
|
||||||
|
{ title: "Deleted", value: "store_until", width: "150px" },
|
||||||
{ title: "Size (MB)", value: "size" },
|
{ title: "Size (MB)", value: "size" },
|
||||||
{ title: "Files", value: "files" },
|
{ title: "Files", value: "files" },
|
||||||
{ title: '', key: 'data-table-expand' },
|
{ title: '', key: 'data-table-expand' },
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<PermissionNeeded v-if="user && !featureEnabled" feature="Archive URL" />
|
<PermissionNeeded v-if="user && !featureEnabled" feature="Archive URL" />
|
||||||
<v-container class="pane" v-if="user?.active && featureEnabled">
|
<v-container class="pane" v-if="user?.active && featureEnabled">
|
||||||
<v-card :loading="loadingArchive">
|
<v-card>
|
||||||
<v-card-title class="text-center">
|
<v-card-title class="text-center">
|
||||||
Archive a single URL
|
Archive a single URL
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
@@ -30,11 +30,12 @@
|
|||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<p v-if="loadingArchive">
|
<p v-if="loadingArchive">
|
||||||
<v-progress-circular color="teal" indeterminate></v-progress-circular>
|
<v-progress-circular color="teal" indeterminate></v-progress-circular>
|
||||||
Archive in progress task id = <code>{{ taskId }}</code>
|
Archive in progress <span v-if="taskId">task id = <code>{{ taskId }}</code></span>
|
||||||
</p>
|
</p>
|
||||||
<v-alert color="success" icon="mdi-information" v-if="archiveResult">
|
<v-alert color="success" icon="mdi-information" v-if="archiveResult">
|
||||||
Archived successfully with id {{ taskId }} available <a :href="getUrlFromResult(archiveResult)"
|
Archived successfully with id {{ archiveResult.id }}
|
||||||
target="_blank">here</a>.
|
<span v-if="urlFromResult"> available <a :href="urlFromResult" target="_blank">here</a>.</span>
|
||||||
|
<span v-if="!urlFromResult">no archived content to show.</span>
|
||||||
</v-alert>
|
</v-alert>
|
||||||
<v-alert color="warning" icon="mdi-alert" v-if="archiveFailure">
|
<v-alert color="warning" icon="mdi-alert" v-if="archiveFailure">
|
||||||
Failure: {{ archiveFailure }}
|
Failure: {{ archiveFailure }}
|
||||||
@@ -115,8 +116,9 @@ export default {
|
|||||||
urlValidator() {
|
urlValidator() {
|
||||||
return urlValidator;
|
return urlValidator;
|
||||||
},
|
},
|
||||||
getUrlFromResult() {
|
urlFromResult() {
|
||||||
return getUrlFromResult;
|
if (!this.archiveResult) return null;
|
||||||
|
return getUrlFromResult(this.archiveResult);
|
||||||
},
|
},
|
||||||
validUrl() {
|
validUrl() {
|
||||||
return this.url && this.urlValidator(this.url) === true;
|
return this.url && this.urlValidator(this.url) === true;
|
||||||
@@ -156,6 +158,10 @@ export default {
|
|||||||
this.archiveResult = null;
|
this.archiveResult = null;
|
||||||
this.archiveFailure = null;
|
this.archiveFailure = null;
|
||||||
this.taskId = null;
|
this.taskId = null;
|
||||||
|
if (this.loadingArchive) {
|
||||||
|
this.loadingArchive = false;
|
||||||
|
this.showSnackbar("Your previous archive will run in the background.", "yellow");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -197,13 +203,15 @@ export default {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error("/archive ", error);
|
console.error("/archive ", error);
|
||||||
this.showSnackbar(`Unable to archive URL: ${error.message}`);
|
this.showSnackbar(`Unable to archive URL: ${error.message}`);
|
||||||
}).finally(() => {
|
|
||||||
this.loadingArchive = false;
|
this.loadingArchive = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
pollForArchiveResults() {
|
pollForArchiveResults() {
|
||||||
this.loadingArchive = true;
|
this.loadingArchive = true;
|
||||||
const poll = () => {
|
const poll = () => {
|
||||||
|
if (!this.loadingArchive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
fetch(`${this.$store.state.API_ENDPOINT}/task/${this.taskId}`, {
|
fetch(`${this.$store.state.API_ENDPOINT}/task/${this.taskId}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -216,8 +224,8 @@ export default {
|
|||||||
if (task.status === "SUCCESS") {
|
if (task.status === "SUCCESS") {
|
||||||
this.showSnackbar(`URL archived successfully with id ${task.result.id}!`, "green");
|
this.showSnackbar(`URL archived successfully with id ${task.result.id}!`, "green");
|
||||||
this.loadingArchive = false;
|
this.loadingArchive = false;
|
||||||
this.taskId = null;
|
|
||||||
this.archiveResult = task;
|
this.archiveResult = task;
|
||||||
|
this.taskId = task.id;
|
||||||
} else if (task.status === "FAILURE") {
|
} else if (task.status === "FAILURE") {
|
||||||
this.showSnackbar(`Failed to archive URL: ${task.result.error}`);
|
this.showSnackbar(`Failed to archive URL: ${task.result.error}`);
|
||||||
this.loadingArchive = false;
|
this.loadingArchive = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user