can provision devices

This commit is contained in:
Carter 2024-12-09 17:26:12 -06:00
parent 0ae37f1370
commit 03f8ed20ca
18 changed files with 1467 additions and 17 deletions

25
src/pbHelpers/Backpack.ts Normal file
View file

@ -0,0 +1,25 @@
import { Backpack } from "models";
import { pond } from "protobuf-ts/pond";
import { Option } from "common/SearchSelect";
export function backpackOptions(backpacks: Backpack[]): Option[] {
return backpacks.map(b => {
return { value: b.settings.backpackId, label: b.name() } as Option;
});
}
export function genericBackpacks(): Backpack[] {
let basic = pond.Backpack.fromObject({
settings: {
backpackId: 0,
name: "Basic",
device: pond.DeviceSettings.fromObject({
name: "Basic",
pondCheckPeriodS: 60,
upgradeChannel: pond.UpgradeChannel.UPGRADE_CHANNEL_STABLE,
automaticallyUpgrade: false
})
}
});
return [Backpack.create(basic)];
}

View file

@ -0,0 +1,116 @@
import React from "react";
import {
DeviceUnknown,
SignalCellular4Bar,
SignalWifi4Bar,
SignalCellularOff,
SignalWifiOff
} from "@mui/icons-material";
import { pond } from "protobuf-ts/pond";
export interface DevicePlatformDescriber {
platform: pond.DevicePlatform;
label: string;
description: string;
icon: any;
offlineIcon: any;
platformName: string;
}
const Default: DevicePlatformDescriber = {
platform: pond.DevicePlatform.DEVICE_PLATFORM_INVALID,
label: "Unknown",
description: "Unknown communication platform",
icon: <DeviceUnknown style={{ color: "#fff" }} />,
offlineIcon: <DeviceUnknown style={{ color: "#fff" }} />,
platformName: "unknown"
};
const Photon: DevicePlatformDescriber = {
platform: pond.DevicePlatform.DEVICE_PLATFORM_PHOTON,
label: "Wi-Fi",
description: "Communicates via Wi-Fi",
icon: <SignalWifi4Bar style={{ color: "#fff" }} />,
offlineIcon: <SignalWifiOff style={{ color: "#fff" }} />,
platformName: "photon"
};
const Electron: DevicePlatformDescriber = {
platform: pond.DevicePlatform.DEVICE_PLATFORM_ELECTRON,
label: "Cellular",
description: "Communicates via cellular",
icon: <SignalCellular4Bar style={{ color: "#fff" }} />,
offlineIcon: <SignalCellularOff style={{ color: "#fff" }} />,
platformName: "electron"
};
const V2_Cellular: DevicePlatformDescriber = {
platform: pond.DevicePlatform.DEVICE_PLATFORM_V2_CELLULAR,
label: "V2 Cellular",
description: "Communicates via cellular",
icon: <SignalCellular4Bar style={{ color: "#fff" }} />,
offlineIcon: <SignalCellularOff style={{ color: "#fff" }} />,
platformName: "v2cellular"
};
const V2_Wifi_S3: DevicePlatformDescriber = {
platform: pond.DevicePlatform.DEVICE_PLATFORM_V2_WIFI_S3,
label: "V2 Wifi S3",
description: "Communicates via cellular",
icon: <SignalCellular4Bar style={{ color: "#fff" }} />,
offlineIcon: <SignalCellularOff style={{ color: "#fff" }} />,
platformName: "v2wifis3"
};
const V2_Cell_Black: DevicePlatformDescriber = {
platform: pond.DevicePlatform.DEVICE_PLATFORM_V2_CELLULAR_BLACK,
label: "V2 Cellular Black",
description: "Communicates via cellular",
icon: <SignalCellular4Bar style={{ color: "#fff" }} />,
offlineIcon: <SignalCellularOff style={{ color: "#fff" }} />,
platformName: "v2cellblack"
};
const V2_Cell_Green: DevicePlatformDescriber = {
platform: pond.DevicePlatform.DEVICE_PLATFORM_V2_CELLULAR_GREEN,
label: "V2 Cellular Green",
description: "Communicates via cellular",
icon: <SignalCellular4Bar style={{ color: "#fff" }} />,
offlineIcon: <SignalCellularOff style={{ color: "#fff" }} />,
platformName: "v2cellgreen"
};
const map = new Map<pond.DevicePlatform, DevicePlatformDescriber>([
[pond.DevicePlatform.DEVICE_PLATFORM_INVALID, Default],
[pond.DevicePlatform.DEVICE_PLATFORM_PHOTON, Photon],
[pond.DevicePlatform.DEVICE_PLATFORM_ELECTRON, Electron],
[pond.DevicePlatform.DEVICE_PLATFORM_V2_CELLULAR, V2_Cellular],
[pond.DevicePlatform.DEVICE_PLATFORM_V2_WIFI_S3, V2_Wifi_S3],
[pond.DevicePlatform.DEVICE_PLATFORM_V2_CELLULAR_BLACK, V2_Cell_Black],
[pond.DevicePlatform.DEVICE_PLATFORM_V2_CELLULAR_GREEN, V2_Cell_Green]
]);
export function getDevicePlatformDescriber(platform: pond.DevicePlatform): DevicePlatformDescriber {
const describer = map.get(platform);
return describer ? describer : Default;
}
export function getDevicePlatformLabel(platform: pond.DevicePlatform): string {
return getDevicePlatformDescriber(platform).label;
}
export function getDevicePlatformDescription(platform: pond.DevicePlatform): string {
return getDevicePlatformDescriber(platform).description;
}
export function getDevicePlatformIcon(platform: pond.DevicePlatform): any {
return getDevicePlatformDescriber(platform).icon;
}
export function getDevicePlatformName(platform: pond.DevicePlatform): string {
return getDevicePlatformDescriber(platform).platformName;
}
export function GetAllDevicePlatformDescribers(): DevicePlatformDescriber[] {
return [...map.values()].filter(p => p.platform !== pond.DevicePlatform.DEVICE_PLATFORM_INVALID);
}