Add sensor model to FE

pull/667/head
Rick Carlino 2018-02-19 14:04:39 -06:00
parent 54569fbba4
commit 0324865b31
5 changed files with 19 additions and 2 deletions

View File

@ -121,6 +121,8 @@ export class API {
get fbosConfigPath() { return `${this.baseUrl}/api/fbos_config/`; }
/** /api/sensor_readings */
get sensorReadingPath() { return `${this.baseUrl}/api/sensor_readings`; }
/** /api/sensor_readings */
get sensorPath() { return `${this.baseUrl}/api/sensors`; }
/** /api/users/verify/:token */
verificationPath = (token: string) => ("/api/users/verify/" + token);
}

View File

@ -21,6 +21,13 @@ export interface SelectOptionsParams {
z?: number;
}
export interface Sensor {
id?: number;
pin: number | undefined;
label: string;
mode: number;
}
export interface SensorReading {
id?: number | undefined;
x: number | undefined;

View File

@ -75,7 +75,8 @@ export function emptyState(): RestResources {
FbosConfig: [],
FirmwareConfig: [],
WebAppConfig: [],
SensorReading: []
SensorReading: [],
Sensor: []
},
byKindAndId: {},
references: {}
@ -130,6 +131,7 @@ export let resourceReducer = generateReducer
case "WebAppConfig":
case "FirmwareConfig":
case "FbosConfig":
case "Sensor":
reindexResource(s.index, resource);
dontTouchThis(resource);
s.index.references[resource.uuid] = resource;
@ -161,6 +163,7 @@ export let resourceReducer = generateReducer
case "FirmwareConfig":
case "SensorReading":
case "Image":
case "Sensor":
removeFromIndex(s.index, resource);
break;
default:

View File

@ -8,6 +8,7 @@ import {
PlantPointer,
ToolSlotPointer,
SensorReading,
Sensor,
} from "../interfaces";
import { Peripheral } from "../controls/peripherals/interfaces";
import { User } from "../auth/interfaces";
@ -34,6 +35,7 @@ export type ResourceName =
| "Plant"
| "Point"
| "Regimen"
| "Sensor"
| "SensorReading"
| "Sequence"
| "Tool"
@ -93,6 +95,7 @@ export type TaggedResource =
| TaggedPeripheral
| TaggedPoint
| TaggedRegimen
| TaggedSensor
| TaggedSensorReading
| TaggedSequence
| TaggedTool
@ -112,6 +115,7 @@ export type TaggedFbosConfig = Resource<"FbosConfig", FbosConfig>;
export type TaggedFirmwareConfig = Resource<"FirmwareConfig", FirmwareConfig>;
export type TaggedWebAppConfig = Resource<"WebAppConfig", WebAppConfig>;
export type TaggedSensorReading = Resource<"SensorReading", SensorReading>;
export type TaggedSensor = Resource<"Sensor", Sensor>;
type PointUnion = GenericPointer | PlantPointer | ToolSlotPointer;

View File

@ -1,5 +1,5 @@
import axios from "axios";
import { Log, Point, SensorReading } from "../interfaces";
import { Log, Point, SensorReading, Sensor } from "../interfaces";
import { API } from "../api";
import { Sequence } from "../sequences/interfaces";
import { Tool } from "../tools/interfaces";
@ -52,4 +52,5 @@ export function fetchSyncData(dispatch: Function) {
fetch<Sequence[]>("Sequence", API.current.sequencesPath);
fetch<Tool[]>("Tool", API.current.toolsPath);
fetch<SensorReading[]>("SensorReading", API.current.sensorReadingPath);
fetch<Sensor[]>("Sensor", API.current.sensorPath);
}