Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ui error when input block is linked to DS2408 and print trace in console on error #1885

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/widget/WidgetWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ provide(ContextKey, reactive<WidgetContext>(cloneDeep(props.context)));

provide(InvalidateKey, (reason?: string) => {
error.value = reason ?? 'Unknown error';
// eslint-disable-next-line no-console
console.error(error.value);
invalidateParent(reason);
});

Expand All @@ -60,6 +62,8 @@ provide(ChangeWidgetTitleKey, () => startChangeWidgetTitle(props.widget));

onErrorCaptured((err: Error) => {
error.value = err.message;
// eslint-disable-next-line no-console
console.trace(err);
return false;
});
</script>
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/builder/components/PartWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ onErrorCaptured((err: Error) => {
error.value = err.message;
const { type, x, y } = props.part;
notify.error(`${type} (${x},${y}) :${err.message}`);
// eslint-disable-next-line no-console
console.trace(err);
return false;
});
</script>
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/spark/components/widget/BlockWidgetWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ watch(

onErrorCaptured((err: Error) => {
error.value = err.message;
// eslint-disable-next-line no-console
console.trace(err);
return false;
});
</script>
Expand Down
14 changes: 13 additions & 1 deletion src/plugins/spark/components/widget/IoArray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
BlockType,
ChannelCapabilities,
DigitalActuatorBlock,
DigitalInputBlock,
DigitalState,
FastPwmBlock,
IoArrayInterfaceBlock,
Expand All @@ -31,6 +32,7 @@ interface EditableChannel extends IoChannel {
pwmActuator: FastPwmBlock | null;
actuatorClaimed: boolean;
compatibleTypes: BlockOrIntfType[];
input: DigitalInputBlock | null;
}

const sparkStore = useSparkStore();
Expand All @@ -46,6 +48,9 @@ const channels = computed<EditableChannel[]>(() =>
if (c.capabilities & ChannelCapabilities.CHAN_SUPPORTS_PWM_100HZ) {
compatibleTypes.push(BlockOrIntfType.FastPwm);
}
if (c.capabilities & ChannelCapabilities.CHAN_SUPPORTS_DIGITAL_INPUT) {
compatibleTypes.push(BlockOrIntfType.DigitalInput);
}
return {
...c,
compatibleTypes,
Expand All @@ -55,7 +60,8 @@ const channels = computed<EditableChannel[]>(() =>
BlockIntfType.ActuatorDigitalInterface,
),
pwmActuator: ifCompatible(actuator, BlockType.FastPwm),
actuatorClaimed: actuator?.data.claimedBy.id != null,
actuatorClaimed: actuator?.data.claimedBy?.id != null,
input: ifCompatible(actuator, BlockType.DigitalInput),
};
}),
);
Expand Down Expand Up @@ -135,6 +141,12 @@ async function updatePwmSetting(channel: EditableChannel): Promise<void> {
@click="updatePwmSetting(channel)"
/>
</div>
<DigitalStateButton
v-else-if="channel.input"
disable
:model-value="channel.input.data.state"
class="col-auto self-center"
/>
<div
v-else
class="darkened text-italic q-pa-sm"
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/spark/features/DS2408/DS2408Widget.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script setup lang="ts">
import {
BlockIntfType,
BlockType,
DigitalActuatorBlock,
DigitalInputBlock,
DS2408Block,
DS2408ConnectMode,
MotorValveBlock,
Expand Down Expand Up @@ -33,8 +35,10 @@ function setConnectMode(mode: DS2408ConnectMode): void {
}
const linked = sparkStore
.blocksByService(serviceId)
.filter((b): b is DigitalActuatorBlock | MotorValveBlock =>
isCompatible(b.type, BlockIntfType.ActuatorDigitalInterface),
.filter(
(b): b is DigitalActuatorBlock | MotorValveBlock | DigitalInputBlock =>
isCompatible(b.type, BlockIntfType.ActuatorDigitalInterface) ||
b.type === BlockType.DigitalInput,
)
.filter((b) => b.data.hwDevice.id === block.value.id);

Expand Down
Loading