mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 21:00:57 +00:00
[feature] implement short syntax for clock week (#3775)
Hello and thank you for wanting to contribute to the MagicMirror² project! **Please make sure that you have followed these 4 rules before submitting your Pull Request:** > 1. Base your pull requests against the `develop` branch. > 2. Include these infos in the description: implement short syntax for clock week > > - Does the pull request solve a **related** issue? n/a > - If so, can you reference the issue like this `Fixes #<issue_number>`? > - What does the pull request accomplish? Use a list if needed. > - If it includes major visual changes please add screenshots. > > 3. Please run `npm run lint:prettier` before submitting so that > style issues are fixed. > 4. Don't forget to add an entry about your changes to > the CHANGELOG.md file.   **Note**: Sometimes the development moves very fast. It is highly recommended that you update your branch of `develop` before creating a pull request to send us your changes. This makes everyone's lives easier (including yours) and helps us out on the development team. Thanks again and have a nice day! --------- Co-authored-by: BugHaver <43462320+lsaadeh@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,7 @@ planned for 2025-07-01
|
||||
|
||||
- [config] Allow to change module order for final renderer (or dynamically with CSS): Feature `order` in config (#3762)
|
||||
- [clock] Added option 'disableNextEvent' to hide next sun event (#3769)
|
||||
- [clock] Implement short syntax for clock week (#3775)
|
||||
|
||||
### Changed
|
||||
|
||||
|
@@ -14,7 +14,7 @@ Module.register("clock", {
|
||||
clockBold: false,
|
||||
showDate: true,
|
||||
showTime: true,
|
||||
showWeek: false,
|
||||
showWeek: false, // options: true, false, 'short'
|
||||
dateFormat: "dddd, LL",
|
||||
sendNotifications: false,
|
||||
|
||||
@@ -224,7 +224,12 @@ Module.register("clock", {
|
||||
}
|
||||
|
||||
if (this.config.showWeek) {
|
||||
weekWrapper.innerHTML = this.translate("WEEK", { weekNumber: now.week() });
|
||||
if (this.config.showWeek === "short") {
|
||||
weekWrapper.innerHTML = this.translate("WEEK_SHORT", { weekNumber: now.week() });
|
||||
} else {
|
||||
weekWrapper.innerHTML = this.translate("WEEK", { weekNumber: now.week() });
|
||||
}
|
||||
|
||||
digitalWrapper.appendChild(weekWrapper);
|
||||
}
|
||||
|
||||
|
20
tests/configs/modules/clock/clock_showWeek_short.js
Normal file
20
tests/configs/modules/clock/clock_showWeek_short.js
Normal file
@@ -0,0 +1,20 @@
|
||||
let config = {
|
||||
address: "0.0.0.0",
|
||||
ipWhitelist: [],
|
||||
timeFormat: 12,
|
||||
|
||||
modules: [
|
||||
{
|
||||
module: "clock",
|
||||
position: "middle_center",
|
||||
config: {
|
||||
showWeek: "short"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = config;
|
||||
}
|
21
tests/configs/modules/clock/de/clock_showWeek.js
Normal file
21
tests/configs/modules/clock/de/clock_showWeek.js
Normal file
@@ -0,0 +1,21 @@
|
||||
let config = {
|
||||
address: "0.0.0.0",
|
||||
ipWhitelist: [],
|
||||
language: "de",
|
||||
timeFormat: 12,
|
||||
|
||||
modules: [
|
||||
{
|
||||
module: "clock",
|
||||
position: "middle_center",
|
||||
config: {
|
||||
showWeek: true
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = config;
|
||||
}
|
21
tests/configs/modules/clock/de/clock_showWeek_short.js
Normal file
21
tests/configs/modules/clock/de/clock_showWeek_short.js
Normal file
@@ -0,0 +1,21 @@
|
||||
let config = {
|
||||
address: "0.0.0.0",
|
||||
ipWhitelist: [],
|
||||
language: "de",
|
||||
timeFormat: 12,
|
||||
|
||||
modules: [
|
||||
{
|
||||
module: "clock",
|
||||
position: "middle_center",
|
||||
config: {
|
||||
showWeek: "short"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = config;
|
||||
}
|
21
tests/configs/modules/clock/es/clock_showWeek_short.js
Normal file
21
tests/configs/modules/clock/es/clock_showWeek_short.js
Normal file
@@ -0,0 +1,21 @@
|
||||
let config = {
|
||||
address: "0.0.0.0",
|
||||
ipWhitelist: [],
|
||||
language: "es",
|
||||
timeFormat: 12,
|
||||
|
||||
modules: [
|
||||
{
|
||||
module: "clock",
|
||||
position: "middle_center",
|
||||
config: {
|
||||
showWeek: "short"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = config;
|
||||
}
|
31
tests/e2e/modules/clock_de_spec.js
Normal file
31
tests/e2e/modules/clock_de_spec.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const helpers = require("../helpers/global-setup");
|
||||
|
||||
describe("Clock set to german language module", () => {
|
||||
afterAll(async () => {
|
||||
await helpers.stopApplication();
|
||||
});
|
||||
|
||||
describe("with showWeek config enabled", () => {
|
||||
beforeAll(async () => {
|
||||
await helpers.startApplication("tests/configs/modules/clock/de/clock_showWeek.js");
|
||||
await helpers.getDocument();
|
||||
});
|
||||
|
||||
it("shows week with correct format", async () => {
|
||||
const weekRegex = /^[0-9]{1,2}. Kalenderwoche$/;
|
||||
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with showWeek short config enabled", () => {
|
||||
beforeAll(async () => {
|
||||
await helpers.startApplication("tests/configs/modules/clock/de/clock_showWeek_short.js");
|
||||
await helpers.getDocument();
|
||||
});
|
||||
|
||||
it("shows week with correct format", async () => {
|
||||
const weekRegex = /^[0-9]{1,2}KW$/;
|
||||
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
@@ -62,4 +62,16 @@ describe("Clock set to spanish language module", () => {
|
||||
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with showWeek short config enabled", () => {
|
||||
beforeAll(async () => {
|
||||
await helpers.startApplication("tests/configs/modules/clock/es/clock_showWeek_short.js");
|
||||
await helpers.getDocument();
|
||||
});
|
||||
|
||||
it("shows week with correct format", async () => {
|
||||
const weekRegex = /^S[0-9]{1,2}$/;
|
||||
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -138,6 +138,26 @@ describe("Clock module", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("with showWeek short config enabled", () => {
|
||||
beforeAll(async () => {
|
||||
await helpers.startApplication("tests/configs/modules/clock/clock_showWeek_short.js");
|
||||
await helpers.getDocument();
|
||||
});
|
||||
|
||||
it("should show the week in the correct format", async () => {
|
||||
const weekRegex = /^W[0-9]{1,2}$/;
|
||||
await expect(helpers.testMatch(".clock .week", weekRegex)).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it("should show the week with the correct number of week of year", async () => {
|
||||
const currentWeekNumber = moment().week();
|
||||
const weekToShow = `W${currentWeekNumber}`;
|
||||
const elem = await helpers.waitForElement(".clock .week");
|
||||
expect(elem).not.toBeNull();
|
||||
expect(elem.textContent).toBe(weekToShow);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with analog clock face enabled", () => {
|
||||
beforeAll(async () => {
|
||||
await helpers.startApplication("tests/configs/modules/clock/clock_analog.js");
|
||||
|
@@ -9,6 +9,7 @@
|
||||
"RUNNING": "noch",
|
||||
"EMPTY": "Keine Termine.",
|
||||
"WEEK": "{weekNumber}. Kalenderwoche",
|
||||
"WEEK_SHORT": "{weekNumber}KW",
|
||||
|
||||
"N": "N",
|
||||
"NNE": "NNO",
|
||||
|
@@ -7,6 +7,7 @@
|
||||
"RUNNING": "Ends in",
|
||||
"EMPTY": "No upcoming events.",
|
||||
"WEEK": "Week {weekNumber}",
|
||||
"WEEK_SHORT": "W{weekNumber}",
|
||||
|
||||
"N": "N",
|
||||
"NNE": "NNE",
|
||||
|
@@ -9,6 +9,7 @@
|
||||
"RUNNING": "Termina en",
|
||||
"EMPTY": "No hay eventos programados.",
|
||||
"WEEK": "Semana {weekNumber}",
|
||||
"WEEK_SHORT": "S{weekNumber}",
|
||||
|
||||
"N": "N",
|
||||
"NNE": "NNE",
|
||||
|
@@ -9,6 +9,7 @@
|
||||
"RUNNING": "Se termine dans",
|
||||
"EMPTY": "Aucun RDV à venir.",
|
||||
"WEEK": "Semaine {weekNumber}",
|
||||
"WEEK_SHORT": "S{weekNumber}",
|
||||
|
||||
"N": "N",
|
||||
"NNE": "NNE",
|
||||
|
Reference in New Issue
Block a user