Have got the processor plumbing working

This commit is contained in:
Leon Mika 2026-03-26 21:16:50 +11:00
parent 036b683eab
commit 599c72d465
11 changed files with 185 additions and 39 deletions

View file

@ -47,6 +47,13 @@ export default class UploadEditController extends Controller {
this._createSession();
}
async addProcessor(ev) {
ev.preventDefault();
await this._addProcessor({
type: "shadow"
});
}
_rebuildProcessList() {
let el = this.processListTarget;
@ -66,6 +73,10 @@ export default class UploadEditController extends Controller {
try {
let resp = await fetch(`/sites/${this.siteIdValue}/imageedit/`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"base_upload": this.uploadIdValue,
})
@ -79,4 +90,22 @@ export default class UploadEditController extends Controller {
console.error(e);
}
}
async _addProcessor(processor) {
try {
let resp = await fetch(`/sites/${this.siteIdValue}/imageedit/${this._state.session.guid}/processors`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(processor)
});
this._state = await resp.json();
this.previewTarget.src = this._state.preview_url;
} catch (e) {
console.error(e);
}
}
}