mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Finish loading empty calendars. Fixes issue: #124
This commit is contained in:
parent
700ebc53f8
commit
c4bfa6d4d8
@ -112,6 +112,18 @@ The following properties can be configured:
|
|||||||
</code>
|
</code>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>loadingText</code></td>
|
||||||
|
<td>Text to display while loading item.<br>
|
||||||
|
<br><b>Default value:</b> <code>'Loading events …'</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>emptyCalendarText</code></td>
|
||||||
|
<td>Text to display when there are no upcoming events.<br>
|
||||||
|
<br><b>Default value:</b> <code>''No upcoming events.'</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@ Module.register('calendar',{
|
|||||||
],
|
],
|
||||||
titleReplace: {
|
titleReplace: {
|
||||||
'De verjaardag van ' : ''
|
'De verjaardag van ' : ''
|
||||||
}
|
},
|
||||||
|
loadingText: 'Loading events …',
|
||||||
|
emptyCalendarText: 'No upcoming events.'
|
||||||
},
|
},
|
||||||
|
|
||||||
// Define required scripts.
|
// Define required scripts.
|
||||||
@ -55,6 +57,7 @@ Module.register('calendar',{
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.calendarData = {};
|
this.calendarData = {};
|
||||||
|
this.loaded = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Override socket notification handler.
|
// Override socket notification handler.
|
||||||
@ -62,6 +65,7 @@ Module.register('calendar',{
|
|||||||
if (notification === 'CALENDAR_EVENTS') {
|
if (notification === 'CALENDAR_EVENTS') {
|
||||||
if (this.hasCalendarURL(payload.url)) {
|
if (this.hasCalendarURL(payload.url)) {
|
||||||
this.calendarData[payload.url] = payload.events;
|
this.calendarData[payload.url] = payload.events;
|
||||||
|
this.loaded = true;
|
||||||
}
|
}
|
||||||
} else if(notification === 'FETCH_ERROR') {
|
} else if(notification === 'FETCH_ERROR') {
|
||||||
Log.error('Calendar Error. Could not fetch calendar: ' + payload.url);
|
Log.error('Calendar Error. Could not fetch calendar: ' + payload.url);
|
||||||
@ -82,7 +86,7 @@ Module.register('calendar',{
|
|||||||
wrapper.className = "small";
|
wrapper.className = "small";
|
||||||
|
|
||||||
if (events.length === 0) {
|
if (events.length === 0) {
|
||||||
wrapper.innerHTML = "Loading events ...";
|
wrapper.innerHTML = (this.loaded) ? this.config.emptyCalendarText : this.config.loadingText;
|
||||||
wrapper.className = "small dimmed";
|
wrapper.className = "small dimmed";
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,6 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
* Broadcast the exsisting events.
|
* Broadcast the exsisting events.
|
||||||
*/
|
*/
|
||||||
this.broadcastEvents = function() {
|
this.broadcastEvents = function() {
|
||||||
if (events.length <= 0) {
|
|
||||||
//console.log('No events to broadcast yet.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//console.log('Broadcasting ' + events.length + ' events.');
|
//console.log('Broadcasting ' + events.length + ' events.');
|
||||||
eventsReceivedCallback(self);
|
eventsReceivedCallback(self);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user