1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Thumbnails: Added OOM handling and regen endpoint

- Added some level of app out-of-memory handling so we can show a proper
  error message upon OOM events.
- Added endpoint and image-manager button/action for regenerating
  thumbnails for an image so they can be re-created upon failure.
This commit is contained in:
Dan Brown
2023-09-29 13:54:08 +01:00
parent cc0827ff28
commit 5af3041b9b
8 changed files with 138 additions and 0 deletions

View File

@ -90,6 +90,15 @@ export class ImageManager extends Component {
}
});
// Rebuild thumbs click
onChildEvent(this.formContainer, '#image-manager-rebuild-thumbs', 'click', async (_, button) => {
button.disabled = true;
if (this.lastSelected) {
await this.rebuildThumbnails(this.lastSelected.id);
}
button.disabled = false;
});
// Edit form submit
this.formContainer.addEventListener('ajax-form-success', () => {
this.refreshGallery();
@ -268,4 +277,14 @@ export class ImageManager extends Component {
return this.loadMore.querySelector('button') && !this.loadMore.hasAttribute('hidden');
}
async rebuildThumbnails(imageId) {
try {
const response = await window.$http.put(`/images/${imageId}/rebuild-thumbnails`);
window.$events.success(response.data);
this.refreshGallery();
} catch (err) {
window.$events.showResponseError(err);
}
}
}