updated the component and device api's to have as be a parameter for the function
This commit is contained in:
parent
c617ebf868
commit
b62c7dbe5c
39 changed files with 346 additions and 651 deletions
|
|
@ -64,6 +64,7 @@ import {
|
|||
|
||||
} from "@mui/icons-material"
|
||||
import CancelSubmit from "common/CancelSubmit";
|
||||
import { useGlobalState } from "providers";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => {
|
||||
return ({
|
||||
|
|
@ -158,6 +159,7 @@ export default function ComponentSettings(props: Props) {
|
|||
addressTypeRestriction,
|
||||
deviceComponentPrefs
|
||||
} = props;
|
||||
const [{as}] = useGlobalState();
|
||||
const prevComponent = usePrevious(props.component);
|
||||
const prevIsDialogOpen = usePrevious(isDialogOpen);
|
||||
const steps = [0, 1];
|
||||
|
|
@ -304,7 +306,7 @@ export default function ComponentSettings(props: Props) {
|
|||
//component.settings.calibrationCoefficient = Number(form.coefficient);
|
||||
if (cableID > 0) component.settings.addressType = cableID + 8;
|
||||
componentAPI
|
||||
.add(device.id(), component.settings)
|
||||
.add(device.id(), component.settings, as)
|
||||
.then((response: any) => {
|
||||
success(component.name() + " was successfully added!");
|
||||
refresh();
|
||||
|
|
@ -318,13 +320,13 @@ export default function ComponentSettings(props: Props) {
|
|||
const updateComponent = () => {
|
||||
const component = formComponent;
|
||||
componentAPI
|
||||
.update(device.id(), component.settings, getContextKeys(), getContextTypes())
|
||||
.update(device.id(), component.settings, getContextKeys(), getContextTypes(), as)
|
||||
.then((response: any) => {
|
||||
success(component.name() + " was successfully updated!");
|
||||
let updatedPrefs = pond.DeviceComponentPreferences.create();
|
||||
updatedPrefs.excludedNodes = excludedNodes;
|
||||
deviceAPI
|
||||
.updateComponentPreferences(device.id(), component.key(), updatedPrefs)
|
||||
.updateComponentPreferences(device.id(), component.key(), updatedPrefs, undefined, undefined, as)
|
||||
.then(resp => {
|
||||
console.log("Preferences updated");
|
||||
})
|
||||
|
|
@ -343,7 +345,7 @@ export default function ComponentSettings(props: Props) {
|
|||
|
||||
const removeComponent = () => {
|
||||
componentAPI
|
||||
.remove(device.id(), formComponent.key(), getContextKeys(), getContextTypes())
|
||||
.remove(device.id(), formComponent.key(), getContextKeys(), getContextTypes(), as)
|
||||
.then((response: any) => {
|
||||
success(formComponent.name() + " was successfully removed!");
|
||||
refresh();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue