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