diff --git a/app/routes.ts b/app/routes.ts
index 2f0cf34..51a6363 100644
--- a/app/routes.ts
+++ b/app/routes.ts
@@ -27,7 +27,7 @@ export default [
...prefix('/settings', [
index('routes/settings/overview.tsx'),
route('/auth-keys', 'routes/settings/auth-keys.tsx'),
- route('/local-agent', 'routes/settings/local-agent.tsx'),
+ // route('/local-agent', 'routes/settings/local-agent.tsx'),
]),
]),
]),
diff --git a/app/routes/machines/components/machine.tsx b/app/routes/machines/components/machine.tsx
index a55148b..f2a73c9 100644
--- a/app/routes/machines/components/machine.tsx
+++ b/app/routes/machines/components/machine.tsx
@@ -153,6 +153,7 @@ export default function MachineRow({ machine, routes, magic, users, stats }: Pro
+ {/**
{stats !== undefined ? (
<>
@@ -169,6 +170,7 @@ export default function MachineRow({ machine, routes, magic, users, stats }: Pro
)}
+ **/}
- Version
+ {/**Version **/}
Last Seen
diff --git a/app/routes/settings/components/agent.tsx b/app/routes/settings/components/agent.tsx
new file mode 100644
index 0000000..0ac49c6
--- /dev/null
+++ b/app/routes/settings/components/agent.tsx
@@ -0,0 +1,38 @@
+import Link from '~/components/Link';
+import Button from '~/components/Button';
+import { Link as RemixLink } from 'react-router';
+import { ArrowRightIcon } from '@primer/octicons-react';
+import { cn } from '~/utils/cn';
+
+export default function AgentSection() {
+ return (
+ <>
+
+
Local Agent
+
+ Headplane provides a local agent that can be installed on a
+ server to provide additional features including viewing device
+ information and SSH access via the web interface (soon).
+ To learn more about the agent visit the{' '}
+
+ Headplane documentation
+
+
+
+
+
+
+ >
+ )
+}
diff --git a/app/routes/settings/components/agent/manage.tsx b/app/routes/settings/components/agent/manage.tsx
new file mode 100644
index 0000000..a2ff409
--- /dev/null
+++ b/app/routes/settings/components/agent/manage.tsx
@@ -0,0 +1,44 @@
+import Card from '~/components/Card'
+import StatusCircle from '~/components/StatusCircle'
+import type { HostInfo } from '~/types';
+import * as hinfo from '~/utils/host-info';
+
+export type Props = {
+ reachable: boolean;
+ hostInfo: HostInfo;
+};
+
+export default function AgentManagement({ reachable, hostInfo }: Props) {
+ console.log('hostInfo:', hostInfo);
+ return (
+
+
+ Local Agent Configuration
+
+
+ A local agent has already been configured for this
+ Headplane instance. You can manage the agent settings here.
+
+
+
+
+
+
+ {hostInfo.Hostname ?? 'Unknown'}
+
+
+ {hinfo.getTSVersion(hostInfo)}
+
+ {hinfo.getOSInfo(hostInfo)}
+
+
+
+
+ {JSON.stringify(hostInfo)}
+
+
+ )
+}
diff --git a/app/routes/settings/local-agent.tsx b/app/routes/settings/local-agent.tsx
new file mode 100644
index 0000000..972d0a3
--- /dev/null
+++ b/app/routes/settings/local-agent.tsx
@@ -0,0 +1,44 @@
+import { useMemo } from 'react';
+import { useLoaderData, type LoaderFunctionArgs } from 'react-router';
+import { getSession, commitSession } from '~/utils/sessions.server'
+import { queryAgent } from '~/utils/ws-agent'
+import AgentManagement from './components/agent/manage'
+
+export async function loader({ request, context }: LoaderFunctionArgs) {
+ const { ws, wsAuthKey } = context;
+ const session = await getSession(request.headers.get('Cookie'));
+ const onboarding = session.get('agent_onboarding') ?? false;
+
+ const nodeKey = 'nodekey:542dad28354eb8d51e240aada7adf0222ba3ecc74af0bbd56123f03eefdb391b'
+ const stats = await queryAgent([nodeKey]);
+
+ return {
+ configured: wsAuthKey !== undefined,
+ onboarding,
+ stats: stats[nodeKey]
+ }
+}
+
+export default function Page() {
+ const data = useLoaderData();
+
+ // Whether we show the onboarding or management UI
+ const management = useMemo(() => {
+ return data.configured && (data.onboarding === false)
+ }, [data.configured, data.onboarding]);
+
+ return (
+
+ {management ? (
+
+ ) : (
+
+
Local Agent Coming Soon
+
+ )}
+
+ )
+}
diff --git a/app/routes/settings/overview.tsx b/app/routes/settings/overview.tsx
index 33f5757..f69ea9e 100644
--- a/app/routes/settings/overview.tsx
+++ b/app/routes/settings/overview.tsx
@@ -4,6 +4,8 @@ import { Link as RemixLink } from 'react-router';
import { ArrowRightIcon } from '@primer/octicons-react';
import { cn } from '~/utils/cn';
+import AgentSection from './components/agent';
+
export default function Page() {
return (
@@ -30,16 +32,17 @@ export default function Page() {
-
Manage Auth Keys
-
+
+ {/** **/}
);
}
diff --git a/app/utils/config/headplane.ts b/app/utils/config/headplane.ts
index abeaa64..b0e08bc 100644
--- a/app/utils/config/headplane.ts
+++ b/app/utils/config/headplane.ts
@@ -111,12 +111,12 @@ export async function loadContext(): Promise {
const cacheTTL = 300 * 1000; // 5 minutes
// Load agent cache
- if (cacheEnabled) {
- log.info('CTXT', 'Initializing Agent Cache');
- log.debug('CTXT', 'Cache Path: %s', cachePath);
- log.debug('CTXT', 'Cache TTL: %d', cacheTTL);
- await initAgentCache(cacheTTL, cachePath);
- }
+ // if (cacheEnabled) {
+ // log.info('CTXT', 'Initializing Agent Cache');
+ // log.debug('CTXT', 'Cache Path: %s', cachePath);
+ // log.debug('CTXT', 'Cache TTL: %d', cacheTTL);
+ // await initAgentCache(cacheTTL, cachePath);
+ // }
context = {
debug,
diff --git a/app/utils/sessions.server.ts b/app/utils/sessions.server.ts
index 9791da1..6286d90 100644
--- a/app/utils/sessions.server.ts
+++ b/app/utils/sessions.server.ts
@@ -5,6 +5,7 @@ export type SessionData = {
oidc_state: string;
oidc_code_verif: string;
oidc_nonce: string;
+ agent_onboarding: boolean;
user: {
subject: string;
name: string;
diff --git a/app/utils/ws-agent.ts b/app/utils/ws-agent.ts
index 178b723..55ac591 100644
--- a/app/utils/ws-agent.ts
+++ b/app/utils/ws-agent.ts
@@ -97,6 +97,7 @@ export function initAgentSocket(context: LoaderFunctionArgs['context']) {
// Check the cache and then attempt the websocket query
// If we aren't connected to an agent, then debug log and return the cache
export async function queryAgent(nodes: string[]) {
+ return;
if (!cache) {
log.error('CACH', 'Cache not initialized');
return;
diff --git a/server/ws.ts b/server/ws.ts
index c05123b..7f6bc3d 100644
--- a/server/ws.ts
+++ b/server/ws.ts
@@ -3,6 +3,9 @@ import log from '~server/log'
const server = new WebSocketServer({ noServer: true });
export function initWebsocket() {
+ // TODO: Finish this and make public
+ return;
+
const key = process.env.LOCAL_AGENT_AUTHKEY;
if (!key) {
return;