create a type for loading status

This commit is contained in:
Lemuel 2022-03-04 03:16:21 +08:00
parent 50cf3e2486
commit 01fdbb1a73
4 changed files with 13 additions and 8 deletions

View File

@ -91,6 +91,7 @@ import {
PlotConfig, PlotConfig,
PairCandlePayload, PairCandlePayload,
PairHistoryPayload, PairHistoryPayload,
LoadingStatus,
} from '@/types'; } from '@/types';
import CandleChart from '@/components/charts/CandleChart.vue'; import CandleChart from '@/components/charts/CandleChart.vue';
import PlotConfigurator from '@/components/charts/PlotConfigurator.vue'; import PlotConfigurator from '@/components/charts/PlotConfigurator.vue';
@ -137,11 +138,11 @@ export default class CandleChartContainer extends Vue {
@ftbot.Action setPlotConfigName; @ftbot.Action setPlotConfigName;
@ftbot.Getter [BotStoreGetters.candleDataStatus]!: 'loading' | 'success' | 'error'; @ftbot.Getter [BotStoreGetters.candleDataStatus]!: LoadingStatus;
@ftbot.Getter [BotStoreGetters.candleData]!: PairHistory; @ftbot.Getter [BotStoreGetters.candleData]!: PairHistory;
@ftbot.Getter [BotStoreGetters.historyStatus]!: 'loading' | 'success' | 'error'; @ftbot.Getter [BotStoreGetters.historyStatus]!: LoadingStatus;
@ftbot.Getter [BotStoreGetters.history]!: PairHistory; @ftbot.Getter [BotStoreGetters.history]!: PairHistory;

View File

@ -36,6 +36,7 @@ import {
DeleteTradeResponse, DeleteTradeResponse,
BlacklistResponse, BlacklistResponse,
ForceSellPayload, ForceSellPayload,
LoadingStatus,
} from '@/types'; } from '@/types';
import { import {
@ -312,13 +313,13 @@ export function createBotSubStore(botId: string, botName: string) {
[BotStoreGetters.strategyList](state: FtbotStateType): string[] { [BotStoreGetters.strategyList](state: FtbotStateType): string[] {
return state.strategyList; return state.strategyList;
}, },
[BotStoreGetters.candleDataStatus](state: FtbotStateType): 'loading' | 'success' | 'error' { [BotStoreGetters.candleDataStatus](state: FtbotStateType): LoadingStatus {
return state.candleDataStatus; return state.candleDataStatus;
}, },
[BotStoreGetters.candleData](state: FtbotStateType): PairHistory | {} { [BotStoreGetters.candleData](state: FtbotStateType): PairHistory | {} {
return state.candleData; return state.candleData;
}, },
[BotStoreGetters.historyStatus](state: FtbotStateType): 'loading' | 'success' | 'error' { [BotStoreGetters.historyStatus](state: FtbotStateType): LoadingStatus {
return state.historyStatus; return state.historyStatus;
}, },
// TODO: Type me // TODO: Type me
@ -414,13 +415,13 @@ export function createBotSubStore(botId: string, botName: string) {
updatePairs(state: FtbotStateType, pairlist: string[]) { updatePairs(state: FtbotStateType, pairlist: string[]) {
state.pairlist = pairlist; state.pairlist = pairlist;
}, },
setCandleDataStatus(state: FtbotStateType, loading: 'loading' | 'success' | 'error') { setCandleDataStatus(state: FtbotStateType, loading: LoadingStatus) {
state.candleDataStatus = loading; state.candleDataStatus = loading;
}, },
updatePairCandles(state: FtbotStateType, { pair, timeframe, data }) { updatePairCandles(state: FtbotStateType, { pair, timeframe, data }) {
state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data }; state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data };
}, },
setHistoryStatus(state: FtbotStateType, loading: 'loading' | 'success' | 'error') { setHistoryStatus(state: FtbotStateType, loading: LoadingStatus) {
state.historyStatus = loading; state.historyStatus = loading;
}, },
updatePairHistory(state: FtbotStateType, { pair, timeframe, data }) { updatePairHistory(state: FtbotStateType, { pair, timeframe, data }) {

View File

@ -15,6 +15,7 @@ import {
BacktestSteps, BacktestSteps,
LogLine, LogLine,
SysInfoResponse, SysInfoResponse,
LoadingStatus,
} from '@/types'; } from '@/types';
export interface FtbotStateType { export interface FtbotStateType {
@ -40,10 +41,10 @@ export interface FtbotStateType {
selectedPair: string; selectedPair: string;
// TODO: type me // TODO: type me
candleData: {}; candleData: {};
candleDataStatus: 'loading' | 'success' | 'error'; candleDataStatus: LoadingStatus;
// TODO: type me // TODO: type me
history: {}; history: {};
historyStatus: 'loading' | 'success' | 'error'; historyStatus: LoadingStatus;
strategyPlotConfig?: PlotConfig; strategyPlotConfig?: PlotConfig;
customPlotConfig: PlotConfigStorage; customPlotConfig: PlotConfigStorage;
plotConfigName: string; plotConfigName: string;

View File

@ -237,3 +237,5 @@ export interface DeleteTradeResponse {
export interface UiVersion { export interface UiVersion {
version: string; version: string;
} }
export type LoadingStatus = 'loading' | 'success' | 'error';