A MagicMirror module that renders calendars using the fullcalendar.io javascript libraries.
There are a 2 things you will need to do in your overall configuration so you can then render these webview(s).
- Electron Options
Referring to the MagicMirror Configuration, you will need to add the
nodeIntegration: true
toelectronOptions
. I am uncertain why this is needed (I have plenty of educated guesses), but if this value is false, things don't render.
electronOptions: {
/* Note: MagicMirror uses Object.assign() to 'override' its defaults. In order to ensure
you get the defaults for webPreferences along with your 'override' you must fully define
webPreferences to have all the MagicMirror defaults along with your override (nodeIntegration).
Thankfully, MagicMirror's default for webPreferences is zoomFactor: 1
and we are overriding the other default nodeIntegration
*/
webPreferences: {
zoomFactor: 1, // default is actually zoomFactor: config.zoom, and zoom's default is 1.
nodeIntegration: true, // the default for this is false. we are overriding this.
},
- Custom CSS
This is a kinda optional. Things do render without it, but the sizing is all crap. Basically what I am saying here is use CSS to style your webview; do not use the webview inline style. There are PLENTY of references/complaints online about how the webview isn't rendering fully as specified in the inline style. I wanted my entire screen to render as the webview. I finally came across a reference that presented a solution that actually worked (I hate css). This CSS did the trick; put this in your MagicMirror custom css
css/custom.css
.
.MMMFullCalendarIO {
position: absolute;
top: 30;
left: 20;
width: 90%;
height: 100%;
margin: 0 0 0 2em;
display: inline-flex;
}
I did some adjustments based on the page I was loading as in my application the rendered webview was 'too wide' and then shifted too much to the left.
-
Install and Build This module uses angular to render the calendar. After pulling down the module to your modules directory as MMM-FullCalendarIO, you will need to:
cd modules/MMM-FullCalendarIO
npm install
npm run build
Add or Change 1 or more MMM-FullCalendarIO
module configurations in ~/MagicMirror/config/config.js
file:
```javascript
{
module: "MMM-FullCalendarIO",
position: "fullscreen_above",
config: {
identifier: 'OurCalendar',
cssClassname: 'MMMFullCalendarIO',
fullcalendar: {
// see https://fullcalendar.io/docs/initialization
// document read function javascript
// see '// put your options and callbacks here'
}
}
}
```
Option | Description |
---|---|
updateInterval |
the update interval for the HTML page. Example for 30 seconds: 30 * 1000
Default value: "0" (never update; except based on module lifecycle)
|
identifier |
unique id/name used in generating the html file. This field is necessary to differentiate configurations when more than 1 use if this module is present in the config.js Default value: 'calendar'
|
cssClassname |
The name of the css definition for this Calendar. If you created a CSS class definition in ***Custom CSS*** setup step above you should provide that name for this option Default value: 'webview' (no actual assignment as the element name matches the css class name)
Example using css class definition `.MMMFullCalendarIO`: '.MMMFullCalendarIO'
|
backgroundColor |
The background color of the rendered calendar area.
Default value: #A9A9A9 (grey)
|
themeName |
The name of the specific theme within the fullcalendar.themeSystem specified theme for css.
Default value: flatly (bootstrap4 themesystem theme)
|
fullcalendar |
The [fullcalendar IO option object](https://fullcalendar.io/docs/initialization) passed to the fullcalendar function in the HTML. This is passed without interpretation to the fullcalendar.io function call in the javascript of the generated HTML file. Default value:
Defaults result in following:
All that is needed is the data for your events. |