Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
elcojacobs committed Jul 1, 2024
1 parent d9e4cd5 commit 6554f68
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dev/makecert.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env bash
set -euox pipefail
set -euo pipefail
pushd "$(git rev-parse --show-toplevel)" >/dev/null

mkdir -p dev/traefik/
Expand Down
32 changes: 17 additions & 15 deletions src/plugins/spark/components/widget/AnalogArrayEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,32 @@ import {
Block,
BlockOrIntfType,
} from 'brewblox-proto/ts';
import { defineProps } from 'vue';
import { computed } from 'vue';
import { ENUM_LABELS_ANALOG_SENSOR_TYPE } from '@/plugins/spark/const';
import { useSparkStore } from '@/plugins/spark/store';
import { BlockAddress } from '@/plugins/spark/types';
import { createBlockDialog } from '@/utils/block-dialog';
import { createDialog } from '@/utils/dialog';
interface Props {
channels: AnalogModuleChannel[];
serviceId: string;
blockId: string;
address: BlockAddress;
}
const sparkStore = useSparkStore();
const props = defineProps<Props>();
function existingSensors(channel: number): Block[] {
return sparkStore
const existingSensors = computed<{ [channelId: number]: Block[] }>(() => {
const sensors = sparkStore
.blocksByType(props.serviceId, BlockOrIntfType.TempSensorAnalog)

Check failure on line 25 in src/plugins/spark/components/widget/AnalogArrayEditor.vue

View workflow job for this annotation

GitHub Actions / build

Property 'serviceId' does not exist on type 'DefineProps<LooseRequired<Props>, never>'.
.filter(
(block) =>
block.data.analogDevice.id === props.blockId &&
block.data.analogChannel === channel,
.filter((block) => block.data.analogDevice.id === props.address.id);
return props.channels.reduce((acc, channel) => {
acc[channel.id] = sensors.filter(
(block) => block.data.analogChannel === channel.id,
);
}
return acc;
}, {});
});
function sensorToBlockType(
sensorType: AnalogSensorType,
Expand All @@ -44,13 +46,13 @@ function sensorToBlockType(
}
function createSensor(sensorType: BlockOrIntfType | null): void {
if (sensorType === null) {
if (sensorType == null) {
return;
}
createDialog({
component: 'BlockWizardDialog',
componentProps: {
serviceId: props.serviceId,
serviceId: props.address.serviceId,
compatible: sensorType,
},
});
Expand Down Expand Up @@ -107,13 +109,13 @@ function createSensor(sensorType: BlockOrIntfType | null): void {
class="col-2"
/>
<LabeledField
v-if="existingSensors(channel.id).length > 0"
v-if="existingSensors[channel.id].length > 0"
label="Used by"
readonly
class="col-grow row"
>
<q-btn
v-for="userBlock in existingSensors(channel.id)"
v-for="userBlock in existingSensors[channel.id]"
:key="userBlock.id"
:label="userBlock.id"
dense
Expand All @@ -126,7 +128,7 @@ function createSensor(sensorType: BlockOrIntfType | null): void {
<LabeledField
v-if="
sensorToBlockType(channel.sensorType) !== null &&
existingSensors(channel.id).length == 0
existingSensors[channel.id].length == 0
"
label="Not used"
readonly
Expand Down
1 change: 0 additions & 1 deletion src/plugins/spark/features/GpioModule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const plugin: Plugin = {
cols: 4,
rows: 4,
},
experimental: true,
};

specStore.addBlockSpec(blockSpec);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/spark/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ const plugins: Plugin[] = [
DS2413,
DeprecatedObject,
FastPwm,
GpioModule,
InactiveObject,
MockPins,
Pid,
MotorValve,
Mutex,
GpioModule,
Pid,
Sequence,
SetpointProfile,
SetpointSensorPair,
Expand Down

0 comments on commit 6554f68

Please sign in to comment.