Frontend: Add archive button to card view and improve upload dialog

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-06-09 15:56:47 +02:00
parent 57286b5587
commit fe0dc09b01
3 changed files with 36 additions and 29 deletions

View file

@ -173,10 +173,14 @@
<v-layout row wrap align-center>
<v-flex xs12>
<div class="text-xs-center">
<v-btn color="secondary-dark" small depressed dark @click.stop="photo.approve()"
class="action-approve text-xs-center">
<span>Approve</span>
</v-btn>
<v-btn color="secondary-dark" small flat dark @click.stop="photo.archive()"
class="action-approve text-xs-center">
<span>Archive</span>
</v-btn>
<v-btn color="secondary-dark" small depressed dark @click.stop="photo.approve()"
class="action-approve text-xs-center">
<span>Approve</span>
</v-btn>
</div>
</v-flex>
</v-layout>

View file

@ -157,21 +157,35 @@
uploadDialog() {
this.$refs.upload.click();
},
reset() {
this.busy = false;
this.selected = [];
this.uploads = [];
this.indexing = false;
this.failed = false;
this.current = 0;
this.total = 0;
this.completed = 0;
this.started = 0;
},
upload() {
this.selected = this.$refs.upload.files;
this.total = this.selected.length;
if(this.total < 1) {
return;
}
this.started = Date.now();
this.selected = this.$refs.upload.files;
this.total = this.selected.length;
this.busy = true;
this.indexing = false;
this.failed = false;
this.total = this.selected.length;
this.current = 0;
this.completed = 0;
this.uploads = [];
if (!this.total) {
return
}
Notify.info(this.$gettext("Uploading photos..."));
let addToAlbums = [];
@ -205,13 +219,8 @@
).then(() => {
ctx.completed = Math.round((ctx.current / ctx.total) * 100);
}).catch(() => {
ctx.busy = false;
ctx.indexing = false;
ctx.completed = 100;
ctx.failed = true;
Notify.error(ctx.$gettext("Upload failed"));
});
ctx.completed = Math.round((ctx.current / ctx.total) * 100);
})
}
}
@ -223,29 +232,19 @@
move: true,
albums: addToAlbums,
}).then(() => {
ctx.reset();
Notify.success(ctx.$gettext("Upload complete"));
ctx.busy = false;
ctx.indexing = false;
ctx.$emit('confirm');
}).catch(() => {
ctx.reset();
Notify.error(ctx.$gettext("Failure while importing uploaded files"));
ctx.busy = false;
ctx.indexing = false;
});
});
},
},
watch: {
show: function () {
this.selected = [];
this.uploads = [];
this.busy = false;
this.indexing = false;
this.failed = false;
this.current = 0;
this.total = 0;
this.completed = 0;
this.started = 0;
this.reset();
this.review = this.$config.feature("review");
this.safe = !this.$config.get("uploadNSFW");
this.findAlbums("");

View file

@ -412,6 +412,10 @@ export class Photo extends RestModel {
return "Unknown";
}
archive() {
return Api.post("batch/photos/archive", {"photos": [this.getId()]});
}
approve() {
return Api.post(this.getEntityResource() + "/approve");
}