Introduce the "Reset disk" button

This commit is contained in:
Alessandro Pignotti 2024-10-18 12:12:41 +02:00
parent aa1935e389
commit 8055466b7a
4 changed files with 31 additions and 3 deletions

View file

@ -16,6 +16,7 @@ export default {
case '.fa-github:before':
case '.fa-star:before':
case '.fa-circle:before':
case '.fa-trash-can:before':
return false;
}
return true;

View file

@ -1,8 +1,32 @@
<script>
import PanelButton from './PanelButton.svelte';
import { createEventDispatcher } from 'svelte';
import { diskLatency } from './activities.js'
var dispatch = createEventDispatcher();
let state = "START";
function handleReset()
{
if(state == "START")
state = "CONFIRM";
else
dispatch('reset');
}
function getButtonText()
{
if(state == "START")
return "Reset disk";
else
return "Confirm?"
}
</script>
<h1 class="text-lg font-bold">Disk</h1>
<p><span class="font-bold">Backend latency: </span>{$diskLatency}ms</p>
<PanelButton buttonIcon="fa-solid fa-trash-can" clickHandler={handleReset} buttonText={getButtonText(state)} bgColor="bg-red-900" hoverColor="hover:bg-red-700">
</PanelButton>
{#if state == "CONFIRM"}
<p><span class="font-bold">Warning: </span>WebVM will reload</p>
{:else}
<p><span class="font-bold">Backend latency: </span>{$diskLatency}ms</p>
{/if}
<p>WebVM runs on top of a complete Linux distribution</p>
<p>Filesystems up to 2GB are supported and data is downloaded completely on-demand</p>
<p>The WebVM cloud backend uses WebSockets and a it's distributed via a global CDN to minimize download latency</p>

View file

@ -52,7 +52,7 @@
{:else if activeInfo === 'CPU'}
<CpuTab/>
{:else if activeInfo === 'Disk'}
<DiskTab/>
<DiskTab on:reset/>
{:else if activeInfo === 'Discord'}
<DiscordTab/>
{:else if activeInfo === 'GitHub'}

View file

@ -282,12 +282,15 @@
await cx.networkLogin();
w.location.href = await startLogin();
}
async function handleReset()
{
}
</script>
<main class="relative w-full h-full">
<Nav />
<div class="absolute top-10 bottom-0 left-0 right-0">
<SideBar on:connect={handleConnect}/>
<SideBar on:connect={handleConnect} on:reset={handleReset}/>
{#if configObj.needsDisplay}
<canvas class="absolute top-0 bottom-0 left-14 right-0" width="1024" height="768" id="display"></canvas>
{/if}