DiskTab.svelte 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <script>
  2. import PanelButton from './PanelButton.svelte';
  3. import { createEventDispatcher } from 'svelte';
  4. import { diskLatency } from './activities.js'
  5. var dispatch = createEventDispatcher();
  6. let state = "START";
  7. function handleReset()
  8. {
  9. if(state == "START")
  10. state = "CONFIRM";
  11. else if (state == "CONFIRM") {
  12. state = "RESETTING";
  13. dispatch('reset');
  14. }
  15. }
  16. function getButtonText(state)
  17. {
  18. if(state == "START")
  19. return "Reset disk";
  20. else if (state == "RESETTING")
  21. return "Resetting...";
  22. else
  23. return "Reset disk. Confirm?";
  24. }
  25. function getBgColor(state)
  26. {
  27. if(state == "START")
  28. {
  29. // Use default
  30. return undefined;
  31. }
  32. else
  33. {
  34. return "bg-red-900";
  35. }
  36. }
  37. function getHoverColor(state)
  38. {
  39. if(state == "START")
  40. {
  41. // Use default
  42. return undefined;
  43. }
  44. else
  45. {
  46. return "hover:bg-red-700";
  47. }
  48. }
  49. </script>
  50. <h1 class="text-lg font-bold">Disk</h1>
  51. <PanelButton buttonIcon="fa-solid fa-trash-can" clickHandler={handleReset} buttonText={getButtonText(state)} bgColor={getBgColor(state)} hoverColor={getHoverColor(state)}>
  52. </PanelButton>
  53. {#if state == "CONFIRM"}
  54. <p><span class="font-bold">Warning: </span>WebVM will reload</p>
  55. {:else if state == "RESETTING"}
  56. <p><span class="font-bold">Reset in progress: </span>Please wait...</p>
  57. {:else}
  58. <p><span class="font-bold">Backend latency: </span>{$diskLatency}ms</p>
  59. {/if}
  60. <p>WebVM runs on top of a complete Linux distribution</p>
  61. <p>Filesystems up to 2GB are supported and data is downloaded completely on-demand</p>
  62. <p>The WebVM cloud backend uses WebSockets and a it's distributed via a global CDN to minimize download latency</p>