Merge branch 'develop' into test-set-MM_PORT

This commit is contained in:
Rodrigo Ramírez Norambuena 2017-03-30 16:12:08 -03:00 committed by GitHub
commit 19b9d3737e
10 changed files with 85 additions and 2 deletions

View File

@ -58,6 +58,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added meta tags to support fullscreen mode on iOS (for server mode) - Added meta tags to support fullscreen mode on iOS (for server mode)
- Added `ignoreOldItems` and `ignoreOlderThan` options to the News Feed module - Added `ignoreOldItems` and `ignoreOlderThan` options to the News Feed module
- Added test for MM_PORT enviroment variable. - Added test for MM_PORT enviroment variable.
- Added a configurable Week section to the clock module.
### Fixed ### Fixed
- Update .gitignore to not ignore default modules folder. - Update .gitignore to not ignore default modules folder.

View File

@ -15,6 +15,7 @@ var fs = require("fs");
var helmet = require("helmet"); var helmet = require("helmet");
var Server = function(config, callback) { var Server = function(config, callback) {
console.log("Starting server on port " + config.port + " ... ");
var port = config.port; var port = config.port;
if (process.env.MM_PORT) { if (process.env.MM_PORT) {

View File

@ -30,6 +30,7 @@ The following properties can be configured:
| `showPeriodUpper` | Show the period (AM/PM) with 12 hour format as uppercase. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false` | `showPeriodUpper` | Show the period (AM/PM) with 12 hour format as uppercase. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
| `clockBold` | Remove the colon and bold the minutes to make a more modern look. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false` | `clockBold` | Remove the colon and bold the minutes to make a more modern look. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
| `showDate` | Turn off or on the Date section. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true` | `showDate` | Turn off or on the Date section. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true`
| `showWeek` | Turn off or on the Week section. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
| `dateFormat` | Configure the date format as you like. <br><br> **Possible values:** [Docs](http://momentjs.com/docs/#/displaying/format/) <br> **Default value:** `"dddd, LL"` | `dateFormat` | Configure the date format as you like. <br><br> **Possible values:** [Docs](http://momentjs.com/docs/#/displaying/format/) <br> **Default value:** `"dddd, LL"`
| `displayType` | Display a digital clock, analog clock, or both together. <br><br> **Possible values:** `digital`, `analog`, or `both` <br> **Default value:** `digital` | `displayType` | Display a digital clock, analog clock, or both together. <br><br> **Possible values:** `digital`, `analog`, or `both` <br> **Default value:** `digital`
| `analogSize` | **Specific to the analog clock.** Defines how large the analog display is. <br><br> **Possible values:** A positive number of pixels` <br> **Default value:** `200px` | `analogSize` | **Specific to the analog clock.** Defines how large the analog display is. <br><br> **Possible values:** A positive number of pixels` <br> **Default value:** `200px`

View File

@ -16,6 +16,7 @@ Module.register("clock",{
showPeriodUpper: false, showPeriodUpper: false,
clockBold: false, clockBold: false,
showDate: true, showDate: true,
showWeek: false,
dateFormat: "dddd, LL", dateFormat: "dddd, LL",
/* specific to the analog clock */ /* specific to the analog clock */
@ -61,10 +62,12 @@ Module.register("clock",{
var timeWrapper = document.createElement("div"); var timeWrapper = document.createElement("div");
var secondsWrapper = document.createElement("sup"); var secondsWrapper = document.createElement("sup");
var periodWrapper = document.createElement("span"); var periodWrapper = document.createElement("span");
var weekWrapper = document.createElement("div")
// Style Wrappers // Style Wrappers
dateWrapper.className = "date normal medium"; dateWrapper.className = "date normal medium";
timeWrapper.className = "time bright large light"; timeWrapper.className = "time bright large light";
secondsWrapper.className = "dimmed"; secondsWrapper.className = "dimmed";
weekWrapper.className = "week dimmed medium"
// Set content of wrappers. // Set content of wrappers.
// The moment().format("h") method has a bug on the Raspberry Pi. // The moment().format("h") method has a bug on the Raspberry Pi.
@ -90,6 +93,9 @@ Module.register("clock",{
if(this.config.showDate){ if(this.config.showDate){
dateWrapper.innerHTML = now.format(this.config.dateFormat); dateWrapper.innerHTML = now.format(this.config.dateFormat);
} }
if (this.config.showWeek) {
weekWrapper.innerHTML = this.translate("WEEK") + " " + now.week();
}
timeWrapper.innerHTML = timeString; timeWrapper.innerHTML = timeString;
secondsWrapper.innerHTML = now.format("ss"); secondsWrapper.innerHTML = now.format("ss");
if (this.config.showPeriodUpper) { if (this.config.showPeriodUpper) {
@ -172,16 +178,25 @@ Module.register("clock",{
// Display only a digital clock // Display only a digital clock
wrapper.appendChild(dateWrapper); wrapper.appendChild(dateWrapper);
wrapper.appendChild(timeWrapper); wrapper.appendChild(timeWrapper);
wrapper.appendChild(weekWrapper);
} else if (this.config.displayType === "analog") { } else if (this.config.displayType === "analog") {
// Display only an analog clock // Display only an analog clock
dateWrapper.style.textAlign = "center"; dateWrapper.style.textAlign = "center";
dateWrapper.style.paddingBottom = "15px";
if (this.config.showWeek) {
weekWrapper.style.paddingBottom = "15px";
} else {
dateWrapper.style.paddingBottom = "15px";
}
if (this.config.analogShowDate === "top") { if (this.config.analogShowDate === "top") {
wrapper.appendChild(dateWrapper); wrapper.appendChild(dateWrapper);
wrapper.appendChild(weekWrapper);
wrapper.appendChild(clockCircle); wrapper.appendChild(clockCircle);
} else if (this.config.analogShowDate === "bottom") { } else if (this.config.analogShowDate === "bottom") {
wrapper.appendChild(clockCircle); wrapper.appendChild(clockCircle);
wrapper.appendChild(dateWrapper); wrapper.appendChild(dateWrapper);
wrapper.appendChild(weekWrapper);
} else { } else {
wrapper.appendChild(clockCircle); wrapper.appendChild(clockCircle);
} }
@ -198,6 +213,7 @@ Module.register("clock",{
digitalWrapper.style.cssFloat = "none"; digitalWrapper.style.cssFloat = "none";
digitalWrapper.appendChild(dateWrapper); digitalWrapper.appendChild(dateWrapper);
digitalWrapper.appendChild(timeWrapper); digitalWrapper.appendChild(timeWrapper);
digitalWrapper.appendChild(weekWrapper);
var appendClocks = function(condition, pos1, pos2) { var appendClocks = function(condition, pos1, pos2) {
var padding = [0,0,0,0]; var padding = [0,0,0,0];

View File

@ -0,0 +1,32 @@
/* Magic Mirror Test config for default clock module
*
* By Johan Hammar
* MIT Licensed.
*/
var config = {
port: 8080,
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
language: "en",
timeFormat: 12,
units: "metric",
electronOptions: {
webPreferences: {
nodeIntegration: true,
},
},
modules: [
{
module: "clock",
position: "middle_center",
config: {
showWeek: true
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {module.exports = config;}

View File

@ -100,4 +100,25 @@ describe("Clock module", function () {
}); });
}); });
describe("with showWeek config enabled", function() {
before(function() {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js";
});
beforeEach(function (done) {
app.start().then(function() { done(); } );
});
afterEach(function (done) {
app.stop().then(function() { done(); });
});
it("shows week with correct format", function() {
const weekRegex = /^Week [0-9]{1,2}$/;
return app.client.waitUntilWindowLoaded()
.getText(".clock .week").should.eventually.match(weekRegex);
});
});
}); });

View File

@ -7,6 +7,8 @@
"RUNNING": "Ends in", "RUNNING": "Ends in",
"EMPTY": "No upcoming events.", "EMPTY": "No upcoming events.",
"WEEK": "Week",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",
"NE": "NE", "NE": "NE",

View File

@ -7,6 +7,8 @@
"RUNNING": "Termina en", "RUNNING": "Termina en",
"EMPTY": "No hay eventos programados.", "EMPTY": "No hay eventos programados.",
"WEEK": "Semana",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",
"NE": "NE", "NE": "NE",

View File

@ -7,6 +7,8 @@
"RUNNING": "Slutar", "RUNNING": "Slutar",
"EMPTY": "Inga kommande händelser.", "EMPTY": "Inga kommande händelser.",
"WEEK": "Vecka",
"N": "N", "N": "N",
"NNE": "NNO", "NNE": "NNO",
"NE": "NO", "NE": "NO",

View File

@ -3,6 +3,7 @@
"TODAY": "今天", "TODAY": "今天",
"TOMORROW": "明天", "TOMORROW": "明天",
"DAYAFTERTOMORROW": "后天",
"RUNNING": "结束日期", "RUNNING": "结束日期",
"EMPTY": "没有更多的活动。", "EMPTY": "没有更多的活动。",
@ -21,5 +22,9 @@
"W": "西风", "W": "西风",
"WNW": "西偏北风", "WNW": "西偏北风",
"NW": "西北风", "NW": "西北风",
"NNW": "北偏西风" "NNW": "北偏西风",
"UPDATE_NOTIFICATION": "MagicMirror² 有新的更新",
"UPDATE_NOTIFICATION_MODULE": "模块 MODULE_NAME 可更新",
"UPDATE_INFO": "当前已安装版本为 COMMIT_COUNT 落后于分支 BRANCH_NAME "
} }