2016-07-06 22:52:31 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('ffhb')
|
2016-07-11 10:06:12 +02:00
|
|
|
.controller('MainCtrl',function($rootScope,$scope,$interval,store,$state,AuthenticationService){
|
2016-07-09 10:15:03 +02:00
|
|
|
$scope.isOpen = false;
|
2016-07-06 22:52:31 +02:00
|
|
|
$scope.$state = $state;
|
|
|
|
$scope.refresh = store.refresh;
|
2016-07-11 10:06:12 +02:00
|
|
|
if($rootScope.passphrase === undefined){
|
|
|
|
$rootScope.passphrase = '';
|
|
|
|
}
|
2016-07-06 22:52:31 +02:00
|
|
|
var timediff = new Date(1970,1,1);
|
2016-07-09 10:15:03 +02:00
|
|
|
|
2016-07-06 22:52:31 +02:00
|
|
|
function render(prom){
|
|
|
|
prom.then(function(data){
|
|
|
|
timediff = data.lastupdate;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
render(store.getData);
|
|
|
|
$scope.$on('store', function(ev, prom) {
|
|
|
|
render(prom);
|
|
|
|
});
|
2016-07-09 10:15:03 +02:00
|
|
|
|
|
|
|
$scope.toggleOpen = function(){
|
|
|
|
$scope.isOpen = !$scope.isOpen;
|
|
|
|
};
|
|
|
|
|
|
|
|
$interval(function() {
|
|
|
|
$scope.timeRefresh = parseInt((new Date() - timediff) / 1000);
|
|
|
|
},100);
|
|
|
|
|
|
|
|
|
2016-07-06 22:52:31 +02:00
|
|
|
$scope.passphraseUpdate = function(){
|
2016-07-11 10:06:12 +02:00
|
|
|
if($rootScope.passphrase !== undefined && $rootScope.passphrase !== '' && $rootScope.passphrase !== '*****'){
|
|
|
|
console.log("set new basicauth");
|
|
|
|
AuthenticationService.SetCredentials('client',$rootScope.passphrase);
|
|
|
|
}
|
2016-07-06 22:52:31 +02:00
|
|
|
};
|
|
|
|
});
|