@axium/sysadmin 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare function getOnlineHosts(): Promise<string[]>;
@@ -0,0 +1,12 @@
1
+ import { socket } from '@axium/client/socket';
2
+ export async function getOnlineHosts() {
3
+ if (!socket)
4
+ return [];
5
+ try {
6
+ const systems = await socket.emitWithAck('sysadmin:ping');
7
+ return systems.map(s => s.hostname);
8
+ }
9
+ catch {
10
+ return [];
11
+ }
12
+ }
@@ -1,9 +1,15 @@
1
1
  import { addListener, io } from '@axium/server/socket';
2
2
  addListener('sysadmin:ping', async (socket, cb) => {
3
- const result = await io.in(`local:${socket.data.user.id}`).timeout(5000).emitWithAck('sysadmin:ping');
4
- cb(result);
3
+ cb(await io
4
+ .in(`local:${socket.data.user.id}`)
5
+ .timeout(5000)
6
+ .emitWithAck('sysadmin:ping')
7
+ .catch(e => e.responses || []));
5
8
  });
6
9
  addListener('sysadmin:getSystemInfo', async (socket, cb) => {
7
- const result = await io.in(`local:${socket.data.user.id}`).timeout(5000).emitWithAck('sysadmin:getSystemInfo');
8
- cb(result);
10
+ cb(await io
11
+ .in(`local:${socket.data.user.id}`)
12
+ .timeout(5000)
13
+ .emitWithAck('sysadmin:getSystemInfo')
14
+ .catch(e => e.responses || []));
9
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/sysadmin",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "author": "James Prevett <axium@jamespre.dev>",
5
5
  "description": "System administration for Axium",
6
6
  "funding": {
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { text } from '@axium/client';
3
3
  import { Icon } from '@axium/client/components';
4
- import { socket } from '@axium/client/socket';
4
+ import { getOnlineHosts } from '@axium/sysadmin/client/web';
5
5
  import { SystemCard, SystemInitDialog, UserCard, UserInitDialog } from '@axium/sysadmin/components';
6
6
 
7
7
  const { data } = $props();
@@ -9,7 +9,7 @@
9
9
  let systems = $state(data.systems);
10
10
  let users = $state(data.users);
11
11
 
12
- const onlineHosts = $derived(await socket?.emitWithAck('sysadmin:ping').then(systems => systems.map(s => s.hostname)));
12
+ const onlineHosts = $derived(await getOnlineHosts());
13
13
  </script>
14
14
 
15
15
  <svelte:head>
@@ -1,14 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { text } from '@axium/client';
3
3
  import { Icon } from '@axium/client/components';
4
- import { socket } from '@axium/client/socket';
4
+ import { getOnlineHosts } from '@axium/sysadmin/client/web';
5
5
  import { SystemCard, SystemInitDialog } from '@axium/sysadmin/components';
6
6
 
7
7
  const { data } = $props();
8
8
 
9
9
  let systems = $state(data.systems);
10
10
 
11
- const onlineHosts = $derived(await socket?.emitWithAck('sysadmin:ping').then(systems => systems.map(s => s.hostname)));
11
+ const onlineHosts = $derived(await getOnlineHosts());
12
12
  </script>
13
13
 
14
14
  <svelte:head>
@@ -2,7 +2,7 @@
2
2
  import { goto } from '$app/navigation';
3
3
  import { fetchAPI, text } from '@axium/client';
4
4
  import { Icon } from '@axium/client/components';
5
- import { socket } from '@axium/client/socket';
5
+ import { getOnlineHosts } from '@axium/sysadmin/client/web';
6
6
  import { toastStatus } from '@axium/client/toast';
7
7
  import { SystemCard, UserInitDialog } from '@axium/sysadmin/components';
8
8
 
@@ -12,7 +12,7 @@
12
12
  let systems = $state(data.systems);
13
13
  let editDialog = $state<HTMLDialogElement>();
14
14
 
15
- const onlineHosts = $derived(await socket?.emitWithAck('sysadmin:ping').then(systems => systems.map(s => s.hostname)));
15
+ const onlineHosts = $derived(await getOnlineHosts());
16
16
 
17
17
  function remove() {
18
18
  toastStatus(