Skip to content

Commit

Permalink
chore: set proper code
Browse files Browse the repository at this point in the history
Signed-off-by: yuda <[email protected]>
  • Loading branch information
yuda110 committed Jan 3, 2025
1 parent 77730cb commit f787412
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
5 changes: 1 addition & 4 deletions apps/web/src/common/modules/widgets/_widgets/gauge/Gauge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ const errorMessage = computed<string|undefined>(() => {
/* Util */
const drawChart = (rawData: WidgetLoadResponse|null) => {
if (isEmpty(rawData)) return;
// HACK: Change the code below when the backend data is modified
// state.chartData = rawData?.results?.[0]?.[widgetOptionsState.dataFieldInfo?.data as string] || 0;
const _targetData = state.data?.results?.find((d) => !!d[widgetOptionsState.dataFieldInfo?.data as string]);
state.chartData = _targetData?.[widgetOptionsState.dataFieldInfo?.data as string] || 0;
state.chartData = rawData?.results?.[0]?.[widgetOptionsState.dataFieldInfo?.data as string] || 0;
};
const loadWidget = () => {
state.runQueries = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,8 @@ const state = reactive({
data: computed<WidgetLoadResponse | null>(() => queryResults.value?.[0].data || null),
previousData: computed<WidgetLoadResponse | null>(() => queryResults.value?.[1]?.data || null),
unit: computed<string|undefined>(() => widgetFrameProps.value.unitMap?.[widgetOptionsState.dataFieldInfo?.data as string]),
previousValue: computed<number>(() => {
// HACK: Change the code below when the backend data is modified
// return state.previousData?.results?.[0]?.[widgetOptionsState.dataFieldInfo?.data as string] ?? 0;
const _targetData = state.previousData?.results?.find((d) => !!d[widgetOptionsState.dataFieldInfo?.data as string]);
return _targetData?.[widgetOptionsState.dataFieldInfo?.data as string] || 0;
}),
currentValue: computed<number>(() => {
// HACK: Change the code below when the backend data is modified
// return state.data?.results?.[0]?.[widgetOptionsState.dataFieldInfo?.data as string] ?? 0;
const _targetData = state.data?.results?.find((d) => !!d[widgetOptionsState.dataFieldInfo?.data as string]);
return _targetData?.[widgetOptionsState.dataFieldInfo?.data as string] || 0;
}),
previousValue: computed<number>(() => state.previousData?.results?.[0]?.[widgetOptionsState.dataFieldInfo?.data as string] ?? 0),
currentValue: computed<number>(() => state.data?.results?.[0]?.[widgetOptionsState.dataFieldInfo?.data as string] ?? 0),
valueText: computed<string|undefined>(() => getFormattedNumber(state.currentValue, widgetOptionsState.numberFormatInfo?.[widgetOptionsState.dataFieldInfo?.data as string], state.unit)),
iconName: computed<string|undefined>(() => widgetOptionsState.iconInfo?.icon?.name),
Expand Down

0 comments on commit f787412

Please sign in to comment.