Display relay status on relays page
This commit is contained in:
		@@ -45,6 +45,14 @@ export interface UpdatedInfo {
 | 
			
		||||
  enabled: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface DeviceState {
 | 
			
		||||
  id: string;
 | 
			
		||||
  last_ping: number;
 | 
			
		||||
  online: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export type DevicesState = Map<string, DeviceState>;
 | 
			
		||||
 | 
			
		||||
export function DeviceURL(d: Device): string {
 | 
			
		||||
  return `/dev/${encodeURIComponent(d.id)}`;
 | 
			
		||||
}
 | 
			
		||||
@@ -74,6 +82,22 @@ export class DeviceApi {
 | 
			
		||||
    ).data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Get the state of devices
 | 
			
		||||
   */
 | 
			
		||||
  static async DevicesState(): Promise<DevicesState> {
 | 
			
		||||
    const devs: DeviceState[] = (
 | 
			
		||||
      await APIClient.exec({
 | 
			
		||||
        uri: "/devices/state",
 | 
			
		||||
        method: "GET",
 | 
			
		||||
      })
 | 
			
		||||
    ).data;
 | 
			
		||||
 | 
			
		||||
    const m = new Map();
 | 
			
		||||
    devs.forEach((d) => m.set(d.id, d));
 | 
			
		||||
    return m;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Validate a device
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user