11<template >
22 <div class =" flex flex-col gap-10 overflow-x-hidden" :class =" { 'hidden': !maxNumCores }" >
33 <div >
4- <x-label class =" mb-4 text-neutral-300" >Resources </x-label >
4+ <x-label class =" mb-4 text-neutral-300" >Container </x-label >
55 <div class =" flex flex-col gap-4" >
6+ <!-- RAM Allocation -->
67 <x-card
78 class =" flex flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
89 <div >
2829 <p class =" text-neutral-100" >GB</p >
2930 </div >
3031 </x-card >
32+
33+ <!-- CPU Cores -->
3134 <x-card
3235 class =" flex flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
3336 <div >
5356 <p class =" text-neutral-100" >Cores</p >
5457 </div >
5558 </x-card >
59+
60+ <!-- Shared Home Folder -->
5661 <x-card class =" flex relative z-20 flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
5762 <div >
5863 <div class =" flex flex-row items-center gap-2 mb-2" >
7479 ></x-switch >
7580 </div >
7681 </x-card >
82+
83+ <!-- Auto Start Container -->
84+ <x-card class =" flex relative z-20 flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
85+ <div >
86+ <div class =" flex flex-row items-center gap-2 mb-2" >
87+ <Icon class =" text-violet-400 inline-flex size-8" icon =" clarity:power-solid" ></Icon >
88+ <h1 class =" text-lg my-0 font-semibold" >
89+ Auto Start Container
90+ </h1 >
91+ </div >
92+ <p class =" text-neutral-400 text-[0.9rem] !pt-0 !mt-0" >
93+ If enabled, the Windows container will automatically be started when the system boots up
94+ </p >
95+ </div >
96+ <div class =" flex flex-row justify-center items-center gap-2" >
97+ <x-switch
98+ :toggled =" autoStartContainer"
99+ @toggle =" (_: any) => autoStartContainer = !autoStartContainer"
100+ size =" large"
101+ ></x-switch >
102+ </div >
103+ </x-card >
104+
105+ <!-- FreeRDP Port -->
77106 <x-card
78107 class =" flex items-center p-2 flex-row justify-between w-full py-3 my-0 bg-neutral-800/20 backdrop-brightness-150 backdrop-blur-xl" >
79108 <div >
105134 </div >
106135 <x-button
107136 :disabled =" saveButtonDisabled || isUpdatingUSBPrerequisites"
108- @click =" applyChanges ()"
137+ @click =" saveDockerCompose ()"
109138 class =" w-24"
110139 >
111140 <span v-if =" !isApplyingChanges || isUpdatingUSBPrerequisites" >Save</span >
116145 <div v-show =" wbConfig.config.experimentalFeatures" :key =" rerenderExperimental" >
117146 <x-label class =" mb-4 text-neutral-300" >Devices</x-label >
118147 <div class =" flex flex-col gap-4" >
148+ <!-- USB Passthrough -->
119149 <x-card class =" flex relative z-20 flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
120150 <div class =" w-full" >
121151 <div class =" flex flex-row gap-2 items-center mb-2" >
227257 <div >
228258 <x-label class =" mb-4 text-neutral-300" >General</x-label >
229259 <div class =" flex flex-col gap-4" >
260+ <!-- Display Scaling -->
230261 <x-card
231262 class =" flex relative z-10 flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
232263 <div >
258289 </x-select >
259290 </div >
260291 </x-card >
292+
293+ <!-- Smartcard Passthrough -->
261294 <x-card
262295 class =" flex flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
263296 <div >
279312 ></x-switch >
280313 </div >
281314 </x-card >
315+
316+ <!-- RDP Monitoring -->
282317 <x-card
283318 class =" flex flex-row justify-between items-center p-2 py-3 my-0 w-full backdrop-blur-xl backdrop-brightness-150 bg-neutral-800/20" >
284319 <div >
305340
306341 <div >
307342 <x-label class =" mb-4 text-neutral-300" >WinBoat</x-label >
343+
344+ <!-- Experimental Features -->
308345 <x-card
309346 class =" flex items-center p-2 flex-row justify-between w-full py-3 my-0 bg-neutral-800/20 backdrop-brightness-150 backdrop-blur-xl" >
310347 <div >
@@ -367,7 +404,9 @@ import { type Device } from "usb";
367404import {
368405 RDP_PORT ,
369406 PORT_MAX ,
370- USB_VID_BLACKLIST
407+ USB_VID_BLACKLIST ,
408+ RESTART_ON_FAILURE ,
409+ RESTART_NO
371410} from ' ../lib/constants' ;
372411const { app }: typeof import (' @electron/remote' ) = require (' @electron/remote' );
373412
@@ -393,6 +432,8 @@ const origRamGB = ref(0);
393432const maxRamGB = ref (0 );
394433const origShareHomeFolder = ref (false );
395434const shareHomeFolder = ref (false );
435+ const origAutoStartContainer = ref (false );
436+ const autoStartContainer = ref (false );
396437const freerdpPort = ref (0 );
397438const origFreerdpPort = ref (0 );
398439const isApplyingChanges = ref (false );
@@ -413,6 +454,10 @@ onMounted(async () => {
413454 await assignValues ();
414455});
415456
457+ /**
458+ * Assigns the initial values from the Docker Compose file to the reactive refs
459+ * so we can display them and track when a change has been made
460+ */
416461async function assignValues() {
417462 compose .value = winboat .parseCompose ();
418463
@@ -425,6 +470,9 @@ async function assignValues() {
425470 shareHomeFolder .value = compose .value .services .windows .volumes .includes (HOMEFOLDER_SHARE_STR );
426471 origShareHomeFolder .value = shareHomeFolder .value ;
427472
473+ autoStartContainer .value = compose .value .services .windows .restart === RESTART_ON_FAILURE ;
474+ origAutoStartContainer .value = autoStartContainer .value ;
475+
428476 const rdpEntry = compose .value .services .windows .ports .find (x => x .includes (` :${RDP_PORT } ` ))
429477 freerdpPort .value = Number (rdpEntry ?.split (" :" )?.at (0 ) ?? RDP_PORT );
430478 origFreerdpPort .value = freerdpPort .value ;
@@ -436,6 +484,10 @@ async function assignValues() {
436484 refreshAvailableDevices ();
437485}
438486
487+ /**
488+ * Saves the currently specified values to the Docker Compose file
489+ * and then re-assigns the initial values to the reactive refs
490+ */
439491async function saveDockerCompose() {
440492 compose .value ! .services .windows .environment .RAM_SIZE = ` ${ramGB .value }G ` ;
441493 compose .value ! .services .windows .environment .CPU_CORES = ` ${numCores .value } ` ;
@@ -448,6 +500,8 @@ async function saveDockerCompose() {
448500 compose .value ! .services .windows .volumes = compose .value ! .services .windows .volumes .filter (v => v !== HOMEFOLDER_SHARE_STR );
449501 }
450502
503+ compose .value ! .services .windows .restart = autoStartContainer .value ? RESTART_ON_FAILURE : RESTART_NO ;
504+
451505 const newPortEntries = compose .value ! .services .windows .ports .filter (x => ! x .includes (` :${RDP_PORT } ` ));
452506
453507 newPortEntries .push (` ${freerdpPort .value }:${RDP_PORT }/tcp ` );
@@ -466,21 +520,10 @@ async function saveDockerCompose() {
466520 }
467521}
468522
469- async function applyChanges() {
470- compose .value ! .services .windows .environment .RAM_SIZE = ` ${ramGB .value }G ` ;
471- compose .value ! .services .windows .environment .CPU_CORES = ` ${numCores .value } ` ;
472-
473- const composeHasHomefolderShare = compose .value ! .services .windows .volumes .includes (HOMEFOLDER_SHARE_STR );
474-
475- if (shareHomeFolder .value && ! composeHasHomefolderShare ) {
476- compose .value ! .services .windows .volumes .push (HOMEFOLDER_SHARE_STR );
477- } else if (! shareHomeFolder .value && composeHasHomefolderShare ) {
478- compose .value ! .services .windows .volumes = compose .value ! .services .windows .volumes .filter (v => v !== HOMEFOLDER_SHARE_STR );
479- }
480-
481- await saveDockerCompose ();
482- }
483-
523+ /**
524+ * Adds the required fields for USB passthrough to work
525+ * to the Docker Compose file if they don't already exist
526+ */
484527async function addRequiredComposeFieldsUSB() {
485528 if (! usbPassthroughDisabled .value ) {
486529 return ;
@@ -551,7 +594,8 @@ const saveButtonDisabled = computed(() => {
551594 origNumCores .value !== numCores .value ||
552595 origRamGB .value !== ramGB .value ||
553596 shareHomeFolder .value !== origShareHomeFolder .value ||
554- freerdpPort .value !== origFreerdpPort .value ;
597+ freerdpPort .value !== origFreerdpPort .value ||
598+ autoStartContainer .value !== origAutoStartContainer .value ;
555599
556600 const shouldBeDisabled =
557601 errors .value .length ||
0 commit comments