Compare commits
2 Commits
419eccf4d0
...
c8456a0885
| Author | SHA1 | Date | |
|---|---|---|---|
| c8456a0885 | |||
| add4260a9b |
@@ -2,6 +2,7 @@ import app from "ags/gtk4/app";
|
||||
import { Astal, Gtk } from "ags/gtk4";
|
||||
import { execAsync } from "ags/process";
|
||||
import css from "./homelab.css";
|
||||
import { writeFile } from "ags/file";
|
||||
import GLib from "gi://GLib";
|
||||
|
||||
let hasConfig = false;
|
||||
@@ -10,9 +11,7 @@ const CONFIG_PATH = GLib.getenv("HOMELAB_CONFIG") || `${GLib.getenv("HOME")}/.co
|
||||
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`;
|
||||
try {
|
||||
GLib.mkdir_with_parents(GLib.path_get_dirname(CONFIG_PATH), 0o755);
|
||||
const ok = GLib.file_set_contents(CONFIG_PATH, yaml);
|
||||
print(`[homelab] save: dir created, write=${ok}`);
|
||||
writeFile(CONFIG_PATH, yaml);
|
||||
} catch (e) {
|
||||
print(`[homelab] save error: ${e}`);
|
||||
return;
|
||||
@@ -1131,15 +1130,13 @@ function startRefreshTimer() {
|
||||
}
|
||||
|
||||
function SetupView() {
|
||||
let hostEntry: Gtk.Entry | null = null;
|
||||
let userEntry: Gtk.Entry | null = null;
|
||||
let portEntry: Gtk.Entry | null = null;
|
||||
let host = "";
|
||||
let user = "root";
|
||||
let port = "22";
|
||||
|
||||
function doSave() {
|
||||
if (!hostEntry || !userEntry || !portEntry) return;
|
||||
const host = hostEntry.get_text();
|
||||
if (!host) return;
|
||||
saveConfig(host, userEntry.get_text() || "root", portEntry.get_text() || "22");
|
||||
saveConfig(host, user || "root", port || "22");
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -1149,24 +1146,24 @@ function SetupView() {
|
||||
<label class="subtitle" xalign={0} label="Ersteinrichtung — Serververbindung konfigurieren" />
|
||||
</box>
|
||||
<entry
|
||||
setup={self => { hostEntry = self; }}
|
||||
onChanged={self => { host = self.text || self.get_text(); }}
|
||||
onActivate={doSave}
|
||||
placeholderText="Server-Adresse (IP oder Domain)"
|
||||
hexpand
|
||||
onActivate={doSave}
|
||||
/>
|
||||
<entry
|
||||
setup={self => { userEntry = self; }}
|
||||
onChanged={self => { user = self.text || self.get_text(); }}
|
||||
onActivate={doSave}
|
||||
placeholderText="SSH-Benutzer"
|
||||
text="root"
|
||||
hexpand
|
||||
onActivate={doSave}
|
||||
/>
|
||||
<entry
|
||||
setup={self => { portEntry = self; }}
|
||||
onChanged={self => { port = self.text || self.get_text(); }}
|
||||
onActivate={doSave}
|
||||
placeholderText="SSH-Port"
|
||||
text="22"
|
||||
hexpand
|
||||
onActivate={doSave}
|
||||
/>
|
||||
<button
|
||||
class="button primary"
|
||||
|
||||
Reference in New Issue
Block a user