mirror of
https://github.com/tale/headplane.git
synced 2026-08-28 16:07:07 +00:00
feat: ingest data from new agent system
This commit is contained in:
@@ -15,6 +15,7 @@ interface Props {
|
|||||||
machine: Machine;
|
machine: Machine;
|
||||||
routes: Route[];
|
routes: Route[];
|
||||||
users: User[];
|
users: User[];
|
||||||
|
isAgent?: boolean;
|
||||||
magic?: string;
|
magic?: string;
|
||||||
stats?: HostInfo;
|
stats?: HostInfo;
|
||||||
}
|
}
|
||||||
@@ -22,8 +23,9 @@ interface Props {
|
|||||||
export default function MachineRow({
|
export default function MachineRow({
|
||||||
machine,
|
machine,
|
||||||
routes,
|
routes,
|
||||||
magic,
|
|
||||||
users,
|
users,
|
||||||
|
isAgent,
|
||||||
|
magic,
|
||||||
stats,
|
stats,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const expired =
|
const expired =
|
||||||
@@ -79,6 +81,10 @@ export default function MachineRow({
|
|||||||
tags.unshift('Subnets');
|
tags.unshift('Subnets');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isAgent) {
|
||||||
|
tags.unshift('Headplane Agent');
|
||||||
|
}
|
||||||
|
|
||||||
const ipOptions = useMemo(() => {
|
const ipOptions = useMemo(() => {
|
||||||
if (magic) {
|
if (magic) {
|
||||||
return [...machine.ipAddresses, `${machine.givenName}.${prefix}`];
|
return [...machine.ipAddresses, `${machine.givenName}.${prefix}`];
|
||||||
|
|||||||
@@ -14,11 +14,16 @@ import cn from '~/utils/cn';
|
|||||||
import { hs_getConfig } from '~/utils/config/loader';
|
import { hs_getConfig } from '~/utils/config/loader';
|
||||||
import { pull } from '~/utils/headscale';
|
import { pull } from '~/utils/headscale';
|
||||||
import { getSession } from '~/utils/sessions.server';
|
import { getSession } from '~/utils/sessions.server';
|
||||||
|
import type { AppContext } from '~server/context/app';
|
||||||
import { menuAction } from './action';
|
import { menuAction } from './action';
|
||||||
import MenuOptions from './components/menu';
|
import MenuOptions from './components/menu';
|
||||||
import Routes from './dialogs/routes';
|
import Routes from './dialogs/routes';
|
||||||
|
|
||||||
export async function loader({ request, params }: LoaderFunctionArgs) {
|
export async function loader({
|
||||||
|
request,
|
||||||
|
params,
|
||||||
|
context,
|
||||||
|
}: LoaderFunctionArgs<AppContext>) {
|
||||||
const session = await getSession(request.headers.get('Cookie'));
|
const session = await getSession(request.headers.get('Cookie'));
|
||||||
if (!params.id) {
|
if (!params.id) {
|
||||||
throw new Error('No machine ID provided');
|
throw new Error('No machine ID provided');
|
||||||
@@ -44,6 +49,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
|
|||||||
routes: routes.routes.filter((route) => route.node.id === params.id),
|
routes: routes.routes.filter((route) => route.node.id === params.id),
|
||||||
users: users.users,
|
users: users.users,
|
||||||
magic,
|
magic,
|
||||||
|
agent: context?.agents.includes(machine.node.id),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +58,10 @@ export async function action({ request }: ActionFunctionArgs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const { machine, magic, routes, users } = useLoaderData<typeof loader>();
|
const { machine, magic, routes, users, agent } =
|
||||||
|
useLoaderData<typeof loader>();
|
||||||
const [showRouting, setShowRouting] = useState(false);
|
const [showRouting, setShowRouting] = useState(false);
|
||||||
|
console.log(machine.expiry);
|
||||||
|
|
||||||
const expired =
|
const expired =
|
||||||
machine.expiry === '0001-01-01 00:00:00' ||
|
machine.expiry === '0001-01-01 00:00:00' ||
|
||||||
@@ -68,6 +76,10 @@ export default function Page() {
|
|||||||
tags.unshift('Expired');
|
tags.unshift('Expired');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (agent) {
|
||||||
|
tags.unshift('Headplane Agent');
|
||||||
|
}
|
||||||
|
|
||||||
// This is much easier with Object.groupBy but it's too new for us
|
// This is much easier with Object.groupBy but it's too new for us
|
||||||
const { exit, subnet, subnetApproved } = routes.reduce<{
|
const { exit, subnet, subnetApproved } = routes.reduce<{
|
||||||
exit: Route[];
|
exit: Route[];
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export async function loader({
|
|||||||
magic,
|
magic,
|
||||||
server: ctx.headscale.url,
|
server: ctx.headscale.url,
|
||||||
publicServer: ctx.headscale.public_url,
|
publicServer: ctx.headscale.public_url,
|
||||||
|
agents: context.agents,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +125,7 @@ export default function Page() {
|
|||||||
users={data.users}
|
users={data.users}
|
||||||
magic={data.magic}
|
magic={data.magic}
|
||||||
stats={stats?.[machine.nodeKey]}
|
stats={stats?.[machine.nodeKey]}
|
||||||
|
isAgent={data.agents.includes(machine.id)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user