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',
|
|
|
|
config: {
|
2016-04-02 14:46:46 +02:00
|
|
|
// The config property is optional.
|
|
|
|
// 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:
|
|
|
|
|
|
|
|
|
|
|
|
<table width="100%">
|
|
|
|
<!-- why, markdown... -->
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Option</th>
|
|
|
|
<th width="100%">Description</th>
|
|
|
|
</tr>
|
|
|
|
<thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td><code>effect</code></td>
|
2016-04-03 03:04:38 +02:00
|
|
|
<td>The animation effect to use for notifications.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>scale</code> <code>slide</code> <code>genie</code> <code>jelly</code> <code>flip</code> <code>exploader</code> <code>bouncyflip</code>
|
2016-04-02 14:46:46 +02:00
|
|
|
<br><b>Default value:</b> <code>slide</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2016-04-03 03:04:38 +02:00
|
|
|
<td><code>alert_effect</code></td>
|
|
|
|
<td>The animation effect to use for alerts.<br>
|
|
|
|
<br><b>Possible values:</b> <code>scale</code> <code>slide</code> <code>genie</code> <code>jelly</code> <code>flip</code> <code>exploader</code> <code>bouncyflip</code>
|
|
|
|
<br><b>Default value:</b> <code>jelly</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2016-04-02 14:46:46 +02:00
|
|
|
<tr>
|
|
|
|
<td><code>display_time</code></td>
|
|
|
|
<td>Time a notification is displayed.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>int</code>
|
|
|
|
<br><b>Default value:</b> <code>3500</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>position</code></td>
|
|
|
|
<td>Position where the notifications should be displayed.<br>
|
|
|
|
<br><b>Possible values:</b> <code>left</code> <code>center</code> <code>right</code>
|
2016-04-02 14:46:46 +02:00
|
|
|
<br><b>Default value:</b> <code>3500</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>welcome_message</code></td>
|
|
|
|
<td>Message shown at startup.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>string</code> <code>false</code>
|
2016-04-02 14:46:46 +02:00
|
|
|
<br><b>Default value:</b> <code>Welcome, start was successfull!</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
## Developer notes
|
2016-04-01 22:07:50 +02:00
|
|
|
|
2016-04-02 14:46:46 +02:00
|
|
|
### Display notification
|
2016-04-01 22:07:50 +02:00
|
|
|
```
|
2016-04-02 20:05:05 +02:00
|
|
|
self.sendNotification("SHOW_NOTIFICATION", {title: "Hello", message: "This is a test!"});
|
2016-04-02 03:59:18 +02:00
|
|
|
```
|
2016-04-02 20:05:05 +02:00
|
|
|
<table width="100%">
|
|
|
|
<!-- why, markdown... -->
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Option</th>
|
|
|
|
<th width="100%">Description</th>
|
|
|
|
</tr>
|
|
|
|
<thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td><code>title</code></td>
|
|
|
|
<td>The title of the notification.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>text</code> or <code>html</code>
|
2016-04-02 20:05:05 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>message</code></td>
|
|
|
|
<td>The message of the notification.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>text</code> or <code>html</code>
|
2016-04-02 20:05:05 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2016-04-02 03:59:18 +02:00
|
|
|
|
2016-04-02 14:46:46 +02:00
|
|
|
### Display alert
|
2016-04-02 03:59:18 +02:00
|
|
|
```
|
|
|
|
self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!", type: "success", imageUrl:"url", imageSize: "50x50", timer:1000});
|
|
|
|
```
|
2016-04-02 14:57:29 +02:00
|
|
|
<table width="100%">
|
|
|
|
<!-- why, markdown... -->
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Option</th>
|
|
|
|
<th width="100%">Description</th>
|
|
|
|
</tr>
|
|
|
|
<thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td><code>title</code></td>
|
|
|
|
<td>The title of the alert.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>text</code> or <code>html</code>
|
2016-04-02 14:57:29 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>message</code></td>
|
|
|
|
<td>The message of the alert.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>text</code> or <code>html</code>
|
2016-04-02 14:57:29 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>imageUrl</code> (optional)</td>
|
|
|
|
<td>Image to show in the alert<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>url</code>
|
2016-04-02 14:57:29 +02:00
|
|
|
<br><b>Default value:</b> <code>none</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2016-04-03 03:04:38 +02:00
|
|
|
<td><code>imageHeight</code> (optional even with imageUrl set)</td>
|
|
|
|
<td>Height of the image<br>
|
|
|
|
<br><b>Possible values:</b> "<code>int</code><code>px</code>"
|
|
|
|
<br><b>Default value:</b> <code>80px</code>
|
2016-04-02 14:57:29 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><code>timer</code> (optional)</td>
|
|
|
|
<td>How long the alert should stay visible.<br>
|
2016-04-02 23:54:15 +02:00
|
|
|
<br><b>Possible values:</b> <code>int</code>
|
2016-04-02 14:57:29 +02:00
|
|
|
<br><b>Default value:</b> <code>none</code>
|
|
|
|
<br><b>Important:</b> If you do not use the `timer`, it is your duty to hide the alert by using <code>self.sendNotification("HIDE_ALERT");</code>!
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
2016-04-02 04:17:58 +02:00
|
|
|
|
2016-04-02 14:46:46 +02:00
|
|
|
## Open Source Licenses
|
2016-04-02 04:17:58 +02:00
|
|
|
###[SweetAlert](http://t4t5.github.io/sweetalert/)
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
|
|
|
Copyright (c) 2014 Tristan Edwards
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
###[NotificationStyles](https://github.com/codrops/NotificationStyles)
|
|
|
|
See [ympanus.net](http://tympanus.net/codrops/licensing/) for license.
|