diff --git a/config-dist.php b/config-dist.php index 6f2318fc..9186c8e1 100644 --- a/config-dist.php +++ b/config-dist.php @@ -45,3 +45,6 @@ DefaultUserSetting('product_presets_qu_id', -1); // Default quantity unit id for # If the page should be automatically reloaded when there was # an external change DefaultUserSetting('auto_reload_on_db_change', true); + +# Show a clock in the header next to the logo or not +DefaultUserSetting('show_clock_in_header', false); diff --git a/localization/en/strings.php b/localization/en/strings.php index 7595abe5..45f05fca 100644 --- a/localization/en/strings.php +++ b/localization/en/strings.php @@ -321,5 +321,6 @@ return array( 'Product expires' => 'Product expires', 'Task due' => 'Task due', 'Chore due' => 'Chore due', - 'Battery charge cycle due' => 'Battery charge cycle due' + 'Battery charge cycle due' => 'Battery charge cycle due', + 'Show clock in header' => 'Show clock in header' ); diff --git a/public/css/grocy.css b/public/css/grocy.css index a8f31e45..01a72aa2 100644 --- a/public/css/grocy.css +++ b/public/css/grocy.css @@ -156,6 +156,10 @@ input::-webkit-inner-spin-button { background-color: #d6d6d6 !important; } +.navbar-brand { + margin-right: 0; +} + /* Third party component customizations - DataTables */ td { vertical-align: middle !important; diff --git a/public/js/grocy_clock.js b/public/js/grocy_clock.js new file mode 100644 index 00000000..0922d430 --- /dev/null +++ b/public/js/grocy_clock.js @@ -0,0 +1,37 @@ +$("#show-clock-in-header").on("change", function () +{ + CheckHeaderClockEnabled(); +}); + +function RefreshHeaderClock() +{ + $("#clock-small").text(moment().format("l LT")); + $("#clock-big").text(moment().format("LLLL")); +} + +Grocy.HeaderClockInterval = null; +function CheckHeaderClockEnabled() +{ + // Refresh the clock in the header every second when enabled + if (BoolVal(Grocy.UserSettings.show_clock_in_header)) + { + RefreshHeaderClock(); + $("#clock-container").removeClass("d-none"); + + Grocy.HeaderClockInterval = setInterval(function() + { + RefreshHeaderClock(); + }, 1000); + } + else + { + if (Grocy.HeaderClockInterval !== null) + { + clearInterval(Grocy.HeaderClockInterval); + Grocy.HeaderClockInterval = null; + } + + $("#clock-container").addClass("d-none"); + } +} +CheckHeaderClockEnabled(); diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index ca6dd9b7..9db0d76c 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -50,6 +50,11 @@ @if(!($embedded))