Moved the Notifications into the AngularJS System

This commit is contained in:
Tim Windelschmidt 2015-09-16 17:33:56 +02:00
parent 129fae722c
commit 8e041efb86
1 changed files with 14 additions and 0 deletions

View File

@ -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;
}
}