2016-06-02 05:34:03 +00:00
|
|
|
angular.module('dashboard')
|
2016-09-23 04:54:58 +00:00
|
|
|
.controller('MasterCtrl', ['$scope', '$cookieStore', 'Settings', 'Config', 'Info',
|
|
|
|
function ($scope, $cookieStore, Settings, Config, Info) {
|
2016-06-02 05:34:03 +00:00
|
|
|
/**
|
|
|
|
* Sidebar Toggle & Cookie Control
|
|
|
|
*/
|
|
|
|
var mobileView = 992;
|
|
|
|
|
|
|
|
$scope.getWidth = function() {
|
|
|
|
return window.innerWidth;
|
|
|
|
};
|
|
|
|
|
2016-09-23 04:54:58 +00:00
|
|
|
$scope.swarm_mode = false;
|
|
|
|
|
|
|
|
Config.$promise.then(function (c) {
|
2016-11-07 04:14:58 +00:00
|
|
|
$scope.logo = c.logo;
|
2016-09-23 04:54:58 +00:00
|
|
|
$scope.swarm = c.swarm;
|
|
|
|
Info.get({}, function(d) {
|
2016-09-23 06:02:03 +00:00
|
|
|
if ($scope.swarm && !_.startsWith(d.ServerVersion, 'swarm')) {
|
2016-09-23 04:54:58 +00:00
|
|
|
$scope.swarm_mode = true;
|
|
|
|
$scope.swarm_manager = false;
|
|
|
|
if (d.Swarm.ControlAvailable) {
|
|
|
|
$scope.swarm_manager = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2016-06-16 05:27:07 +00:00
|
|
|
|
2016-06-02 05:34:03 +00:00
|
|
|
$scope.$watch($scope.getWidth, function(newValue, oldValue) {
|
|
|
|
if (newValue >= mobileView) {
|
|
|
|
if (angular.isDefined($cookieStore.get('toggle'))) {
|
|
|
|
$scope.toggle = ! $cookieStore.get('toggle') ? false : true;
|
|
|
|
} else {
|
|
|
|
$scope.toggle = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$scope.toggle = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.toggleSidebar = function() {
|
|
|
|
$scope.toggle = !$scope.toggle;
|
|
|
|
$cookieStore.put('toggle', $scope.toggle);
|
|
|
|
};
|
|
|
|
|
|
|
|
window.onresize = function() {
|
|
|
|
$scope.$apply();
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.uiVersion = Settings.uiVersion;
|
|
|
|
}]);
|