Skip to content

Commit 8776603

Browse files
LevevTibixDev
andauthored
chore: Add loading animation in place of novnc while the container is starting (#513)
chore: Refactor 'InstallStates' into enum Co-authored-by: Tibix <fuloptibi03@gmail.com>
1 parent 8d74e7f commit 8776603

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

src/renderer/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ onMounted(async () => {
202202
console.log("Not installed, redirecting to setup...");
203203
$router.push("/setup");
204204
}
205-
205+
206206
// Apply or remove disable-animations class based on config
207207
const updateAnimationClass = () => {
208208
if (wbConfig?.config.disableAnimations) {

src/renderer/lib/install.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@ const remote: typeof import("@electron/remote") = require("@electron/remote");
1414
const argon2: typeof import("argon2") = require("argon2");
1515
const logger = createLogger(path.join(WINBOAT_DIR, "install.log"));
1616

17-
export const InstallStates = {
18-
IDLE: "Preparing",
19-
CREATING_COMPOSE_FILE: "Creating Compose File",
20-
CREATING_OEM: "Creating OEM Assets",
21-
STARTING_CONTAINER: "Starting Container",
22-
MONITORING_PREINSTALL: "Monitoring Preinstall",
23-
INSTALLING_WINDOWS: "Installing Windows",
24-
COMPLETED: "Completed",
25-
INSTALL_ERROR: "Install Error",
26-
} as const;
27-
28-
export type InstallState = (typeof InstallStates)[keyof typeof InstallStates];
17+
export enum InstallStates {
18+
IDLE = "Preparing",
19+
CREATING_COMPOSE_FILE = "Creating Compose File",
20+
CREATING_OEM = "Creating OEM Assets",
21+
STARTING_CONTAINER = "Starting Container",
22+
MONITORING_PREINSTALL = "Monitoring Preinstall",
23+
INSTALLING_WINDOWS = "Installing Windows",
24+
COMPLETED = "Completed",
25+
INSTALL_ERROR = "Install Error",
26+
};
2927

3028
interface InstallEvents {
31-
stateChanged: (state: InstallState) => void;
29+
stateChanged: (state: InstallStates) => void;
3230
preinstallMsg: (msg: string) => void;
3331
error: (error: Error) => void;
3432
vncPortChanged: (port: number) => void;
@@ -37,7 +35,7 @@ interface InstallEvents {
3735
export class InstallManager {
3836
conf: InstallConfiguration;
3937
emitter: Emitter<InstallEvents>;
40-
state: InstallState;
38+
state: InstallStates;
4139
preinstallMsg: string;
4240
container: ContainerManager;
4341

@@ -49,7 +47,7 @@ export class InstallManager {
4947
this.container = createContainer(conf.container);
5048
}
5149

52-
changeState(newState: InstallState) {
50+
changeState(newState: InstallStates) {
5351
this.state = newState;
5452
this.emitter.emit("stateChanged", newState);
5553
logger.info(`New state: "${newState}"`);

src/renderer/views/SetupUI.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,19 @@
706706
<p class="text-lg text-gray-400 text-justify">
707707
WinBoat is now installing Windows. Please be patient as this may take up to an hour. In the
708708
meantime, you can grab a coffee and check the installation status
709-
<a :href="`http://127.0.0.1:${vncPort}`" @click="openAnchorLink">in your browser</a>.
709+
<span v-if="linkableInstallSteps.includes(installState)">
710+
<a :href="`http://127.0.0.1:${vncPort}`" @click="openAnchorLink">in your browser</a>.
711+
</span>
712+
<span v-else>
713+
over at
714+
<div
715+
style="animation-duration: 3s!important;"
716+
class="ml-1 inline-block relative text-transparent rounded-md bg-neutral-700 animate-pulse select-none"
717+
>
718+
in your browser
719+
<Icon icon="eos-icons:three-dots-loading" class="pointer-events-none absolute top-0 left-[50%] size-16 text-violet-400 -translate-x-[50%] -translate-y-[27.5%]"></Icon>
720+
</div>
721+
</span>
710722
</p>
711723

712724
<!-- Installing -->
@@ -777,7 +789,7 @@ import { computedAsync } from "@vueuse/core";
777789
import { InstallConfiguration, Specs } from "../../types";
778790
import { getSpecs, getMemoryInfo, defaultSpecs, satisfiesPrequisites, type MemoryInfo } from "../lib/specs";
779791
import { WINDOWS_VERSIONS, WINDOWS_LANGUAGES, type WindowsVersionKey } from "../lib/constants";
780-
import { InstallManager, type InstallState, InstallStates } from "../lib/install";
792+
import { InstallManager, InstallStates } from "../lib/install";
781793
import { openAnchorLink } from "../utils/openLink";
782794
import license from "../assets/LICENSE.txt?raw";
783795
import {
@@ -893,10 +905,12 @@ const username = ref("winboat");
893905
const password = ref("");
894906
const confirmPassword = ref("");
895907
const homeFolderSharing = ref(false);
896-
const installState = ref<InstallState>(InstallStates.IDLE);
908+
const installState = ref<InstallStates>(InstallStates.IDLE);
897909
const preinstallMsg = ref("");
898910
const containerRuntime = ref(ContainerRuntimes.DOCKER);
899911
const vncPort = ref(8006);
912+
// These are the install steps where the container is actually up and running
913+
const linkableInstallSteps = [ InstallStates.MONITORING_PREINSTALL, InstallStates.INSTALLING_WINDOWS, InstallStates.COMPLETED ];
900914
901915
let installManager: InstallManager | null;
902916

0 commit comments

Comments
 (0)