determine chart color based on state type

This commit is contained in:
Jesse Lucas
2020-03-29 16:51:12 -04:00
parent 6158b20a8c
commit d67c9b66d3
6 changed files with 84 additions and 29 deletions
+27
View File
@@ -1,3 +1,5 @@
import { colors } from './style';
interface Device {
deviceID: string;
name: string;
@@ -41,6 +43,31 @@ namespace Device {
}
}
/**
* stateTypeToColor looks up a hex color string based on StateType
* @param s StateType
*/
export function stateTypeToColor(s: StateType): string {
switch (s) {
case StateType.Insync:
return colors.get("green");
case StateType.UnusedInsync:
return colors.get("grey");
case StateType.Unknown:
return colors.get("grey");
case StateType.Syncing:
return colors.get("blue");
case StateType.Paused:
return colors.get("grey");
case StateType.UnusedPaused:
return colors.get("grey");
case StateType.Disconnected:
return colors.get("yellow");
case StateType.UnusedDisconnected:
return colors.get("grey");
}
}
export function getStateType(d: Device): StateType {
// StateType Unknown is set in DeviceService
if (d.state === StateType.Unknown) {