-
Notifications
You must be signed in to change notification settings - Fork 2
feat(ui): Add setup wizard and improve initial load experience #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| VITE_API_URL=http://localhost:8080 | ||
| # FlatRun UI Environment Variables | ||
| # Copy this file to .env.local and adjust values for your environment. | ||
| # .env.local is gitignored and will not be committed. | ||
|
|
||
| # API base URL — defaults to "/api" (works with nginx proxy in production) | ||
| # For local development, point to the agent directly: | ||
| VITE_API_URL=http://localhost:8090/api |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| import { defineStore } from "pinia"; | ||
| import { ref } from "vue"; | ||
| import { apiClient } from "@/services/api"; | ||
|
|
||
| export interface SetupCheck { | ||
| name: string; | ||
| status: "pass" | "fail" | "warn"; | ||
| message: string; | ||
| required: boolean; | ||
| } | ||
|
|
||
| export interface DNSResult { | ||
| valid: boolean; | ||
| domain: string; | ||
| expected: string; | ||
| actual: string[]; | ||
| message?: string; | ||
| } | ||
|
|
||
| export interface AuthResult { | ||
| auth_method: string; | ||
| username?: string; | ||
| user_uid?: string; | ||
| api_key?: string; | ||
| api_key_id?: string; | ||
| } | ||
|
|
||
| export const useSetupStore = defineStore("setup", () => { | ||
| const initialized = ref<boolean | null>(null); | ||
| const instanceIp = ref(""); | ||
| const agentVersion = ref(""); | ||
| const loading = ref(false); | ||
| const error = ref(""); | ||
|
|
||
| async function checkSetupStatus(force = false) { | ||
| if (!force && initialized.value !== null) return; | ||
| try { | ||
| const { data } = await apiClient.get("/setup/status"); | ||
| initialized.value = data.initialized; | ||
| } catch (e: any) { | ||
nfebe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (e.code === "ERR_NETWORK") { | ||
| error.value = "Unable to reach FlatRun Agent. Is the service running?"; | ||
| } else { | ||
| error.value = e.response?.data?.error || "Failed to check setup status"; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const infoLoaded = ref(false); | ||
|
|
||
| async function fetchSetupInfo() { | ||
nfebe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| try { | ||
| const { data } = await apiClient.get("/setup/info"); | ||
| instanceIp.value = data.instance_ip || "Unknown"; | ||
| agentVersion.value = | ||
| typeof data.agent_version === "object" ? data.agent_version.version : data.agent_version || "Unknown"; | ||
| } catch { | ||
| // non-critical, setup wizard still works without it | ||
| } finally { | ||
| infoLoaded.value = true; | ||
| } | ||
| } | ||
|
|
||
| async function runValidation(): Promise<SetupCheck[]> { | ||
| loading.value = true; | ||
| error.value = ""; | ||
| try { | ||
| const { data } = await apiClient.post("/setup/validate"); | ||
| return data.checks || []; | ||
| } catch (e: any) { | ||
| error.value = e.response?.data?.error || "Validation failed"; | ||
| return []; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
| } | ||
|
|
||
| async function verifyDNS(domain: string): Promise<DNSResult | null> { | ||
| loading.value = true; | ||
| error.value = ""; | ||
| try { | ||
| const { data } = await apiClient.get("/setup/verify-dns", { params: { domain } }); | ||
| return data; | ||
| } catch (e: any) { | ||
| error.value = e.response?.data?.error || "DNS verification failed"; | ||
| return null; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
| } | ||
|
|
||
| async function saveSettings(payload: { domain?: string; auto_ssl?: boolean; cors_origins?: string[] }) { | ||
| loading.value = true; | ||
| error.value = ""; | ||
| try { | ||
| const { data } = await apiClient.post("/setup/settings", payload); | ||
| return data; | ||
| } catch (e: any) { | ||
| error.value = e.response?.data?.error || "Failed to save settings"; | ||
| return null; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
| } | ||
|
|
||
| async function configureAuth(payload: { | ||
| auth_method: string; | ||
| username?: string; | ||
| password?: string; | ||
| email?: string; | ||
| }): Promise<AuthResult | null> { | ||
| loading.value = true; | ||
| error.value = ""; | ||
| try { | ||
| const { data } = await apiClient.post("/setup/authentication", payload); | ||
| return data; | ||
| } catch (e: any) { | ||
| error.value = e.response?.data?.error || "Failed to configure authentication"; | ||
| return null; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
| } | ||
|
|
||
| async function completeSetup() { | ||
| loading.value = true; | ||
| error.value = ""; | ||
| try { | ||
| const { data } = await apiClient.post("/setup/complete"); | ||
| initialized.value = true; | ||
| return data; | ||
| } catch (e: any) { | ||
| error.value = e.response?.data?.error || "Failed to complete setup"; | ||
| return null; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| initialized, | ||
| instanceIp, | ||
| agentVersion, | ||
| infoLoaded, | ||
| loading, | ||
| error, | ||
| checkSetupStatus, | ||
| fetchSetupInfo, | ||
| runValidation, | ||
| verifyDNS, | ||
| saveSettings, | ||
| configureAuth, | ||
| completeSetup, | ||
| }; | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.