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:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user