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
|
|
@ -236,16 +236,16 @@ export function unitMeasurementSummary(
|
|||
): Summary {
|
||||
let vals: string[] = [];
|
||||
convertedMeasurement.values.forEach(val => {
|
||||
vals.push(val + describer.unit());
|
||||
vals.push(val + convertedMeasurement.unit);
|
||||
});
|
||||
let v = vals.join(", ");
|
||||
if (describer.enumerations().length > 0) {
|
||||
v = describer.enumerations()[parseFloat(vals[0])];
|
||||
}
|
||||
return {
|
||||
colour: describer.colour(),
|
||||
label: describer.label(),
|
||||
type: describer.type(),
|
||||
colour: convertedMeasurement.colour,
|
||||
label: convertedMeasurement.label,
|
||||
type: convertedMeasurement.type,
|
||||
value: v,
|
||||
error: convertedMeasurement.error
|
||||
};
|
||||
|
|
@ -258,6 +258,8 @@ export function unitMeasurementSummaries(
|
|||
): Summary[] {
|
||||
let summaries: Summary[] = [];
|
||||
measurements.measurementsFor.forEach(measurement => {
|
||||
//the only reason the user doesnt need to be passed in here is because it is only used for enumerations,
|
||||
//things like the unit and colour are in the measurement itself at this point
|
||||
let describer = describeMeasurement(measurement.type, compType, subtype);
|
||||
summaries.push(unitMeasurementSummary(measurement, describer));
|
||||
});
|
||||
|
|
@ -530,6 +532,7 @@ export function simpleLineChartData(
|
|||
}
|
||||
});
|
||||
}
|
||||
console.log(lineData)
|
||||
return lineData;
|
||||
}
|
||||
|
||||
|
|
@ -945,6 +948,15 @@ function getOverlayAreas(
|
|||
return overlayAreas;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* this function adds lines to victory graphs for interactions on the component
|
||||
* DEPRECATED: we now use Recharts for our graphs
|
||||
* @param componentType
|
||||
* @param subtype
|
||||
* @param interactionCondition
|
||||
* @returns
|
||||
*/
|
||||
function createInteractionLine(
|
||||
componentType: quack.ComponentType,
|
||||
subtype: number,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Interaction, Component } from "models";
|
||||
import { Interaction, Component, User } from "models";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { quack } from "protobuf-ts/quack";
|
||||
import { or, notNull } from "utils/types";
|
||||
|
|
@ -172,7 +172,8 @@ export const interactionResultText = (interaction: Interaction, sink?: Component
|
|||
export const interactionConditionText = (
|
||||
source: Component | undefined,
|
||||
condition: pond.IInteractionCondition,
|
||||
and: boolean
|
||||
and: boolean,
|
||||
user?: User
|
||||
) => {
|
||||
let comparison = "is exactly";
|
||||
switch (condition.comparison) {
|
||||
|
|
@ -189,7 +190,7 @@ export const interactionConditionText = (
|
|||
if (!condition.measurementType) return "Unknown " + comparison + " " + condition.value;
|
||||
let sourceType = source && source.settings.type;
|
||||
let sourceSubtype = source && source.settings.subtype;
|
||||
let measurement = describeMeasurement(condition.measurementType, sourceType, sourceSubtype);
|
||||
let measurement = describeMeasurement(condition.measurementType, sourceType, sourceSubtype, undefined, user);
|
||||
return (
|
||||
(and ? "and " : "") +
|
||||
measurement.label() +
|
||||
|
|
|
|||
|
|
@ -694,11 +694,12 @@ export function describeMeasurement(
|
|||
componentType: quack.ComponentType | null | undefined = quack.ComponentType
|
||||
.COMPONENT_TYPE_INVALID,
|
||||
componentSubtype: number = 0,
|
||||
product?: pond.DeviceProduct
|
||||
product?: pond.DeviceProduct,
|
||||
user?: User
|
||||
): MeasurementDescriber {
|
||||
measurementType = measurementType
|
||||
? measurementType
|
||||
: quack.MeasurementType.MEASUREMENT_TYPE_INVALID;
|
||||
componentType = componentType ? componentType : quack.ComponentType.COMPONENT_TYPE_INVALID;
|
||||
return new MeasurementDescriber(measurementType, componentType, componentSubtype, product);
|
||||
return new MeasurementDescriber(measurementType, componentType, componentSubtype, product, user);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue