Michael Metternich pushed to branch release/5.0 at cms-community / hippo-addon-channel-manager
Commits: 97ea8187 by Mathijs den Burger at 2018-01-05T16:12:14+01:00 CHANNELMGR-1658 Backport of CHANNELMGR-1585 - - - - - 158f2ee7 by Michael Metternich at 2018-01-05T16:14:04+01:00 CHANNELMGR-1658 Reintegrate bugfix/CHANNELMGR-1658 into release/5.0 - - - - - 4 changed files: - frontend-ng/src/angularjs/hippo-cm.config.js - frontend-ng/src/angularjs/hippo-cm.spec.js - frontend-ng/src/angularjs/services/hst.service.js - frontend-ng/src/angularjs/services/hst.service.spec.js Changes: ===================================== frontend-ng/src/angularjs/hippo-cm.config.js ===================================== --- a/frontend-ng/src/angularjs/hippo-cm.config.js +++ b/frontend-ng/src/angularjs/hippo-cm.config.js @@ -18,6 +18,7 @@ import template from './hippo-cm.html'; function config( $compileProvider, + $httpProvider, $mdIconProvider, $mdThemingProvider, $stateProvider, @@ -168,6 +169,18 @@ function config( // only enable Angular debug information when the CMS runs in 'Wicket development mode' const devMode = angular.element(window.parent.document.documentElement).hasClass('wicket-development-mode'); $compileProvider.debugInfoEnabled(devMode); + + // report all HTTP requests as 'user activity' to the CMS to prevent active logout + $httpProvider.interceptors.push((CmsService) => { + 'ngInject'; + + return { + request: (httpConfig) => { + CmsService.publish('user-activity'); + return httpConfig; + }, + }; + }); } export default config; ===================================== frontend-ng/src/angularjs/hippo-cm.spec.js ===================================== --- a/frontend-ng/src/angularjs/hippo-cm.spec.js +++ b/frontend-ng/src/angularjs/hippo-cm.spec.js @@ -19,10 +19,12 @@ import 'angular-mocks'; describe('The hippo-cm module', () => { let configService; + let $http; let $httpBackend; let $rootScope; let $state; let $translate; + let $window; const MOCK_TRANSLATIONS = { en: { @@ -40,12 +42,14 @@ describe('The hippo-cm module', () => { $translateProvider.translations('nl', MOCK_TRANSLATIONS.nl); }); - inject((ConfigService, _$httpBackend_, _$rootScope_, _$state_, _$translate_) => { + inject((ConfigService, _$http_, _$httpBackend_, _$rootScope_, _$state_, _$translate_, _$window_) => { configService = ConfigService; + $http = _$http_; $httpBackend = _$httpBackend_; $rootScope = _$rootScope_; $state = _$state_; $translate = _$translate_; + $window = _$window_; }); }); @@ -74,4 +78,14 @@ describe('The hippo-cm module', () => { expect($translate.instant('HIPPO')).toEqual('Hippo'); }); + + it('reports user activity to the CMS when the backend is called', () => { + spyOn($window.APP_TO_CMS, 'publish'); + $httpBackend.expectGET('/some-url', { + Accept: 'application/json, text/plain, */*', + }).respond(200); + $http.get('/some-url'); + $httpBackend.flush(); + expect($window.APP_TO_CMS.publish).toHaveBeenCalledWith('user-activity'); + }); }); ===================================== frontend-ng/src/angularjs/services/hst.service.js ===================================== --- a/frontend-ng/src/angularjs/services/hst.service.js +++ b/frontend-ng/src/angularjs/services/hst.service.js @@ -1,5 +1,5 @@ /* - * Copyright 2016 Hippo B.V. (http://www.onehippo.com) + * Copyright 2016-2017 Hippo B.V. (http://www.onehippo.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,8 +90,6 @@ class HstService { headers['CMS-User'] = this.config.cmsUser; headers['Force-Client-Host'] = 'true'; - this.CmsService.publish('user-activity'); - return q((resolve, reject) => { http({ method, url, headers, data }) .success(response => resolve(response)) ===================================== frontend-ng/src/angularjs/services/hst.service.spec.js ===================================== --- a/frontend-ng/src/angularjs/services/hst.service.spec.js +++ b/frontend-ng/src/angularjs/services/hst.service.spec.js @@ -341,16 +341,4 @@ describe('HstService', () => { hstService.doPut({ foo: 1 }, 'some-uuid', 'one', 'two', 'three').catch(fail); $httpBackend.flush(); }); - - it('reports user activity to the CMS when the backend is called', () => { - spyOn(window.APP_TO_CMS, 'publish'); - $httpBackend.expectGET(`${contextPath}${apiUrlPrefix}/some-uuid./one/two/three`, { - 'CMS-User': 'testUser', - 'Force-Client-Host': 'true', - Accept: 'application/json, text/plain, */*', - }).respond(200); - hstService.doGet('some-uuid', 'one', 'two', 'three'); - expect(window.APP_TO_CMS.publish).toHaveBeenCalledWith('user-activity'); - $httpBackend.flush(); - }); }); View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/81a057f945b9fbfd9f6aa0797c56584dbb8cd56a...158f2ee7bd2f20c6206bd909703956d3fb2b3860 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/81a057f945b9fbfd9f6aa0797c56584dbb8cd56a...158f2ee7bd2f20c6206bd909703956d3fb2b3860 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn