fix: show rollback button loading

This commit is contained in:
Andras Bacsai 2022-11-10 15:43:28 +01:00
parent c6a2e3e328
commit 3c94723b23

View File

@ -46,7 +46,8 @@
save: false, save: false,
remove: false, remove: false,
proxyMigration: false, proxyMigration: false,
restart: false restart: false,
rollback: false
}; };
let rollbackVersion = localStorage.getItem('lastVersion'); let rollbackVersion = localStorage.getItem('lastVersion');
@ -55,14 +56,20 @@
const sure = confirm(`Are you sure you want rollback Coolify to ${rollbackVersion}?`); const sure = confirm(`Are you sure you want rollback Coolify to ${rollbackVersion}?`);
if (sure) { if (sure) {
try { try {
loading.rollback = true;
console.log('loading.rollback', loading.rollback);
if (dev) { if (dev) {
console.log('rolling back to', rollbackVersion); console.log('rolling back to', rollbackVersion);
await asyncSleep(4000); await asyncSleep(4000);
return window.location.reload(); return window.location.reload();
} else { } else {
addToast({
message: 'Rollback started...',
type: 'success'
});
await post(`/update`, { type: 'update', latestVersion: rollbackVersion }); await post(`/update`, { type: 'update', latestVersion: rollbackVersion });
addToast({ addToast({
message: 'Update completed.<br><br>Waiting for the new version to start...', message: 'Rollback completed.<br><br>Waiting for the new version to start...',
type: 'success' type: 'success'
}); });
@ -89,7 +96,7 @@
} catch (error) { } catch (error) {
return errorNotification(error); return errorNotification(error);
} finally { } finally {
loading.remove = false; loading.rollback = false;
} }
} }
} }
@ -374,8 +381,11 @@
name="rollbackVersion" name="rollbackVersion"
id="rollbackVersion" id="rollbackVersion"
/> />
<button class="btn btn-primary ml-2" disabled={!rollbackVersion} on:click|preventDefault|stopPropagation={rollback} <button
>Rollback</button class:loading={loading.rollback}
class="btn btn-primary ml-2"
disabled={!rollbackVersion || loading.rollback}
on:click|preventDefault|stopPropagation={rollback}>Rollback</button
> >
</div> </div>
<div class="grid grid-cols-2 items-center"> <div class="grid grid-cols-2 items-center">