|
|
|
@ -528,42 +528,6 @@ export default class DtpSiteAdminHostStatsApp extends DtpApp {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async submitImageForm (event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
|
|
const formElement = event.currentTarget || event.target;
|
|
|
|
|
const form = new FormData(formElement);
|
|
|
|
|
|
|
|
|
|
this.cropper.getCroppedCanvas().toBlob(async (imageData) => {
|
|
|
|
|
try {
|
|
|
|
|
form.append('imageFile', imageData, 'icon.png');
|
|
|
|
|
|
|
|
|
|
this.log.info('submitImageForm', 'updating site image', { event, action: formElement.action });
|
|
|
|
|
const response = await fetch(formElement.action, {
|
|
|
|
|
method: formElement.method,
|
|
|
|
|
body: form,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
let json;
|
|
|
|
|
try {
|
|
|
|
|
json = await response.json();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw new Error('Server error');
|
|
|
|
|
}
|
|
|
|
|
throw new Error(json.message || 'Server error');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.processResponse(response);
|
|
|
|
|
window.location.reload();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
UIkit.modal.alert(`Failed to update site image: ${error.message}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dtp.DtpSiteAdminHostStatsApp = DtpSiteAdminHostStatsApp;
|