From 685665bd46e0e56e820b2825f4b9237cb400ed6f Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 9 Oct 2022 19:59:47 +0200 Subject: [PATCH] feat: add option to change date & time format in settings (#1069) --- src/components/charts/TempChart.vue | 11 +++ src/components/console/ConsoleTableEntry.vue | 12 ++- src/components/mixins/base.ts | 93 +++++++++++++++++++ src/components/panels/GcodefilesPanel.vue | 5 +- src/components/panels/HistoryListPanel.vue | 18 ++-- .../panels/Machine/ConfigFilesPanel.vue | 5 +- .../panels/Status/PrintstatusPrinting.vue | 33 ++----- .../panels/Timelapse/TimelapseFilesPanel.vue | 5 +- .../settings/SettingsGeneralTab.vue | 76 +++++++++++++++ src/locales/en.json | 6 +- src/plugins/helpers.ts | 6 -- src/store/getters.ts | 17 +--- src/store/gui/getters.ts | 13 +++ src/store/gui/index.ts | 2 + src/store/gui/types.ts | 2 + src/store/printer/getters.ts | 24 +++++ src/store/server/getters.ts | 3 +- src/store/server/mutations.ts | 4 +- src/store/server/types.ts | 1 - 19 files changed, 263 insertions(+), 73 deletions(-) diff --git a/src/components/charts/TempChart.vue b/src/components/charts/TempChart.vue index b030cd758..ffd913680 100644 --- a/src/components/charts/TempChart.vue +++ b/src/components/charts/TempChart.vue @@ -84,6 +84,7 @@ export default class TempChart extends Mixins(BaseMixin) { axisLabel: { color: 'rgba(255, 255, 255, 0.24)', margin: 10, + formatter: this.timeFormat, }, }, yAxis: [ @@ -225,8 +226,13 @@ export default class TempChart extends Mixins(BaseMixin) { return this.$store.getters['printer/tempHistory/getSelectedLegends'] } + get timeFormat() { + return this.hours12Format ? '{hh}:{mm}' : '{HH}:{mm}' + } + mounted() { this.initChart() + this.chartOptions.xAxis.axisLabel.formatter = this.timeFormat } beforeDestroy() { @@ -383,5 +389,10 @@ export default class TempChart extends Mixins(BaseMixin) { boolDisplayPwmAxisChanged() { this.updateChartPwmAxis() } + + @Watch('hours12Format') + hours12FormatChanged() { + this.chartOptions.xAxis.axisLabel.formatter = this.timeFormat + } } diff --git a/src/components/console/ConsoleTableEntry.vue b/src/components/console/ConsoleTableEntry.vue index 75a7ce396..ff92cb463 100644 --- a/src/components/console/ConsoleTableEntry.vue +++ b/src/components/console/ConsoleTableEntry.vue @@ -25,7 +25,7 @@ @@ -289,13 +291,13 @@ {{ $t('History.StartTime') }} - {{ formatDate(detailsDialog.item.start_time) }} + {{ formatDateTime(detailsDialog.item.start_time) }} @@ -462,7 +462,7 @@ diff --git a/src/components/panels/Timelapse/TimelapseFilesPanel.vue b/src/components/panels/Timelapse/TimelapseFilesPanel.vue index 9f42fc63d..bc1f26cf9 100644 --- a/src/components/panels/Timelapse/TimelapseFilesPanel.vue +++ b/src/components/panels/Timelapse/TimelapseFilesPanel.vue @@ -181,7 +181,7 @@ {{ item.isDirectory ? '--' : formatFilesize(item.size) }} - {{ formatDate(item.modified) }} + {{ formatDateTime(item.modified) }} @@ -396,7 +396,7 @@