66 lines
3.3 KiB
Markdown
Raw Normal View History

2016-04-01 22:05:09 +02:00
# Module: Alert
The alert module is one of the default modules of the MagicMirror. This module displays notifications from other modules.
## Usage
To use this module, add it to the modules array in the config/config.js file:
```
modules: [
{
module: "alert",
2016-04-01 22:05:09 +02:00
config: {
2016-04-02 14:46:46 +02:00
// The config property is optional.
2017-02-12 13:29:36 -03:00
// See 'Configuration options' for more information.
2016-04-01 22:05:09 +02:00
}
}
]
2016-04-01 22:07:50 +02:00
```
2016-04-02 14:46:46 +02:00
## Configuration options
The following properties can be configured:
2017-01-17 16:12:03 +01:00
| Option | Description
| ----------------- | -----------
| `effect` | The animation effect to use for notifications. <br><br> **Possible values:** `scale` `slide` `genie` `jelly` `flip` `exploader` `bouncyflip` <br> **Default value:** `slide`
| `alert_effect` | The animation effect to use for alerts. <br><br> **Possible values:** `scale` `slide` `genie` `jelly` `flip` `exploader` `bouncyflip` <br> **Default value:** `jelly`
| `display_time` | Time a notification is displayed in milliseconds. <br><br> **Possible values:** `int` <br> **Default value:** `3500`
| `position` | Position where the notifications should be displayed. <br><br> **Possible values:** `left` `center` `right` <br> **Default value:** `center`
| `welcome_message` | Message shown at startup. <br><br> **Possible values:** `string` `false` <br> **Default value:** `false` (no message at startup)
2016-04-02 14:46:46 +02:00
## Developer notes
For notifications use:
2016-04-01 22:07:50 +02:00
```
2017-02-12 13:29:36 -03:00
self.sendNotification("SHOW_ALERT", {type: "notification"});
2016-04-02 03:59:18 +02:00
```
For alerts use:
```
2017-02-12 13:29:36 -03:00
self.sendNotification("SHOW_ALERT", {});
```
### Notification params
2019-03-13 12:01:49 +01:00
| Option | Description
| ------------------ | -----------
| `title` | The title of the notification. <br><br> **Possible values:** `text` or `html`
| `message` | The message of the notification. <br><br> **Possible values:** `text` or `html`
| `timer` (optional) | How long the notification should stay visible in ms. <br> If absent, the default `display_time` is used. <br> **Possible values:** `int` `float`
2017-01-17 16:12:03 +01:00
2016-04-02 03:59:18 +02:00
### Alert params
2017-01-17 16:12:03 +01:00
| Option | Description
| ----------------------------------------------- | -----------
| `title` | The title of the alert. <br><br> **Possible values:** `text` or `html`
| `message` | The message of the alert. <br><br> **Possible values:** `text` or `html`
| `imageUrl` (optional) | Image to show in the alert <br><br> **Possible values:** `url` `path` <br> **Default value:** `none`
| `imageFA` (optional) | Font Awesome icon to show in the alert <br><br> **Possible values:** See [Font Awsome](http://fontawesome.io/icons/) website. <br> **Default value:** `none`
| `imageHeight` (optional even with imageUrl set) | Height of the image <br><br> **Possible values:** `intpx` <br> **Default value:** `80px`
| `timer` (optional) | How long the alert should stay visible in ms. <br> **Important:** If you do not use the `timer`, it is your duty to hide the alert by using `self.sendNotification("HIDE_ALERT");`! <br><br>**Possible values:** `int` `float` <br> **Default value:** `none`
2016-04-02 14:46:46 +02:00
## Open Source Licenses
2018-03-01 11:53:10 +02:00
### [NotificationStyles](https://github.com/codrops/NotificationStyles)
2019-03-01 23:34:27 +01:00
See [tympanus.net](http://tympanus.net/codrops/licensing/) for license.