mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 05:25:17 +00:00
Add backgroundsync Setting
This commit is contained in:
parent
0ce64a17ea
commit
3718ba007a
|
@ -11,21 +11,25 @@ export enum OpenTradeVizOptions {
|
|||
export enum SettingsGetters {
|
||||
openTradesInTitle = 'openTradesInTitle',
|
||||
timezone = 'timezone',
|
||||
backgroundSync = 'backgroundSync',
|
||||
}
|
||||
|
||||
export enum SettingsActions {
|
||||
setOpenTradesInTitle = 'setOpenTradesInTitle',
|
||||
setTimeZone = 'setTimeZone',
|
||||
setBackgroundSync = 'setBackgroundSync',
|
||||
}
|
||||
|
||||
export enum SettingsMutations {
|
||||
setOpenTrades = 'setOpenTrades',
|
||||
setTimeZone = 'setTimeZone',
|
||||
setBackgroundSync = 'setBackgroundSync',
|
||||
}
|
||||
|
||||
export interface SettingsType {
|
||||
openTradesInTitle: string;
|
||||
timezone: string;
|
||||
backgroundSync: boolean;
|
||||
}
|
||||
|
||||
function getSettings() {
|
||||
|
@ -37,7 +41,7 @@ function getSettings() {
|
|||
}
|
||||
const storedSettings = getSettings();
|
||||
|
||||
function updateSetting(key: string, value: string) {
|
||||
function updateSetting(key: string, value: string | boolean) {
|
||||
const settings = getSettings() || {};
|
||||
settings[key] = value;
|
||||
localStorage.setItem(STORE_UI_SETTINGS, JSON.stringify(settings));
|
||||
|
@ -46,18 +50,22 @@ function updateSetting(key: string, value: string) {
|
|||
const state: SettingsType = {
|
||||
openTradesInTitle: storedSettings?.openTradesInTitle || OpenTradeVizOptions.showPill,
|
||||
timezone: storedSettings.timezone || 'UTC',
|
||||
backgroundSync: storedSettings.backgroundSync || true,
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters: {
|
||||
[SettingsGetters.openTradesInTitle](state) {
|
||||
[SettingsGetters.openTradesInTitle](state): string {
|
||||
return state.openTradesInTitle;
|
||||
},
|
||||
[SettingsGetters.timezone](state) {
|
||||
[SettingsGetters.timezone](state): string {
|
||||
return state.timezone;
|
||||
},
|
||||
[SettingsGetters.backgroundSync](state): boolean {
|
||||
return state.backgroundSync;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
[SettingsMutations.setOpenTrades](state, value: string) {
|
||||
|
@ -68,6 +76,10 @@ export default {
|
|||
state.timezone = timezone;
|
||||
updateSetting('timezone', timezone);
|
||||
},
|
||||
[SettingsMutations.setBackgroundSync](state, backgroundSync: boolean) {
|
||||
state.backgroundSync = backgroundSync;
|
||||
updateSetting('backgroundSync', backgroundSync);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
[SettingsActions.setOpenTradesInTitle]({ commit }, locked: boolean) {
|
||||
|
@ -77,5 +89,8 @@ export default {
|
|||
setTimezone(timezone);
|
||||
commit(SettingsMutations.setTimeZone, timezone);
|
||||
},
|
||||
[SettingsActions.setBackgroundSync]({ commit }, timezone: string) {
|
||||
commit(SettingsMutations.setBackgroundSync, timezone);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
>
|
||||
<b-form-select v-model="timezoneLoc" :options="timezoneOptions"></b-form-select>
|
||||
</b-form-group>
|
||||
<b-form-group description="Keep background sync running while other bots are selected.">
|
||||
<b-checkbox v-model="backgroundSyncLocal">Background sync</b-checkbox>
|
||||
</b-form-group>
|
||||
</div>
|
||||
</b-card>
|
||||
</div>
|
||||
|
@ -46,10 +49,14 @@ export default class Template extends Vue {
|
|||
|
||||
@uiSettingsNs.Getter [SettingsGetters.timezone]: string;
|
||||
|
||||
@uiSettingsNs.Getter [SettingsGetters.backgroundSync]: boolean;
|
||||
|
||||
@uiSettingsNs.Action [SettingsActions.setOpenTradesInTitle];
|
||||
|
||||
@uiSettingsNs.Action [SettingsActions.setTimeZone];
|
||||
|
||||
@uiSettingsNs.Action [SettingsActions.setBackgroundSync];
|
||||
|
||||
openTradesOptions = [
|
||||
{ value: OpenTradeVizOptions.showPill, text: 'Show pill in icon' },
|
||||
{ value: OpenTradeVizOptions.asTitle, text: 'Show in title' },
|
||||
|
@ -82,6 +89,14 @@ export default class Template extends Vue {
|
|||
set layoutLockedLocal(value: boolean) {
|
||||
this.setLayoutLocked(value);
|
||||
}
|
||||
|
||||
get backgroundSyncLocal(): boolean {
|
||||
return this.backgroundSync;
|
||||
}
|
||||
|
||||
set backgroundSyncLocal(value: boolean) {
|
||||
this.setBackgroundSync(value);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user