mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-06 01:45:22 +00:00
Expand accounts page.
This commit is contained in:
@@ -77,7 +77,7 @@ let index = function () {
|
||||
sort(column) {
|
||||
this.sortingColumn = column;
|
||||
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
const url = './accounts/'+type+'?column='+column+'&direction='+this.sortDirection;
|
||||
const url = './accounts/' + type + '?column=' + column + '&direction=' + this.sortDirection;
|
||||
|
||||
window.history.pushState({}, "", url);
|
||||
|
||||
@@ -140,6 +140,11 @@ let index = function () {
|
||||
this.accounts[index].nameEditorVisible = true;
|
||||
},
|
||||
loadAccounts() {
|
||||
|
||||
// get start and end from the store:
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
|
||||
this.notifications.wait.show = true;
|
||||
this.notifications.wait.text = i18next.t('firefly.wait_loading_data')
|
||||
this.accounts = [];
|
||||
@@ -147,7 +152,7 @@ let index = function () {
|
||||
// &sorting[0][column]=description&sorting[0][direction]=asc
|
||||
const sorting = [{column: this.sortingColumn, direction: this.sortDirection}];
|
||||
// one page only.o
|
||||
(new Get()).index({sorting: sorting, type: type, page: this.page}).then(response => {
|
||||
(new Get()).index({sorting: sorting, type: type, page: this.page, start: start, end: end}).then(response => {
|
||||
for (let i = 0; i < response.data.data.length; i++) {
|
||||
if (response.data.data.hasOwnProperty(i)) {
|
||||
let current = response.data.data[i];
|
||||
@@ -165,7 +170,10 @@ let index = function () {
|
||||
native_current_balance: current.attributes.native_current_balance,
|
||||
native_currency_code: current.attributes.native_currency_code,
|
||||
last_activity: null === current.attributes.last_activity ? '' : format(new Date(current.attributes.last_activity), i18next.t('config.month_and_day_fns')),
|
||||
balance_difference: current.attributes.balance_difference,
|
||||
native_balance_difference: current.attributes.native_balance_difference
|
||||
};
|
||||
console.log(current.attributes.balance_difference);
|
||||
this.accounts.push(account);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import {format} from "date-fns";
|
||||
import {getVariable} from "../../store/get-variable.js";
|
||||
import formatMoney from "../../util/format-money.js";
|
||||
import {getCacheKey} from "../../support/get-cache-key.js";
|
||||
import {cleanupCache} from "../../support/cleanup-cache.js";
|
||||
|
||||
let afterPromises = false;
|
||||
export default () => ({
|
||||
@@ -38,6 +39,7 @@ export default () => ({
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const boxesCacheKey = getCacheKey('dashboard-boxes-data', start, end);
|
||||
cleanupCache();
|
||||
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(boxesCacheKey);
|
||||
|
||||
34
resources/assets/v2/src/support/cleanup-cache.js
Normal file
34
resources/assets/v2/src/support/cleanup-cache.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* load-translations.js
|
||||
* Copyright (c) 2023 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {format} from "date-fns";
|
||||
import store from "store";
|
||||
|
||||
function cleanupCache() {
|
||||
const localValue = store.get('lastActivity');
|
||||
|
||||
store.each(function(value, key) {
|
||||
if(key.startsWith('dcx') && !key.includes(localValue)) {
|
||||
store.remove(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export {cleanupCache};
|
||||
@@ -23,7 +23,7 @@ import store from "store";
|
||||
|
||||
function getCacheKey(string, start, end) {
|
||||
const localValue = store.get('lastActivity');
|
||||
const cacheKey = format(start, 'y-MM-dd') + '_' + format(end, 'y-MM-dd') + '_' + string + localValue;
|
||||
const cacheKey = 'dcx' + format(start, 'yMMdd')+ format(end, 'yMMdd') + string + localValue;
|
||||
console.log('getCacheKey: ' + cacheKey);
|
||||
return String(cacheKey);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user