mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Now supports alerts and notifications
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
Module.register('alert',{
|
||||
defaults: {
|
||||
// layout type: growl|attached|bar|other
|
||||
// layout type: growl|attached|bar
|
||||
layout: "growl",
|
||||
// effects for the specified layout:
|
||||
// for growl layout: scale|slide|genie|jelly
|
||||
@@ -20,12 +20,12 @@ Module.register('alert',{
|
||||
welcome_message: "Welcome, start was successfull!"
|
||||
},
|
||||
getScripts: function() {
|
||||
return ["classie.js", "modernizr.custom.js", 'notificationFx.js'];
|
||||
return ["classie.js", "modernizr.custom.js", 'notificationFx.js', 'sweetalert.js'];
|
||||
},
|
||||
getStyles: function() {
|
||||
return ['ns-style-growl.css', 'ns-style-bar.css', 'ns-style-attached.css', 'ns-default.css'];
|
||||
return ['ns-style-growl.css', 'ns-style-bar.css', 'ns-style-attached.css', 'ns-default.css', 'sweetalert.css'];
|
||||
},
|
||||
show_alert: function (message) {
|
||||
show_notification: function (message) {
|
||||
//If another alert is in view remove it first
|
||||
if (this.alert){
|
||||
this.alert.dismiss()
|
||||
@@ -39,15 +39,38 @@ Module.register('alert',{
|
||||
});
|
||||
this.alert.show()
|
||||
},
|
||||
show_alert: function (params) {
|
||||
if (typeof params["type"] === 'undefined') { params["type"] = null; }
|
||||
if (typeof params["imageUrl"] === 'undefined') { params["imageUrl"] = null; }
|
||||
if (typeof params["imageSize"] === 'undefined') { params["imageSize"] = null; }
|
||||
if (typeof params["timer"] === 'undefined') { params["timer"] = null; }
|
||||
swal({
|
||||
title: params["title"],
|
||||
imageUrl: params["imageUrl"],
|
||||
imageSize: params["imageSize"],
|
||||
type: params["type"],
|
||||
text: params["message"],
|
||||
timer: params["timer"],
|
||||
html: true,
|
||||
showConfirmButton: false
|
||||
});
|
||||
},
|
||||
hide_alert: function () {
|
||||
swal.close()
|
||||
},
|
||||
notificationReceived: function(notification, payload, sender) {
|
||||
if (notification === 'SHOW_ALERT') {
|
||||
console.log(this.config.layout);
|
||||
this.show_alert(payload.message)
|
||||
if (notification === 'SHOW_NOTIFICATION') {
|
||||
this.show_notification(payload)
|
||||
}
|
||||
else if (notification === 'SHOW_ALERT') {
|
||||
this.show_alert(payload)
|
||||
}
|
||||
else if (notification === 'HIDE_ALERT') {
|
||||
this.hide_alert()
|
||||
}
|
||||
},
|
||||
start: function() {
|
||||
// create the notification
|
||||
this.show_alert(this.config.welcome_message)
|
||||
this.show_notification(this.config.welcome_message)
|
||||
Log.info('Starting module: ' + this.name);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user