2015-05-06 04:06:13 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {angular.Module}
|
|
|
|
*/
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
2015-12-08 22:45:24 +01:00
|
|
|
navController.$inject = ['$rootScope', '$scope', '$timeout', '$interval', '$http', '$mdSidenav', '$mdToast', '$mdMedia', '$log', 'sgConstant', 'sgSettings', 'Alarm'];
|
|
|
|
function navController($rootScope, $scope, $timeout, $interval, $http, $mdSidenav, $mdToast, $mdMedia, $log, sgConstant, sgSettings, Alarm) {
|
2015-07-14 22:12:07 +02:00
|
|
|
|
2015-09-04 23:31:16 +02:00
|
|
|
$scope.isPopup = sgSettings.isPopup;
|
2015-08-03 17:53:54 +02:00
|
|
|
$scope.activeUser = sgSettings.activeUser();
|
2015-08-14 18:14:15 +02:00
|
|
|
$scope.baseURL = sgSettings.baseURL();
|
2015-12-04 21:00:58 +01:00
|
|
|
$scope.leftIsClose = $mdMedia(sgConstant.xs);
|
2015-05-06 04:06:13 +02:00
|
|
|
|
|
|
|
// Show current day in top bar
|
|
|
|
$scope.currentDay = window.currentDay;
|
|
|
|
$timeout(function() {
|
|
|
|
// Update date when day ends
|
|
|
|
$interval(function() {
|
2015-12-14 18:20:39 +01:00
|
|
|
$http.get('../date').then(function(data) {
|
2015-05-06 04:06:13 +02:00
|
|
|
$scope.currentDay = data;
|
|
|
|
});
|
|
|
|
}, 24 * 3600 * 1000);
|
2015-08-03 17:53:54 +02:00
|
|
|
}, window.currentDay.secondsBeforeTomorrow * 1000);
|
2015-05-06 04:06:13 +02:00
|
|
|
|
2015-11-27 22:40:23 +01:00
|
|
|
$scope.toggleLeft = function() {
|
|
|
|
$scope.leftIsClose = leftIsClose();
|
2015-05-06 04:06:13 +02:00
|
|
|
$mdSidenav('left').toggle()
|
|
|
|
.then(function () {
|
|
|
|
$log.debug("toggle left is done");
|
|
|
|
});
|
|
|
|
};
|
2015-11-27 22:40:23 +01:00
|
|
|
$scope.toggleRight = function() {
|
2015-05-06 04:06:13 +02:00
|
|
|
$mdSidenav('right').toggle()
|
|
|
|
.then(function () {
|
2015-11-27 22:40:23 +01:00
|
|
|
$log.debug("toggle right is done");
|
2015-05-06 04:06:13 +02:00
|
|
|
});
|
|
|
|
};
|
2015-09-03 16:27:11 +02:00
|
|
|
// $scope.openBottomSheet = function() {
|
|
|
|
// $mdBottomSheet.show({
|
|
|
|
// parent: angular.element(document.getElementById('left-sidenav')),
|
|
|
|
// templateUrl: 'bottomSheetTemplate.html'
|
|
|
|
// });
|
|
|
|
// };
|
2015-11-25 17:12:30 +01:00
|
|
|
// $scope.toggleDetailView = function() {
|
|
|
|
// var detail = angular.element(document.getElementById('detailView'));
|
|
|
|
// detail.toggleClass('sg-close');
|
|
|
|
// };
|
2015-05-06 04:06:13 +02:00
|
|
|
$scope.$watch(function() {
|
2015-11-30 20:13:15 +01:00
|
|
|
return $mdMedia(sgConstant['gt-sm']);
|
2015-05-06 04:06:13 +02:00
|
|
|
}, function(newVal) {
|
|
|
|
$scope.isGtMedium = newVal;
|
2015-11-27 22:40:23 +01:00
|
|
|
if (newVal) {
|
|
|
|
$scope.leftIsClose = false;
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
});
|
2015-07-28 17:54:49 +02:00
|
|
|
|
2015-11-27 22:40:23 +01:00
|
|
|
function leftIsClose() {
|
|
|
|
return !$mdSidenav('left').isOpen();
|
|
|
|
}
|
|
|
|
|
2015-12-08 22:45:24 +01:00
|
|
|
function onHttpError(event, response) {
|
|
|
|
var message;
|
|
|
|
if (response.data.message)
|
|
|
|
message = response.data.message;
|
|
|
|
else
|
|
|
|
message = response.statusText;
|
|
|
|
|
|
|
|
$mdToast.show({
|
|
|
|
template: [
|
|
|
|
'<md-toast>',
|
2015-12-10 00:52:52 +01:00
|
|
|
' <div class="md-toast-content">',
|
|
|
|
' <md-icon class="md-warn md-hue-1">error_outline</md-icon>',
|
|
|
|
' <span flex>' + l(message) + '</span>',
|
|
|
|
' </div>',
|
2015-12-08 22:45:24 +01:00
|
|
|
'</md-toast>'
|
|
|
|
].join(''),
|
|
|
|
hideDelay: 5000,
|
|
|
|
position: 'top right'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Listen to HTTP errors broadcasted from HTTP interceptor
|
|
|
|
$rootScope.$on('http:Error', onHttpError);
|
|
|
|
|
2015-07-28 17:54:49 +02:00
|
|
|
Alarm.getAlarms();
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
angular.module('SOGo.Common')
|
|
|
|
.controller('navController', navController);
|
|
|
|
})();
|