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 Aug 1, 2019
1 parent caf6c0f commit 989d5ea
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 22 deletions.
12 changes: 10 additions & 2 deletions app/i18n/strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,16 @@
"SLEEP_MODE_HOUR":"hour(s)",
"STOP_MUSIC":"Stop Music",
"TURN_OFF":"Turn off",
"TIME_SELECT_ERROR":"Please select an alarm start time",
"PLAYLIST_SELECT_ERROR":"Please select a Playlist"
"TIME_SELECT_ERROR":"Please select an alarm start time",
"PLAYLIST_SELECT_ERROR":"Please select a Playlist",
"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"
},
"SYSTEM":{
"SYSTEM_SETTINGS":"System Settings",
Expand Down
24 changes: 16 additions & 8 deletions app/i18n/strings_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"ADVANCED_AUDIO_TWEAKS":"Réglages audio avancés",
"AUDIO_RESAMPLING":"Ré-échantillonage",
"AUDIO_RESAMPLING_SETTINGS_SAVED":"Réglage du ré-échantillonnage enregistré",
"AUDIO_RESAMPLING_DOC":"Contrôle les options de ré-échantillonnage. Pour la lecture de fichiers locaux uniquement (ne s'applique pas à Shairport ou services tiers comme ROON)",
"AUDIO_RESAMPLING_DOC":"Contrôle les options de ré-échantillonnage. Pour la lecture de fichiers locaux uniquement (ne s'applique pas à Shairport ou services tiers comme ROON)",
"TARGET_BITDEPTH":"Nombre de bits cible",
"TARGET_SAMPLERATE":"Fréquence d’échantillonnage",
"NATIVE":"Native",
Expand Down Expand Up @@ -81,7 +81,7 @@
"PLAYBACK_MODE":"Mode de lecture",
"PLAYBACK_MODE_DOC":"Vous pouvez choisir le comportement de lecture : Continue remplacera la liste courante par tous les morceaux de l'album ou de la playlist, Unitaire ajoutera seulement le morceau sélectionné",
"PLAYBACK_MODE_CONTINUOUS":"Continue",
"PLAYBACK_MODE_SINGLE":"Unitaire"
"PLAYBACK_MODE_SINGLE":"Unitaire"
},

"NETWORK": {
Expand Down Expand Up @@ -181,7 +181,7 @@
"ALBUMS":"Albums",
"ALBUM":"Album",
"GENRE":"Genre",
"GENRES":"Genres",
"GENRES":"Genres",
"TRACKS":"Pistes",
"TRACK":"Piste",
"WITH":"avec",
Expand Down Expand Up @@ -232,7 +232,7 @@
"COMPILATION_METADATA_DOC":"Configure les métadonnées utilisées pour décrire albumart dans les compilations ou multi-artistes. Utilise la virgule comme séparateur.",
"COMPILATION_METADATA":"Champs métadonnées pour les compilations",
"ALBUMART_CACHE_CLEARED":"Cache des images des albums réinitialisé avec succès",
"ALBUMART_CACHE_CLEAR_ERROR":"Une erreur est survenue en effaçant le cache, réessayer ultérieurement",
"ALBUMART_CACHE_CLEAR_ERROR":"Une erreur est survenue en effaçant le cache, réessayer ultérieurement",
"ALBUMART_RESET_CACHE":"Réinitialiser le cache des images des albums",
"ALBUMART_RESET_CACHE_DOC":"Volumio met en cache les images des albums pour améliorer la performance, cependant cela empêche les nouveaux albums d'apparaître. En réinitialisant le cache, le système peut afficher les nouveaux ajouts d'albums ",
"METADATA_IMAGE":"Montrer les images inclues dans les fichiers",
Expand Down Expand Up @@ -265,7 +265,15 @@
"STOP_MUSIC":"Arrêter la musique dans",
"TURN_OFF":"Éteindre dans",
"TIME_SELECT_ERROR":"Sélectionner l'heure de l'alarme",
"PLAYLIST_SELECT_ERROR":"Sélectionner une Playlist"
"PLAYLIST_SELECT_ERROR":"Sélectionner une Playlist",
"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"
},
"SYSTEM":{
"SYSTEM_SETTINGS":"Réglages du Système",
Expand Down Expand Up @@ -305,7 +313,7 @@
"INSTALL_TO_DISK_SIZE":"TAILLE",
"INSTALL_TO_DISK_MESSAGE_WARNING":" ATTENTION: Prenez soin de sélectionner le bon disque de destination, toutes les données vont être effacées.",
"INSTALLING_TO_DISK_SUCCESS_TITLE":"Système installé avec succès",
"INSTALLING_TO_DISK_SUCCESS_MESSAGE":"Pour pouvoir utiliser le nouveau système, enlevez les médias amovibles et redémarrez l'appareil.",
"INSTALLING_TO_DISK_SUCCESS_MESSAGE":"Pour pouvoir utiliser le nouveau système, enlevez les médias amovibles et redémarrez l'appareil.",
"CREDITS_OPEN_SOURCE_LICENSES":"Crédits et licences Open Source",
"VIDEO_OUT_OPTIONS": "Options sortie vidéo",
"HDMI_UI_DOC":"Affiche l'interface via la sortie vidéo HDMI. ATTENTION: Cela peut dégrader les performances du système",
Expand All @@ -325,7 +333,7 @@
"SIMPLE_SETTINGS_SET":"Mode réglage simplifié",
"SIMPLE_SETTINGS_SET_EXTENDED":"Accès seulement aux réglages de base",
"KEEP_PRESSED_TO_TURN_OFF_IN":"Maintenir appuyé pour éteindre",
"TURN_OFF_IN":"Eteindre"
"TURN_OFF_IN":"Eteindre"
},
"WEBRADIO":{
"MY_WEB_RADIOS":"Mes radios Internet",
Expand Down Expand Up @@ -374,5 +382,5 @@
"UPDATE":"Mise à jour",
"CHECKING_FOR_UPDATES":"Recherche de mise à jour",
"CHECKING_FOR_UPDATES_WAIT":"Merci de patienter"
}
}
}
82 changes: 79 additions & 3 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,9 +398,78 @@
"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
}
}
]
}
]
}
}
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
62 changes: 53 additions & 9 deletions app/plugins/miscellanea/alarm-clock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,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 @@ -128,19 +149,39 @@ 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();

if (item.enabled) {

var func = self.fireAlarm.bind(self);
var j = schedule.scheduleJob(rule, function(){
func(item);
});

self.logger.info("Alarm: Scheduling " + j.name + " at " +rule.hour + ":" + rule.minute) ;
self.jobs.push(j);
}
var func = self.fireAlarm.bind(self);
var j = schedule.scheduleJob(rule, function(){
func(item);
});
self.logger.info("Alarm: Scheduling " + j.name + " at " +rule.hour + ":" + rule.minute) ;
self.jobs.push(j);
}
}
}

Expand Down Expand Up @@ -212,6 +253,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 989d5ea

Please sign in to comment.