changover to use the components settings and not the prefs
This commit is contained in:
parent
67cafbe2ed
commit
90776b0c06
6 changed files with 32 additions and 49 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -42,7 +42,7 @@
|
||||||
"mui-tel-input": "^7.0.0",
|
"mui-tel-input": "^7.0.0",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"openweathermap-ts": "^1.2.10",
|
"openweathermap-ts": "^1.2.10",
|
||||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging",
|
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#node_exclusion_update",
|
||||||
"query-string": "^9.2.1",
|
"query-string": "^9.2.1",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
|
|
@ -10889,7 +10889,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/protobuf-ts": {
|
"node_modules/protobuf-ts": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#4523ffef42032eb4a923bd50d4cfcccbb1397dbd",
|
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#c027bd51ae890e5b6dc6b9468e3eb5e3cd207828",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"protobufjs": "^6.8.8"
|
"protobufjs": "^6.8.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
"mui-tel-input": "^7.0.0",
|
"mui-tel-input": "^7.0.0",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"openweathermap-ts": "^1.2.10",
|
"openweathermap-ts": "^1.2.10",
|
||||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging",
|
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#node_exclusion_update",
|
||||||
"query-string": "^9.2.1",
|
"query-string": "^9.2.1",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ export default function ComponentCard(props: Props) {
|
||||||
// ) : (
|
// ) : (
|
||||||
<UnitMeasurementSummary
|
<UnitMeasurementSummary
|
||||||
component={component}
|
component={component}
|
||||||
excludedNodes={deviceComponentPreferences?.excludedNodes}
|
excludedNodes={component.settings.excludedNodes}
|
||||||
reading={UnitMeasurement.convertLastMeasurement(measurements)}
|
reading={UnitMeasurement.convertLastMeasurement(measurements)}
|
||||||
//dense
|
//dense
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ export default function ComponentChart(props: Props) {
|
||||||
|
|
||||||
//use the excluded nodes to set the default for the graph filters
|
//use the excluded nodes to set the default for the graph filters
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let excludedNodes = deviceComponentPreferences?.excludedNodes;
|
let excludedNodes = component.settings.excludedNodes;
|
||||||
if (excludedNodes === undefined || excludedNodes.length === 0) return;
|
if (excludedNodes === undefined || excludedNodes.length === 0) return;
|
||||||
let updatedFilters = cloneDeep(graphFilters);
|
let updatedFilters = cloneDeep(graphFilters);
|
||||||
if (excludedNodes && component.lastMeasurement[0]) {
|
if (excludedNodes && component.lastMeasurement[0]) {
|
||||||
|
|
@ -165,7 +165,7 @@ export default function ComponentChart(props: Props) {
|
||||||
updatedFilters.selectedNodes = includedNodes;
|
updatedFilters.selectedNodes = includedNodes;
|
||||||
}
|
}
|
||||||
setGraphFilters(updatedFilters);
|
setGraphFilters(updatedFilters);
|
||||||
}, [deviceComponentPreferences, component]); //eslint-disable-line react-hooks/exhaustive-deps
|
}, [component]); //eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
const updateDateRange = (newStartDate: any, newEndDate: any, live: boolean) => {
|
const updateDateRange = (newStartDate: any, newEndDate: any, live: boolean) => {
|
||||||
setStartDate(newStartDate);
|
setStartDate(newStartDate);
|
||||||
|
|
@ -211,10 +211,11 @@ export default function ComponentChart(props: Props) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const cableControls = () => {
|
const cableControls = () => {
|
||||||
const { component, samples, deviceComponentPreferences } = props;
|
const { component, samples } = props;
|
||||||
const excludedNodes = deviceComponentPreferences?.excludedNodes ?? [];
|
|
||||||
const selectedNodes = graphFilters.selectedNodes ? graphFilters.selectedNodes : ["all"];
|
const selectedNodes = graphFilters.selectedNodes ? graphFilters.selectedNodes : ["all"];
|
||||||
const lastMeasurement = component.status.lastMeasurement;
|
const lastMeasurement = component.status.lastMeasurement;
|
||||||
|
const excludedNodes = component.settings.excludedNodes ?? [];
|
||||||
|
|
||||||
let numNodes = 0;
|
let numNodes = 0;
|
||||||
if (samples) {
|
if (samples) {
|
||||||
numNodes = GetNumNodes(
|
numNodes = GetNumNodes(
|
||||||
|
|
@ -322,7 +323,7 @@ export default function ComponentChart(props: Props) {
|
||||||
checked={selectedNodes.includes((i - 1).toString()) ? true : false}
|
checked={selectedNodes.includes((i - 1).toString()) ? true : false}
|
||||||
onChange={handleGrainCableControlsChange((i - 1).toString())}
|
onChange={handleGrainCableControlsChange((i - 1).toString())}
|
||||||
value={(i - 1).toString()}
|
value={(i - 1).toString()}
|
||||||
disabled={excludedNodes.includes(i - 1)}
|
//disabled={excludedNodes.includes(i - 1)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
label={<Typography variant="body2">{nodeLabel}</Typography>}
|
label={<Typography variant="body2">{nodeLabel}</Typography>}
|
||||||
|
|
@ -724,7 +725,7 @@ export default function ComponentChart(props: Props) {
|
||||||
<UnitMeasurementSummary
|
<UnitMeasurementSummary
|
||||||
component={component}
|
component={component}
|
||||||
reading={convertedLastMeasurement}
|
reading={convertedLastMeasurement}
|
||||||
excludedNodes={deviceComponentPreferences?.excludedNodes}
|
excludedNodes={component.settings.excludedNodes}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
@ -764,7 +765,7 @@ export default function ComponentChart(props: Props) {
|
||||||
reading={convertedLastMeasurement}
|
reading={convertedLastMeasurement}
|
||||||
largeText
|
largeText
|
||||||
boldMeasurements
|
boldMeasurements
|
||||||
excludedNodes={deviceComponentPreferences?.excludedNodes}
|
excludedNodes={component.settings.excludedNodes}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -180,11 +180,11 @@ export default function ComponentSettings(props: Props) {
|
||||||
setTabVal(newValue);
|
setTabVal(newValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (deviceComponentPrefs) {
|
// if (deviceComponentPrefs) {
|
||||||
setExcludedNodes(deviceComponentPrefs.excludedNodes);
|
// setExcludedNodes(deviceComponentPrefs.excludedNodes);
|
||||||
}
|
// }
|
||||||
}, [deviceComponentPrefs]);
|
// }, [deviceComponentPrefs]);
|
||||||
|
|
||||||
const init = useCallback(() => {
|
const init = useCallback(() => {
|
||||||
let component = props.component;
|
let component = props.component;
|
||||||
|
|
@ -207,6 +207,7 @@ export default function ComponentSettings(props: Props) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
setFormComponent(initComponent);
|
setFormComponent(initComponent);
|
||||||
|
setExcludedNodes(initComponent.settings.excludedNodes)
|
||||||
}, [props.component, componentTypeOptions]);
|
}, [props.component, componentTypeOptions]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -238,7 +239,6 @@ export default function ComponentSettings(props: Props) {
|
||||||
componentType: quack.ComponentType
|
componentType: quack.ComponentType
|
||||||
): number[] => {
|
): number[] => {
|
||||||
let positions = availablePositions.get(addressType);
|
let positions = availablePositions.get(addressType);
|
||||||
console.log(positions)
|
|
||||||
if (!positions) return [];
|
if (!positions) return [];
|
||||||
switch (addressType) {
|
switch (addressType) {
|
||||||
case quack.AddressType.ADDRESS_TYPE_I2C:
|
case quack.AddressType.ADDRESS_TYPE_I2C:
|
||||||
|
|
@ -320,20 +320,21 @@ export default function ComponentSettings(props: Props) {
|
||||||
|
|
||||||
const updateComponent = () => {
|
const updateComponent = () => {
|
||||||
const component = formComponent;
|
const component = formComponent;
|
||||||
|
component.settings.excludedNodes = excludedNodes
|
||||||
componentAPI
|
componentAPI
|
||||||
.update(device.id(), component.settings, getContextKeys(), getContextTypes(), as)
|
.update(device.id(), component.settings, getContextKeys(), getContextTypes(), as)
|
||||||
.then((_response: any) => {
|
.then((_response: any) => {
|
||||||
success(component.name() + " was successfully updated!");
|
success(component.name() + " was successfully updated!");
|
||||||
let updatedPrefs = pond.DeviceComponentPreferences.create();
|
// let updatedPrefs = pond.DeviceComponentPreferences.create();
|
||||||
updatedPrefs.excludedNodes = excludedNodes;
|
// updatedPrefs.excludedNodes = excludedNodes;
|
||||||
deviceAPI
|
// deviceAPI
|
||||||
.updateComponentPreferences(device.id(), component.key(), updatedPrefs, undefined, undefined, as)
|
// .updateComponentPreferences(device.id(), component.key(), updatedPrefs, undefined, undefined, as)
|
||||||
.then(_resp => {
|
// .then(_resp => {
|
||||||
console.log("Preferences updated");
|
// console.log("Preferences updated");
|
||||||
})
|
// })
|
||||||
.catch(_err => {
|
// .catch(_err => {
|
||||||
console.log("Preferences failed to update");
|
// console.log("Preferences failed to update");
|
||||||
});
|
// });
|
||||||
refresh();
|
refresh();
|
||||||
})
|
})
|
||||||
.catch((_err: any) => {
|
.catch((_err: any) => {
|
||||||
|
|
@ -413,7 +414,6 @@ export default function ComponentSettings(props: Props) {
|
||||||
for (let i = 0; i < addressTypes.length; i++) {
|
for (let i = 0; i < addressTypes.length; i++) {
|
||||||
let addressType = addressTypes[i];
|
let addressType = addressTypes[i];
|
||||||
let availablePositions = getAvailablePositions(addressType, type);
|
let availablePositions = getAvailablePositions(addressType, type);
|
||||||
console.log(availablePositions)
|
|
||||||
|
|
||||||
availableMenuItemPositions.push(
|
availableMenuItemPositions.push(
|
||||||
<MenuItem key={addressType} divider disabled>
|
<MenuItem key={addressType} divider disabled>
|
||||||
|
|
@ -976,24 +976,6 @@ export default function ComponentSettings(props: Props) {
|
||||||
}}>
|
}}>
|
||||||
Clear Excluded Nodes
|
Clear Excluded Nodes
|
||||||
</Button>
|
</Button>
|
||||||
{/* button for testing the pref update */}
|
|
||||||
{/* {prevComponent && (
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
let pref = pond.DeviceComponentPreferences.create();
|
|
||||||
pref.excludedNodes = excludedNodes;
|
|
||||||
deviceAPI
|
|
||||||
.updateComponentPreferences(device.id(), prevComponent.key(), pref)
|
|
||||||
.then(resp => {
|
|
||||||
console.log("no errors");
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log("errors");
|
|
||||||
});
|
|
||||||
}}>
|
|
||||||
Update Prefs
|
|
||||||
</Button>
|
|
||||||
)} */}
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -1019,7 +1001,7 @@ export default function ComponentSettings(props: Props) {
|
||||||
onChange={handleChange}>
|
onChange={handleChange}>
|
||||||
<Tab label="General" />
|
<Tab label="General" />
|
||||||
<Tab label="Overlays" />
|
<Tab label="Overlays" />
|
||||||
<Tab label="Preferences" disabled={!prevComponent} />
|
<Tab label="Nodes" disabled={!prevComponent} />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
)}
|
)}
|
||||||
<TabPanelMine value={tabVal} index={0}>
|
<TabPanelMine value={tabVal} index={0}>
|
||||||
|
|
|
||||||
|
|
@ -487,7 +487,7 @@ export default function DeviceComponent() {
|
||||||
component={component}
|
component={component}
|
||||||
reading={row}
|
reading={row}
|
||||||
tableCell={true}
|
tableCell={true}
|
||||||
excludedNodes={deviceComponentPrefs?.excludedNodes}
|
excludedNodes={component.settings.excludedNodes}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -528,7 +528,7 @@ export default function DeviceComponent() {
|
||||||
// component={component}
|
// component={component}
|
||||||
// reading={row}
|
// reading={row}
|
||||||
// tableCell={true}
|
// tableCell={true}
|
||||||
// excludedNodes={deviceComponentPrefs?.excludedNodes}
|
// excludedNodes={component.settings.excludedNodes}
|
||||||
// />
|
// />
|
||||||
// )
|
// )
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue