Have got session creation working
This commit is contained in:
parent
18f9f49c0a
commit
036b683eab
10 changed files with 438 additions and 3 deletions
|
|
@ -36,10 +36,15 @@ const processors = [
|
|||
];
|
||||
|
||||
export default class UploadEditController extends Controller {
|
||||
static targets = ['processList'];
|
||||
static targets = ['processList', 'preview'];
|
||||
static values = {
|
||||
uploadId: Number,
|
||||
siteId: Number,
|
||||
};
|
||||
|
||||
connect() {
|
||||
this._rebuildProcessList();
|
||||
this._createSession();
|
||||
}
|
||||
|
||||
_rebuildProcessList() {
|
||||
|
|
@ -56,4 +61,22 @@ export default class UploadEditController extends Controller {
|
|||
el.innerHTML = cardOuter;
|
||||
// END TEMP
|
||||
}
|
||||
|
||||
async _createSession() {
|
||||
try {
|
||||
let resp = await fetch(`/sites/${this.siteIdValue}/imageedit/`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
"base_upload": this.uploadIdValue,
|
||||
})
|
||||
});
|
||||
|
||||
this._state = await resp.json();
|
||||
this.previewTarget.src = this._state.preview_url;
|
||||
|
||||
console.log("Session created");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue