fix: hyprland config globbing error (source=~), dotfiles deploy stabilität (cp -aT, set -e fix), homelab AGS setup form
This commit is contained in:
@@ -4,14 +4,25 @@ import { execAsync } from "ags/process";
|
||||
import css from "./homelab.css";
|
||||
import GLib from "gi://GLib";
|
||||
|
||||
let hasConfig = false;
|
||||
const CONFIG_PATH = GLib.getenv("HOMELAB_CONFIG") || `${GLib.getenv("HOME")}/.config/homelab/config.yaml`;
|
||||
|
||||
function saveConfig(host: string, user: string, port: string) {
|
||||
const yaml = `# Homelab Configuration\ngenerated_by: Omeron\n\nserver:\n address: "${host}"\n username: "${user}"\n port: ${port}\n\ncontrol_center:\n refresh_interval: 5\n theme: "dark"\n\nfeatures:\n docker: true\n services: true\n storage: true\n network: true\n monitoring: true\n`;
|
||||
GLib.file_set_contents(CONFIG_PATH, new TextEncoder().encode(yaml));
|
||||
hasConfig = true;
|
||||
const win = app.get_window("homelab-control");
|
||||
if (win) win.set_child(<box marginTop={WINDOW_MARGIN_TOP}>{authed ? <DashboardView /> : <LoginView />}</box> as Gtk.Widget);
|
||||
}
|
||||
|
||||
function loadConfig() {
|
||||
const configPath = GLib.getenv("HOMELAB_CONFIG") || `${GLib.getenv("HOME")}/.config/homelab/config.yaml`;
|
||||
const defaults = { host: "10.0.0.15", user: "root", port: 22 };
|
||||
|
||||
try {
|
||||
const [ok, contents] = GLib.file_get_contents(configPath);
|
||||
const [ok, contents] = GLib.file_get_contents(CONFIG_PATH);
|
||||
if (!ok || !contents) return defaults;
|
||||
|
||||
hasConfig = true;
|
||||
const text = new TextDecoder().decode(contents);
|
||||
const lines = text.split("\n");
|
||||
let host = defaults.host;
|
||||
@@ -1113,6 +1124,55 @@ function startRefreshTimer() {
|
||||
});
|
||||
}
|
||||
|
||||
function SetupView() {
|
||||
let host = "";
|
||||
let user = "root";
|
||||
let port = "22";
|
||||
|
||||
return (
|
||||
<box class="login-panel" orientation={Gtk.Orientation.VERTICAL} spacing={14}>
|
||||
<box orientation={Gtk.Orientation.VERTICAL} spacing={4}>
|
||||
<label class="title" xalign={0} label="Homelab Control Center" />
|
||||
<label class="subtitle" xalign={0} label="Ersteinrichtung — Serververbindung konfigurieren" />
|
||||
</box>
|
||||
<entry
|
||||
placeholderText="Server-Adresse (IP oder Domain)"
|
||||
hexpand
|
||||
onChanged={entry => { host = entry.get_text(); }}
|
||||
onActivate={() => {
|
||||
if (host && user && port) saveConfig(host, user, port);
|
||||
}}
|
||||
/>
|
||||
<entry
|
||||
placeholderText="SSH-Benutzer"
|
||||
text="root"
|
||||
hexpand
|
||||
onChanged={entry => { user = entry.get_text() || "root"; }}
|
||||
onActivate={() => {
|
||||
if (host && user && port) saveConfig(host, user, port);
|
||||
}}
|
||||
/>
|
||||
<entry
|
||||
placeholderText="SSH-Port"
|
||||
text="22"
|
||||
hexpand
|
||||
onChanged={entry => { port = entry.get_text() || "22"; }}
|
||||
onActivate={() => {
|
||||
if (host && user && port) saveConfig(host, user, port);
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
class="button primary"
|
||||
label="Speichern"
|
||||
onClicked={() => {
|
||||
if (!host) return;
|
||||
saveConfig(host, user, port);
|
||||
}}
|
||||
/>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
function HomelabWindow() {
|
||||
return (
|
||||
<window
|
||||
@@ -1132,7 +1192,7 @@ function HomelabWindow() {
|
||||
return false;
|
||||
}} />
|
||||
<box marginTop={WINDOW_MARGIN_TOP}>
|
||||
{authed ? <DashboardView /> : <LoginView />}
|
||||
{!hasConfig ? <SetupView /> : (authed ? <DashboardView /> : <LoginView />)}
|
||||
</box>
|
||||
</window>
|
||||
);
|
||||
@@ -1143,7 +1203,7 @@ function rebuild() {
|
||||
if (!win) {
|
||||
return;
|
||||
}
|
||||
win.set_child(<box marginTop={WINDOW_MARGIN_TOP}>{authed ? <DashboardView /> : <LoginView />}</box> as Gtk.Widget);
|
||||
win.set_child(<box marginTop={WINDOW_MARGIN_TOP}>{!hasConfig ? <SetupView /> : (authed ? <DashboardView /> : <LoginView />)}</box> as Gtk.Widget);
|
||||
}
|
||||
|
||||
app.start({
|
||||
|
||||
Reference in New Issue
Block a user