mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 18:01:26 -06:00
Rebuild frontend.
This commit is contained in:
parent
993fe3ae0a
commit
bfd925fbfe
@ -42,21 +42,17 @@
|
|||||||
class="btn btn-secondary btn-sm" :title="$t('firefly.custom_period')"
|
class="btn btn-secondary btn-sm" :title="$t('firefly.custom_period')"
|
||||||
@click="togglePopover({ placement: 'auto-start', positionFixed: true })"
|
@click="togglePopover({ placement: 'auto-start', positionFixed: true })"
|
||||||
><i class="fas fa-calendar-alt"></i></button>
|
><i class="fas fa-calendar-alt"></i></button>
|
||||||
<button
|
<button @click="resetDate"
|
||||||
class="btn btn-secondary"
|
class="btn btn-secondary"
|
||||||
:title="$t('firefly.reset_to_current')"
|
:title="$t('firefly.reset_to_current')"
|
||||||
><i class="fas fa-history"></i></button>
|
><i class="fas fa-history"></i></button>
|
||||||
|
|
||||||
|
|
||||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
|
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
|
||||||
:title="$t('firefly.select_period')"
|
:title="$t('firefly.select_period')"
|
||||||
aria-expanded="false">
|
aria-expanded="false">
|
||||||
<i class="fas fa-list"></i>
|
<i class="fas fa-list"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||||
<a class="dropdown-item" href="#">(prev period)</a>
|
<a v-for="period in periods" class="dropdown-item" href="#" @click="customDate(period.start, period.end)">{{ period.title }}</a>
|
||||||
<a class="dropdown-item" href="#">(next period)</a>
|
|
||||||
<a class="dropdown-item" href="#">(this week?)</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -89,6 +85,21 @@ export default {
|
|||||||
this.ready = true;
|
this.ready = true;
|
||||||
this.locale = localStorage.locale ?? 'en-US';
|
this.locale = localStorage.locale ?? 'en-US';
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
locale: 'en-US',
|
||||||
|
ready: false,
|
||||||
|
range: {
|
||||||
|
start: null,
|
||||||
|
end: null,
|
||||||
|
},
|
||||||
|
defaultRange: {
|
||||||
|
start: null,
|
||||||
|
end: null,
|
||||||
|
},
|
||||||
|
periods: []
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(
|
...mapMutations(
|
||||||
[
|
[
|
||||||
@ -96,40 +107,76 @@ export default {
|
|||||||
'setStart',
|
'setStart',
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
resetDate: function () {
|
||||||
|
//console.log('Reset date to');
|
||||||
|
//console.log(this.defaultStart);
|
||||||
|
//console.log(this.defaultEnd);
|
||||||
|
this.range.start = this.defaultStart;
|
||||||
|
this.range.end = this.defaultEnd;
|
||||||
|
this.setStart(this.defaultStart);
|
||||||
|
this.setEnd(this.defaultEnd);
|
||||||
|
},
|
||||||
|
customDate: function (startStr, endStr) {
|
||||||
|
let start = new Date(startStr);
|
||||||
|
let end = new Date(endStr);
|
||||||
|
this.setStart(start);
|
||||||
|
this.setEnd(end);
|
||||||
|
this.range.start = start;
|
||||||
|
this.range.end = end;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
'viewRange',
|
'viewRange',
|
||||||
'start',
|
'start',
|
||||||
'end'
|
'end',
|
||||||
|
'defaultStart',
|
||||||
|
'defaultEnd'
|
||||||
]),
|
]),
|
||||||
'datesReady': function () {
|
'datesReady': function () {
|
||||||
return null !== this.start && null !== this.end && this.ready;
|
return null !== this.start && null !== this.end && this.ready;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
datesReady: function (value) {
|
datesReady: function (value) {
|
||||||
if (true === value) {
|
if (false === value) {
|
||||||
this.range.start = new Date(this.start);
|
return;
|
||||||
this.range.end = new Date(this.end);
|
|
||||||
}
|
}
|
||||||
|
this.range.start = new Date(this.start);
|
||||||
|
this.range.end = new Date(this.end);
|
||||||
|
this.periods = [];
|
||||||
|
// create periods.
|
||||||
|
// last 7 days
|
||||||
|
let today = new Date;
|
||||||
|
let end = new Date;
|
||||||
|
end.setDate(end.getDate() - 7);
|
||||||
|
this.periods.push(
|
||||||
|
{
|
||||||
|
start: end.toDateString(),
|
||||||
|
end: today.toDateString(),
|
||||||
|
title: this.$t('firefly.last_seven_days')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// last 30 days:
|
||||||
|
end.setDate(end.getDate() - 23);
|
||||||
|
this.periods.push(
|
||||||
|
{
|
||||||
|
start: end.toDateString(),
|
||||||
|
end: today.toDateString(),
|
||||||
|
title: this.$t('firefly.last_thirty_days')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// last 30 days
|
||||||
|
// everything
|
||||||
},
|
},
|
||||||
range: function(value) {
|
range: function (value) {
|
||||||
console.log('User updated range');
|
//console.log('User updated range');
|
||||||
this.setStart(value.start);
|
this.setStart(value.start);
|
||||||
this.setEnd(value.end);
|
this.setEnd(value.end);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
locale: 'en-US',
|
|
||||||
ready: false,
|
|
||||||
range: {
|
|
||||||
start: new Date,
|
|
||||||
end: new Date,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
initialiseChart: function () {
|
initialiseChart: function () {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
this.error = false;
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
let url = './api/v1/chart/account/overview?start=' + startStr + '&end=' + endStr;
|
let url = './api/v1/chart/account/overview?start=' + startStr + '&end=' + endStr;
|
||||||
|
@ -107,10 +107,22 @@ export default {
|
|||||||
if (true === value) {
|
if (true === value) {
|
||||||
this.initialiseList();
|
this.initialiseList();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
start: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.initialiseList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.initialiseList();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initialiseList: function () {
|
initialiseList: function () {
|
||||||
|
this.loading = true;
|
||||||
|
this.accounts = [];
|
||||||
axios.get('./api/v1/preferences/frontpageAccounts')
|
axios.get('./api/v1/preferences/frontpageAccounts')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loadAccounts(response);
|
this.loadAccounts(response);
|
||||||
|
@ -103,7 +103,17 @@ export default {
|
|||||||
if (true === value) {
|
if (true === value) {
|
||||||
this.initialiseBills();
|
this.initialiseBills();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
start: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.initialiseBills();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.initialiseBills();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
@ -112,6 +122,8 @@ export default {
|
|||||||
components: {},
|
components: {},
|
||||||
methods: {
|
methods: {
|
||||||
initialiseBills: function () {
|
initialiseBills: function () {
|
||||||
|
this.loading = true;
|
||||||
|
this.bills = [];
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
|
|
||||||
|
@ -101,9 +101,19 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
datesReady: function (value) {
|
datesReady: function (value) {
|
||||||
if (true === value) {
|
if (true === value) {
|
||||||
this.collectData();
|
this.getBudgets();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
start: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getBudgets();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getBudgets();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapGetters([
|
||||||
@ -116,16 +126,24 @@ export default {
|
|||||||
},
|
},
|
||||||
methods:
|
methods:
|
||||||
{
|
{
|
||||||
collectData() {
|
|
||||||
this.getBudgets();
|
|
||||||
},
|
|
||||||
getBudgets() {
|
getBudgets() {
|
||||||
|
this.budgets = {};
|
||||||
|
this.rawBudgets = [];
|
||||||
|
this.budgetLimits = {
|
||||||
|
daily: [],
|
||||||
|
weekly: [],
|
||||||
|
monthly: [],
|
||||||
|
quarterly: [],
|
||||||
|
half_year: [],
|
||||||
|
yearly: [],
|
||||||
|
other: [],
|
||||||
|
};
|
||||||
|
this.loading = true;
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
axios.get('./api/v1/budgets?start=' + startStr + '&end=' + endStr)
|
axios.get('./api/v1/budgets?start=' + startStr + '&end=' + endStr)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.parseBudgets(response.data);
|
this.parseBudgets(response.data);
|
||||||
this.loading = false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -152,14 +170,13 @@ export default {
|
|||||||
}
|
}
|
||||||
this.getBudgetLimits();
|
this.getBudgetLimits();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
getBudgetLimits() {
|
getBudgetLimits() {
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
axios.get('./api/v1/budgets/limits?start=' + startStr + '&end=' + endStr)
|
axios.get('./api/v1/budgets/limits?start=' + startStr + '&end=' + endStr)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.parseBudgetLimits(response.data);
|
this.parseBudgetLimits(response.data);
|
||||||
|
this.loading = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -117,11 +117,26 @@ export default {
|
|||||||
if (true === value) {
|
if (true === value) {
|
||||||
this.getCategories();
|
this.getCategories();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
start: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getCategories();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getCategories();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods:
|
methods:
|
||||||
{
|
{
|
||||||
getCategories() {
|
getCategories() {
|
||||||
|
this.categories = [];
|
||||||
|
this.sortedList = [];
|
||||||
|
this.spent = 0;
|
||||||
|
this.earned = 0;
|
||||||
|
this.loading = true;
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
axios.get('./api/v1/categories?start=' + startStr + '&end=' + endStr)
|
axios.get('./api/v1/categories?start=' + startStr + '&end=' + endStr)
|
||||||
|
@ -101,10 +101,23 @@ export default {
|
|||||||
if (true === value) {
|
if (true === value) {
|
||||||
this.getIncome();
|
this.getIncome();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
start: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getIncome();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getIncome();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getIncome() {
|
getIncome() {
|
||||||
|
this.loading = true;
|
||||||
|
this.income = [];
|
||||||
|
this.error=false;
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
axios.get('./api/v1/insight/income/date/basic?start=' + startStr + '&end=' + endStr)
|
axios.get('./api/v1/insight/income/date/basic?start=' + startStr + '&end=' + endStr)
|
||||||
|
@ -101,10 +101,23 @@ export default {
|
|||||||
if (true === value) {
|
if (true === value) {
|
||||||
this.getExpenses();
|
this.getExpenses();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
start: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getExpenses();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.getExpenses();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getExpenses() {
|
getExpenses() {
|
||||||
|
this.loading = true;
|
||||||
|
this.error=false;
|
||||||
|
this.expenses = [];
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
axios.get('./api/v1/insight/expense/date/basic?start=' + startStr + '&end=' + endStr)
|
axios.get('./api/v1/insight/expense/date/basic?start=' + startStr + '&end=' + endStr)
|
||||||
|
@ -194,7 +194,17 @@ export default {
|
|||||||
if (true === value) {
|
if (true === value) {
|
||||||
this.prepareComponent();
|
this.prepareComponent();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
start: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.prepareComponent();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: function () {
|
||||||
|
if (false === this.loading) {
|
||||||
|
this.prepareComponent();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
@ -231,6 +241,14 @@ export default {
|
|||||||
* Prepare the component.
|
* Prepare the component.
|
||||||
*/
|
*/
|
||||||
prepareComponent() {
|
prepareComponent() {
|
||||||
|
this.error=false;
|
||||||
|
this.loading = true;
|
||||||
|
this.summary = [];
|
||||||
|
this.balances = [];
|
||||||
|
this.billsPaid = [];
|
||||||
|
this.billsUnpaid = [];
|
||||||
|
this.leftToSpend = [];
|
||||||
|
this.netWorth = [];
|
||||||
let startStr = this.start.toISOString().split('T')[0];
|
let startStr = this.start.toISOString().split('T')[0];
|
||||||
let endStr = this.end.toISOString().split('T')[0];
|
let endStr = this.end.toISOString().split('T')[0];
|
||||||
axios.get('./api/v1/summary/basic?start=' + startStr + '&end=' + endStr)
|
axios.get('./api/v1/summary/basic?start=' + startStr + '&end=' + endStr)
|
||||||
|
@ -21,9 +21,12 @@
|
|||||||
// initial state
|
// initial state
|
||||||
const state = () => (
|
const state = () => (
|
||||||
{
|
{
|
||||||
|
viewRange: 'default',
|
||||||
start: null,
|
start: null,
|
||||||
end: null,
|
end: null,
|
||||||
viewRange: 'default'
|
// default range:
|
||||||
|
defaultStart: null,
|
||||||
|
defaultEnd: null,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,6 +39,12 @@ const getters = {
|
|||||||
end: state => {
|
end: state => {
|
||||||
return state.end;
|
return state.end;
|
||||||
},
|
},
|
||||||
|
defaultStart: state => {
|
||||||
|
return state.defaultStart;
|
||||||
|
},
|
||||||
|
defaultEnd: state => {
|
||||||
|
return state.defaultEnd;
|
||||||
|
},
|
||||||
viewRange: state => {
|
viewRange: state => {
|
||||||
return state.viewRange;
|
return state.viewRange;
|
||||||
}
|
}
|
||||||
@ -64,13 +73,25 @@ const actions = {
|
|||||||
// console.log('Must set dates from viewRange "' + context.state.viewRange + '"');
|
// console.log('Must set dates from viewRange "' + context.state.viewRange + '"');
|
||||||
// check local storage first?
|
// check local storage first?
|
||||||
if (localStorage.viewRangeStart) {
|
if (localStorage.viewRangeStart) {
|
||||||
// console.log('view range set from local storage.');
|
// console.log('view range start set from local storage.');
|
||||||
context.commit('setStart', new Date(localStorage.viewRangeStart));
|
context.commit('setStart', new Date(localStorage.viewRangeStart));
|
||||||
}
|
}
|
||||||
if (localStorage.viewRangeEnd) {
|
if (localStorage.viewRangeEnd) {
|
||||||
// console.log('view range set from local storage.');
|
// console.log('view range end set from local storage.');
|
||||||
context.commit('setEnd', new Date(localStorage.viewRangeEnd));
|
context.commit('setEnd', new Date(localStorage.viewRangeEnd));
|
||||||
}
|
}
|
||||||
|
// also set default:
|
||||||
|
if(localStorage.viewRangeDefaultStart) {
|
||||||
|
// console.log('view range default start set from local storage.');
|
||||||
|
// console.log(localStorage.viewRangeDefaultStart);
|
||||||
|
context.commit('setDefaultStart', new Date(localStorage.viewRangeDefaultStart));
|
||||||
|
}
|
||||||
|
if(localStorage.viewRangeDefaultEnd) {
|
||||||
|
// console.log('view range default end set from local storage.');
|
||||||
|
// console.log(localStorage.viewRangeDefaultEnd);
|
||||||
|
context.commit('setDefaultEnd', new Date(localStorage.viewRangeDefaultEnd));
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== context.getters.end && null !== context.getters.start) {
|
if (null !== context.getters.end && null !== context.getters.start) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -160,6 +181,8 @@ const actions = {
|
|||||||
// console.log('End is ' + end);
|
// console.log('End is ' + end);
|
||||||
context.commit('setStart', start);
|
context.commit('setStart', start);
|
||||||
context.commit('setEnd', end);
|
context.commit('setEnd', end);
|
||||||
|
context.commit('setDefaultStart', start);
|
||||||
|
context.commit('setDefaultEnd', end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +196,14 @@ const mutations = {
|
|||||||
state.end = value;
|
state.end = value;
|
||||||
window.localStorage.setItem('viewRangeEnd', value);
|
window.localStorage.setItem('viewRangeEnd', value);
|
||||||
},
|
},
|
||||||
|
setDefaultStart(state, value) {
|
||||||
|
state.defaultStart = value;
|
||||||
|
window.localStorage.setItem('viewRangeDefaultStart', value);
|
||||||
|
},
|
||||||
|
setDefaultEnd(state, value) {
|
||||||
|
state.defaultEnd = value;
|
||||||
|
window.localStorage.setItem('viewRangeDefaultEnd', value);
|
||||||
|
},
|
||||||
setViewRange(state, range) {
|
setViewRange(state, range) {
|
||||||
state.viewRange = range;
|
state.viewRange = range;
|
||||||
}
|
}
|
||||||
|
2
public/v2/js/dashboard.js
vendored
2
public/v2/js/dashboard.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
public/v2/js/vendor.js
vendored
2
public/v2/js/vendor.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user