From ffa850b0819d1ec27f41438554c1cd63f56ba0c2 Mon Sep 17 00:00:00 2001 From: Tagaishi Date: Wed, 9 Aug 2023 20:33:17 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Option=20to=20show=20time=20for=20a?= =?UTF-8?q?=20city=20(#1236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 + public/locales/en/modules/date.json | 21 ++ .../Tiles/Widgets/WidgetsEditModal.tsx | 55 +++-- src/pages/_app.tsx | 22 +- src/server/api/root.ts | 10 +- src/server/api/routers/timezone.ts | 17 ++ src/tools/language.ts | 38 +++- src/widgets/date/DateTile.tsx | 142 ++++++++++--- src/widgets/widgets.ts | 11 +- yarn.lock | 196 +++++++++++++++++- 10 files changed, 444 insertions(+), 71 deletions(-) create mode 100644 src/server/api/routers/timezone.ts diff --git a/package.json b/package.json index 4c1d29909..002df8b6f 100644 --- a/package.json +++ b/package.json @@ -67,9 +67,12 @@ "dockerode": "^3.3.2", "fily-publish-gridstack": "^0.0.13", "framer-motion": "^10.0.0", + "geo-tz": "^7.0.7", "html-entities": "^2.3.3", "i18next": "^22.5.1", "js-file-download": "^0.4.12", + "moment": "^2.29.4", + "moment-timezone": "^0.5.43", "next": "13.4.10", "next-i18next": "^13.0.0", "nzbget-api": "^0.0.3", diff --git a/public/locales/en/modules/date.json b/public/locales/en/modules/date.json index 3f925d2d5..1a9e36efc 100644 --- a/public/locales/en/modules/date.json +++ b/public/locales/en/modules/date.json @@ -6,6 +6,27 @@ "title": "Settings for Date and Time widget", "display24HourFormat": { "label": "Display full time (24-hour)" + }, + "dateFormat": { + "label": "Date formatting", + "data": { + "hide": "Hide Date" + } + }, + "enableTimezone": { + "label": "Display a custom Timezone" + }, + "timezoneLocation": { + "label": "Timezone Location" + }, + "titleState": { + "label": "City title", + "info": "In case you activate the Timezone option, the name of the city and the timezone code can be shown.
You can also show the city alone or even show none.", + "data": { + "both": "City and Timezone", + "city": "City only", + "none": "None" + } } } } diff --git a/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx b/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx index 0d7cbcfb4..574a76b4a 100644 --- a/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx +++ b/src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx @@ -19,13 +19,13 @@ import { IconAlertTriangle, IconPlaylistX, IconPlus } from '@tabler/icons-react' import { Trans, useTranslation } from 'next-i18next'; import { FC, useState } from 'react'; -import { InfoCard } from '../../../InfoCard/InfoCard'; import { useConfigContext } from '../../../../config/provider'; import { useConfigStore } from '../../../../config/store'; import { mapObject } from '../../../../tools/client/objects'; import Widgets from '../../../../widgets'; import type { IDraggableListInputValue, IWidgetOptionValue } from '../../../../widgets/widgets'; import { IWidget } from '../../../../widgets/widgets'; +import { InfoCard } from '../../../InfoCard/InfoCard'; import { DraggableList } from './Inputs/DraggableList'; import { LocationSelection } from './Inputs/LocationSelection'; import { StaticDraggableList } from './Inputs/StaticDraggableList'; @@ -148,15 +148,17 @@ const WidgetOptionTypeSwitch: FC<{ onChange={(ev) => handleChange(key, ev.currentTarget.checked)} {...option.inputProps} /> - {info && } + {info && } ); case 'text': return ( - {t(`descriptor.settings.${key}.label`)} - {info && } + + {t(`descriptor.settings.${key}.label`)} + + {info && } - {t(`descriptor.settings.${key}.label`)} - {info && } + + {t(`descriptor.settings.${key}.label`)} + + {info && } ); case 'select': + const items = typeof option.data === 'function' ? option.data() : option.data; + const data = items.map((dataType) => { + return !dataType.label + ? { + value: dataType.value, + label: t(`descriptor.settings.${key}.data.${dataType.value}`), + } + : dataType; + }); return ( - {t(`descriptor.settings.${key}.label`)} - {info && } + + {t(`descriptor.settings.${key}.label`)} + + {info && }