mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Merge pull request #131 from paviro/v2-beta
Use SHOW_ALERT for all type of notifications
This commit is contained in:
@@ -70,11 +70,18 @@ The following properties can be configured:
|
|||||||
|
|
||||||
|
|
||||||
## Developer notes
|
## Developer notes
|
||||||
|
For notifications use:
|
||||||
|
|
||||||
### Display notification
|
|
||||||
```
|
```
|
||||||
self.sendNotification("SHOW_NOTIFICATION", {title: "Hello", message: "This is a test!"});
|
self.sendNotification("SHOW_ALERT", {type: "notification"});
|
||||||
```
|
```
|
||||||
|
For alerts use:
|
||||||
|
|
||||||
|
```
|
||||||
|
self.sendNotification("SHOW_ALERT", {});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Notification params
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
<!-- why, markdown... -->
|
<!-- why, markdown... -->
|
||||||
<thead>
|
<thead>
|
||||||
@@ -99,10 +106,7 @@ self.sendNotification("SHOW_NOTIFICATION", {title: "Hello", message: "This is a
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### Display alert
|
### Alert params
|
||||||
```
|
|
||||||
self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!", imageUrl:"url", imageHeight: "30px", timer:2});
|
|
||||||
```
|
|
||||||
<table width="100%">
|
<table width="100%">
|
||||||
<!-- why, markdown... -->
|
<!-- why, markdown... -->
|
||||||
<thead>
|
<thead>
|
||||||
@@ -140,7 +144,7 @@ self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!",
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>timer</code> (optional)</td>
|
<td><code>timer</code> (optional)</td>
|
||||||
<td>How long the alert should stay visible in seconds.
|
<td>How long the alert should stay visible in ms.
|
||||||
<br><b>Important:</b> If you do not use the <code>timer</code>, it is your duty to hide the alert by using <code>self.sendNotification("HIDE_ALERT");</code>!<br>
|
<br><b>Important:</b> If you do not use the <code>timer</code>, it is your duty to hide the alert by using <code>self.sendNotification("HIDE_ALERT");</code>!<br>
|
||||||
<br><b>Possible values:</b> <code>int</code> <code>float</code>
|
<br><b>Possible values:</b> <code>int</code> <code>float</code>
|
||||||
<br><b>Default value:</b> <code>none</code>
|
<br><b>Default value:</b> <code>none</code>
|
||||||
@@ -149,8 +153,6 @@ self.sendNotification("SHOW_ALERT", {title: "Hello", message: "This is a test!",
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Open Source Licenses
|
## Open Source Licenses
|
||||||
###[NotificationStyles](https://github.com/codrops/NotificationStyles)
|
###[NotificationStyles](https://github.com/codrops/NotificationStyles)
|
||||||
See [ympanus.net](http://tympanus.net/codrops/licensing/) for license.
|
See [ympanus.net](http://tympanus.net/codrops/licensing/) for license.
|
@@ -14,7 +14,7 @@ Module.register('alert',{
|
|||||||
// scale|slide|genie|jelly|flip|bouncyflip|exploader
|
// scale|slide|genie|jelly|flip|bouncyflip|exploader
|
||||||
alert_effect:"jelly",
|
alert_effect:"jelly",
|
||||||
//time a notification is displayed in seconds
|
//time a notification is displayed in seconds
|
||||||
display_time: 3.5,
|
display_time: 3500,
|
||||||
//Position
|
//Position
|
||||||
position: "center",
|
position: "center",
|
||||||
//shown at startup
|
//shown at startup
|
||||||
@@ -32,18 +32,13 @@ Module.register('alert',{
|
|||||||
message : message,
|
message : message,
|
||||||
layout : "growl",
|
layout : "growl",
|
||||||
effect : this.config.effect,
|
effect : this.config.effect,
|
||||||
ttl: this.config.display_time * 1000
|
ttl: this.config.display_time
|
||||||
}).show();
|
}).show();
|
||||||
},
|
},
|
||||||
show_alert: function (params, sender) {
|
show_alert: function (params, sender) {
|
||||||
var self = this
|
var self = this
|
||||||
//Set standard params if not provided by module
|
//Set standard params if not provided by module
|
||||||
if (typeof params.timer === 'undefined') {
|
if (typeof params.timer === 'undefined') { params.timer = null; }
|
||||||
params.timer = null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
params.timer = params.timer * 1000
|
|
||||||
}
|
|
||||||
if (typeof params.imageHeight === 'undefined') { params.imageHeight = "80px"; }
|
if (typeof params.imageHeight === 'undefined') { params.imageHeight = "80px"; }
|
||||||
if (typeof params.imageUrl === 'undefined') {
|
if (typeof params.imageUrl === 'undefined') {
|
||||||
params.imageUrl = null;
|
params.imageUrl = null;
|
||||||
@@ -99,11 +94,14 @@ Module.register('alert',{
|
|||||||
|
|
||||||
},
|
},
|
||||||
notificationReceived: function(notification, payload, sender) {
|
notificationReceived: function(notification, payload, sender) {
|
||||||
if (notification === 'SHOW_NOTIFICATION') {
|
if (typeof payload.type === 'undefined') { payload.type = "alert"; }
|
||||||
this.show_notification(payload)
|
if (notification === 'SHOW_ALERT') {
|
||||||
}
|
if (payload.type == "alert"){
|
||||||
else if (notification === 'SHOW_ALERT') {
|
this.show_alert(payload, sender)
|
||||||
this.show_alert(payload, sender)
|
}
|
||||||
|
else if (payload.type = "notification"){
|
||||||
|
this.show_notification(payload)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (notification === 'HIDE_ALERT') {
|
else if (notification === 'HIDE_ALERT') {
|
||||||
this.hide_alert(sender)
|
this.hide_alert(sender)
|
||||||
|
Reference in New Issue
Block a user