Frontend updates

This commit is contained in:
James Cole
2022-05-02 18:54:43 +02:00
parent 8c64c1d5e4
commit 0babe84a33
11 changed files with 834 additions and 452 deletions

View File

@@ -25,47 +25,49 @@
import {defineComponent} from 'vue';
import Preferences from "./api/preferences";
import Currencies from "./api/currencies";
import {setDatesFromViewRange} from "./store/fireflyiii/actions";
import {useFireflyIIIStore} from 'stores/fireflyiii'
export default defineComponent(
{
name: 'App',
preFetch({store}) {
const ffStore = useFireflyIIIStore(store);
store.dispatch('fireflyiii/refreshCacheKey');
ffStore.refreshCacheKey();
const getViewRange = function() {
const getViewRange = function () {
let pref = new Preferences();
return pref.getByName('viewRange').then(data => {
return pref.getByName('viewRange').then(data => {
const viewRange = data.data.data.attributes.data;
store.commit('fireflyiii/updateViewRange', viewRange);
store.dispatch('fireflyiii/setDatesFromViewRange');
ffStore.updateViewRange(viewRange);
ffStore.setDatesFromViewRange();
}).catch((err) => {
console.error('Could not load view range.')
console.log(err);
});
};
const getListPageSize = function() {
const getListPageSize = function () {
let pref = new Preferences();
return pref.getByName('listPageSize').then(data => {
return pref.getByName('listPageSize').then(data => {
const listPageSize = data.data.data.attributes.data;
store.commit('fireflyiii/updateListPageSize', listPageSize);
ffStore.updateListPageSize(listPageSize);
}).catch((err) => {
console.error('Could not load listPageSize.')
console.log(err);
});
};
const getDefaultCurrency = function() {
const getDefaultCurrency = function () {
let curr = new Currencies();
return curr.default().then(data => {
return curr.default().then(data => {
let currencyId = parseInt(data.data.data.id);
let currencyCode = data.data.data.attributes.code;
store.commit('fireflyiii/setCurrencyId', currencyId);
store.commit('fireflyiii/setCurrencyCode', currencyCode);
ffStore.setCurrencyId(currencyId);
ffStore.setCurrencyCode(currencyCode);
}).catch((err) => {
console.error('Could not load preferences.');
console.log(err);