Regenerate frontend.

This commit is contained in:
James Cole
2021-04-18 12:29:42 +02:00
parent 57cb428105
commit f1798a1c97
66 changed files with 160 additions and 151 deletions

View File

@@ -79,17 +79,21 @@
import {createNamespacedHelpers} from "vuex";
import Vue from "vue";
import DatePicker from "v-calendar/lib/components/date-picker.umd";
import subDays from 'date-fns/subDays'
import addDays from 'date-fns/addDays'
import startOfDay from 'date-fns/startOfDay'
import endOfDay from 'date-fns/endOfDay'
import startOfWeek from 'date-fns/startOfWeek'
import endOfWeek from 'date-fns/endOfWeek'
import format from 'date-fns/format'
import subDays from 'date-fns/subDays';
import addDays from 'date-fns/addDays';
import addMonths from 'date-fns/addMonths';
import startOfDay from 'date-fns/startOfDay';
import endOfDay from 'date-fns/endOfDay';
import startOfWeek from 'date-fns/startOfWeek';
import endOfWeek from 'date-fns/endOfWeek';
import endOfMonth from 'date-fns/endOfMonth';
import format from 'date-fns/format';
import startOfQuarter from 'date-fns/startOfQuarter';
import subMonths from 'date-fns/subMonths';
import endOfQuarter from 'date-fns/endOfQuarter';
import subQuarters from 'date-fns/subQuarters';
import addQuarters from 'date-fns/addQuarters';
import startOfMonth from 'date-fns/startOfMonth';
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('dashboard/index')
@@ -182,13 +186,20 @@ export default {
},
generateWeekly: function () {
console.log('weekly');
let today = new Date(this.range.start);
console.log('Today is ' + today);
let start = startOfDay(startOfWeek(subDays(today, 7), {weekStartsOn: 1}));
let end = endOfDay(endOfWeek(subDays(today, 7), {weekStartsOn: 1}));
let dateFormat = this.$t('config.week_in_year_fns');
console.log('Date format: "'+dateFormat+'"');
let title = format(start, dateFormat);
// last week
console.log('Last week');
console.log(start);
console.log(end);
console.log(title);
this.periods.push(
{
start: start.toDateString(),
@@ -201,6 +212,10 @@ export default {
start = startOfDay(startOfWeek(today, {weekStartsOn: 1}));
end = endOfDay(endOfWeek(today, {weekStartsOn: 1}));
title = format(start, dateFormat);
console.log('This week');
console.log(start);
console.log(end);
console.log(title);
this.periods.push(
{
start: start.toDateString(),
@@ -213,6 +228,10 @@ export default {
start = startOfDay(startOfWeek(addDays(today, 7), {weekStartsOn: 1}));
end = endOfDay(endOfWeek(addDays(today, 7), {weekStartsOn: 1}));
title = format(start, dateFormat);
console.log('Next week');
console.log(start);
console.log(end);
console.log(title);
this.periods.push(
{
start: start.toDateString(),
@@ -224,35 +243,35 @@ export default {
generateMonthly: function () {
let today = new Date(this.range.start);
// previous month
firstDayOfMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1);
lastDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 0);
let start = startOfDay(startOfMonth(subMonths(today, 1)));
let end = endOfDay(endOfMonth(subMonths(today, 1)));
this.periods.push(
{
start: firstDayOfMonth.toDateString(),
end: lastDayOfMonth.toDateString(),
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(firstDayOfMonth)
start: start.toDateString(),
end: end.toDateString(),
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(start)
}
);
// this month
firstDayOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
lastDayOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
start = startOfDay(startOfMonth(today));
end = endOfDay(endOfMonth(today));
this.periods.push(
{
start: firstDayOfMonth.toDateString(),
end: lastDayOfMonth.toDateString(),
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(firstDayOfMonth)
start: start.toDateString(),
end: end.toDateString(),
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(start)
}
);
// next month
let firstDayOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 1);
let lastDayOfMonth = new Date(today.getFullYear(), today.getMonth() + 2, 0);
start = startOfDay(startOfMonth(addMonths(today, 1)));
end = endOfDay(endOfMonth(addMonths(today, 1)));
this.periods.push(
{
start: firstDayOfMonth.toDateString(),
end: lastDayOfMonth.toDateString(),
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(firstDayOfMonth)
start: start.toDateString(),
end: end.toDateString(),
title: new Intl.DateTimeFormat(this.locale, {year: 'numeric', month: 'long'}).format(start)
}
);
@@ -389,7 +408,7 @@ export default {
}
);
// this year, second half:
// this year, current (second) half:
start = today;
start.setMonth(6);
start.setDate(1);

View File

@@ -19,6 +19,15 @@
*/
// initial state
import startOfDay from "date-fns/startOfDay";
import endOfDay from 'date-fns/endOfDay'
import startOfWeek from 'date-fns/startOfWeek'
import endOfWeek from 'date-fns/endOfWeek'
import startOfQuarter from 'date-fns/startOfQuarter';
import endOfQuarter from 'date-fns/endOfQuarter';
import endOfMonth from "date-fns/endOfMonth";
import startOfMonth from 'date-fns/startOfMonth';
const state = () => (
{
viewRange: 'default',
@@ -66,7 +75,7 @@ const actions = {
// console.log('View range changed from "' + oldViewRange + '" to "' + viewRange + '"');
context.dispatch('setDatesFromViewRange');
}
if(viewRange === oldViewRange) {
if (viewRange === oldViewRange) {
// console.log('Restore view range dates');
context.dispatch('restoreViewRangeDates');
}
@@ -77,7 +86,7 @@ const actions = {
});
},
restoreViewRangeDates: function(context) {
restoreViewRangeDates: function (context) {
// check local storage first?
if (localStorage.viewRangeStart) {
// console.log('view range start set from local storage.');
@@ -111,87 +120,68 @@ const actions = {
let start;
let end;
let viewRange = context.getters.viewRange;
let today = new Date;
// console.log('Will recreate view range on ' + viewRange);
switch (viewRange) {
case '1D':
// one day:
start = new Date;
end = new Date(start.getTime());
start.setHours(0, 0, 0, 0);
end.setHours(23, 59, 59, 999);
// today:
start = startOfDay(today);
end = endOfDay(today);
break;
case '1W':
// this week:
start = new Date;
end = new Date(start.getTime());
// start of week
let diff = start.getDate() - start.getDay() + (start.getDay() === 0 ? -6 : 1);
start.setDate(diff);
start.setHours(0, 0, 0, 0);
// end of week
let lastday = end.getDate() - (end.getDay() - 1) + 6;
end.setDate(lastday);
end.setHours(23, 59, 59, 999);
start = startOfDay(startOfWeek(today, {weekStartsOn: 1}));
end = endOfDay(endOfWeek(today, {weekStartsOn: 1}));
break;
case '1M':
// this month:
start = new Date;
start = new Date(start.getFullYear(), start.getMonth(), 1);
start.setHours(0, 0, 0, 0);
end = new Date(start.getFullYear(), start.getMonth() + 1, 0);
end.setHours(23, 59, 59, 999);
start = startOfDay(startOfMonth(today));
end = endOfDay(endOfMonth(today));
break;
case '3M':
// this quarter
start = new Date;
end = new Date;
let quarter = Math.floor((start.getMonth() + 3) / 3) - 1;
// start and end months? I'm sure this could be better:
let startMonths = [0, 3, 6, 9];
let endMonths = [2, 5, 8, 11];
// set start to the correct month, day one:
start = new Date(start.getFullYear(), startMonths[quarter], 1);
start.setHours(0, 0, 0, 0);
// set end to the correct month, day one
end = new Date(end.getFullYear(), endMonths[quarter], 1);
// then to the last day of the month:
end = new Date(end.getFullYear(), end.getMonth() + 1, 0);
end.setHours(23, 59, 59, 999);
start = startOfDay(startOfQuarter(today));
end = endOfDay(endOfQuarter(today));
break;
case '6M':
// this half-year
start = new Date;
end = new Date;
let half = start.getMonth() <= 5 ? 0 : 1;
let startHalf = [0, 6];
let endHalf = [5, 11];
// set start to the correct month, day one:
start = new Date(start.getFullYear(), startHalf[half], 1);
start.setHours(0, 0, 0, 0);
// set end to the correct month, day one
end = new Date(end.getFullYear(), endHalf[half], 1);
// then to the last day of the month:
end = new Date(end.getFullYear(), end.getMonth() + 1, 0);
end.setHours(23, 59, 59, 999);
if (today.getMonth() <= 5) {
start = new Date(today);
start.setMonth(0);
start.setDate(1);
start = startOfDay(start);
end = new Date(today);
end.setMonth(5);
end.setDate(30);
end = endOfDay(start);
}
if (today.getMonth() > 5) {
start = new Date(today);
start.setMonth(6);
start.setDate(1);
start = startOfDay(start);
end = new Date(today);
end.setMonth(11);
end.setDate(31);
end = endOfDay(start);
}
break;
case '1Y':
// this year
start = new Date;
end = new Date;
start = new Date(start.getFullYear(), 0, 1);
start = new Date(today);
start.setMonth(0);
start.setDate(1);
start = startOfDay(start);
end = new Date(end.getFullYear(), 11, 31);
start.setHours(0, 0, 0, 0);
end.setHours(23, 59, 59, 999);
end = new Date(today);
end.setMonth(11);
end.setDate(31);
end = endOfDay(end);
break;
}
// console.log('Range is ' + viewRange);
// console.log('Start is ' + start);
// console.log('End is ' + end);
console.log('Range is ' + viewRange);
console.log('Start is ' + start);
console.log('End is ' + end);
context.commit('setStart', start);
context.commit('setEnd', end);
context.commit('setDefaultStart', start);

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "bg",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "cs",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "de",
"week_in_year_fns": "'Woche' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "el",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "en-gb",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "en",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "es",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "fi",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "fr",
"week_in_year_fns": "'Semaine' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "hu",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "it",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "nb",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "nl",
"week_in_year_fns": "'week' l, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "pl",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "pt-br",
"week_in_year_fns": "'Semana' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "pt",
"week_in_year_fns": "'Semana' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Trimestre' Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "ro",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "ru",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "sk",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "sv",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "vi",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "zh-cn",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -142,7 +142,7 @@
},
"config": {
"html_language": "zh-tw",
"week_in_year_fns": "'Week' I, yyyy",
"week_in_year_fns": "'Week' w, yyyy",
"quarter_fns": "'Q'Q, yyyy",
"half_year_fns": "'H{half}', yyyy"
},

View File

@@ -7870,9 +7870,9 @@ wrappy@1:
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
ws@^7.4.4:
version "7.4.4"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.4.tgz#383bc9742cb202292c9077ceab6f6047b17f2d59"
integrity sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw==
version "7.4.5"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.5.tgz#a484dd851e9beb6fdb420027e3885e8ce48986c1"
integrity sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==
xmldoc@^1.1.2:
version "1.1.2"