mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 19:45:15 +00:00
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
|
import {
|
||
|
getAllPlotConfigNames,
|
||
|
getPlotConfigName,
|
||
|
storeCustomPlotConfig,
|
||
|
storePlotConfigName,
|
||
|
} from '@/shared/storage';
|
||
|
import { PlotConfigStorage, EMPTY_PLOTCONFIG } from '@/types';
|
||
|
import { defineStore } from 'pinia';
|
||
|
|
||
|
export const usePlotConfigStore = defineStore('plotConfig', {
|
||
|
state: () => {
|
||
|
return {
|
||
|
customPlotConfig: {} as PlotConfigStorage,
|
||
|
plotConfigName: getPlotConfigName(),
|
||
|
availablePlotConfigNames: getAllPlotConfigNames(),
|
||
|
};
|
||
|
},
|
||
|
getters: {
|
||
|
plotConfig: (state) => state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG },
|
||
|
},
|
||
|
actions: {
|
||
|
saveCustomPlotConfig(plotConfig: PlotConfigStorage) {
|
||
|
this.customPlotConfig = plotConfig;
|
||
|
storeCustomPlotConfig(plotConfig);
|
||
|
this.availablePlotConfigNames = getAllPlotConfigNames();
|
||
|
},
|
||
|
updatePlotConfigName(plotConfigName: string) {
|
||
|
// Set default plot config name
|
||
|
this.plotConfigName = plotConfigName;
|
||
|
storePlotConfigName(plotConfigName);
|
||
|
},
|
||
|
setPlotConfigName(plotConfigName: string) {
|
||
|
// TODO: This is identical to updatePlotConfigName
|
||
|
this.plotConfigName = plotConfigName;
|
||
|
storePlotConfigName(plotConfigName);
|
||
|
},
|
||
|
// plotConfigChanged() {
|
||
|
// console.log('plotConfigChanged');
|
||
|
// plotConfig.value = getCustomPlotConfig(this.plotConfigName);
|
||
|
// plotStore.setPlotConfigName(plotConfigName.value);
|
||
|
// },
|
||
|
},
|
||
|
});
|