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 <http://angular-ui.github.io/bootstrap>`_, License: MIT
* `angular-bootstrap-colorpicker <https://github.com/buberdds/angular-bootstrap-colorpicker>`_, 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-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-csv-import <https://github.com/bahaaldine/angular-csv-import>`_, License: MIT
* `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
@ -206,6 +205,7 @@ OpenSlides uses the following projects or parts of them:
* `lodash <https://lodash.com/>`_, License: MIT * `lodash <https://lodash.com/>`_, License: MIT
* `ng-dialog <https://github.com/likeastore/ngDialog>`_, License: MIT * `ng-dialog <https://github.com/likeastore/ngDialog>`_, License: MIT
* `ng-file-upload <https://github.com/danialfarid/ng-file-upload>`_, 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 * `ngbootbox <https://github.com/eriktufvesson/ngBootbox>`_, License: MIT
* `open-sans-fontface <https://github.com/FontFaceKit/open-sans>`_, License: Apache License version 2.0 * `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 * `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-bootstrap-colorpicker": "~3.0.25",
"angular-chosen-localytics": "~1.5.0", "angular-chosen-localytics": "~1.5.0",
"angular-csv-import": "0.0.36", "angular-csv-import": "0.0.36",
"angular-cookies": "~1.5.9",
"angular-file-saver": "~1.1.2", "angular-file-saver": "~1.1.2",
"angular-formly": "~8.4.0", "angular-formly": "~8.4.0",
"angular-formly-templates-bootstrap": "~6.2.0", "angular-formly-templates-bootstrap": "~6.2.0",
@ -33,6 +32,7 @@
"lodash": "~4.16.0", "lodash": "~4.16.0",
"ng-dialog": "~0.6.4", "ng-dialog": "~0.6.4",
"ng-file-upload": "~11.2.3", "ng-file-upload": "~11.2.3",
"ngstorage": "~0.3.11",
"ngBootbox": "~0.1.3", "ngBootbox": "~0.1.3",
"pdfmake-dist": "~0.1.27", "pdfmake-dist": "~0.1.27",
"open-sans-fontface": "https://github.com/OpenSlides/open-sans.git#1.4.2.post1", "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 // Filtering
$scope.filter = osTableFilter.createInstance('AgendaTableFilter'); $scope.filter = osTableFilter.createInstance('AgendaTableFilter');
if (!$scope.filter.existsCookie()) { if (!$scope.filter.existsStorageEntry()) {
$scope.filter.booleanFilters = { $scope.filter.booleanFilters = {
closed: { closed: {
value: undefined, value: undefined,
@ -162,8 +162,6 @@ angular.module('OpenSlidesApp.agenda.site', [
choiceNo: gettext('No internal items'), choiceNo: gettext('No internal items'),
}, },
}; };
$scope.filter.save();
} }
$scope.filter.propertyList = ['item_number', 'title', 'title_list_view', 'comment', 'duration']; $scope.filter.propertyList = ['item_number', 'title', 'title_list_view', 'comment', 'duration'];
$scope.filter.propertyFunctionList = [ $scope.filter.propertyFunctionList = [

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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