Skip to content

Commit

Permalink
Extend alarm-clock module : weekday selection
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonMellerin committed Jul 3, 2020
1 parent b12174c commit f3fb350
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 5 deletions.
12 changes: 10 additions & 2 deletions app/i18n/strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
"SLEEP_MODE_SYSTEM_WILL": "The system will ",
"SLEEP_MODE_TITLE": "Sleep Mode",
"STOP_MUSIC": "Stop Music",
"TIME_SELECT_ERROR": "Please select an alarm start time",
"TURN_OFF": "Turn off"
"TURN_OFF": "Turn off",
"TIME_SELECT_ERROR":"Please select an alarm start time",
"DAY_SELECT_ERROR":"Please select at least one day of week",
"MONDAY":"Monday",
"TUESDAY":"Tuesday",
"WEDNESDAY":"Wednesday",
"THURSDAY":"Thursday",
"FRIDAY":"Friday",
"SATURDAY":"Saturday",
"SUNDAY":"Sunday"
},
"APPEARANCE": {
"ALBUMARTIST": "Albumartist",
Expand Down
10 changes: 9 additions & 1 deletion app/i18n/strings_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
"SLEEP_MODE_TITLE": "Mode sommeil",
"STOP_MUSIC": "Arrêter la musique dans",
"TIME_SELECT_ERROR": "Sélectionner l'heure de l'alarme",
"TURN_OFF": "Éteindre dans"
"TURN_OFF": "Éteindre dans",
"DAY_SELECT_ERROR":"Sélectionner au moins un jour de la semaine",
"MONDAY":"Lundi",
"TUESDAY":"Mardi",
"WEDNESDAY":"Mercredi",
"THURSDAY":"Jeudi",
"FRIDAY":"Vendredi",
"SATURDAY":"Samedi",
"SUNDAY":"Dimanche"
},
"APPEARANCE": {
"ALBUMARTIST": "Albumartist",
Expand Down
80 changes: 78 additions & 2 deletions app/plugins/miscellanea/alarm-clock/UIConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
"data": [
"enabled",
"hour",
"minute"
"minute",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday"
]
},
"content": [
Expand Down Expand Up @@ -391,7 +398,76 @@
"field": "enabled",
"value": true
}

},
{
"id": "monday",
"element": "switch",
"label": "TRANSALTE.ALARM.MONDAY",
"value": true,
"visibleIf": {
"field": "enabled",
"value": true
}
},
{
"id": "tuesday",
"element": "switch",
"label": "TRANSALTE.ALARM.TUESDAY",
"value": true,
"visibleIf": {
"field": "enabled",
"value": true
}
},
{
"id": "wednesday",
"element": "switch",
"label": "TRANSALTE.ALARM.WEDNESDAY",
"value": true,
"visibleIf": {
"field": "enabled",
"value": true
}
},
{
"id": "thursday",
"element": "switch",
"label": "TRANSALTE.ALARM.THURSDAY",
"value": true,
"visibleIf": {
"field": "enabled",
"value": true
}
},
{
"id": "friday",
"element": "switch",
"label": "TRANSALTE.ALARM.FRIDAY",
"value": true,
"visibleIf": {
"field": "enabled",
"value": true
}
},
{
"id": "saturday",
"element": "switch",
"label": "TRANSALTE.ALARM.SATURDAY",
"value": true,
"visibleIf": {
"field": "enabled",
"value": true
}
},
{
"id": "sunday",
"element": "switch",
"label": "TRANSALTE.ALARM.SUNDAY",
"value": true,
"visibleIf": {
"field": "enabled",
"value": true
}
}
]
}
Expand Down
7 changes: 7 additions & 0 deletions app/plugins/miscellanea/alarm-clock/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"enabled":{"value":true,"type":"boolean"},
"hour":{"value":"8","type":"number"},
"minute":{"value":"0","type":"number"},
"monday":{"value":true,"type":"boolean"},
"tuesday":{"value":true,"type":"boolean"},
"wednesday":{"value":true,"type":"boolean"},
"thursday":{"value":true,"type":"boolean"},
"friday":{"value":true,"type":"boolean"},
"saturday":{"value":true,"type":"boolean"},
"sunday":{"value":true,"type":"boolean"},
"sleep_enabled":{"type":"boolean","value":false},
"sleep_hour":{"value":"0","type":"number"},
"sleep_minute":{"value":"0","type":"number"},
Expand Down
46 changes: 46 additions & 0 deletions app/plugins/miscellanea/alarm-clock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ AlarmClock.prototype.getUIConfig = function () {
// minute
uiconf.sections[0].content[2].value.value = config.get('minute');

//monday
uiconf.sections[0].content[3].value.value=config.get('monday');

//tuesday
uiconf.sections[0].content[4].value.value=config.get('tuesday');

//wednesday
uiconf.sections[0].content[5].value.value=config.get('wednesday');

//thursday
uiconf.sections[0].content[6].value.value=config.get('thursday');

//friday
uiconf.sections[0].content[7].value.value=config.get('friday');

//saturday
uiconf.sections[0].content[8].value.value=config.get('saturday');

//sunday
uiconf.sections[0].content[9].value.value=config.get('sunday');

return uiconf;
};

Expand Down Expand Up @@ -121,6 +142,28 @@ AlarmClock.prototype.applyConf = function (conf) {

var schedule = require('node-schedule');
var rule = new schedule.RecurrenceRule();
rule.dayOfWeek = [];
if (item.monday) {
rule.dayOfWeek.push(1);
}
if (item.tuesday) {
rule.dayOfWeek.push(2);
}
if (item.wednesday) {
rule.dayOfWeek.push(3);
}
if (item.thursday) {
rule.dayOfWeek.push(4);
}
if (item.friday) {
rule.dayOfWeek.push(5);
}
if (item.saturday) {
rule.dayOfWeek.push(6);
}
if (item.sunday) {
rule.dayOfWeek.push(7);
}
rule.minute = d.getMinutes();
rule.hour = d.getHours();
let currentItem = Object.assign({}, item);
Expand Down Expand Up @@ -196,6 +239,9 @@ AlarmClock.prototype.saveAlarm = function (data) {
} else if (!data[i].playlist) {
var error = true;
self.commandRouter.pushToastMessage('error', self.commandRouter.getI18nString('ALARM.ALARM_CLOCK_TITLE'), self.commandRouter.getI18nString('ALARM.PLAYLIST_SELECT_ERROR'));
} else if (!data[i].monday && !data[i].tuesday && !data[i].wednesday && !data[i].thursday && !data[i].friday && !data[i].saturday && !data[i].sunday) {
var error = true;
self.commandRouter.pushToastMessage('error', self.commandRouter.getI18nString('ALARM.ALARM_CLOCK_TITLE'), self.commandRouter.getI18nString('ALARM.DAY_SELECT_ERROR'));
}
}

Expand Down

0 comments on commit f3fb350

Please sign in to comment.