introduce config path to json

This commit is contained in:
Michel Roegl-Brunner 2025-04-23 13:59:22 +02:00
parent de12da037c
commit 79fd16a339
6 changed files with 37 additions and 1 deletions

View File

@ -9,6 +9,7 @@
"updateable": false, "updateable": false,
"privileged": false, "privileged": false,
"interface_port": 80, "interface_port": 80,
"config_path": "/opt/librenms/config.php",
"documentation": "https://docs.librenms.org/", "documentation": "https://docs.librenms.org/",
"website": "https://librenms.org/", "website": "https://librenms.org/",
"logo": "https://raw.githubusercontent.com/selfhst/icons/refs/heads/main/svg/librenms.svg", "logo": "https://raw.githubusercontent.com/selfhst/icons/refs/heads/main/svg/librenms.svg",
@ -31,4 +32,4 @@
"password": null "password": null
}, },
"notes": [] "notes": []
} }

View File

@ -34,6 +34,7 @@ export const ScriptSchema = z.object({
website: z.string().url().nullable(), website: z.string().url().nullable(),
logo: z.string().url().nullable(), logo: z.string().url().nullable(),
description: z.string().min(1, "Description is required"), description: z.string().min(1, "Description is required"),
config_path: z.string(),
install_methods: z.array(InstallMethodSchema).min(1, "At least one install method is required"), install_methods: z.array(InstallMethodSchema).min(1, "At least one install method is required"),
default_credentials: z.object({ default_credentials: z.object({
username: z.string().nullable(), username: z.string().nullable(),

View File

@ -32,6 +32,7 @@ const initialScript: Script = {
privileged: false, privileged: false,
interface_port: null, interface_port: null,
documentation: null, documentation: null,
config_path: "",
website: null, website: null,
logo: null, logo: null,
description: "", description: "",
@ -184,6 +185,14 @@ export default function JSONGenerator() {
onChange={(e) => updateScript("description", e.target.value)} onChange={(e) => updateScript("description", e.target.value)}
/> />
</div> </div>
<div>
<Label>Config Path</Label>
<Input
placeholder="Path to config file"
value={script.config_path || ""}
onChange={(e) => updateScript("config_path", e.target.value || null)}
/>
</div>
<Categories script={script} setScript={setScript} categories={categories} /> <Categories script={script} setScript={setScript} categories={categories} />
<div className="flex gap-2"> <div className="flex gap-2">
<div className="flex flex-col gap-2 w-full"> <div className="flex flex-col gap-2 w-full">

View File

@ -18,9 +18,11 @@ import Buttons from "./ScriptItems/Buttons";
import DefaultPassword from "./ScriptItems/DefaultPassword"; import DefaultPassword from "./ScriptItems/DefaultPassword";
import Description from "./ScriptItems/Description"; import Description from "./ScriptItems/Description";
import InstallCommand from "./ScriptItems/InstallCommand"; import InstallCommand from "./ScriptItems/InstallCommand";
import ConfigFile from "./ScriptItems/ConfigFile";
import InterFaces from "./ScriptItems/InterFaces"; import InterFaces from "./ScriptItems/InterFaces";
import Tooltips from "./ScriptItems/Tooltips"; import Tooltips from "./ScriptItems/Tooltips";
interface ScriptItemProps { interface ScriptItemProps {
item: Script; item: Script;
setSelectedScript: (script: string | null) => void; setSelectedScript: (script: string | null) => void;
@ -141,6 +143,7 @@ export function ScriptItem({ item, setSelectedScript }: ScriptItemProps) {
<Alerts item={item} /> <Alerts item={item} />
<div className="mt-4 rounded-lg border shadow-sm"> <div className="mt-4 rounded-lg border shadow-sm">
<div className="flex gap-3 px-4 py-2 bg-accent/25"> <div className="flex gap-3 px-4 py-2 bg-accent/25">
<h2 className="text-lg font-semibold"> <h2 className="text-lg font-semibold">
How to {item.type === "pve" ? "use" : item.type === "addon" ? "apply" : "install"} How to {item.type === "pve" ? "use" : item.type === "addon" ? "apply" : "install"}
@ -151,6 +154,17 @@ export function ScriptItem({ item, setSelectedScript }: ScriptItemProps) {
<div className=""> <div className="">
<InstallCommand item={item} /> <InstallCommand item={item} />
</div> </div>
<Separator />
<div className="flex gap-3 px-4 py-2 bg-accent/25">
<h2 className="text-lg font-semibold">
Location of config file
</h2>
</div>
<Separator />
<div className="">
<ConfigFile item={item} />
</div>
</div> </div>
<DefaultPassword item={item} /> <DefaultPassword item={item} />

View File

@ -0,0 +1,10 @@
import CodeCopyButton from "@/components/ui/code-copy-button";
import { Script } from "@/lib/types";
export default function ConfigFile({ item }: { item: Script }) {
return (
<div className="px-4 pb-4">
<CodeCopyButton>{item.config_path ? item.config_path : "No config path set"}</CodeCopyButton>
</div>
);
}

View File

@ -13,6 +13,7 @@ export type Script = {
website: string | null; website: string | null;
logo: string | null; logo: string | null;
description: string; description: string;
config_path: string | null;
install_methods: { install_methods: {
type: "default" | "alpine"; type: "default" | "alpine";
script: string; script: string;