Moved the Notifications into the AngularJS System
This commit is contained in:
parent
129fae722c
commit
8e041efb86
|
@ -1,6 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var gpower;
|
var gpower;
|
||||||
|
var laststate;
|
||||||
|
|
||||||
angular.module('roomstateapp.controllers', []).
|
angular.module('roomstateapp.controllers', []).
|
||||||
controller('StatusCtrl', function ($scope, $http, Socket) {
|
controller('StatusCtrl', function ($scope, $http, Socket) {
|
||||||
|
@ -20,6 +21,7 @@ angular.module('roomstateapp.controllers', []).
|
||||||
|
|
||||||
Socket.on('sdata', function(message) {
|
Socket.on('sdata', function(message) {
|
||||||
console.log("received data from server: " + message.data.names);
|
console.log("received data from server: " + message.data.names);
|
||||||
|
stateNotification(message.data.state);
|
||||||
$scope.simple = message.data;
|
$scope.simple = message.data;
|
||||||
gpower.refresh(message.data.power);
|
gpower.refresh(message.data.power);
|
||||||
});
|
});
|
||||||
|
@ -82,3 +84,15 @@ gpower = new JustGage({
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function stateNotification(state) {
|
||||||
|
if (state == true && laststate != true && laststate != null) {
|
||||||
|
laststate = true;
|
||||||
|
showNotification("CTDO - Status", "Der Chaostreff ist nun offen.", "/img/green.png", 4);
|
||||||
|
} else if (state == false && laststate != false && laststate != null) {
|
||||||
|
laststate = false;
|
||||||
|
showNotification("CTDO - Staus", "Der Chaostreff ist nun geschlossen", "/img/red.png", 4);
|
||||||
|
} else {
|
||||||
|
laststate = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue