mirror of
https://github.com/moghtech/komodo.git
synced 2026-07-17 15:27:44 -05:00
optional custom passkey
This commit is contained in:
@@ -15,6 +15,7 @@ const servers = fp((app: FastifyInstance, _: {}, done: () => void) => {
|
||||
cpuAlert: { type: Number, default: CPU_USAGE_NOTIFY_LIMIT },
|
||||
memAlert: { type: Number, default: MEM_USAGE_NOTIFY_LIMIT },
|
||||
diskAlert: { type: Number, default: DISK_USAGE_NOTIFY_LIMIT },
|
||||
passkey: String,
|
||||
});
|
||||
|
||||
app.decorate("servers", model(app, "Server", schema));
|
||||
|
||||
@@ -1,81 +1,86 @@
|
||||
import { Collection, CommandLogError, ContainerStatus, Log, Server } from "@monitor/types";
|
||||
import {
|
||||
Collection,
|
||||
CommandLogError,
|
||||
ContainerStatus,
|
||||
Log,
|
||||
Server,
|
||||
} from "@monitor/types";
|
||||
import { generateQuery } from "@monitor/util";
|
||||
import axios from "axios";
|
||||
import { SECRETS } from "../../config";
|
||||
|
||||
export async function getPeripheryContainers({ address }: Server) {
|
||||
return (await axios.get(`${address}/containers`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
},
|
||||
}).then(({ data }) => data)) as Collection<ContainerStatus>;
|
||||
export async function getPeripheryContainers({ address, passkey }: Server) {
|
||||
return (await axios
|
||||
.get(`${address}/containers`, {
|
||||
headers: {
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data)) as Collection<ContainerStatus>;
|
||||
}
|
||||
|
||||
export async function getPeripheryContainer(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
name: string
|
||||
) {
|
||||
return (await axios
|
||||
return (await axios
|
||||
.get(`${address}/container/${name}`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data)) as ContainerStatus | "not deployed";
|
||||
}
|
||||
|
||||
export async function getPeripheryContainerLog(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
name: string,
|
||||
tail?: number
|
||||
) {
|
||||
return (await axios
|
||||
.get(`${address}/container/log/${name}${generateQuery({ tail })}`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
|
||||
})
|
||||
.then(({ data }) => data)) as Log;
|
||||
}
|
||||
|
||||
export async function startPeripheryContainer(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
name: string
|
||||
) {
|
||||
return (await axios
|
||||
.get(`${address}/container/start/${name}`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data)) as CommandLogError;
|
||||
}
|
||||
|
||||
export async function stopPeripheryContainer(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
name: string
|
||||
) {
|
||||
return (await axios
|
||||
.get(`${address}/container/stop/${name}`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data)) as CommandLogError;
|
||||
}
|
||||
|
||||
export async function deletePeripheryContainer(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
name: string
|
||||
) {
|
||||
return (await axios
|
||||
.get(`${address}/container/delete/${name}`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data)) as CommandLogError;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import axios from "axios";
|
||||
import { SECRETS } from "../../config";
|
||||
|
||||
export async function deployPeriphery(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
deployment: Deployment,
|
||||
image?: string,
|
||||
dockerAccount?: string
|
||||
@@ -20,7 +20,7 @@ export async function deployPeriphery(
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ import axios from "axios";
|
||||
import { SECRETS } from "../../config";
|
||||
|
||||
export async function clonePeriphery(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
deployment: Deployment
|
||||
) {
|
||||
return (await axios
|
||||
@@ -12,7 +12,7 @@ export async function clonePeriphery(
|
||||
{ deployment },
|
||||
{
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -20,7 +20,7 @@ export async function clonePeriphery(
|
||||
}
|
||||
|
||||
export async function pullPeriphery(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
deployment: Deployment
|
||||
) {
|
||||
return (await axios
|
||||
@@ -29,7 +29,7 @@ export async function pullPeriphery(
|
||||
{ deployment },
|
||||
{
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -37,7 +37,7 @@ export async function pullPeriphery(
|
||||
}
|
||||
|
||||
export async function deleteRepoPeriphery(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
deployment: Deployment
|
||||
) {
|
||||
return (await axios
|
||||
@@ -46,7 +46,7 @@ export async function deleteRepoPeriphery(
|
||||
{ deployment },
|
||||
{
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,44 +3,47 @@ import { generateQuery } from "@monitor/util";
|
||||
import axios from "axios";
|
||||
import { SECRETS } from "../../config";
|
||||
|
||||
export async function getPeripheryNetworks({ address }: Server) {
|
||||
export async function getPeripheryNetworks({ address, passkey }: Server) {
|
||||
return await axios
|
||||
.get<Network[]>(`${address}/networks`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function prunePeripheryNetworks({ address }: Server) {
|
||||
export async function prunePeripheryNetworks({ address, passkey }: Server) {
|
||||
return await axios
|
||||
.get<CommandLogError>(`${address}/networks/prune`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function createPeripheryNetwork({ address }: Server, name: string, driver?: string) {
|
||||
export async function createPeripheryNetwork({ address, passkey }: Server, name: string, driver?: string) {
|
||||
return await axios
|
||||
.get<CommandLogError>(`${address}/network/create/${name}${generateQuery({ driver })}`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.get<CommandLogError>(
|
||||
`${address}/network/create/${name}${generateQuery({ driver })}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function deletePeripheryNetwork(
|
||||
{ address }: Server,
|
||||
{ address, passkey }: Server,
|
||||
name: string
|
||||
) {
|
||||
return await axios
|
||||
.get<CommandLogError>(`${address}/network/delete/${name}`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data);
|
||||
|
||||
@@ -2,31 +2,31 @@ import { CommandLogError, DockerStat, Server, SystemStats } from "@monitor/types
|
||||
import axios from "axios";
|
||||
import { SECRETS } from "../../config";
|
||||
|
||||
export async function prunePeripheryImages({ address }: Server) {
|
||||
export async function prunePeripheryImages({ address, passkey }: Server) {
|
||||
return await axios
|
||||
.get<CommandLogError>(`${address}/images/prune`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function getPeripheryDockerStats({ address }: Server) {
|
||||
export async function getPeripheryDockerStats({ address, passkey }: Server) {
|
||||
return await axios
|
||||
.get<DockerStat[]>(`${address}/stats`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function getPeripherySystemStats({ address }: Server) {
|
||||
export async function getPeripherySystemStats({ address, passkey }: Server) {
|
||||
return await axios
|
||||
.get<SystemStats>(`${address}/sys-stats`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
})
|
||||
.then(({ data }) => data);
|
||||
|
||||
@@ -6,6 +6,7 @@ export async function serverStatusPeriphery({
|
||||
address,
|
||||
enabled,
|
||||
isCore,
|
||||
passkey,
|
||||
}: Server) {
|
||||
// returns true if can be reached, false else
|
||||
if (isCore) return true;
|
||||
@@ -19,7 +20,7 @@ export async function serverStatusPeriphery({
|
||||
try {
|
||||
await axios.get(`${address}/status`, {
|
||||
headers: {
|
||||
Authorization: SECRETS.PASSKEY,
|
||||
Authorization: passkey || SECRETS.PASSKEY,
|
||||
},
|
||||
signal: controller.signal,
|
||||
});
|
||||
@@ -29,4 +30,4 @@ export async function serverStatusPeriphery({
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import Address from "./Address";
|
||||
import Alerts from "./Alerts";
|
||||
import Enabled from "./Enabled";
|
||||
import Networks from "./Networks";
|
||||
import Passkey from "./Passkey";
|
||||
import { useConfig } from "./Provider";
|
||||
|
||||
const Config: Component<{}> = (p) => {
|
||||
@@ -18,6 +19,7 @@ const Config: Component<{}> = (p) => {
|
||||
<Show when={!server.isCore}>
|
||||
<Address />
|
||||
<Enabled />
|
||||
<Passkey />
|
||||
</Show>
|
||||
<Networks />
|
||||
<Alerts />
|
||||
|
||||
27
frontend/src/components/server/tabs/config/Passkey.tsx
Normal file
27
frontend/src/components/server/tabs/config/Passkey.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Component } from "solid-js";
|
||||
import { useTheme } from "../../../../state/ThemeProvider";
|
||||
import { combineClasses } from "../../../../util/helpers";
|
||||
import Input from "../../../util/Input";
|
||||
import Flex from "../../../util/layout/Flex";
|
||||
import { useConfig } from "./Provider";
|
||||
|
||||
const Passkey: Component<{}> = (p) => {
|
||||
const { server, setServer } = useConfig();
|
||||
const { themeClass } = useTheme();
|
||||
return (
|
||||
<Flex
|
||||
class={combineClasses("config-item shadow", themeClass())}
|
||||
justifyContent="space-between"
|
||||
>
|
||||
<h1>passkey</h1>
|
||||
<Input
|
||||
value={server.passkey}
|
||||
placeholder="using default"
|
||||
onEdit={(value) => setServer("passkey", value)}
|
||||
style={{ width: "13rem" }}
|
||||
/>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default Passkey;
|
||||
2
types/types.d.ts
vendored
2
types/types.d.ts
vendored
@@ -55,6 +55,8 @@ export type Server = {
|
||||
cpuAlert?: number; // 0 - 100
|
||||
memAlert?: number; // 0 - 100
|
||||
diskAlert?: number; // 0 - 100
|
||||
// optional custom passkey
|
||||
passkey?: string;
|
||||
};
|
||||
|
||||
export type DockerBuildArgs = {
|
||||
|
||||
Reference in New Issue
Block a user