diff --git a/js/logging.service.js b/js/logging.service.js deleted file mode 100644 index 88ba2c7..0000000 --- a/js/logging.service.js +++ /dev/null @@ -1,494 +0,0 @@ -/** - * The Slurp logging service tracks various events, such as searches, and - * opening of records, and submits them to a server for storage. - * - * We've tried to create the service with privacy in mind: It does not track - * users, does not store IP addresses, geolocation or other user information. - * All information is exchanged over SSL, stored locally at the University of - * Oslo and not exchanged with third parties. - * - * Events are associated with a UUIDv1 session ID generated locally in the - * browser and stored in the browser's sessionStorage. By using sessionStorage, - * each browser tab or window is threated as a different session. A session - * times out after 30 minutes or when the tab/window is closed. - */ - -import get from 'lodash/get'; -import uniq from 'lodash/uniq'; -import pick from 'lodash/pick'; -import uuidv1 from 'uuid/v1'; - -class LoggingService { - /* - $rootScope: IRootScopeService; - primoVersion: string; - searchStateService: SearchStateService; - trail: list; - keypresses: number - pasted: boolean - t1: Date - */ - - /**************************************************************************** - * Constructor - ****************************************************************************/ - - log() { - let debug = false; - - let args = [].slice.call(arguments); - args[0] = '[slurp] ' + args[0]; - if (debug) console.log.apply(this, args); - } - - constructor($rootScope, $window) { - this.$rootScope = $rootScope; - this.$window = $window; - - // Primo version - this.primoVersion = null; - - // Unfortunately many of the Primo services are not injectable, so we need - // to get them from one of the components when ready. - this.searchStateService = null; - this.userSessionManagerService = null; - - // Navigation trail - this.trail = []; - - // User language - this.lang = null; - - // Number of keypresses in main search field. Tracked by prmSearchBarAfter - this.keypresses = 0; - - // Received a paste event? Tracked by prmSearchBarAfter - this.pasted = false; - - // Server url - this.url = 'https://ub-www01.uio.no/slurp/'; - - $rootScope.$on('$stateChangeSuccess', (event, toState, toParams, fromState) => { - var sc = { - from: fromState.name, - fromTime: new Date(), - to: toState.name, - toTime: new Date(), - params: toParams, - }; - - if (toParams.lang) { - this.lang = toParams.lang; - } - - var dt = ''; - if (this.trail.length > 0) { - sc.fromTime = this.trail[this.trail.length - 1].toTime; - dt = `after ${(sc.toTime - sc.fromTime)/1000} secs`; - } - this.trail.push(sc); - this.t1 = new Date(); - this.log(`%cState changed from ${sc.from} to ${sc.to} ${dt}`, 'background: green; color: white; display: block;'); - - // if (toState.name == 'exploreMain.search') { - // req.params = { - // mode: toParams.mode, // 'advanced' or '?' - // lang: toParams.lang, - // query: toParams.query, - // search_scope: toParams.search_scope, // 'default', 'everything', 'local_scope' (Bøker ved UiO), 'bibsys_ils', .. - // tab: toParams.tab, // 'default_tab', 'everything', 'local_uio', 'bibsys_consortia' ... - // sortby: toParams.sortby, // "rank" - - // // pfilter: Materialtype/språk/utgivelsesdato - // // Can be either a string or an array! - // // Examples: - // // - "pfilter,exact,books,AND" - // // - ["lang,exact,nor,AND", "pfilter,exact,books,AND", "creationdate,exact,1-YEAR,AND"] - // pfilter: toParams.pfilter, - - // // Facets - // // Can be either a string or an array! - // // Examples: - // // - "local4,include,NB" - // // - ["local4,include,NB", "local10,include,641.5", "local14,include,Matoppskrifter"] - // facet: toParams.facet, - // }; - // } - }); - } - - /**************************************************************************** - * Internal methods - ****************************************************************************/ - - isLoggedIn() { - if (!this.userSessionManagerService) { - return false; - } - return !!this.userSessionManagerService.getUserName().length; - } - - getUserLanguage() { - if (!this.userSessionManagerService) { - return this.lang; - } - - return this.userSessionManagerService.getUserLanguage(); - } - - simplifyRecord(record) { - return { - id: get(record, 'pnx.control.recordid.0'), - is_local: get(record, 'context') == 'L', - adds_id: get(record, 'pnx.control.addsrcrecordid.0'), - source: get(record, 'pnx.control.sourcesystem.0'), - ddc: uniq(get(record, 'pnx.facets.lfc10', [])), - hume: uniq(get(record, 'pnx.facets.lfc14', [])), - real: uniq(get(record, 'pnx.facets.lfc20', [])), - rsrctype: get(record, 'pnx.facets.rsrctype', []), - disptype: get(record, 'pnx.display.type.0'), - title: get(record, 'pnx.display.title.0') - }; - } - - trackEvent(action, data) { - - if (!this.trail.length) { - this.error('Ouch!'); - // something is wrong - return; - } - let trailStep = this.trail[this.trail.length - 1]; - let meta = { - trailStep: this.trail.length, - prepTime: trailStep.toTime - trailStep.fromTime, - loadTime: (new Date() - trailStep.toTime), - version: this.primoVersion, - }; - - let size = JSON.stringify(data).length; - this.log(`%cTrack "${action}" action (${size} bytes)`, 'background: green; color: white; display: block;'); - this.log('', data); - - // Read or create session - let sessionTimeout = 30 * 60 ; // 30 minutes - let now = Math.round((new Date()).getTime() / 1000); - let session = JSON.parse(this.$window.sessionStorage.getItem('slurpSession')); - if (!session || now - session.lastActive > sessionTimeout) { - // Create new session - session = { - id: uuidv1(), - created: now, - lastAction: null, - actionCount: 1, - lastData: null, - }; - } - - if (action == session.lastAction && JSON.stringify(data) == session.lastData) { - // Ignore duplicate due to page reload, login or similar - this.log('Ingore duplicate action'); - return; - } - - // Prepare payload - let payload = { - last_action: session.lastAction, - action: action, - lang: this.getUserLanguage(), - logged_in: this.isLoggedIn(), - data: data, - meta: meta, - session_id: session.id, - session_start: session.created, - action_no: session.actionCount, - hist: this.$window.history.length, - }; - - // Don't use $http since we don't want the Primo default headers etc. - // By creating a simple request instead, we avoid the browser having - // to do an extra CORS preflight request. - let req = new XMLHttpRequest(); - req.open('POST', this.url); - // post and forget - req.send(JSON.stringify(payload)); - - // Update session - session.actionCount++; - session.lastAction = action; - session.lastActive = now; - session.lastData = JSON.stringify(data); - this.$window.sessionStorage.setItem('slurpSession', JSON.stringify(session)); - } - - trackError(msg) { - this.log(`%c${msg}`, 'background: red; color: white; display: block;'); - // TODO: Actually send something to server - } - - trackSearch(search, result, pageNo) { - this.log(`%cGot search results`, 'background: green; color: white; display: block;'); - this.log('', search, result); - - let recs = result.data.map(this.simplifyRecord); - - let facets = search.facets.map(facet => pick(facet, [ - 'name', // ex: 'local20' - 'value', // ex: 'Fisker' - 'type', // ex: 'include' - 'multiFacetGroupId', // int - ])); - - // - Multiple query parts are split by semicolon - // - Each part consists of {field},{precision},{term},{operator} - // - Semicolons are stripped from queries. - // - Colons are included and NOT escaped. Example: - // title,contains,fisker,krabber,OR;creator,contains,tor,NOT;any,exact,laks,AND - // - In advanced search, there is always a trailing operator, in simple search not. - // - Material type, language and date selected in advanced search are included as - // part of the query, but prefixed with "facet_" - - let query = [], query_facets = []; - - search.query.split(/;/).forEach(function(x) { - let comp = x.split(/,/); - let res; - - if (comp[comp.length-1].match(/^(?:AND|OR|NOT)$/)) { - res = { - op: comp[comp.length-1], - field: comp[0], - prec: comp[1], - term: comp.slice(2, comp.length-1).join(','), - }; - } else { - res = { - op: null, - field: comp[0], - prec: comp[1], - term: comp.slice(2, comp.length).join(','), - }; - } - if (res.field.match(/^facet_/)) { - query_facets.push({ - field: res.field, - prec: res.prec, - term: res.term, - }); - } else { - query.push(res); - } - }); - - for (var i = query.length - 1; i > 0; i--) { - query[i].op = query[i - 1].op; - } - query[0].op = null; - - - let data = { - // Input - keypresses: this.keypresses, - pasted: this.pasted, - - // Search - advanced: search.mode == 'advanced', - query: query, - query_facets: query_facets, - scope: search.scope, // Trenger vi både scope og tab? - sort: search.sortby, - facets: facets, - pc: search.pcAvailability == "true", - - // Results - first: parseInt(result.info.first), - last: parseInt(result.info.last), - total: parseInt(result.info.total), - results: recs.map((x) => x.id), - page_no: pageNo, - - aggs: { - records: recs.length, // greit å ha lett tilgjengelig for å kunne regne prosenter - is_local: recs.filter((x) => x.is_local).length, // for å si noe om hvor mange av treffene som er relevante for emnesøk? - has_dewey: recs.filter((x) => x.ddc.length).length, - has_humord: recs.filter((x) => x.hume.length).length, - has_rt: recs.filter((x) => x.real.length).length, - }, - }; - - // var summary = `${data.scope}:${data.query}: Loaded ${data.results.length} of ${data.total} results, of which - // ${data.aggs.is_local} local (non-PCI), ${data.aggs.has_dewey} got DDC, - // ${data.aggs.has_humord} got Humord, ${data.aggs.has_rt} got Realfagstermer.`; - // TODO: Notify as event? - - let action = 'search'; - if (get(search, 'facets.0.name') == 'frbrgroupid') { - action = 'expand_frbr_group'; - } else if (pageNo > 1) { - action = 'change_page'; - } else if (facets.length) { - action = 'refinement'; - } - - this.trackEvent(action, data); - - // Reset search state params - this.pasted = false; - this.keypresses = 0; - } - - /**************************************************************************** - * Interface for prmSearchBarAfter - ****************************************************************************/ - - // public - initSearchBar() { - this.pasted = false; - this.keypresses = 0; - } - - // public - incrKeypressCount() { - this.keypresses++; - } - - // public - setSearchStateService(searchStateService) { - this.searchStateService = searchStateService; - } - - // public - setUserSessionManagerService(userSessionManagerService) { - this.userSessionManagerService = userSessionManagerService; - } - - // public - setPrimoVersion(version) { - this.primoVersion = version; - } - - // public - searchBarElementPasteEvent() { - this.pasted = true; - } - - /**************************************************************************** - * Interface for prmSearchResultListAfter - ****************************************************************************/ - - /** - * Method called from prmSearchResultListAfter when any number of pages - * are loaded. This also indicates that search results are ready. - */ - searchPageLoaded(pages) { - - if (!this.searchStateService) { - // Something is really wrong - this.trackError('searchStateService not injected'); - return; - } - - if (this.searchStateService.isSearchInProgress()) { - this.trackError('searchStateService search still in progress'); - return; - } - - let search = this.searchStateService.getSearchObject(); - let result = this.searchStateService.getResultObject(); - - if (!search || !result) { - this.trackError('searchObject or resultObject is missing'); - return; - } - - this.trackSearch(search, result, pages); - } - - /**************************************************************************** - * Interface for prmNoSearchResultAfter - ****************************************************************************/ - - noResultsPageLoaded() { - if (!this.searchStateService) { - // Something is really wrong - this.trackError('searchStateService not injected'); - return; - } - - if (this.searchStateService.isSearchInProgress()) { - this.trackError('searchStateService search still in progress'); - return; - } - - let search = this.searchStateService.getSearchObject(); - let result = this.searchStateService.getResultObject(); - - if (!search || !result) { - this.trackError('searchObject or resultObject is missing'); - return; - } - - this.trackSearch(search, result); - } - - /**************************************************************************** - * Interface for prmFullViewAfter - ****************************************************************************/ - - trackViewRecord(record) { - this.log('View record', record); - let data = this.simplifyRecord(record); - this.trackEvent('view_record', data); - } - - leaveViewRecord(record) { - this.log('Leave record', record); - let data = { - id: get(record, 'pnx.control.recordid.0'), - }; - this.trackEvent('leave_record', data); - } - - trackSendTo(serviceName, record) { - let data = { - service: serviceName, - rec: this.simplifyRecord(record), - }; - this.trackEvent('send_to', data); - } - - /**************************************************************************** - * Interface for prmSaveToFavoritesButtonAfter - ****************************************************************************/ - - trackPinRecord(record) { - let data = this.simplifyRecord(record); - this.trackEvent('pin_record', data); - } - - trackUnpinRecord(record) { - let data = this.simplifyRecord(record); - this.trackEvent('unpin_record', data); - } - - /**************************************************************************** - * Interface for prmSearchAfter - ****************************************************************************/ - - trackHome() { - this.trackEvent('goto_home', {}); - } - - /**************************************************************************** - * Interface for prmBrowseSearchAfter - ****************************************************************************/ - - trackBrowse(data) { - this.trackEvent('browse', data); - } - -} - -LoggingService.$inject = ['$rootScope', '$window']; - -export default LoggingService; diff --git a/js/main.js b/js/main.js index 0117138..dcffce1 100644 --- a/js/main.js +++ b/js/main.js @@ -1,52 +1,12 @@ import viewName from './viewName'; -import LoggingService from './logging.service'; -import prmActionListAfter from './prmActionListAfter.component'; -import prmBriefResultContainerAfter from './prmBriefResultContainerAfter.component'; -import prmBrowseSearchAfter from './prmBrowseSearchAfter.component'; -import prmFullViewAfter from './prmFullViewAfter.component'; -import prmNoSearchResultAfter from './prmNoSearchResultAfter.component'; -import prmSaveToFavoritesButtonAfterComponent from './prmSaveToFavoritesButtonAfter.component'; import prmSearchAfterComponent from './prmSearchAfter.component'; -import prmSearchBarAfterConfig from './prmSearchBarAfter.component'; -import prmSearchResultListAfter from './prmSearchResultListAfter.component'; -import prmSilentLoginAfterComponent from './prmSilentLoginAfter.component'; - const app = angular.module('viewCustom', ['angularLoad']); -app.service('loggingService', LoggingService); - -// SearchBar: The search form at the top of the page. Not reloaded on normal page changes. -app.component('prmSearchBarAfter', prmSearchBarAfterConfig); - // SearchAfter: Everything below the searchbar. Reloaded on normal page changes app.component('prmSearchAfter', prmSearchAfterComponent); -// BrowseSearchAfter: Everything below the searchbar for browse pages. Reloaded on normal page changes -app.component('prmBrowseSearchAfter', prmBrowseSearchAfter); - -// SearchResultList: The list of search results, repeated for each search page -app.component('prmSearchResultListAfter', prmSearchResultListAfter); - -// NoSearchResult: If a search yields zero results, we get this instead of SearchResultList -app.component('prmNoSearchResultAfter', prmNoSearchResultAfter); - -// BriefResultContainer: Each search result in the results list -app.component('prmBriefResultContainerAfter', prmBriefResultContainerAfter); - -// FullView: The details view for a single record -app.component('prmFullViewAfter', prmFullViewAfter); - -// ActionList: The action button bar: E-mail, Cite, Permalink, Endnote export etc. -app.component('prmActionListAfter', prmActionListAfter); - -// SaveToFavoritesButton: The "pin record" button, this is found in multiple places -app.component('prmSaveToFavoritesButtonAfter', prmSaveToFavoritesButtonAfterComponent); - -// SilentLogin: Component outside the root uiView. -app.component('prmSilentLoginAfter', prmSilentLoginAfterComponent); - // ------------------------------------------------------------------------ // eslint-disable-next-line no-unused-vars diff --git a/js/prmActionListAfter.component.js b/js/prmActionListAfter.component.js deleted file mode 100644 index 2e8ed78..0000000 --- a/js/prmActionListAfter.component.js +++ /dev/null @@ -1,28 +0,0 @@ - -class PrmActionListAfterController { - constructor(loggingService, $document, $element) { - // Note: action list can be part of results list OR record view. - $document.ready(() => { - let parentElement = $element.parent()[0]; - let btns = angular.element(parentElement.querySelectorAll('#scrollActionList button')); - - if (!btns.length) { - console.error('Error: No action buttons found!'); - } - - btns.on('click', (evt) => { - var sendToType = evt.currentTarget.querySelectorAll('.button-text')[0].getAttribute('translate'); - let item = this.parentCtrl.item.split('.').pop(); - loggingService.trackSendTo(sendToType, item); - }); - }); - } -} - -PrmActionListAfterController.$inject = ['loggingService', '$document', '$element']; - -export default { - bindings: {parentCtrl: '<'}, - controller: PrmActionListAfterController, - template: '', -}; diff --git a/js/prmBriefResultContainerAfter.component.js b/js/prmBriefResultContainerAfter.component.js deleted file mode 100644 index e0ffa04..0000000 --- a/js/prmBriefResultContainerAfter.component.js +++ /dev/null @@ -1,20 +0,0 @@ - -class PrmBriefResultContainerAfterController { - constructor() { - // let item = this.parentCtrl.item; - //loggingService.trackViewRecord(item); - // console.log('brief result', this.parentCtrl) - - // $document.ready(() => { - // console.log('GNU', this); - // }); - } -} - -PrmBriefResultContainerAfterController.$inject = []; - -export default { - bindings: {parentCtrl: '<'}, - controller: PrmBriefResultContainerAfterController, - template: '', -}; diff --git a/js/prmBrowseSearchAfter.component.js b/js/prmBrowseSearchAfter.component.js deleted file mode 100644 index ba25547..0000000 --- a/js/prmBrowseSearchAfter.component.js +++ /dev/null @@ -1,23 +0,0 @@ -import get from 'lodash/get'; - -class PrmBrowseSearchAfterController { - - constructor($scope, $window, $element, $timeout, $document, $rootScope, loggingService) { - $document.ready(() => { - let data = { - input: this.parentCtrl.browseSearchBarService.searchBarInput, - scope: this.parentCtrl.browseSearchService.searchedScope, - }; - loggingService.trackBrowse(data); - }); - } -} - -PrmBrowseSearchAfterController.$inject = ['$scope', '$window', '$element', '$timeout', '$document', '$rootScope', 'loggingService']; - -export default { - // The < symbol denotes one-way bindings which are available since 1.5. - bindings: {parentCtrl: '<'}, - controller: PrmBrowseSearchAfterController, - template: '', -}; diff --git a/js/prmFullViewAfter.component.js b/js/prmFullViewAfter.component.js deleted file mode 100644 index 7a36df3..0000000 --- a/js/prmFullViewAfter.component.js +++ /dev/null @@ -1,20 +0,0 @@ - -class PrmFullViewAfterController { - constructor(loggingService) { - this.loggingService = loggingService; - this.item = this.parentCtrl.item; - this.loggingService.trackViewRecord(this.item); - } - - $onDestroy() { - this.loggingService.leaveViewRecord(this.item); - } -} - -PrmFullViewAfterController.$inject = ['loggingService']; - -export default { - bindings: {parentCtrl: '<'}, - controller: PrmFullViewAfterController, - template: '', -}; diff --git a/js/prmNoSearchResultAfter.component.js b/js/prmNoSearchResultAfter.component.js deleted file mode 100644 index 3053310..0000000 --- a/js/prmNoSearchResultAfter.component.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Adopted from a version by @SarahZum - * https://github.com/SarahZum/primo-explore-custom-no-results - */ - -class PrmNoSearchResultAfterController { - constructor(loggingService) { - loggingService.noResultsPageLoaded(); - - // var vm = this; - // vm.pciSetting = vm.parentCtrl.searchStateService.searchObject.pcAvailability || ''; - // condole.log(vm.parentCtrl.searchStateService.searchObject); - // vm.getSearchTerm = function getSearchTerm() { - // return vm.parentCtrl.term; - // }; - } -} - -PrmNoSearchResultAfterController.$inject = ['loggingService']; - -export default { - bindings: {parentCtrl: '<'}, - controller: PrmNoSearchResultAfterController, - template: '', -}; - -// export default { -// bindings: {parentCtrl: '<'}, -// controller: PrmNoSearchResultAfterController, -// controllerAs: 'vm', -// template: ` -// -// -// -// No records found -// -// -// -//

-// There are no results matching your search:

-// {{$ctrl.getSearchTerm()}}.
-//
-// -// Try again searching items held at other libraries? -// -//
-// -//

-//

-// Suggestions: -//

-// -//

-// -// Search WorldCat -// -//

-//

-// -// Contact a Research Librarian for Assistance -// -//

-//
-//
-// ` -// } diff --git a/js/prmSaveToFavoritesButtonAfter.component.js b/js/prmSaveToFavoritesButtonAfter.component.js deleted file mode 100644 index f02bf66..0000000 --- a/js/prmSaveToFavoritesButtonAfter.component.js +++ /dev/null @@ -1,41 +0,0 @@ - -class PrmSaveToFavoritesButtonAfterController { - - constructor($timeout, $element, loggingService) { - this.$timeout = $timeout; - this.$element = $element; - this.loggingService = loggingService; - } - - $postLink() { - this.$timeout(() => { - let parentElement = this.$element.parent()[0]; - - - var pinBtn = parentElement.querySelector('button.pin-button'), - unpinBtn = parentElement.querySelector('button.unpin-button'); - - // Limitation: This will only save the first click, since then the - // button is replaced with another button element. We could add a - // DOM watcher, but it's not worth it I think. - if (pinBtn) { - pinBtn.addEventListener('click', () => { - this.loggingService.trackPinRecord(this.parentCtrl.item); - }, {passive: true, capture: true}); - } else if (unpinBtn) { - unpinBtn.addEventListener('click', () => { - this.loggingService.trackUnpinRecord(this.parentCtrl.item); - }, {passive: true, capture: true}); - } - - }); - } -} - -PrmSaveToFavoritesButtonAfterController.$inject = ['$timeout', '$element', 'loggingService']; - -export default { - bindings: {parentCtrl: '<'}, - controller: PrmSaveToFavoritesButtonAfterController, - template: '', -}; diff --git a/js/prmSearchAfter.component.js b/js/prmSearchAfter.component.js index ab47964..572af65 100644 --- a/js/prmSearchAfter.component.js +++ b/js/prmSearchAfter.component.js @@ -1,6 +1,6 @@ class PrmSearchAfterController { - constructor($scope, $compile, $timeout, $document, loggingService) { + constructor($scope, $compile, $timeout, $document) { $document.ready(() => { // Note: At this point, the frontpage HTML template might not yet be ready. // We see this problem especially in Firefox for some reason. Until we find a better @@ -14,15 +14,13 @@ class PrmSearchAfterController { prmSearchAfterEl.append(footer.detach().addClass('visible')); let fnLink = $compile(footer); // returns a Link function used to bind template to the scope fnLink($scope); // Bind scope to the template - - loggingService.trackHome(); } }, 100); }); } } -PrmSearchAfterController.$inject = ['$scope', '$compile', '$timeout', '$document', 'loggingService']; +PrmSearchAfterController.$inject = ['$scope', '$compile', '$timeout', '$document']; export default { bindings: {parentCtrl: '<'}, diff --git a/js/prmSearchBarAfter.component.js b/js/prmSearchBarAfter.component.js deleted file mode 100644 index 8d359bf..0000000 --- a/js/prmSearchBarAfter.component.js +++ /dev/null @@ -1,128 +0,0 @@ -import get from 'lodash/get'; - -class PrmSearchBarAfterController { - - constructor($scope, $window, $element, $timeout, $document, $rootScope, loggingService) { - - let primoVersion = get($window.appConfig, 'system-configuration.Primo_Version_Number', 'unknown'); - let searchStateService = this.parentCtrl.searchService.searchStateService; - - this.$scope = $scope; - this.$element = $element; - this.$timeout = $timeout; - this.loggingService = loggingService; - - // Inject Primo's searchStateService into our loggingService - this.loggingService.setSearchStateService(searchStateService); - this.loggingService.setPrimoVersion(primoVersion); - - this.pasteEventHandler = function() { - this.loggingService.searchBarElementPasteEvent(); - }.bind(this); - - this.inputHandler = function() { - this.loggingService.incrKeypressCount(); - }.bind(this); - - this.loggingService.initSearchBar(); - $document.ready(() => { - - // Note: mainSearchField also maps to the first input field on advanced search - // this.$scope.$watch('$ctrl.parentCtrl.mainSearchField', (newValue, oldValue) => { - // if (newValue != oldValue) { - // this.loggingService.incrKeypressCount(); - // } - // }); - - this.$scope.$watch('$ctrl.parentCtrl.advancedSearch', (newValue, oldValue) => { - let parentElement = this.$element.parent()[0]; - let searchBarElement = parentElement.querySelector('#searchBar'); - - // Focus on the search bar, if it exists. - // Note that, when the language is changed, - // the search bar is not available yet here. - // We can watch for the element and then focus on it, - // but it does not seem to worth it. - if (searchBarElement && !oldValue) { - $timeout(() => searchBarElement.focus()); - } - - let $inputElems = angular.element(parentElement.querySelectorAll('input')); - - $inputElems.off('paste', this.pasteEventHandler); // To make sure we don't end up with double handlers - $inputElems.on('paste', this.pasteEventHandler); - - $inputElems.off('input', this.inputHandler); // To make sure we don't end up with double handlers - $inputElems.on('input', this.inputHandler); - - }); - }); - } - - // // Called after this controller's element and its children have been linked. - // $postLink() { - // // Focus input field on load. Adapted from a version by @muratseyhan - // // https://github.com/Det-Kongelige-Bibliotek/primo-explore-rex/commit/86432e68e313a43db1f01a3a251652f84952d5a6 - // this.$timeout(() => { - // let parentElement = this.$element.parent(); - // let searchBarElement = parentElement[0].querySelector('#searchBar'); - - // // Focus on the search bar, if it exists. - // // Note that, when the language is changed, - // // the search bar is not available yet here. - // // We can watch for the element and then focus on it, - // // but it does not seem to worth it. - // if (searchBarElement) { - // searchBarElement.focus(); - - // searchBarElement.addEventListener('paste', () => { - // this.loggingService.searchBarElementPasteEvent(); - // }, {passive: true, capture: true}); - // } - // }, 0); - // } - - // Change placeholder text (needs optimization I think) - // by Alex RS: http://search-test.library.brandeis.edu/primo-explore/search?vid=BRANDTEST - // var myVar = setInterval(function(parentCtrl) { - // parentCtrl._placeHolderText = calculatePlaceHolderText(parentCtrl._selectedTab); - // console.log("placeholder changed"); - // }, 100, this.parentCtrl); - - // setTimeout(function( myIntervalID ) { - // clearInterval(myIntervalID); - // console.log("placeholder interval cleared"); - // }, 5000, myVar); - - // $scope.$watch("$parent.$ctrl._selectedTab", function(newTab, oldTab) { - // $scope.$parent.$ctrl._placeHolderText = calculatePlaceHolderText(newTab); - // }); - - // function calculatePlaceHolderText (myTab) { - // switch (myTab) { - // case "pci": - // return "Find articles and other materials from scholarly journals, newspapers, and online collections"; - // break; - // case "alma": - // return "Find books, movies, music, serials, etc"; - // break; - // case "everything": - // return "Find ALL kinds of library resources (books, movies, journal articles, etc)"; - // break; - // case "course": - // return "Find books & media on reserve for your class."; - // break; - // default: - // return "unknown-tab placeholder"; - // } - // } -} - -PrmSearchBarAfterController.$inject = ['$scope', '$window', '$element', '$timeout', '$document', '$rootScope', 'loggingService']; - -export default { - // The < symbol denotes one-way bindings which are available since 1.5. - bindings: {parentCtrl: '<'}, - controller: PrmSearchBarAfterController, - template: '', -}; diff --git a/js/prmSearchResultListAfter.component.js b/js/prmSearchResultListAfter.component.js deleted file mode 100644 index 53b54b7..0000000 --- a/js/prmSearchResultListAfter.component.js +++ /dev/null @@ -1,28 +0,0 @@ -import get from 'lodash/get'; - -class PrmSearchResultListAfterController { - - constructor($window, $scope, loggingService) { - - let primoVersion = get($window.appConfig, 'system-configuration.Primo_Version_Number', 'unknown'); - let searchStateService = this.parentCtrl.searchService.searchStateService; - - // Inject Primo's searchStateService into our loggingService - loggingService.setSearchStateService(searchStateService); - loggingService.setPrimoVersion(primoVersion); - - $scope.$watch('$ctrl.parentCtrl.numOfLoadedPages', (newValue) => { - if (newValue) { - loggingService.searchPageLoaded(newValue); - } - }); - } -} - -PrmSearchResultListAfterController.$inject = ['$window', '$scope', 'loggingService']; - -export default { - bindings: {parentCtrl: '<'}, - controller: PrmSearchResultListAfterController, - template: '', -}; diff --git a/js/prmSilentLoginAfter.component.js b/js/prmSilentLoginAfter.component.js deleted file mode 100644 index b641d37..0000000 --- a/js/prmSilentLoginAfter.component.js +++ /dev/null @@ -1,15 +0,0 @@ - -class PrmSilentLoginAfterController { - constructor(loggingService) { - let userSessionManagerService = this.parentCtrl.userSessionManagerService; - loggingService.setUserSessionManagerService(userSessionManagerService); - } -} - -PrmSilentLoginAfterController.$inject = ['loggingService']; - -export default { - bindings: {parentCtrl: '<'}, - controller: PrmSilentLoginAfterController, - template: '', -};