diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js
index f9126ab06..574076fae 100644
--- a/openslides/agenda/static/js/agenda/site.js
+++ b/openslides/agenda/static/js/agenda/site.js
@@ -96,9 +96,10 @@ angular.module('OpenSlidesApp.agenda.site', [
'osTableFilter',
'AgendaCsvExport',
'PdfCreate',
+ 'ErrorMessage',
function($scope, $filter, $http, $state, DS, operator, ngDialog, Agenda, TopicForm,
AgendaTree, Projector, ProjectionDefault, AgendaContentProvider, PdfMakeDocumentProvider,
- gettextCatalog, gettext, osTableFilter, AgendaCsvExport, PdfCreate) {
+ gettextCatalog, gettext, osTableFilter, AgendaCsvExport, PdfCreate, ErrorMessage) {
// Bind agenda tree to the scope
$scope.$watch(function () {
return Agenda.lastModified();
@@ -232,15 +233,11 @@ angular.module('OpenSlidesApp.agenda.site', [
// save changed item
$scope.save = function (item) {
Agenda.save(item).then(
- function(success) {
+ function (success) {
$scope.alert.show = false;
},
- function(error){
- var message = '';
- for (var e in error.data) {
- message += e + ': ' + error.data[e] + ' ';
- }
- $scope.alert = { type: 'danger', msg: message, show: true };
+ function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
});
};
// delete related item
@@ -393,7 +390,8 @@ angular.module('OpenSlidesApp.agenda.site', [
'itemId',
'Projector',
'ProjectionDefault',
- function ($scope, $filter, Agenda, itemId, Projector, ProjectionDefault) {
+ 'ErrorMessage',
+ function ($scope, $filter, Agenda, itemId, Projector, ProjectionDefault, ErrorMessage) {
$scope.alert = {};
$scope.$watch(function () {
@@ -447,16 +445,16 @@ angular.module('OpenSlidesApp.agenda.site', [
// add user to list of speakers
$scope.addSpeaker = function (userId) {
- $http.post('/rest/agenda/item/' + $scope.item.id + '/manage_speaker/', {'user': userId})
- .success(function (data){
- $scope.alert.show = false;
- $scope.speakers = $scope.item.speakers;
- $scope.speakerSelectBox = {};
- })
- .error(function (data){
- $scope.alert = {type: 'danger', msg: data.detail, show: true};
- $scope.speakerSelectBox = {};
- });
+ $http.post('/rest/agenda/item/' + $scope.item.id + '/manage_speaker/', {'user': userId}).then(
+ function (success) {
+ $scope.alert.show = false;
+ $scope.speakers = $scope.item.speakers;
+ $scope.speakerSelectBox = {};
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
+ $scope.speakerSelectBox = {};
+ }
+ );
};
// delete speaker(!) from list of speakers
@@ -466,11 +464,10 @@ angular.module('OpenSlidesApp.agenda.site', [
{headers: {'Content-Type': 'application/json'},
data: JSON.stringify({speaker: speakerId})}
)
- .success(function(data){
+ .then(function (success) {
$scope.speakers = $scope.item.speakers;
- })
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
});
$scope.speakers = $scope.item.speakers;
};
@@ -486,11 +483,10 @@ angular.module('OpenSlidesApp.agenda.site', [
{headers: {'Content-Type': 'application/json'},
data: JSON.stringify({speaker: speakersOnList})}
)
- .success(function(data){
+ .then(function (success) {
$scope.speakers = $scope.item.speakers;
- })
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
});
$scope.speakers = $scope.item.speakers;
};
@@ -529,11 +525,10 @@ angular.module('OpenSlidesApp.agenda.site', [
// begin speech of selected/next speaker
$scope.beginSpeech = function (speakerId) {
$http.put('/rest/agenda/item/' + $scope.item.id + '/speak/', {'speaker': speakerId})
- .success(function(data){
+ .then(function (success) {
$scope.alert.show = false;
- })
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
});
};
@@ -542,10 +537,12 @@ angular.module('OpenSlidesApp.agenda.site', [
$http.delete(
'/rest/agenda/item/' + $scope.item.id + '/speak/',
{headers: {'Content-Type': 'application/json'}, data: {}}
- )
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
- });
+ ).then(
+ function (success) {},
+ function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
+ }
+ );
};
// gets speech duration of selected speaker in seconds
$scope.getDuration = function (speaker) {
@@ -576,7 +573,8 @@ angular.module('OpenSlidesApp.agenda.site', [
'$http',
'Agenda',
'AgendaTree',
- function($scope, $http, Agenda, AgendaTree) {
+ 'ErrorMessage',
+ function($scope, $http, Agenda, AgendaTree, ErrorMessage) {
// Bind agenda tree to the scope
$scope.$watch(function () {
return Agenda.lastModified();
@@ -600,7 +598,7 @@ angular.module('OpenSlidesApp.agenda.site', [
).then(
function(success) {},
function(error){
- $scope.alert = {type: 'danger', msg: error.data.detail, show: true};
+ $scope.alert = ErrorMessage.forAlert(error);
}
);
}
diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js
index 1121966f6..5a4558ab1 100644
--- a/openslides/assignments/static/js/assignments/site.js
+++ b/openslides/assignments/static/js/assignments/site.js
@@ -422,9 +422,11 @@ angular.module('OpenSlidesApp.assignments.site', [
'gettextCatalog',
'PdfCreate',
'AssignmentPhases',
+ 'ErrorMessage',
function($scope, $http, $filter, filterFilter, gettext, ngDialog, AssignmentForm, operator, Assignment,
User, assignmentId, Projector, ProjectionDefault, AssignmentContentProvider, BallotContentProvider,
- PdfMakeDocumentProvider, PdfMakeBallotPaperProvider, gettextCatalog, PdfCreate, AssignmentPhases) {
+ PdfMakeDocumentProvider, PdfMakeBallotPaperProvider, gettextCatalog, PdfCreate, AssignmentPhases,
+ ErrorMessage) {
var assignment = Assignment.get(assignmentId);
User.bindAll({}, $scope, 'users');
Assignment.loadRelations(assignment, 'agenda_item');
@@ -455,12 +457,11 @@ angular.module('OpenSlidesApp.assignments.site', [
// add (nominate) candidate
$scope.addCandidate = function (userId) {
$http.post('/rest/assignments/assignment/' + assignment.id + '/candidature_other/', {'user': userId})
- .success(function(data){
+ .then(function (success){
$scope.alert.show = false;
$scope.candidateSelectBox = {};
- })
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
+ }, function (error){
+ $scope.alert = ErrorMessage.forAlert(error);
$scope.candidateSelectBox = {};
});
};
@@ -469,29 +470,31 @@ angular.module('OpenSlidesApp.assignments.site', [
$http.delete('/rest/assignments/assignment/' + assignment.id + '/candidature_other/',
{headers: {'Content-Type': 'application/json'},
data: JSON.stringify({user: userId})})
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
- });
+ .then(function (success) {},
+ function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
+ }
+ );
};
// add me (nominate self as candidate)
$scope.addMe = function () {
- $http.post('/rest/assignments/assignment/' + assignment.id + '/candidature_self/', {})
- .success(function(data){
+ $http.post('/rest/assignments/assignment/' + assignment.id + '/candidature_self/', {}).then(
+ function (success) {
$scope.alert.show = false;
- })
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
- });
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
+ }
+ );
};
// remove me (withdraw own candidature)
$scope.removeMe = function () {
- $http.delete('/rest/assignments/assignment/' + assignment.id + '/candidature_self/')
- .success(function(data){
+ $http.delete('/rest/assignments/assignment/' + assignment.id + '/candidature_self/').then(
+ function (success) {
$scope.alert.show = false;
- })
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
- });
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
+ }
+ );
};
// check if current user is already a candidate (elected==false)
$scope.isCandidate = function () {
@@ -525,15 +528,14 @@ angular.module('OpenSlidesApp.assignments.site', [
// create new ballot
$scope.createBallot = function () {
$scope.activeTab = 0;
- $http.post('/rest/assignments/assignment/' + assignment.id + '/create_poll/')
- .success(function(data){
+ $http.post('/rest/assignments/assignment/' + assignment.id + '/create_poll/').then(
+ function (success) {
$scope.alert.show = false;
if (assignment.phase === 0) {
$scope.updatePhase(1);
}
- })
- .error(function(data){
- $scope.alert = { type: 'danger', msg: data.detail, show: true };
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
});
};
// delete ballot
@@ -560,15 +562,10 @@ angular.module('OpenSlidesApp.assignments.site', [
assignment_id: assignment.id,
published: !poll.published,
})
- .then(function(success) {
+ .then(function (success) {
$scope.alert.show = false;
- })
- .catch(function(error) {
- var message = '';
- for (var e in error.data) {
- message += e + ': ' + error.data[e] + ' ';
- }
- $scope.alert = { type: 'danger', msg: message, show: true };
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
});
};
@@ -637,7 +634,8 @@ angular.module('OpenSlidesApp.assignments.site', [
'AssignmentForm',
'Agenda',
'AgendaUpdate',
- function($scope, $state, Assignment, AssignmentForm, Agenda, AgendaUpdate) {
+ 'ErrorMessage',
+ function($scope, $state, Assignment, AssignmentForm, Agenda, AgendaUpdate, ErrorMessage) {
$scope.model = {};
// set default value for open posts form field
$scope.model.open_posts = 1;
@@ -646,7 +644,7 @@ angular.module('OpenSlidesApp.assignments.site', [
// save assignment
$scope.save = function(assignment, gotoDetailView) {
Assignment.create(assignment).then(
- function(success) {
+ function (success) {
// type: Value 1 means a non hidden agenda item, value 2 means a hidden agenda item,
// see openslides.agenda.models.Item.ITEM_TYPE.
var changes = [{key: 'type', value: (assignment.showAsAgendaItem ? 1 : 2)},
@@ -656,6 +654,9 @@ angular.module('OpenSlidesApp.assignments.site', [
$state.go('assignments.assignment.detail', {id: success.id});
}
$scope.closeThisDialog();
+ },
+ function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
}
);
};
@@ -670,7 +671,8 @@ angular.module('OpenSlidesApp.assignments.site', [
'Agenda',
'AgendaUpdate',
'assignmentId',
- function($scope, $state, Assignment, AssignmentForm, Agenda, AgendaUpdate, assignmentId) {
+ 'ErrorMessage',
+ function($scope, $state, Assignment, AssignmentForm, Agenda, AgendaUpdate, assignmentId, ErrorMessage) {
var assignment = Assignment.get(assignmentId);
$scope.alert = {};
// set initial values for form model by create deep copy of assignment object
@@ -707,11 +709,7 @@ angular.module('OpenSlidesApp.assignments.site', [
// save error: revert all changes by restore
// (refresh) original assignment object from server
Assignment.refresh(assignment);
- var message = '';
- for (var e in error.data) {
- message += e + ': ' + error.data[e] + ' ';
- }
- $scope.alert = {type: 'danger', msg: message, show: true};
+ $scope.alert = ErrorMessage.forAlert(error);
}
);
};
@@ -725,7 +723,8 @@ angular.module('OpenSlidesApp.assignments.site', [
'AssignmentPoll',
'assignmentpollId',
'ballot',
- function($scope, $filter, gettextCatalog, AssignmentPoll, assignmentpollId, ballot) {
+ 'ErrorMessage',
+ function($scope, $filter, gettextCatalog, AssignmentPoll, assignmentpollId, ballot, ErrorMessage) {
// set initial values for form model by create deep copy of assignmentpoll object
// so detail view is not updated while editing poll
var assignmentpoll = angular.copy(AssignmentPoll.get(assignmentpollId));
@@ -879,13 +878,8 @@ angular.module('OpenSlidesApp.assignments.site', [
.then(function(success) {
$scope.alert.show = false;
$scope.closeThisDialog();
- })
- .catch(function(error) {
- var message = '';
- for (var e in error.data) {
- message += e + ': ' + error.data[e] + ' ';
- }
- $scope.alert = { type: 'danger', msg: message, show: true };
+ }, function (error) {
+ $scope.alert = ErrorMessage.forAlert(error);
});
};
}
diff --git a/openslides/core/static/css/app.css b/openslides/core/static/css/app.css
index c082cd255..6bd6f1e90 100644
--- a/openslides/core/static/css/app.css
+++ b/openslides/core/static/css/app.css
@@ -1156,42 +1156,46 @@ img {
font-size: 90%;
}
-/** Pdf creation status bar **/
-#pdf-status {
+/** Messaging status bar **/
+#messaging {
position: fixed;
bottom: 0;
width: 100%;
- z-index: 100;
+ z-index: 100000;
}
-#pdf-status-container {
+#messaging-container {
margin: 0 auto 0 auto;
padding: 0px 20px;
max-width: 1400px;
}
-#pdf-status-container > div {
+#messaging-container > div {
margin-bottom: 10px;
padding: 10px 20px;
border-radius: 6px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
-#pdf-status .generating {
+#messaging .info {
color: #222;
background-color: #bed4de;
border-color: #46b8da;
}
-#pdf-status .error {
+#messaging .error {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
-#pdf-status .finished {
+#messaging .success {
color: #3c763d;
background-color: #dff0d8;
border-color: #d6e9c6;
}
+#messaging .warning {
+ color: #8a6d3b;
+ background-color: #fcf8e3;
+ border-color: #faebcc;
+}
/** General helper classes **/
-
.disabled {
color: #555;
cursor: not-allowed !important;
diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js
index 34d9efa0f..2bd0b6667 100644
--- a/openslides/core/static/js/core/base.js
+++ b/openslides/core/static/js/core/base.js
@@ -47,7 +47,8 @@ angular.module('OpenSlidesApp.core', [
'REALM',
'ProjectorID',
'$q',
- function (DS, REALM, ProjectorID, $q) {
+ 'ErrorMessage',
+ function (DS, REALM, ProjectorID, $q, ErrorMessage) {
var socket = null;
var recInterval = null;
@@ -82,11 +83,12 @@ angular.module('OpenSlidesApp.core', [
Autoupdate.newConnect = function () {
socket = new WebSocket(websocketProtocol + '//' + location.host + websocketPath);
clearInterval(recInterval);
- socket.onclose = function () {
+ socket.onclose = function (event) {
socket = null;
recInterval = setInterval(function () {
Autoupdate.newConnect();
}, 1000);
+ ErrorMessage.setConnectionError();
};
socket.onmessage = function (event) {
_.forEach(Autoupdate.messageReceivers, function (receiver) {
@@ -96,6 +98,7 @@ angular.module('OpenSlidesApp.core', [
if (Autoupdate.firstMessageDeferred.promise.$$state.status === 0) {
Autoupdate.firstMessageDeferred.resolve();
}
+ ErrorMessage.clearConnectionError();
};
};
return Autoupdate;
@@ -460,6 +463,108 @@ angular.module('OpenSlidesApp.core', [
}
])
+.factory('ErrorMessage', [
+ '$timeout',
+ 'gettextCatalog',
+ 'Messaging',
+ function ($timeout, gettextCatalog, Messaging) {
+ return {
+ forAlert: function (error) {
+ var message = gettextCatalog.getString('Error') + ': ';
+
+ if (!error.data) {
+ message += gettextCatalog.getString("The server didn't respond.");
+ } else if (error.data.detail) {
+ message += error.data.detail;
+ } else {
+ for (var e in error.data) {
+ message += e + ': ' + error.data[e] + ' ';
+ }
+ }
+ return { type: 'danger', msg: message, show: true };
+ },
+ setConnectionError: function () {
+ $timeout(function () {
+ Messaging.createOrEditMessage(
+ 'connectionLostMessage',
+ gettextCatalog.getString('Connection lost. You are not connected to the server anymore.'),
+ 'error',
+ {noClose: true});
+ }, 1);
+ },
+ clearConnectionError: function () {
+ $timeout(function () {
+ Messaging.deleteMessage('connectionLostMessage');
+ }, 1);
+ },
+ };
+ }
+])
+
+/* Messaging factory. The text is html-binded into the document, so you can
+ * provide also html markup for the messages. There are 4 types: 'info',
+ * 'success', 'warning', 'error'. The timeout is for autodeleting the message.
+ * Args that could be provided:
+ * - timeout: Milliseconds until autoclose the message
+ * - noClose: Whether to show the close button*/
+.factory('Messaging', [
+ '$timeout',
+ function($timeout) {
+ var callbackList = [],
+ messages = {},
+ idCounter = 0;
+
+ var onChange = function () {
+ _.forEach(callbackList, function (callback) {
+ callback();
+ });
+ };
+
+ return {
+ addMessage: function (text, type, args) {
+ var id = idCounter++;
+ return this.createOrEditMessage(id, text, type, args);
+ },
+ createOrEditMessage: function (id, text, type, args) {
+ if (!args) {
+ args = {};
+ }
+ if (messages[id] && messages[id].timeout) {
+ $timeout.cancel(messages[id].timeout);
+ }
+ messages[id] = {
+ text: text,
+ type: type,
+ id: id,
+ args: args,
+ };
+ if (typeof args.timeout === 'number' && args.timeout > 0) {
+ var self = this;
+ messages[id].timeout = $timeout(function () {
+ self.deleteMessage(id);
+ }, args.timeout);
+ }
+ onChange();
+ return id;
+ },
+ deleteMessage: function (id) {
+ delete messages[id];
+ onChange();
+ },
+ getMessages: function () {
+ return messages;
+ },
+ registerMessageChangeCallback: function (fn) {
+ if (typeof fn === 'function') {
+ callbackList.push(fn);
+ } else {
+ throw 'fn has to be a function';
+ }
+ },
+ };
+ }
+])
+
.factory('Tag', [
'DS',
function(DS) {
diff --git a/openslides/core/static/js/core/pdf.js b/openslides/core/static/js/core/pdf.js
index b750c6f11..2f3b95749 100644
--- a/openslides/core/static/js/core/pdf.js
+++ b/openslides/core/static/js/core/pdf.js
@@ -784,8 +784,9 @@ angular.module('OpenSlidesApp.core.pdf', [])
.factory('PdfCreate', [
'$timeout',
'FileSaver',
- function ($timeout, FileSaver) {
- var stateChangeCallbacks = [];
+ 'Messaging',
+ function ($timeout, FileSaver, Messaging) {
+ var filenameMessageMap = {};
var b64toBlob = function(b64Data) {
var byteCharacters = atob(b64Data);
var byteNumbers = new Array(byteCharacters.length);
@@ -797,18 +798,36 @@ angular.module('OpenSlidesApp.core.pdf', [])
return blob;
};
var stateChange = function (state, filename, error) {
- _.forEach(stateChangeCallbacks, function (cb) {
- $timeout(function () {cb(state, filename, error);}, 1);
- });
+ var text, timeout;
+ switch (state) {
+ case 'info':
+ text = '' +
+ '{{ pdf.errorMessage | translate }}
' ;
+ break;
+ }
+ $timeout(function () {
+ filenameMessageMap[filename] = Messaging.createOrEditMessage(
+ filenameMessageMap[filename], text, state, {timeout: timeout});
+ }, 1);
};
return {
download: function (pdfDocument, filename) {
- stateChange('generating', filename);
+ stateChange('info', filename);
var pdfWorker = new Worker('/static/js/workers/pdf-worker.js');
pdfWorker.addEventListener('message', function (event) {
var blob = b64toBlob(event.data);
- stateChange('finished', filename);
+ stateChange('success', filename);
FileSaver.saveAs(blob, filename);
});
pdfWorker.addEventListener('error', function (event) {
@@ -816,43 +835,6 @@ angular.module('OpenSlidesApp.core.pdf', [])
});
pdfWorker.postMessage(JSON.stringify(pdfDocument));
},
- registerStateChangeCallback: function (cb) {
- if (cb && typeof cb === 'function') {
- stateChangeCallbacks.push(cb);
- }
- },
- };
- }
-])
-
-.directive('pdfGenerationStatus', [
- '$timeout',
- 'PdfCreate',
- function($timeout, PdfCreate) {
- return {
- restrict: 'E',
- templateUrl: 'static/templates/pdf-status.html',
- scope: {},
- controller: function ($scope, $element, $attrs, $location) {
- $scope.pdfs = {};
-
- var createStateChange = function (state, filename, error) {
- $scope.pdfs[filename] = {
- state: state,
- errorMessage: error
- };
- if (state === 'finished') {
- $timeout(function () {
- $scope.close(filename);
- }, 3000);
- }
- };
- PdfCreate.registerStateChangeCallback(createStateChange);
-
- $scope.close = function (filename) {
- delete $scope.pdfs[filename];
- };
- },
};
}
]);
diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js
index 8774db95a..39de51a4a 100644
--- a/openslides/core/static/js/core/site.js
+++ b/openslides/core/static/js/core/site.js
@@ -806,6 +806,30 @@ angular.module('OpenSlidesApp.core.site', [
}
])
+.directive('messaging', [
+ '$timeout',
+ 'Messaging',
+ function ($timeout, Messaging) {
+ return {
+ restrict: 'E',
+ templateUrl: 'static/templates/messaging.html',
+ scope: {},
+ controller: function ($scope, $element, $attrs, $location) {
+ $scope.messages = {};
+
+ var update = function () {
+ $scope.messages = Messaging.getMessages();
+ };
+ Messaging.registerMessageChangeCallback(update);
+
+ $scope.close = function (id) {
+ Messaging.deleteMessage(id);
+ };
+ },
+ };
+ }
+])
+
.controller('MainMenuCtrl', [
'$scope',
'mainMenu',
@@ -893,9 +917,9 @@ angular.module('OpenSlidesApp.core.site', [
'$scope',
'$http',
function ($scope, $http) {
- $http.get('/core/version/').success(function(data) {
- $scope.core_version = data.openslides_version;
- $scope.plugins = data.plugins;
+ $http.get('/core/version/').then(function (success) {
+ $scope.core_version = success.data.openslides_version;
+ $scope.plugins = success.data.plugins;
});
}
])
@@ -1424,7 +1448,8 @@ angular.module('OpenSlidesApp.core.site', [
'ngDialog',
'TagForm',
'gettext',
- function($scope, Tag, ngDialog, TagForm, gettext) {
+ 'ErrorMessage',
+ function($scope, Tag, ngDialog, TagForm, gettext, ErrorMessage) {
Tag.bindAll({}, $scope, 'tags');
$scope.alert = {};
@@ -1447,11 +1472,7 @@ angular.module('OpenSlidesApp.core.site', [
show: true,
};
}, function (error) {
- var message = '';
- for (var e in error.data) {
- message += e + ': ' + error.data[e] + ' ';
- }
- $scope.alert = {type: 'danger', msg: message, show: true};
+ $scope.alert = ErrorMessage.forAlert(error);
}
);
};
@@ -1465,7 +1486,8 @@ angular.module('OpenSlidesApp.core.site', [
'$scope',
'Tag',
'TagForm',
- function($scope, Tag, TagForm) {
+ 'ErrorMessage',
+ function($scope, Tag, TagForm, ErrorMessage) {
$scope.model = {};
$scope.alert = {};
$scope.formFields = TagForm.getFormFields();
@@ -1475,11 +1497,7 @@ angular.module('OpenSlidesApp.core.site', [
$scope.closeThisDialog();
},
function (error) {
- var message = '';
- for (var e in error.data) {
- message += e + ': ' + error.data[e] + ' ';
- }
- $scope.alert = {type: 'danger', msg: message, show: true};
+ $scope.alert = ErrorMessage.forAlert(error);
}
);
};
@@ -1491,7 +1509,8 @@ angular.module('OpenSlidesApp.core.site', [
'Tag',
'tagId',
'TagForm',
- function($scope, Tag, tagId, TagForm) {
+ 'ErrorMessage',
+ function($scope, Tag, tagId, TagForm, ErrorMessage) {
$scope.model = angular.copy(Tag.get(tagId));
$scope.alert = {};
$scope.formFields = TagForm.getFormFields();
@@ -1503,11 +1522,7 @@ angular.module('OpenSlidesApp.core.site', [
// save error: revert all changes by restore
// the original object
Tag.refresh(tag);
- var message = '';
- for (var e in error.data) {
- message += e + ': ' + error.data[e] + ' ';
- }
- $scope.alert = {type: 'danger', msg: message, show: true};
+ $scope.alert = ErrorMessage.forAlert(error);
});
};
}
@@ -1541,16 +1556,14 @@ angular.module('OpenSlidesApp.core.site', [
$http.post(
'/rest/core/chat-message/',
{message: $scope.newMessage}
- )
- .success(function () {
+ ).then(function (success) {
$scope.newMessage = '';
angular.element('#messageSendButton').removeClass('disabled');
angular.element('#messageInput').removeAttr('disabled');
$timeout(function () {
angular.element('#messageInput').focus();
}, 0);
- })
- .error(function () {
+ }, function (error) {
angular.element('#messageSendButton').removeClass('disabled');
angular.element('#messageInput').removeAttr('disabled');
});
diff --git a/openslides/core/static/js/core/start.js b/openslides/core/static/js/core/start.js
index 77e8a542e..a780009e4 100644
--- a/openslides/core/static/js/core/start.js
+++ b/openslides/core/static/js/core/start.js
@@ -14,15 +14,15 @@ angular.module('OpenSlidesApp.core.start', [])
'mainMenu',
function($http, $rootScope, $state, autoupdate, operator, Group, mainMenu) {
$rootScope.openslidesBootstrapDone = false;
- $http.get('/users/whoami/').success(function(data) {
- $rootScope.guest_enabled = data.guest_enabled;
- if (data.user_id === null && !data.guest_enabled) {
+ $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: data.guest_enabled});
+ $state.go('login', {guest_enabled: success.data.guest_enabled});
} else {
autoupdate.newConnect();
autoupdate.firstMessageDeferred.promise.then(function () {
- operator.setUser(data.user_id, data.user);
+ operator.setUser(success.data.user_id, success.data.user);
$rootScope.operator = operator;
mainMenu.updateMainMenu();
$rootScope.openslidesBootstrapDone = true;
diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html
index 36353bfee..be535fea0 100644
--- a/openslides/core/static/templates/index.html
+++ b/openslides/core/static/templates/index.html
@@ -218,7 +218,7 @@
-