From 0e4637185363539af13a4cb2c21360ddd46aa18d Mon Sep 17 00:00:00 2001 From: Anton Ulyanov Date: Wed, 6 Nov 2024 20:59:39 +0300 Subject: [PATCH] StatsHouse UI: fix pack show total and filled graph update total line dark theme remove dv param in single dash link create new dash --- .../src/store2/helpers/getPlotLink.ts | 1 + .../plotDataStore/changePlotParamForData.ts | 7 ++-- .../store2/plotDataStore/normalizePlotData.ts | 3 +- statshouse-ui/src/store2/urlStore/urlStore.ts | 38 +------------------ statshouse-ui/src/url2/url.test.ts | 4 +- 5 files changed, 10 insertions(+), 43 deletions(-) diff --git a/statshouse-ui/src/store2/helpers/getPlotLink.ts b/statshouse-ui/src/store2/helpers/getPlotLink.ts index e4ddf775c..082afa48e 100644 --- a/statshouse-ui/src/store2/helpers/getPlotLink.ts +++ b/statshouse-ui/src/store2/helpers/getPlotLink.ts @@ -80,6 +80,7 @@ export function getPlotSingleLink(plotKey: PlotKey, params: QueryParams): string produce(params, (p) => { p.tabNum = plotKey; p.dashboardId = undefined; + p.dashboardVersion = undefined; }) ) ).toString() diff --git a/statshouse-ui/src/store2/plotDataStore/changePlotParamForData.ts b/statshouse-ui/src/store2/plotDataStore/changePlotParamForData.ts index 183d3fa41..9ea8181db 100644 --- a/statshouse-ui/src/store2/plotDataStore/changePlotParamForData.ts +++ b/statshouse-ui/src/store2/plotDataStore/changePlotParamForData.ts @@ -1,6 +1,5 @@ -import { type PlotParams, type VariableParams } from 'url2'; +import { type PlotParams } from 'url2'; import { dequal } from 'dequal/lite'; -import { useVariableChangeStatusStore } from '../variableChangeStatusStore'; export function changePlotParamForData(plot?: PlotParams, prevPlot?: PlotParams) { return ( @@ -16,6 +15,8 @@ export function changePlotParamForData(plot?: PlotParams, prevPlot?: PlotParams) plot.maxHost !== prevPlot.maxHost || plot.backendVersion !== prevPlot.backendVersion || plot.type !== prevPlot.type || - plot.prometheusCompat !== prevPlot.prometheusCompat + plot.prometheusCompat !== prevPlot.prometheusCompat || + plot.totalLine !== prevPlot.totalLine || + plot.filledGraph !== prevPlot.filledGraph ); } diff --git a/statshouse-ui/src/store2/plotDataStore/normalizePlotData.ts b/statshouse-ui/src/store2/plotDataStore/normalizePlotData.ts index 309bbc8a7..b7885cb4a 100644 --- a/statshouse-ui/src/store2/plotDataStore/normalizePlotData.ts +++ b/statshouse-ui/src/store2/plotDataStore/normalizePlotData.ts @@ -21,6 +21,7 @@ import { calcYRange2 } from '../../common/calcYRange'; import { getEmptyPlotData } from './getEmptyPlotData'; import { deepClone } from '../../common/helpers'; import { formatLegendValue, formatPercent, timeShiftToDash } from 'view/utils2'; +import { useThemeStore } from '../themeStore'; export function normalizePlotData( response: SeriesResponse, @@ -44,7 +45,7 @@ export function normalizePlotData( let series_data = [...response.series.series_data]; const totalLineId = plot.totalLine ? series_meta.length : null; const totalLineLabel = 'Total'; - const totalLineColor = '#333333'; + const totalLineColor = useThemeStore.getState().dark ? '#999999' : '#333333'; const prefColor = '9'; // it`s magic prefix const usedDashes = {}; const usedBaseColors = {}; diff --git a/statshouse-ui/src/store2/urlStore/urlStore.ts b/statshouse-ui/src/store2/urlStore/urlStore.ts index b8dfc1e81..287ee9815 100644 --- a/statshouse-ui/src/store2/urlStore/urlStore.ts +++ b/statshouse-ui/src/store2/urlStore/urlStore.ts @@ -71,7 +71,6 @@ export type UrlStore = { addDashboardGroup(groupKey: GroupKey): void; removeDashboardGroup(groupKey: GroupKey): void; setDashboardGroup(groupKey: GroupKey, next: ProduceUpdate): void; - // moveDashboardPlot(index: PlotKey | null, indexTarget: PlotKey | null, indexGroup: GroupKey | null): void; setNextDashboardSchemePlot(nextScheme: { groupKey: GroupKey; plots: PlotKey[] }[]): void; autoSearchVariable(): Promise>; saveDashboard(): Promise; @@ -276,42 +275,6 @@ export const urlStore: StoreSlice = (setState, getSta setDashboardGroup(groupKey, next) { setUrlStore(updateGroup(groupKey, next)); }, - // moveDashboardPlot(plotKey, plotKeyTarget, groupKey) { - // if (plotKey != null && groupKey != null) { - // setUrlStore( - // updateParamsPlotStruct((plotStruct) => { - // const sourceGroupKey = plotStruct.mapPlotToGroup[plotKey] ?? ''; - // const sourceGroupIndex = plotStruct.mapGroupIndex[sourceGroupKey]; - // const sourcePlotIndex = plotStruct.mapPlotIndex[plotKey]; - // const targetGroupIndex = plotStruct.mapGroupIndex[groupKey ?? sourceGroupKey]; - // let targetPlotIndex = plotStruct.mapPlotIndex[plotKeyTarget ?? plotKey]; - // if (sourceGroupIndex != null && sourcePlotIndex != null) { - // const sourcePlots = plotStruct.groups[sourceGroupIndex].plots.splice(sourcePlotIndex, 1); - // if (targetGroupIndex == null) { - // plotStruct.groups.push({ - // plots: [...sourcePlots], - // groupInfo: { - // ...getNewGroup(), - // id: groupKey, - // }, - // }); - // } else { - // if (targetPlotIndex) { - // if (sourceGroupIndex === targetGroupIndex) { - // targetPlotIndex = plotStruct.groups[targetGroupIndex].plots.findIndex( - // ({ plotInfo }) => plotInfo.id === plotKeyTarget - // ); - // } - // plotStruct.groups[targetGroupIndex].plots.splice(targetPlotIndex, 0, ...sourcePlots); - // } else { - // plotStruct.groups[targetGroupIndex].plots.push(...sourcePlots); - // } - // } - // } - // }) - // ); - // } - // }, setNextDashboardSchemePlot(nextScheme) { setUrlStore( updateParamsPlotStruct((plotStruct) => { @@ -358,6 +321,7 @@ export const urlStore: StoreSlice = (setState, getSta setUrlStore((store) => { store.saveParams = saveParams; store.params.dashboardVersion = saveParams.dashboardVersion; + store.params.dashboardId = saveParams.dashboardId; }); } }, diff --git a/statshouse-ui/src/url2/url.test.ts b/statshouse-ui/src/url2/url.test.ts index c8e8bf620..6f54bd7f4 100644 --- a/statshouse-ui/src/url2/url.test.ts +++ b/statshouse-ui/src/url2/url.test.ts @@ -57,11 +57,11 @@ const params2: QueryParams = { }; describe('urlStore', () => { - test.skip('urlEncode => urlDecode', () => { + test('urlEncode => urlDecode', () => { expect(urlDecode(toTreeObj(arrToObj(urlEncode(params))), params)).toEqual(params); }); test('urlEncode => urlDecode save', () => { - // expect(urlDecode(toTreeObj(arrToObj(urlEncode(params2, params))), params)).toEqual(params2); + expect(urlDecode(toTreeObj(arrToObj(urlEncode(params2, params))), params)).toEqual(params2); expect(urlDecode(toTreeObj(arrToObj(urlEncode(params, params2))), params2)).toEqual(params); }); });