Merge pull request #2737 from FinnStutzenstein/Issue2730

Use session cookies and store filter settings in sessionStorage
This commit is contained in:
Norman Jäckel 2016-12-07 11:25:06 +01:00 committed by GitHub
commit b27a975075
10 changed files with 32 additions and 21 deletions

View File

@ -178,7 +178,6 @@ OpenSlides uses the following projects or parts of them:
* `angular-bootstrap <http://angular-ui.github.io/bootstrap>`_, License: MIT
* `angular-bootstrap-colorpicker <https://github.com/buberdds/angular-bootstrap-colorpicker>`_, License: MIT
* `angular-chosen-localytics <http://github.com/leocaseiro/angular-chosen>`_, License: MIT
* `angular-cookies <https://github.com/angular/bower-angular-cookies>`_, License: MIT
* `angular-csv-import <https://github.com/bahaaldine/angular-csv-import>`_, 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
@ -206,6 +205,7 @@ OpenSlides uses the following projects or parts of them:
* `lodash <https://lodash.com/>`_, License: MIT
* `ng-dialog <https://github.com/likeastore/ngDialog>`_, License: MIT
* `ng-file-upload <https://github.com/danialfarid/ng-file-upload>`_, License: MIT
* `ngStorage <https://github.com/gsklee/ngStorage>`_, License: MIT
* `ngbootbox <https://github.com/eriktufvesson/ngBootbox>`_, License: MIT
* `open-sans-fontface <https://github.com/FontFaceKit/open-sans>`_, License: Apache License version 2.0
* `pdfjs-dist <http://mozilla.github.io/pdf.js/>`_, License: Apache-2.0

View File

@ -9,7 +9,6 @@
"angular-bootstrap-colorpicker": "~3.0.25",
"angular-chosen-localytics": "~1.5.0",
"angular-csv-import": "0.0.36",
"angular-cookies": "~1.5.9",
"angular-file-saver": "~1.1.2",
"angular-formly": "~8.4.0",
"angular-formly-templates-bootstrap": "~6.2.0",
@ -33,6 +32,7 @@
"lodash": "~4.16.0",
"ng-dialog": "~0.6.4",
"ng-file-upload": "~11.2.3",
"ngstorage": "~0.3.11",
"ngBootbox": "~0.1.3",
"pdfmake-dist": "~0.1.27",
"open-sans-fontface": "https://github.com/OpenSlides/open-sans.git#1.4.2.post1",

View File

@ -147,7 +147,7 @@ angular.module('OpenSlidesApp.agenda.site', [
// Filtering
$scope.filter = osTableFilter.createInstance('AgendaTableFilter');
if (!$scope.filter.existsCookie()) {
if (!$scope.filter.existsStorageEntry()) {
$scope.filter.booleanFilters = {
closed: {
value: undefined,
@ -162,8 +162,6 @@ angular.module('OpenSlidesApp.agenda.site', [
choiceNo: gettext('No internal items'),
},
};
$scope.filter.save();
}
$scope.filter.propertyList = ['item_number', 'title', 'title_list_view', 'comment', 'duration'];
$scope.filter.propertyFunctionList = [

View File

@ -327,7 +327,7 @@ angular.module('OpenSlidesApp.assignments.site', [
// Filtering
$scope.filter = osTableFilter.createInstance('AssignmentTableFilter');
if (!$scope.filter.existsCookie()) {
if (!$scope.filter.existsStorageEntry()) {
$scope.filter.multiselectFilters = {
tag: [],
phase: [],

View File

@ -19,7 +19,7 @@ angular.module('OpenSlidesApp.core', [
'$httpProvider',
function($httpProvider) {
// Combine the django csrf system with the angular csrf system
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfCookieName = 'OpenSlidesCsrfToken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}
])

View File

@ -13,11 +13,11 @@ angular.module('OpenSlidesApp.core.site', [
'formlyBootstrap',
'localytics.directives',
'ngBootbox',
'ngCookies',
'ngDialog',
'ngFileSaver',
'ngMessages',
'ngCsvImport',
'ngStorage',
'ui.tinymce',
'luegg.directives',
'xeditable',
@ -374,6 +374,13 @@ angular.module('OpenSlidesApp.core.site', [
}
])
.config([
'$sessionStorageProvider',
function ($sessionStorageProvider) {
$sessionStorageProvider.setKeyPrefix('OpenSlides');
}
])
// Helper to add ui.router states at runtime.
// Needed for the django url_patterns.
.provider('runtimeStates', [
@ -402,25 +409,25 @@ angular.module('OpenSlidesApp.core.site', [
* - propertyList, propertyFunctionList, propertyDict: See function getObjectQueryString
*/
.factory('osTableFilter', [
'$cookies',
function ($cookies) {
var createInstance = function (cookieName) {
'$sessionStorage',
function ($sessionStorage) {
var createInstance = function (tableName) {
var self = {
multiselectFilters: {},
booleanFilters: {},
filterString: '',
};
var existsCookie = function () {
return $cookies.getObject(cookieName);
var existsStorageEntry = function () {
return $sessionStorage[tableName];
};
var cookie = existsCookie();
if (cookie) {
self = cookie;
var storage = existsStorageEntry();
if (storage) {
self = storage;
}
self.existsCookie = existsCookie;
self.existsStorageEntry = existsStorageEntry;
self.save = function () {
$cookies.putObject(cookieName, self);
$sessionStorage[tableName] = self;
};
self.areFiltersSet = function () {
var areFiltersSet = _.find(self.multiselectFilters, function (filterList) {

View File

@ -101,6 +101,12 @@ SESSION_ENGINE = 'openslides.core.session_backend'
SESSION_COOKIE_NAME = 'OpenSlidesSessionID'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
CSRF_COOKIE_NAME = 'OpenSlidesCsrfToken'
CSRF_COOKIE_AGE = None
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',

View File

@ -105,7 +105,7 @@ angular.module('OpenSlidesApp.mediafiles.site', ['ngFileUpload', 'OpenSlidesApp.
// Filtering
$scope.filter = osTableFilter.createInstance('MediafilesTableFilter');
if (!$scope.filter.existsCookie()) {
if (!$scope.filter.existsStorageEntry()) {
$scope.filter.booleanFilters = {
isPrivate: {
value: undefined,

View File

@ -834,7 +834,7 @@ angular.module('OpenSlidesApp.motions.site', [
// Filtering
$scope.filter = osTableFilter.createInstance('MotionTableFilter');
if (!$scope.filter.existsCookie()) {
if (!$scope.filter.existsStorageEntry()) {
$scope.filter.multiselectFilters = {
state: [],
category: [],

View File

@ -522,7 +522,7 @@ angular.module('OpenSlidesApp.users.site', [
// Filtering
$scope.filter = osTableFilter.createInstance('UserTableFilter');
if (!$scope.filter.existsCookie()) {
if (!$scope.filter.existsStorageEntry()) {
$scope.filter.multiselectFilters = {
group: [],
};