Upload: Publish photos.created event
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
4ef19bb671
commit
f57c6688a5
|
@ -3,7 +3,7 @@
|
|||
v-model="show" persistent class="p-upload-dialog" @keydown.esc="cancel">
|
||||
<v-card color="application">
|
||||
<v-toolbar dark color="navigation">
|
||||
<v-btn icon dark @click.stop="cancel" :disabled="busy">
|
||||
<v-btn icon dark @click.stop="cancel">
|
||||
<v-icon>close</v-icon>
|
||||
</v-btn>
|
||||
<v-toolbar-title><translate>Upload</translate></v-toolbar-title>
|
||||
|
@ -74,9 +74,19 @@
|
|||
},
|
||||
methods: {
|
||||
cancel() {
|
||||
if(this.busy) {
|
||||
Notify.info(this.$gettext("Uploading photos..."));
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit('cancel');
|
||||
},
|
||||
confirm() {
|
||||
if(this.busy) {
|
||||
Notify.info(this.$gettext("Uploading photos..."));
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit('confirm');
|
||||
},
|
||||
submit() {
|
||||
|
@ -101,7 +111,6 @@
|
|||
}
|
||||
|
||||
Notify.info(this.$gettext("Uploading photos..."));
|
||||
Notify.blockUI();
|
||||
|
||||
async function performUpload(ctx) {
|
||||
for (let i = 0; i < ctx.selected.length; i++) {
|
||||
|
@ -126,7 +135,7 @@
|
|||
ctx.indexing = false;
|
||||
ctx.completed = 100;
|
||||
ctx.failed = true;
|
||||
Notify.unblockUI();
|
||||
|
||||
throw Error("upload failed");
|
||||
});
|
||||
}
|
||||
|
@ -139,13 +148,11 @@
|
|||
Api.post('import/upload/' + this.started, {
|
||||
move: true,
|
||||
}).then(() => {
|
||||
Notify.unblockUI();
|
||||
Notify.success(ctx.$gettext("Upload complete"));
|
||||
ctx.busy = false;
|
||||
ctx.indexing = false;
|
||||
ctx.$emit('confirm');
|
||||
}).catch(() => {
|
||||
Notify.unblockUI();
|
||||
Notify.error(ctx.$gettext("Failure while importing uploaded files"));
|
||||
ctx.busy = false;
|
||||
ctx.indexing = false;
|
||||
|
|
|
@ -264,17 +264,7 @@
|
|||
onImportCompleted() {
|
||||
if (!this.listen) return;
|
||||
|
||||
this.dirty = true;
|
||||
|
||||
if (this.selection.length === 0 && this.offset < 1) {
|
||||
this.refresh();
|
||||
}
|
||||
},
|
||||
onCount() {
|
||||
if (!this.listen) return;
|
||||
|
||||
this.dirty = true;
|
||||
this.scrollDisabled = false;
|
||||
this.loadMore();
|
||||
},
|
||||
onUpdate(ev, data) {
|
||||
if (!this.listen) return;
|
||||
|
@ -325,6 +315,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'created':
|
||||
this.dirty = true;
|
||||
this.scrollDisabled = false;
|
||||
|
||||
break;
|
||||
default:
|
||||
console.warn("unexpected event type", ev);
|
||||
|
@ -335,7 +330,6 @@
|
|||
this.search();
|
||||
|
||||
this.subscriptions.push(Event.subscribe("import.completed", (ev, data) => this.onImportCompleted(ev, data)));
|
||||
this.subscriptions.push(Event.subscribe("count.photos", (ev, data) => this.onCount(ev, data)));
|
||||
this.subscriptions.push(Event.subscribe("photos", (ev, data) => this.onUpdate(ev, data)));
|
||||
},
|
||||
destroyed() {
|
||||
|
|
|
@ -212,16 +212,18 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) I
|
|||
return indexResultFailed
|
||||
}
|
||||
} else {
|
||||
event.Publish("count.photos", event.Data{
|
||||
"count": 1,
|
||||
})
|
||||
|
||||
photo.PhotoFavorite = false
|
||||
|
||||
if err := ind.db.Create(&photo).Error; err != nil {
|
||||
log.Errorf("index: %s", err)
|
||||
return indexResultFailed
|
||||
}
|
||||
|
||||
event.Publish("count.photos", event.Data{
|
||||
"count": 1,
|
||||
})
|
||||
|
||||
event.EntitiesCreated("photos", []entity.Photo{photo})
|
||||
}
|
||||
|
||||
if len(labels) > 0 {
|
||||
|
|
Loading…
Reference in a new issue