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

View File

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

View File

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

View File

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