with changing unit preferences and such to use the user object and not local storage, the decriber needed to be updated as well and i missed that part, so now describeMeasurement takes in an optional user and uses its settings for the unit and such and when not passed in will use the defaults
This commit is contained in:
parent
9d41499c27
commit
52c8a02af3
18 changed files with 117 additions and 56 deletions
|
|
@ -6,6 +6,7 @@ import { pond, quack } from "protobuf-ts/pond";
|
|||
import React, { useState } from "react";
|
||||
import NewObjectInteraction from "./NewObjectInteraction";
|
||||
import { Option } from "common/SearchSelect";
|
||||
import { useGlobalState } from "providers";
|
||||
|
||||
export interface Alert {
|
||||
conditions: pond.InteractionCondition[];
|
||||
|
|
@ -20,10 +21,11 @@ interface Props {
|
|||
|
||||
export default function Alerts(props: Props){
|
||||
const {alerts, addNew, permissions} = props
|
||||
const [{user}] = useGlobalState();
|
||||
// const [openNewAlert, setOpenNewAlert] = useState(false)
|
||||
|
||||
const readableCondition = (condition: pond.InteractionCondition) => {
|
||||
let describer = describeMeasurement(condition.measurementType);
|
||||
let describer = describeMeasurement(condition.measurementType, undefined, undefined, undefined, user);
|
||||
let type = describer.label();
|
||||
let comparison =
|
||||
condition.comparison === quack.RelationalOperator.RELATIONAL_OPERATOR_EQUAL_TO
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { Component, Device, Interaction } from "models";
|
|||
import { interactionResultText } from "pbHelpers/Interaction";
|
||||
import { describeMeasurement } from "pbHelpers/MeasurementDescriber";
|
||||
import { pond, quack } from "protobuf-ts/pond";
|
||||
import { useGlobalState } from "providers";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
export interface Control {
|
||||
|
|
@ -23,6 +24,7 @@ interface Props {
|
|||
|
||||
export default function Controls(props: Props){
|
||||
const { devices, controls, addNew, permissions } = props
|
||||
const [{user}] = useGlobalState();
|
||||
const [deviceControls, setDeviceControls] = useState<Map<number, Control[]>>(new Map())
|
||||
const [openDeviceMenu, setOpenDeviceMenu] = useState(false)
|
||||
const [anchor, setAnchor] = useState<null | HTMLElement>(null)
|
||||
|
|
@ -45,7 +47,7 @@ export default function Controls(props: Props){
|
|||
let conditions: string = ""
|
||||
let firstSource = control.sourceComponents[0]
|
||||
control.conditions.forEach((condition, index) => {
|
||||
let describer = describeMeasurement(condition.measurementType, firstSource.type(), firstSource.subType());
|
||||
let describer = describeMeasurement(condition.measurementType, firstSource.type(), firstSource.subType(), undefined, user);
|
||||
let type = describer.label();
|
||||
let comparison =
|
||||
condition.comparison === quack.RelationalOperator.RELATIONAL_OPERATOR_EQUAL_TO
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ const useStyles = makeStyles((theme: Theme) => {
|
|||
export default function NewObjectInteraction(props: Props){
|
||||
const { open, onClose, device, linkedComponents, componentDevices } = props
|
||||
const classes = useStyles()
|
||||
const [{ as }] = useGlobalState();
|
||||
const [{ as, user }] = useGlobalState();
|
||||
const {openSnack} = useSnackbar();
|
||||
const interactionsAPI = useInteractionsAPI();
|
||||
const [newAlertComponentType, setNewAlertComponentType] = useState<quack.ComponentType>(
|
||||
|
|
@ -249,7 +249,7 @@ export default function NewObjectInteraction(props: Props){
|
|||
const measurementTypeMenuItems = () => {
|
||||
return availableMeasurementTypes(newAlertComponentType).map(measurementType => (
|
||||
<MenuItem key={measurementType} value={measurementType}>
|
||||
{describeMeasurement(measurementType).label()}
|
||||
{describeMeasurement(measurementType, undefined, undefined, undefined, user).label()}
|
||||
</MenuItem>
|
||||
));
|
||||
};
|
||||
|
|
@ -531,7 +531,9 @@ export default function NewObjectInteraction(props: Props){
|
|||
return describeMeasurement(
|
||||
Measurement.boolean,
|
||||
or(sink, Component.create()).settings.type,
|
||||
or(sink, Component.create()).settings.subtype
|
||||
or(sink, Component.create()).settings.subtype,
|
||||
undefined,
|
||||
user
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue