Merge pull request #2874 from FinnStutzenstein/StateBuild

StartUp improvements
This commit is contained in:
Norman Jäckel 2017-01-16 15:29:44 +01:00 committed by GitHub
commit 3b58c76287
7 changed files with 45 additions and 27 deletions

View File

@ -195,7 +195,6 @@ OpenSlides uses the following projects or parts of them:
* `angular-formly <http://formly-js.github.io/angular-formly/>`_, License: MIT * `angular-formly <http://formly-js.github.io/angular-formly/>`_, License: MIT
* `angular-formly-templates-bootstrap <https://github.com/formly-js/angular-formly-templates-bootstrap>`_, License: MIT * `angular-formly-templates-bootstrap <https://github.com/formly-js/angular-formly-templates-bootstrap>`_, License: MIT
* `angular-gettext <http://angular-gettext.rocketeer.be/>`_, License: MIT * `angular-gettext <http://angular-gettext.rocketeer.be/>`_, License: MIT
* `angular-loading-bar <https://chieffancypants.github.io/angular-loading-bar>`_, License: MIT
* `angular-messages <http://angularjs.org>`_, License: MIT * `angular-messages <http://angularjs.org>`_, License: MIT
* `pdfmake <https://github.com/bpampuch/pdfmake>`_, License: MIT * `pdfmake <https://github.com/bpampuch/pdfmake>`_, License: MIT
* `angular-pdf <http://github.com/sayanee/angularjs-pdf>`_, License: MIT * `angular-pdf <http://github.com/sayanee/angularjs-pdf>`_, License: MIT

View File

@ -13,7 +13,6 @@
"angular-formly": "~8.4.0", "angular-formly": "~8.4.0",
"angular-formly-templates-bootstrap": "~6.2.0", "angular-formly-templates-bootstrap": "~6.2.0",
"angular-gettext": "~2.3.7", "angular-gettext": "~2.3.7",
"angular-loading-bar": "~0.9.0",
"angular-messages": "~1.5.8", "angular-messages": "~1.5.8",
"angular-pdf": "~1.3.0", "angular-pdf": "~1.3.0",
"angular-sanitize": "~1.5.8", "angular-sanitize": "~1.5.8",

View File

@ -130,22 +130,31 @@ img {
} }
#startup-overlay { #startup-overlay {
display: table; position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: #fff; background-color: #fff;
z-index: 900;
}
#spinner-container {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
max-height: 356px;
z-index: 1000; z-index: 1000;
} }
#startup-overlay h1 { #spinner-container div {
width: 100%;
position: absolute;
bottom: 0;
font-size: 56px; font-size: 56px;
text-align: center; text-align: center;
} color: #317796;
#startup-overlay > div {
display: table-cell;
vertical-align: middle;
} }
/** Header **/ /** Header **/

View File

@ -8,7 +8,6 @@ angular.module('OpenSlidesApp.core.site', [
'OpenSlidesApp.core.start', 'OpenSlidesApp.core.start',
'OpenSlidesApp.poll.majority', 'OpenSlidesApp.poll.majority',
'ui.router', 'ui.router',
'angular-loading-bar',
'colorpicker.module', 'colorpicker.module',
'formly', 'formly',
'formlyBootstrap', 'formlyBootstrap',

View File

@ -13,7 +13,7 @@ angular.module('OpenSlidesApp.core.start', [])
'Group', 'Group',
'mainMenu', 'mainMenu',
function($http, $rootScope, $state, autoupdate, operator, Group, mainMenu) { function($http, $rootScope, $state, autoupdate, operator, Group, mainMenu) {
$rootScope.startupWaitingEnabled = true; $rootScope.openslidesBootstrapDone = false;
$http.get('/users/whoami/').success(function(data) { $http.get('/users/whoami/').success(function(data) {
$rootScope.guest_enabled = data.guest_enabled; $rootScope.guest_enabled = data.guest_enabled;
if (data.user_id === null && !data.guest_enabled) { if (data.user_id === null && !data.guest_enabled) {
@ -25,7 +25,7 @@ angular.module('OpenSlidesApp.core.start', [])
operator.setUser(data.user_id, data.user); operator.setUser(data.user_id, data.user);
$rootScope.operator = operator; $rootScope.operator = operator;
mainMenu.updateMainMenu(); mainMenu.updateMainMenu();
$rootScope.startupWaitingEnabled = false; $rootScope.openslidesBootstrapDone = true;
}); });
} }
}); });

View File

@ -18,11 +18,10 @@
<div id="wrapper" ng-cloak> <div id="wrapper" ng-cloak>
<!-- please wait --> <!-- please wait -->
<div id="startup-overlay" ng-if="startupWaitingEnabled"> <div id="spinner-container" ng-if="!openslidesBootstrapDone">
<div> <div><i class="fa fa-spinner fa-pulse"></i></div>
<h1><i class="fa fa-spinner fa-pulse"></i></h1>
</div>
</div> </div>
<div id="startup-overlay" ng-if="!openslidesBootstrapDone"></div>
<!-- Header --> <!-- Header -->
<div id="header"> <div id="header">
@ -177,7 +176,7 @@
<div class="containerOS"> <div class="containerOS">
<div class="col1" ng-class="isProjectorSidebar ? 'min' : 'max'"> <div class="col1" ng-class="isProjectorSidebar ? 'min' : 'max'">
<!-- dynamic views --> <!-- dynamic views -->
<div ui-view></div> <div ui-view ng-if="openslidesBootstrapDone"></div>
<!-- footer --> <!-- footer -->
<div id="footer"> <div id="footer">
&copy; Copyright by <a href="http://www.openslides.org" target="_blank">OpenSlides</a> | &copy; Copyright by <a href="http://www.openslides.org" target="_blank">OpenSlides</a> |

View File

@ -116,7 +116,10 @@ angular.module('OpenSlidesApp.users.site', [
.state('login', { .state('login', {
template: null, template: null,
url: '/login', url: '/login',
params: { guest_enabled: false }, params: {
guest_enabled: false,
msg: null,
},
onEnter: ['$state', '$stateParams', 'ngDialog', function($state, $stateParams, ngDialog) { onEnter: ['$state', '$stateParams', 'ngDialog', function($state, $stateParams, ngDialog) {
ngDialog.open({ ngDialog.open({
template: 'static/templates/core/login-form.html', template: 'static/templates/core/login-form.html',
@ -1118,7 +1121,7 @@ angular.module('OpenSlidesApp.users.site', [
$scope.groups.forEach(function (group) { $scope.groups.forEach(function (group) {
if ((_.indexOf(group.permissions, 'users.can_see_name') > -1) && if ((_.indexOf(group.permissions, 'users.can_see_name') > -1) &&
(_.indexOf(group.permissions, 'users.can_manage') > -1)){ (_.indexOf(group.permissions, 'users.can_manage') > -1)){
if (!operator.user || operator.isInGroup(group)){ if (operator.isInGroup(group)){
groups_danger.push(group); groups_danger.push(group);
} }
} }
@ -1351,9 +1354,21 @@ angular.module('OpenSlidesApp.users.site', [
'autoupdate', 'autoupdate',
'mainMenu', 'mainMenu',
'DS', 'DS',
function ($rootScope, $scope, $http, $state, $stateParams, $q, operator, gettext, autoupdate, mainMenu, DS) { 'ngDialog',
function ($rootScope, $scope, $http, $state, $stateParams, $q, operator, gettext,
autoupdate, mainMenu, DS, ngDialog) {
$scope.alerts = []; $scope.alerts = [];
if ($stateParams.msg) {
$scope.alerts.push({
type: 'danger',
msg: $stateParams.msg,
});
}
// check if guest login is allowed
$scope.guestAllowed = $rootScope.guest_enabled;
// get login info-text from server // get login info-text from server
$http.get('/users/login/').success(function(data) { $http.get('/users/login/').success(function(data) {
if(data.info_text) { if(data.info_text) {
@ -1375,10 +1390,9 @@ angular.module('OpenSlidesApp.users.site', [
$scope.closeAlert = function(index) { $scope.closeAlert = function(index) {
$scope.alerts.splice(index, 1); $scope.alerts.splice(index, 1);
}; };
// check if guest login is allowed
$scope.guestAllowed = $rootScope.guest_enabled;
// login // login
$scope.login = function () { $scope.login = function () {
$scope.closeThisDialog();
$scope.alerts = []; $scope.alerts = [];
var data = { 'username': $scope.username, 'password': $scope.password }; var data = { 'username': $scope.username, 'password': $scope.password };
if (!navigator.cookieEnabled) { if (!navigator.cookieEnabled) {
@ -1396,16 +1410,14 @@ angular.module('OpenSlidesApp.users.site', [
operator.setUser(response.data.user_id, response.data.user); operator.setUser(response.data.user_id, response.data.user);
$rootScope.operator = operator; $rootScope.operator = operator;
mainMenu.updateMainMenu(); mainMenu.updateMainMenu();
$scope.closeThisDialog();
$state.go('home'); $state.go('home');
$rootScope.startupWaitingEnabled = false; $rootScope.openslidesBootstrapDone = true;
}); });
}, },
function (response) { function (error) {
// Error: Username or password is not correct. // Error: Username or password is not correct.
$scope.alerts.push({ $state.transitionTo($state.current, {msg: error.data.detail}, {
type: 'danger', reload: true, inherit: false, notify: true
msg: response.data.detail
}); });
} }
); );
@ -1413,6 +1425,7 @@ angular.module('OpenSlidesApp.users.site', [
// guest login // guest login
$scope.guestLogin = function () { $scope.guestLogin = function () {
$scope.closeThisDialog(); $scope.closeThisDialog();
$state.go('home');
}; };
} }
]) ])