Do not reload on logout (fixes #2868)

This commit is contained in:
FinnStutzenstein 2017-03-31 08:48:43 +02:00 committed by Norman Jäckel
parent 598dc30486
commit c86f6d3684
4 changed files with 58 additions and 29 deletions

View File

@ -10,6 +10,10 @@ Version 2.2 (unreleased)
Motions: Motions:
- New export dialog. - New export dialog.
Core:
- No reload on logoff. OpenSlides is now a full single page application.
Version 2.1.1 (2017-04-05) Version 2.1.1 (2017-04-05)
========================== ==========================
[https://github.com/OpenSlides/OpenSlides/milestones/2.1.1] [https://github.com/OpenSlides/OpenSlides/milestones/2.1.1]

View File

@ -76,11 +76,6 @@ angular.module('OpenSlidesApp.core', [
Autoupdate.onMessage = function (receiver) { Autoupdate.onMessage = function (receiver) {
Autoupdate.messageReceivers.push(receiver); Autoupdate.messageReceivers.push(receiver);
}; };
Autoupdate.reconnect = function () {
if (socket) {
socket.close();
}
};
Autoupdate.newConnect = function () { Autoupdate.newConnect = function () {
socket = new WebSocket(websocketProtocol + '//' + location.host + websocketPath); socket = new WebSocket(websocketProtocol + '//' + location.host + websocketPath);
clearInterval(recInterval); clearInterval(recInterval);
@ -89,7 +84,9 @@ angular.module('OpenSlidesApp.core', [
recInterval = setInterval(function () { recInterval = setInterval(function () {
Autoupdate.newConnect(); Autoupdate.newConnect();
}, 1000); }, 1000);
if (event.code !== 1000) { // 1000 is a normal close, like the close on logout
ErrorMessage.setConnectionError(); ErrorMessage.setConnectionError();
}
}; };
socket.onmessage = function (event) { socket.onmessage = function (event) {
_.forEach(Autoupdate.messageReceivers, function (receiver) { _.forEach(Autoupdate.messageReceivers, function (receiver) {
@ -102,6 +99,12 @@ angular.module('OpenSlidesApp.core', [
ErrorMessage.clearConnectionError(); ErrorMessage.clearConnectionError();
}; };
}; };
Autoupdate.closeConnection = function () {
if (socket) {
socket.close();
}
Autoupdate.firstMessageDeferred = $q.defer();
};
return Autoupdate; return Autoupdate;
} }
]) ])

View File

@ -4,15 +4,18 @@
angular.module('OpenSlidesApp.core.start', []) angular.module('OpenSlidesApp.core.start', [])
.run([ .factory('OpenSlides', [
'$http', '$http',
'$rootScope', '$rootScope',
'$state', '$state',
'DS',
'autoupdate', 'autoupdate',
'operator', 'operator',
'Group', 'Group',
'mainMenu', 'mainMenu',
function($http, $rootScope, $state, autoupdate, operator, Group, mainMenu) { function($http, $rootScope, $state, DS, autoupdate, operator, Group, mainMenu) {
return {
bootup: function () {
$rootScope.openslidesBootstrapDone = false; $rootScope.openslidesBootstrapDone = false;
$http.get('/users/whoami/').then(function (success) { $http.get('/users/whoami/').then(function (success) {
$rootScope.guest_enabled = success.data.guest_enabled; $rootScope.guest_enabled = success.data.guest_enabled;
@ -29,6 +32,27 @@ angular.module('OpenSlidesApp.core.start', [])
}); });
} }
}); });
},
shutdown: function () {
// Close connection, clear the store and show the OS overlay.
autoupdate.closeConnection();
DS.clear();
operator.setUser(null);
$rootScope.openslidesBootstrapDone = false;
$rootScope.operator = operator;
},
reboot: function () {
this.shutdown();
this.bootup();
},
};
}
])
.run([
'OpenSlides',
function (OpenSlides) {
OpenSlides.bootup();
} }
]) ])

View File

@ -1397,17 +1397,15 @@ angular.module('OpenSlidesApp.users.site', [
.controller('userMenu', [ .controller('userMenu', [
'$scope', '$scope',
'$http', '$http',
'DS', 'OpenSlides',
'User',
'operator',
'ngDialog', 'ngDialog',
'UserProfileForm', 'UserProfileForm',
'UserPasswordForm', 'UserPasswordForm',
function($scope, $http, DS, User, operator, ngDialog, UserProfileForm, UserPasswordForm) { function($scope, $http, OpenSlides, ngDialog, UserProfileForm, UserPasswordForm) {
$scope.logout = function () { $scope.logout = function () {
$http.post('/users/logout/').then(function (response) { $http.post('/users/logout/').then(function (response) {
operator.setUser(null); // Success: User logged out, so reboot OpenSlides.
window.location.reload(); OpenSlides.reboot();
}); });
}; };
$scope.editProfile = function () { $scope.editProfile = function () {