assigning available positions for components when a device is loaded on the device page
This commit is contained in:
parent
8a431127b4
commit
d6a00b9ce9
1 changed files with 8 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ import DeviceActions from "device/DeviceActions";
|
|||
import { pond } from "protobuf-ts/pond";
|
||||
import { cloneDeep } from "lodash";
|
||||
import DeviceOverview from "device/DeviceOverview";
|
||||
import { DeviceAvailabilityMap, OffsetAvailabilityMap } from "pbHelpers/DeviceAvailability";
|
||||
import { DeviceAvailabilityMap, FindAvailablePositions, OffsetAvailabilityMap } from "pbHelpers/DeviceAvailability";
|
||||
import AddComponentManualDialog from "component/AddComponentManualDialog";
|
||||
|
||||
export default function DevicePage() {
|
||||
|
|
@ -53,7 +53,8 @@ export default function DevicePage() {
|
|||
|
||||
setLoading(true)
|
||||
deviceAPI.getPageData(deviceID, getContextKeys(), getContextTypes()).then(resp => {
|
||||
setDevice(Device.any(resp.data.device))
|
||||
let device = Device.any(resp.data.device)
|
||||
setDevice(device)
|
||||
let newPermissions: pond.Permission[] = []
|
||||
resp.data.permissions.forEach(perm => {
|
||||
if (typeof(perm) === "string" ) {
|
||||
|
|
@ -72,6 +73,11 @@ export default function DevicePage() {
|
|||
newComps.push(Component.create(comp))
|
||||
})
|
||||
console.log(resp.data.components)
|
||||
let available = FindAvailablePositions(
|
||||
newComps,
|
||||
device.settings.product
|
||||
);
|
||||
setAvailablePositions(available.GetAvailability());
|
||||
setComponents(newComps)
|
||||
}).catch(err => {
|
||||
setDevice(Device.create());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue