diff --git a/CHANGELOG b/CHANGELOG index 960a0a9d0..bf52cc409 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,10 @@ Version 2.2 (unreleased) Motions: - New export dialog. +Core: +- No reload on logoff. OpenSlides is now a full single page application. + + Version 2.1.1 (2017-04-05) ========================== [https://github.com/OpenSlides/OpenSlides/milestones/2.1.1] diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index f0fdebcca..824ff5f33 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -76,11 +76,6 @@ angular.module('OpenSlidesApp.core', [ Autoupdate.onMessage = function (receiver) { Autoupdate.messageReceivers.push(receiver); }; - Autoupdate.reconnect = function () { - if (socket) { - socket.close(); - } - }; Autoupdate.newConnect = function () { socket = new WebSocket(websocketProtocol + '//' + location.host + websocketPath); clearInterval(recInterval); @@ -89,7 +84,9 @@ angular.module('OpenSlidesApp.core', [ recInterval = setInterval(function () { Autoupdate.newConnect(); }, 1000); - ErrorMessage.setConnectionError(); + if (event.code !== 1000) { // 1000 is a normal close, like the close on logout + ErrorMessage.setConnectionError(); + } }; socket.onmessage = function (event) { _.forEach(Autoupdate.messageReceivers, function (receiver) { @@ -102,6 +99,12 @@ angular.module('OpenSlidesApp.core', [ ErrorMessage.clearConnectionError(); }; }; + Autoupdate.closeConnection = function () { + if (socket) { + socket.close(); + } + Autoupdate.firstMessageDeferred = $q.defer(); + }; return Autoupdate; } ]) diff --git a/openslides/core/static/js/core/start.js b/openslides/core/static/js/core/start.js index a780009e4..3940a8f95 100644 --- a/openslides/core/static/js/core/start.js +++ b/openslides/core/static/js/core/start.js @@ -4,31 +4,55 @@ angular.module('OpenSlidesApp.core.start', []) -.run([ +.factory('OpenSlides', [ '$http', '$rootScope', '$state', + 'DS', 'autoupdate', 'operator', 'Group', 'mainMenu', - function($http, $rootScope, $state, autoupdate, operator, Group, mainMenu) { - $rootScope.openslidesBootstrapDone = false; - $http.get('/users/whoami/').then(function (success) { - $rootScope.guest_enabled = success.data.guest_enabled; - if (success.data.user_id === null && !success.data.guest_enabled) { - // Redirect to login dialog if user is not logged in. - $state.go('login', {guest_enabled: success.data.guest_enabled}); - } else { - autoupdate.newConnect(); - autoupdate.firstMessageDeferred.promise.then(function () { - operator.setUser(success.data.user_id, success.data.user); - $rootScope.operator = operator; - mainMenu.updateMainMenu(); - $rootScope.openslidesBootstrapDone = true; + function($http, $rootScope, $state, DS, autoupdate, operator, Group, mainMenu) { + return { + bootup: function () { + $rootScope.openslidesBootstrapDone = false; + $http.get('/users/whoami/').then(function (success) { + $rootScope.guest_enabled = success.data.guest_enabled; + if (success.data.user_id === null && !success.data.guest_enabled) { + // Redirect to login dialog if user is not logged in. + $state.go('login', {guest_enabled: success.data.guest_enabled}); + } else { + autoupdate.newConnect(); + autoupdate.firstMessageDeferred.promise.then(function () { + operator.setUser(success.data.user_id, success.data.user); + $rootScope.operator = operator; + mainMenu.updateMainMenu(); + $rootScope.openslidesBootstrapDone = true; + }); + } }); - } - }); + }, + 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(); } ]) diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index d143e7505..3fac4c42c 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -1397,17 +1397,15 @@ angular.module('OpenSlidesApp.users.site', [ .controller('userMenu', [ '$scope', '$http', - 'DS', - 'User', - 'operator', + 'OpenSlides', 'ngDialog', 'UserProfileForm', 'UserPasswordForm', - function($scope, $http, DS, User, operator, ngDialog, UserProfileForm, UserPasswordForm) { + function($scope, $http, OpenSlides, ngDialog, UserProfileForm, UserPasswordForm) { $scope.logout = function () { $http.post('/users/logout/').then(function (response) { - operator.setUser(null); - window.location.reload(); + // Success: User logged out, so reboot OpenSlides. + OpenSlides.reboot(); }); }; $scope.editProfile = function () {