Skip to content

Commit

Permalink
automatically switch to OneWireGpioModuleWidget to GpioModule
Browse files Browse the repository at this point in the history
  • Loading branch information
steersbob committed Jul 5, 2024
1 parent c0a2f18 commit 2b7f9d6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
15 changes: 15 additions & 0 deletions dev/presets/brewblox-ui-store.redis.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@
"blockId": "Sequence"
}
},
{
"namespace": "brewblox-ui-store:dashboard-items",
"id": "2-UtLY_8z24JlcbI8oLrF",
"title": "Old OneWire",
"feature": "OneWireGpioModule",
"cols": 4,
"order": 20,
"pinnedPosition": null,
"rows": 4,
"dashboard": "dashboard-home",
"config": {
"serviceId": "sparkey",
"blockId": "gpio-1"
}
},
{
"namespace": "brewblox-ui-store:logged-sessions",
"id": "3d15296d-0abd-4d45-383c-0bec436ae319",
Expand Down
17 changes: 16 additions & 1 deletion src/plugins/spark/features/GpioModule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import {
import { Plugin } from 'vue';
import { discoveredBlockFeature } from '@/plugins/spark/generic';
import { useBlockSpecStore } from '@/plugins/spark/store';
import { BlockSpec } from '@/plugins/spark/types';
import { BlockConfig, BlockSpec } from '@/plugins/spark/types';
import { useFeatureStore, WidgetFeature } from '@/store/features';
import { Widget } from '@/store/widgets';
import { cref } from '@/utils/component-ref';
import widget from './GpioModuleWidget.vue';

Expand Down Expand Up @@ -69,8 +70,22 @@ const plugin: Plugin = {
},
};

const renamedFeature: WidgetFeature = {
...discoveredBlockFeature,
id: 'OneWireGpioModule',
title: 'OneWire GPIO Module (renamed)',
role: 'Output',
component: '',
widgetSize: { cols: 0, rows: 0 },
upgrade: (widget: Widget<unknown>): Widget<BlockConfig> | null => {
return { ...widget, feature: type } as Widget<BlockConfig>;
},
experimental: true,
};

specStore.addBlockSpec(blockSpec);
featureStore.addWidgetFeature(feature);
featureStore.addWidgetFeature(renamedFeature);
},
};

Expand Down

0 comments on commit 2b7f9d6

Please sign in to comment.