mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge branch 'main' into mirador-search-passthrough
This commit is contained in:
9
.github/workflows/docker.yml
vendored
9
.github/workflows/docker.yml
vendored
@@ -31,6 +31,10 @@ jobs:
|
|||||||
# We turn off 'latest' tag by default.
|
# We turn off 'latest' tag by default.
|
||||||
TAGS_FLAVOR: |
|
TAGS_FLAVOR: |
|
||||||
latest=false
|
latest=false
|
||||||
|
# Architectures / Platforms for which we will build Docker images
|
||||||
|
# If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
|
||||||
|
# If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64.
|
||||||
|
PLATFORMS: linux/amd64${{ github.event_name != 'pull_request' && ', linux/arm64' || '' }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# https://github.com/actions/checkout
|
# https://github.com/actions/checkout
|
||||||
@@ -41,6 +45,10 @@ jobs:
|
|||||||
- name: Setup Docker Buildx
|
- name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
# https://github.com/docker/setup-qemu-action
|
||||||
|
- name: Set up QEMU emulation to build for multiple architectures
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
# https://github.com/docker/login-action
|
# https://github.com/docker/login-action
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
# Only login if not a PR, as PRs only trigger a Docker build and not a push
|
# Only login if not a PR, as PRs only trigger a Docker build and not a push
|
||||||
@@ -70,6 +78,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
|
platforms: ${{ env.PLATFORMS }}
|
||||||
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
|
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
|
||||||
# but we ONLY do an image push to DockerHub if it's NOT a PR
|
# but we ONLY do an image push to DockerHub if it's NOT a PR
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -37,3 +37,5 @@ package-lock.json
|
|||||||
|
|
||||||
.env
|
.env
|
||||||
/nbproject/
|
/nbproject/
|
||||||
|
|
||||||
|
junit.xml
|
||||||
|
@@ -330,7 +330,10 @@ All E2E tests must be created under the `./cypress/integration/` folder, and mus
|
|||||||
* In the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner), you'll Cypress automatically visit the page. This first test will succeed, as all you are doing is making sure the _page exists_.
|
* In the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner), you'll Cypress automatically visit the page. This first test will succeed, as all you are doing is making sure the _page exists_.
|
||||||
* From here, you can use the [Selector Playground](https://docs.cypress.io/guides/core-concepts/test-runner#Selector-Playground) in the Cypress Test Runner window to determine how to tell Cypress to interact with a specific HTML element on that page.
|
* From here, you can use the [Selector Playground](https://docs.cypress.io/guides/core-concepts/test-runner#Selector-Playground) in the Cypress Test Runner window to determine how to tell Cypress to interact with a specific HTML element on that page.
|
||||||
* Most commands start by telling Cypress to [get()](https://docs.cypress.io/api/commands/get) a specific element, using a CSS or jQuery style selector
|
* Most commands start by telling Cypress to [get()](https://docs.cypress.io/api/commands/get) a specific element, using a CSS or jQuery style selector
|
||||||
|
* It's generally best not to rely on attributes like `class` and `id` in tests, as those are likely to change later on. Instead, you can add a `data-test` attribute to makes it clear that it's required for a test.
|
||||||
* Cypress can then do actions like [click()](https://docs.cypress.io/api/commands/click) an element, or [type()](https://docs.cypress.io/api/commands/type) text in an input field, etc.
|
* Cypress can then do actions like [click()](https://docs.cypress.io/api/commands/click) an element, or [type()](https://docs.cypress.io/api/commands/type) text in an input field, etc.
|
||||||
|
* When running with server-side rendering enabled, the client first receives HTML without the JS; only once the page is rendered client-side do some elements (e.g. a button that toggles a Bootstrap dropdown) become fully interactive. This can trip up Cypress in some cases as it may try to `click` or `type` in an element that's not fully loaded yet, causing tests to fail.
|
||||||
|
* To work around this issue, define the attributes you use for Cypress selectors as `[attr.data-test]="'button' | ngBrowserOnly"`. This will only show the attribute in CSR HTML, forcing Cypress to wait until CSR is complete before interacting with the element.
|
||||||
* Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions.
|
* Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions.
|
||||||
* Any time you save your test file, the Cypress Test Runner will reload & rerun it. This allows you can see your results quickly as you write the tests & correct any broken tests rapidly.
|
* Any time you save your test file, the Cypress Test Runner will reload & rerun it. This allows you can see your results quickly as you write the tests & correct any broken tests rapidly.
|
||||||
* Cypress also has a great guide on [writing your first test](https://on.cypress.io/writing-first-test) with much more info. Keep in mind, while the examples in the Cypress docs often involve Javascript files (.js), the same examples will work in our Typescript (.ts) e2e tests.
|
* Cypress also has a great guide on [writing your first test](https://on.cypress.io/writing-first-test) with much more info. Keep in mind, while the examples in the Cypress docs often involve Javascript files (.js), the same examples will work in our Typescript (.ts) e2e tests.
|
||||||
|
@@ -164,10 +164,12 @@ browseBy:
|
|||||||
# The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
# The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
||||||
defaultLowerLimit: 1900
|
defaultLowerLimit: 1900
|
||||||
|
|
||||||
# Item Page Config
|
# Item Config
|
||||||
item:
|
item:
|
||||||
edit:
|
edit:
|
||||||
undoTimeout: 10000 # 10 seconds
|
undoTimeout: 10000 # 10 seconds
|
||||||
|
# Show the item access status label in items lists
|
||||||
|
showAccessStatuses: false
|
||||||
|
|
||||||
# Collection Page Config
|
# Collection Page Config
|
||||||
collection:
|
collection:
|
||||||
|
@@ -65,7 +65,7 @@ describe('My DSpace page', () => {
|
|||||||
cy.visit('/mydspace');
|
cy.visit('/mydspace');
|
||||||
|
|
||||||
// Open the New Submission dropdown
|
// Open the New Submission dropdown
|
||||||
cy.get('#dropdownSubmission').click();
|
cy.get('button[data-test="submission-dropdown"]').click();
|
||||||
// Click on the "Item" type in that dropdown
|
// Click on the "Item" type in that dropdown
|
||||||
cy.get('#entityControlsDropdownMenu button[title="none"]').click();
|
cy.get('#entityControlsDropdownMenu button[title="none"]').click();
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ describe('My DSpace page', () => {
|
|||||||
const id = subpaths[2];
|
const id = subpaths[2];
|
||||||
|
|
||||||
// Click the "Save for Later" button to save this submission
|
// Click the "Save for Later" button to save this submission
|
||||||
cy.get('button#saveForLater').click();
|
cy.get('ds-submission-form-footer [data-test="save-for-later"]').click();
|
||||||
|
|
||||||
// "Save for Later" should send us to MyDSpace
|
// "Save for Later" should send us to MyDSpace
|
||||||
cy.url().should('include', '/mydspace');
|
cy.url().should('include', '/mydspace');
|
||||||
@@ -122,7 +122,7 @@ describe('My DSpace page', () => {
|
|||||||
cy.url().should('include', '/workspaceitems/' + id + '/edit');
|
cy.url().should('include', '/workspaceitems/' + id + '/edit');
|
||||||
|
|
||||||
// Discard our new submission by clicking Discard in Submission form & confirming
|
// Discard our new submission by clicking Discard in Submission form & confirming
|
||||||
cy.get('button#discard').click();
|
cy.get('ds-submission-form-footer [data-test="discard"]').click();
|
||||||
cy.get('button#discard_submit').click();
|
cy.get('button#discard_submit').click();
|
||||||
|
|
||||||
// Discarding should send us back to MyDSpace
|
// Discarding should send us back to MyDSpace
|
||||||
@@ -135,7 +135,7 @@ describe('My DSpace page', () => {
|
|||||||
cy.visit('/mydspace');
|
cy.visit('/mydspace');
|
||||||
|
|
||||||
// Open the New Import dropdown
|
// Open the New Import dropdown
|
||||||
cy.get('#dropdownImport').click();
|
cy.get('button[data-test="import-dropdown"]').click();
|
||||||
// Click on the "Item" type in that dropdown
|
// Click on the "Item" type in that dropdown
|
||||||
cy.get('#importControlsDropdownMenu button[title="none"]').click();
|
cy.get('#importControlsDropdownMenu button[title="none"]').click();
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@ describe('Search Page', () => {
|
|||||||
|
|
||||||
// Click each filter toggle to open *every* filter
|
// Click each filter toggle to open *every* filter
|
||||||
// (As we want to scan filter section for accessibility issues as well)
|
// (As we want to scan filter section for accessibility issues as well)
|
||||||
cy.get('.filter-toggle').click({ multiple: true });
|
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
|
||||||
|
|
||||||
// Analyze <ds-search-page> for accessibility issues
|
// Analyze <ds-search-page> for accessibility issues
|
||||||
testA11y(
|
testA11y(
|
||||||
|
@@ -21,7 +21,7 @@ import './commands';
|
|||||||
import 'cypress-axe';
|
import 'cypress-axe';
|
||||||
|
|
||||||
// Runs once before the first test in each "block"
|
// Runs once before the first test in each "block"
|
||||||
before(() => {
|
beforeEach(() => {
|
||||||
// Pre-agree to all Klaro cookies by setting the klaro-anonymous cookie
|
// Pre-agree to all Klaro cookies by setting the klaro-anonymous cookie
|
||||||
// This just ensures it doesn't get in the way of matching other objects in the page.
|
// This just ensures it doesn't get in the way of matching other objects in the page.
|
||||||
cy.setCookie('klaro-anonymous', '{%22authentication%22:true%2C%22preferences%22:true%2C%22acknowledgement%22:true%2C%22google-analytics%22:true}');
|
cy.setCookie('klaro-anonymous', '{%22authentication%22:true%2C%22preferences%22:true%2C%22acknowledgement%22:true%2C%22google-analytics%22:true}');
|
||||||
|
@@ -25,7 +25,7 @@ services:
|
|||||||
### OVERRIDE default 'entrypoint' in 'docker-compose-rest.yml' ####
|
### OVERRIDE default 'entrypoint' in 'docker-compose-rest.yml' ####
|
||||||
# Ensure that the database is ready BEFORE starting tomcat
|
# Ensure that the database is ready BEFORE starting tomcat
|
||||||
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
||||||
# 2. Then, run database migration to init database tables
|
# 2. Then, run database migration to init database tables (including any out-of-order ignored migrations, if any)
|
||||||
# 3. (Custom for Entities) enable Entity-specific collection submission mappings in item-submission.xml
|
# 3. (Custom for Entities) enable Entity-specific collection submission mappings in item-submission.xml
|
||||||
# This 'sed' command inserts the sample configurations specific to the Entities data set, see:
|
# This 'sed' command inserts the sample configurations specific to the Entities data set, see:
|
||||||
# https://github.com/DSpace/DSpace/blob/main/dspace/config/item-submission.xml#L36-L49
|
# https://github.com/DSpace/DSpace/blob/main/dspace/config/item-submission.xml#L36-L49
|
||||||
@@ -35,7 +35,7 @@ services:
|
|||||||
- '-c'
|
- '-c'
|
||||||
- |
|
- |
|
||||||
while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done;
|
while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done;
|
||||||
/dspace/bin/dspace database migrate
|
/dspace/bin/dspace database migrate ignored
|
||||||
sed -i '/name-map collection-handle="default".*/a \\n <name-map collection-handle="123456789/3" submission-name="Publication"/> \
|
sed -i '/name-map collection-handle="default".*/a \\n <name-map collection-handle="123456789/3" submission-name="Publication"/> \
|
||||||
<name-map collection-handle="123456789/4" submission-name="Publication"/> \
|
<name-map collection-handle="123456789/4" submission-name="Publication"/> \
|
||||||
<name-map collection-handle="123456789/281" submission-name="Publication"/> \
|
<name-map collection-handle="123456789/281" submission-name="Publication"/> \
|
||||||
|
@@ -46,14 +46,14 @@ services:
|
|||||||
- solr_configs:/dspace/solr
|
- solr_configs:/dspace/solr
|
||||||
# Ensure that the database is ready BEFORE starting tomcat
|
# Ensure that the database is ready BEFORE starting tomcat
|
||||||
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
||||||
# 2. Then, run database migration to init database tables
|
# 2. Then, run database migration to init database tables (including any out-of-order ignored migrations, if any)
|
||||||
# 3. Finally, start Tomcat
|
# 3. Finally, start Tomcat
|
||||||
entrypoint:
|
entrypoint:
|
||||||
- /bin/bash
|
- /bin/bash
|
||||||
- '-c'
|
- '-c'
|
||||||
- |
|
- |
|
||||||
while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done;
|
while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done;
|
||||||
/dspace/bin/dspace database migrate
|
/dspace/bin/dspace database migrate ignored
|
||||||
catalina.sh run
|
catalina.sh run
|
||||||
# DSpace database container
|
# DSpace database container
|
||||||
# NOTE: This is customized to use our loadsql image, so that we are using a database with existing test data
|
# NOTE: This is customized to use our loadsql image, so that we are using a database with existing test data
|
||||||
|
31
package.json
31
package.json
@@ -9,10 +9,11 @@
|
|||||||
"start:dev": "nodemon --exec \"cross-env NODE_ENV=development yarn run serve\"",
|
"start:dev": "nodemon --exec \"cross-env NODE_ENV=development yarn run serve\"",
|
||||||
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
|
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
|
||||||
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
|
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
|
||||||
"serve": "ng serve -c development",
|
"preserve": "yarn base-href",
|
||||||
|
"serve": "ng serve --configuration development",
|
||||||
"serve:ssr": "node dist/server/main",
|
"serve:ssr": "node dist/server/main",
|
||||||
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
|
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
|
||||||
"build": "ng build -c development",
|
"build": "ng build --configuration development",
|
||||||
"build:stats": "ng build --stats-json",
|
"build:stats": "ng build --stats-json",
|
||||||
"build:prod": "yarn run build:ssr",
|
"build:prod": "yarn run build:ssr",
|
||||||
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
|
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
"cypress:open": "cypress open",
|
"cypress:open": "cypress open",
|
||||||
"cypress:run": "cypress run",
|
"cypress:run": "cypress run",
|
||||||
"env:yaml": "ts-node --project ./tsconfig.ts-node.json scripts/env-to-yaml.ts",
|
"env:yaml": "ts-node --project ./tsconfig.ts-node.json scripts/env-to-yaml.ts",
|
||||||
|
"base-href": "ts-node --project ./tsconfig.ts-node.json scripts/base-href.ts",
|
||||||
"check-circ-deps": "npx madge --exclude '(bitstream|bundle|collection|config-submission-form|eperson|item|version)\\.model\\.ts$' --circular --extensions ts ./"
|
"check-circ-deps": "npx madge --exclude '(bitstream|bundle|collection|config-submission-form|eperson|item|version)\\.model\\.ts$' --circular --extensions ts ./"
|
||||||
},
|
},
|
||||||
"browser": {
|
"browser": {
|
||||||
@@ -68,8 +70,8 @@
|
|||||||
"@material-ui/core": "^4.11.0",
|
"@material-ui/core": "^4.11.0",
|
||||||
"@material-ui/icons": "^4.9.1",
|
"@material-ui/icons": "^4.9.1",
|
||||||
"@ng-bootstrap/ng-bootstrap": "^11.0.0",
|
"@ng-bootstrap/ng-bootstrap": "^11.0.0",
|
||||||
"@ng-dynamic-forms/core": "^14.0.1",
|
"@ng-dynamic-forms/core": "^15.0.0",
|
||||||
"@ng-dynamic-forms/ui-ng-bootstrap": "^14.0.1",
|
"@ng-dynamic-forms/ui-ng-bootstrap": "^15.0.0",
|
||||||
"@ngrx/effects": "^13.0.2",
|
"@ngrx/effects": "^13.0.2",
|
||||||
"@ngrx/router-store": "^13.0.2",
|
"@ngrx/router-store": "^13.0.2",
|
||||||
"@ngrx/store": "^13.0.2",
|
"@ngrx/store": "^13.0.2",
|
||||||
@@ -77,7 +79,8 @@
|
|||||||
"@ngx-translate/core": "^13.0.0",
|
"@ngx-translate/core": "^13.0.0",
|
||||||
"@nicky-lenaers/ngx-scroll-to": "^9.0.0",
|
"@nicky-lenaers/ngx-scroll-to": "^9.0.0",
|
||||||
"angular-idle-preload": "3.0.0",
|
"angular-idle-preload": "3.0.0",
|
||||||
"angulartics2": "^10.0.0",
|
"angulartics2": "^12.0.0",
|
||||||
|
"axios": "^0.27.2",
|
||||||
"bootstrap": "4.3.1",
|
"bootstrap": "4.3.1",
|
||||||
"caniuse-lite": "^1.0.30001165",
|
"caniuse-lite": "^1.0.30001165",
|
||||||
"cerialize": "0.1.18",
|
"cerialize": "0.1.18",
|
||||||
@@ -104,7 +107,7 @@
|
|||||||
"mirador": "^3.3.0",
|
"mirador": "^3.3.0",
|
||||||
"mirador-dl-plugin": "^0.13.0",
|
"mirador-dl-plugin": "^0.13.0",
|
||||||
"mirador-share-plugin": "^0.11.0",
|
"mirador-share-plugin": "^0.11.0",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.2",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"ng-mocks": "^13.1.1",
|
"ng-mocks": "^13.1.1",
|
||||||
"ng2-file-upload": "1.4.0",
|
"ng2-file-upload": "1.4.0",
|
||||||
@@ -119,13 +122,14 @@
|
|||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
"react-copy-to-clipboard": "^5.0.1",
|
"react-copy-to-clipboard": "^5.0.1",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rxjs": "^6.6.3",
|
"rxjs": "^7.5.5",
|
||||||
"sortablejs": "1.13.0",
|
"sortablejs": "1.13.0",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
"url-parse": "^1.5.6",
|
"url-parse": "^1.5.6",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"webfontloader": "1.6.28",
|
"webfontloader": "1.6.28",
|
||||||
"zone.js": "~0.11.5"
|
"zone.js": "~0.11.5",
|
||||||
|
"ngx-ui-switch": "^11.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-builders/custom-webpack": "~13.1.0",
|
"@angular-builders/custom-webpack": "~13.1.0",
|
||||||
@@ -154,14 +158,14 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "5.11.0",
|
"@typescript-eslint/eslint-plugin": "5.11.0",
|
||||||
"@typescript-eslint/parser": "5.11.0",
|
"@typescript-eslint/parser": "5.11.0",
|
||||||
"axe-core": "^4.3.3",
|
"axe-core": "^4.3.3",
|
||||||
"compression-webpack-plugin": "^3.0.1",
|
"compression-webpack-plugin": "^9.2.0",
|
||||||
"copy-webpack-plugin": "^6.4.1",
|
"copy-webpack-plugin": "^6.4.1",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"css-loader": "^6.2.0",
|
"css-loader": "^6.2.0",
|
||||||
"css-minimizer-webpack-plugin": "^3.4.1",
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
||||||
"cssnano": "^5.0.6",
|
"cssnano": "^5.0.6",
|
||||||
"cypress": "9.5.1",
|
"cypress": "9.5.1",
|
||||||
"cypress-axe": "^0.13.0",
|
"cypress-axe": "^0.14.0",
|
||||||
"debug-loader": "^0.0.1",
|
"debug-loader": "^0.0.1",
|
||||||
"deep-freeze": "0.0.1",
|
"deep-freeze": "0.0.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
@@ -170,10 +174,11 @@
|
|||||||
"eslint-plugin-import": "^2.25.4",
|
"eslint-plugin-import": "^2.25.4",
|
||||||
"eslint-plugin-jsdoc": "^38.0.6",
|
"eslint-plugin-jsdoc": "^38.0.6",
|
||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
"eslint-plugin-unused-imports": "^2.0.0",
|
||||||
|
"express-static-gzip": "^2.1.5",
|
||||||
"fork-ts-checker-webpack-plugin": "^6.0.3",
|
"fork-ts-checker-webpack-plugin": "^6.0.3",
|
||||||
"html-loader": "^1.3.2",
|
"html-loader": "^1.3.2",
|
||||||
"jasmine-core": "^3.8.0",
|
"jasmine-core": "^3.8.0",
|
||||||
"jasmine-marbles": "0.6.0",
|
"jasmine-marbles": "0.9.2",
|
||||||
"jasmine-spec-reporter": "~5.0.0",
|
"jasmine-spec-reporter": "~5.0.0",
|
||||||
"karma": "^6.3.14",
|
"karma": "^6.3.14",
|
||||||
"karma-chrome-launcher": "~3.1.0",
|
"karma-chrome-launcher": "~3.1.0",
|
||||||
@@ -181,7 +186,7 @@
|
|||||||
"karma-jasmine": "~4.0.0",
|
"karma-jasmine": "~4.0.0",
|
||||||
"karma-jasmine-html-reporter": "^1.5.0",
|
"karma-jasmine-html-reporter": "^1.5.0",
|
||||||
"karma-mocha-reporter": "2.2.5",
|
"karma-mocha-reporter": "2.2.5",
|
||||||
"ngx-mask": "^12.0.0",
|
"ngx-mask": "^13.1.7",
|
||||||
"nodemon": "^2.0.15",
|
"nodemon": "^2.0.15",
|
||||||
"postcss": "^8.1",
|
"postcss": "^8.1",
|
||||||
"postcss-apply": "0.12.0",
|
"postcss-apply": "0.12.0",
|
||||||
@@ -195,7 +200,7 @@
|
|||||||
"react": "^16.14.0",
|
"react": "^16.14.0",
|
||||||
"react-dom": "^16.14.0",
|
"react-dom": "^16.14.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs-spy": "^7.5.3",
|
"rxjs-spy": "^8.0.2",
|
||||||
"sass": "~1.32.6",
|
"sass": "~1.32.6",
|
||||||
"sass-loader": "^12.6.0",
|
"sass-loader": "^12.6.0",
|
||||||
"sass-resources-loader": "^2.1.1",
|
"sass-resources-loader": "^2.1.1",
|
||||||
|
36
scripts/base-href.ts
Normal file
36
scripts/base-href.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import * as fs from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
import { AppConfig } from '../src/config/app-config.interface';
|
||||||
|
import { buildAppConfig } from '../src/config/config.server';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Script to set baseHref as `ui.nameSpace` for development mode. Adds `baseHref` to angular.json build options.
|
||||||
|
*
|
||||||
|
* Usage (see package.json):
|
||||||
|
*
|
||||||
|
* yarn base-href
|
||||||
|
*/
|
||||||
|
|
||||||
|
const appConfig: AppConfig = buildAppConfig();
|
||||||
|
|
||||||
|
const angularJsonPath = join(process.cwd(), 'angular.json');
|
||||||
|
|
||||||
|
if (!fs.existsSync(angularJsonPath)) {
|
||||||
|
console.error(`Error:\n${angularJsonPath} does not exist\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const angularJson = require(angularJsonPath);
|
||||||
|
|
||||||
|
const baseHref = `${appConfig.ui.nameSpace}${appConfig.ui.nameSpace.endsWith('/') ? '' : '/'}`;
|
||||||
|
|
||||||
|
console.log(`Setting baseHref to ${baseHref} in angular.json`);
|
||||||
|
|
||||||
|
angularJson.projects['dspace-angular'].architect.build.options.baseHref = baseHref;
|
||||||
|
|
||||||
|
fs.writeFileSync(angularJsonPath, JSON.stringify(angularJson, null, 2) + '\n');
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
import { projectRoot} from '../webpack/helpers';
|
import { projectRoot } from '../webpack/helpers';
|
||||||
|
|
||||||
const commander = require('commander');
|
const commander = require('commander');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const JSON5 = require('json5');
|
const JSON5 = require('json5');
|
||||||
@@ -119,7 +120,7 @@ function syncFileWithSource(pathToTargetFile, pathToOutputFile) {
|
|||||||
outputChunks.forEach(function (chunk) {
|
outputChunks.forEach(function (chunk) {
|
||||||
progressBar.increment();
|
progressBar.increment();
|
||||||
chunk.split("\n").forEach(function (line) {
|
chunk.split("\n").forEach(function (line) {
|
||||||
file.write(" " + line + "\n");
|
file.write((line === '' ? '' : ` ${line}`) + "\n");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
file.write("\n}");
|
file.write("\n}");
|
||||||
@@ -192,7 +193,10 @@ function createNewChunkComparingSourceAndTarget(correspondingTargetChunk, source
|
|||||||
|
|
||||||
const targetList = correspondingTargetChunk.split("\n");
|
const targetList = correspondingTargetChunk.split("\n");
|
||||||
const oldKeyValueInTargetComments = getSubStringWithRegex(correspondingTargetChunk, "\\s*\\/\\/\\s*\".*");
|
const oldKeyValueInTargetComments = getSubStringWithRegex(correspondingTargetChunk, "\\s*\\/\\/\\s*\".*");
|
||||||
const keyValueTarget = targetList[targetList.length - 1];
|
let keyValueTarget = targetList[targetList.length - 1];
|
||||||
|
if (!keyValueTarget.endsWith(",")) {
|
||||||
|
keyValueTarget = keyValueTarget + ",";
|
||||||
|
}
|
||||||
|
|
||||||
if (oldKeyValueInTargetComments != null) {
|
if (oldKeyValueInTargetComments != null) {
|
||||||
const oldKeyValueUncommented = getSubStringWithRegex(oldKeyValueInTargetComments[0], "\".*")[0];
|
const oldKeyValueUncommented = getSubStringWithRegex(oldKeyValueInTargetComments[0], "\".*")[0];
|
||||||
|
73
server.ts
73
server.ts
@@ -19,12 +19,14 @@ import 'zone.js/node';
|
|||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import 'rxjs';
|
import 'rxjs';
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
import * as pem from 'pem';
|
import * as pem from 'pem';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
import * as morgan from 'morgan';
|
import * as morgan from 'morgan';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import * as bodyParser from 'body-parser';
|
import * as bodyParser from 'body-parser';
|
||||||
import * as compression from 'compression';
|
import * as compression from 'compression';
|
||||||
|
import * as expressStaticGzip from 'express-static-gzip';
|
||||||
|
|
||||||
import { existsSync, readFileSync } from 'fs';
|
import { existsSync, readFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
@@ -37,14 +39,14 @@ import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
|
|||||||
|
|
||||||
import { environment } from './src/environments/environment';
|
import { environment } from './src/environments/environment';
|
||||||
import { createProxyMiddleware } from 'http-proxy-middleware';
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
||||||
import { hasValue, hasNoValue } from './src/app/shared/empty.util';
|
import { hasNoValue, hasValue } from './src/app/shared/empty.util';
|
||||||
|
|
||||||
import { UIServerConfig } from './src/config/ui-server-config.interface';
|
import { UIServerConfig } from './src/config/ui-server-config.interface';
|
||||||
|
|
||||||
import { ServerAppModule } from './src/main.server';
|
import { ServerAppModule } from './src/main.server';
|
||||||
|
|
||||||
import { buildAppConfig } from './src/config/config.server';
|
import { buildAppConfig } from './src/config/config.server';
|
||||||
import { AppConfig, APP_CONFIG } from './src/config/app-config.interface';
|
import { APP_CONFIG, AppConfig } from './src/config/app-config.interface';
|
||||||
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
|
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -66,6 +68,8 @@ extendEnvironmentWithAppConfig(environment, appConfig);
|
|||||||
// The Express app is exported so that it can be used by serverless Functions.
|
// The Express app is exported so that it can be used by serverless Functions.
|
||||||
export function app() {
|
export function app() {
|
||||||
|
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new express application
|
* Create a new express application
|
||||||
*/
|
*/
|
||||||
@@ -74,11 +78,15 @@ export function app() {
|
|||||||
/*
|
/*
|
||||||
* If production mode is enabled in the environment file:
|
* If production mode is enabled in the environment file:
|
||||||
* - Enable Angular's production mode
|
* - Enable Angular's production mode
|
||||||
* - Enable compression for response bodies. See [compression](https://github.com/expressjs/compression)
|
* - Enable compression for SSR reponses. See [compression](https://github.com/expressjs/compression)
|
||||||
*/
|
*/
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
server.use(compression());
|
server.use(compression({
|
||||||
|
// only compress responses we've marked as SSR
|
||||||
|
// otherwise, this middleware may compress files we've chosen not to compress via compression-webpack-plugin
|
||||||
|
filter: (_, res) => res.locals.ssr,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -133,7 +141,11 @@ export function app() {
|
|||||||
/**
|
/**
|
||||||
* Proxy the sitemaps
|
* Proxy the sitemaps
|
||||||
*/
|
*/
|
||||||
server.use('/sitemap**', createProxyMiddleware({ target: `${environment.rest.baseUrl}/sitemaps`, changeOrigin: true }));
|
router.use('/sitemap**', createProxyMiddleware({
|
||||||
|
target: `${environment.rest.baseUrl}/sitemaps`,
|
||||||
|
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
||||||
|
changeOrigin: true
|
||||||
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the rateLimiter property is present
|
* Checks if the rateLimiter property is present
|
||||||
@@ -150,15 +162,28 @@ export function app() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Serve static resources (images, i18n messages, …)
|
* Serve static resources (images, i18n messages, …)
|
||||||
|
* Handle pre-compressed files with [express-static-gzip](https://github.com/tkoenig89/express-static-gzip)
|
||||||
*/
|
*/
|
||||||
server.get('*.*', cacheControl, express.static(DIST_FOLDER, { index: false }));
|
router.get('*.*', cacheControl, expressStaticGzip(DIST_FOLDER, {
|
||||||
|
index: false,
|
||||||
|
enableBrotli: true,
|
||||||
|
orderPreference: ['br', 'gzip'],
|
||||||
|
}));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fallthrough to the IIIF viewer (must be included in the build).
|
* Fallthrough to the IIIF viewer (must be included in the build).
|
||||||
*/
|
*/
|
||||||
server.use('/iiif', express.static(IIIF_VIEWER, {index:false}));
|
router.use('/iiif', express.static(IIIF_VIEWER, { index: false }));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checking server status
|
||||||
|
*/
|
||||||
|
server.get('/app/health', healthCheck);
|
||||||
|
|
||||||
// Register the ngApp callback function to handle incoming requests
|
// Register the ngApp callback function to handle incoming requests
|
||||||
server.get('*', ngApp);
|
router.get('*', ngApp);
|
||||||
|
|
||||||
|
server.use(environment.ui.nameSpace, router);
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
@@ -180,6 +205,7 @@ function ngApp(req, res) {
|
|||||||
providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }]
|
providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }]
|
||||||
}, (err, data) => {
|
}, (err, data) => {
|
||||||
if (hasNoValue(err) && hasValue(data)) {
|
if (hasNoValue(err) && hasValue(data)) {
|
||||||
|
res.locals.ssr = true; // mark response as SSR
|
||||||
res.send(data);
|
res.send(data);
|
||||||
} else if (hasValue(err) && err.code === 'ERR_HTTP_HEADERS_SENT') {
|
} else if (hasValue(err) && err.code === 'ERR_HTTP_HEADERS_SENT') {
|
||||||
// When this error occurs we can't fall back to CSR because the response has already been
|
// When this error occurs we can't fall back to CSR because the response has already been
|
||||||
@@ -191,13 +217,25 @@ function ngApp(req, res) {
|
|||||||
if (hasValue(err)) {
|
if (hasValue(err)) {
|
||||||
console.warn('Error details : ', err);
|
console.warn('Error details : ', err);
|
||||||
}
|
}
|
||||||
res.sendFile(DIST_FOLDER + '/index.html');
|
res.render(indexHtml, {
|
||||||
|
req,
|
||||||
|
providers: [{
|
||||||
|
provide: APP_BASE_HREF,
|
||||||
|
useValue: req.baseUrl
|
||||||
|
}]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// If preboot is disabled, just serve the client
|
// If preboot is disabled, just serve the client
|
||||||
console.log('Universal off, serving for direct CSR');
|
console.log('Universal off, serving for direct CSR');
|
||||||
res.sendFile(DIST_FOLDER + '/index.html');
|
res.render(indexHtml, {
|
||||||
|
req,
|
||||||
|
providers: [{
|
||||||
|
provide: APP_BASE_HREF,
|
||||||
|
useValue: req.baseUrl
|
||||||
|
}]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +325,21 @@ function start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The callback function to serve health check requests
|
||||||
|
*/
|
||||||
|
function healthCheck(req, res) {
|
||||||
|
const baseUrl = `${environment.rest.baseUrl}${environment.actuators.endpointPath}`;
|
||||||
|
axios.get(baseUrl)
|
||||||
|
.then((response) => {
|
||||||
|
res.status(response.status).send(response.data);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
res.status(error.response.status).send({
|
||||||
|
error: error.message
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
// Webpack will replace 'require' with '__webpack_require__'
|
// Webpack will replace 'require' with '__webpack_require__'
|
||||||
// '__non_webpack_require__' is a proxy to Node 'require'
|
// '__non_webpack_require__' is a proxy to Node 'require'
|
||||||
// The below code is to ensure that the server is run only when not requiring the bundle.
|
// The below code is to ensure that the server is run only when not requiring the bundle.
|
||||||
|
@@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { FormsModule, ReactiveFormsModule, FormArray, FormControl, FormGroup,Validators, NG_VALIDATORS, NG_ASYNC_VALIDATORS } from '@angular/forms';
|
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule, By } from '@angular/platform-browser';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
@@ -35,6 +35,7 @@ import { RouterMock } from '../../../shared/mocks/router.mock';
|
|||||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
import { ValidateGroupExists } from './validators/group-exists.validator';
|
import { ValidateGroupExists } from './validators/group-exists.validator';
|
||||||
|
import { NoContent } from '../../../core/shared/NoContent.model';
|
||||||
|
|
||||||
describe('GroupFormComponent', () => {
|
describe('GroupFormComponent', () => {
|
||||||
let component: GroupFormComponent;
|
let component: GroupFormComponent;
|
||||||
@@ -87,6 +88,9 @@ describe('GroupFormComponent', () => {
|
|||||||
patch(group: Group, operations: Operation[]) {
|
patch(group: Group, operations: Operation[]) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||||
|
return createSuccessfulRemoteDataObject$({});
|
||||||
|
},
|
||||||
cancelEditGroup(): void {
|
cancelEditGroup(): void {
|
||||||
this.activeGroup = null;
|
this.activeGroup = null;
|
||||||
},
|
},
|
||||||
@@ -348,4 +352,46 @@ describe('GroupFormComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('delete', () => {
|
||||||
|
let deleteButton;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
component.initialisePage();
|
||||||
|
|
||||||
|
component.canEdit$ = observableOf(true);
|
||||||
|
component.groupBeingEdited = {
|
||||||
|
permanent: false
|
||||||
|
} as Group;
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
deleteButton = fixture.debugElement.query(By.css('.delete-button')).nativeElement;
|
||||||
|
|
||||||
|
spyOn(groupsDataServiceStub, 'delete').and.callThrough();
|
||||||
|
spyOn(groupsDataServiceStub, 'getActiveGroup').and.returnValue(observableOf({ id: 'active-group' }));
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if confirmed via modal', () => {
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
deleteButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
(document as any).querySelector('.modal-footer .confirm').click();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should call GroupDataService.delete', () => {
|
||||||
|
expect(groupsDataServiceStub.delete).toHaveBeenCalledWith('active-group');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if canceled via modal', () => {
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
deleteButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
(document as any).querySelector('.modal-footer .cancel').click();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not call GroupDataService.delete', () => {
|
||||||
|
expect(groupsDataServiceStub.delete).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -426,7 +426,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe((rd: RemoteData<NoContent>) => {
|
.subscribe((rd: RemoteData<NoContent>) => {
|
||||||
if (rd.hasSucceeded) {
|
if (rd.hasSucceeded) {
|
||||||
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: group.name }));
|
this.notificationsService.success(this.translateService.get(this.messagePrefix + '.notification.deleted.success', { name: group.name }));
|
||||||
this.reset();
|
this.onCancel();
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(
|
this.notificationsService.error(
|
||||||
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.title', { name: group.name }),
|
this.translateService.get(this.messagePrefix + '.notification.deleted.failure.title', { name: group.name }),
|
||||||
@@ -439,16 +439,6 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will ensure that the page gets reset and that the cache is cleared
|
|
||||||
*/
|
|
||||||
reset() {
|
|
||||||
this.groupDataService.getBrowseEndpoint().pipe(take(1)).subscribe((href: string) => {
|
|
||||||
this.requestService.removeByHrefSubstring(href);
|
|
||||||
});
|
|
||||||
this.onCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the current edit when component is destroyed & unsub all subscriptions
|
* Cancel the current edit when component is destroyed & unsub all subscriptions
|
||||||
*/
|
*/
|
||||||
|
@@ -79,7 +79,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<button *ngIf="!groupDto.group?.permanent && groupDto.ableToDelete"
|
<button *ngIf="!groupDto.group?.permanent && groupDto.ableToDelete"
|
||||||
(click)="deleteGroup(groupDto)" class="btn btn-outline-danger btn-sm"
|
(click)="deleteGroup(groupDto)" class="btn btn-outline-danger btn-sm btn-delete"
|
||||||
title="{{messagePrefix + 'table.edit.buttons.remove' | translate: {name: groupDto.group.name} }}">
|
title="{{messagePrefix + 'table.edit.buttons.remove' | translate: {name: groupDto.group.name} }}">
|
||||||
<i class="fas fa-trash-alt fa-fw"></i>
|
<i class="fas fa-trash-alt fa-fw"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@@ -31,6 +31,7 @@ import { RouterMock } from '../../shared/mocks/router.mock';
|
|||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||||
|
import { NoContent } from '../../core/shared/NoContent.model';
|
||||||
|
|
||||||
describe('GroupRegistryComponent', () => {
|
describe('GroupRegistryComponent', () => {
|
||||||
let component: GroupsRegistryComponent;
|
let component: GroupsRegistryComponent;
|
||||||
@@ -145,7 +146,10 @@ describe('GroupRegistryComponent', () => {
|
|||||||
totalPages: 1,
|
totalPages: 1,
|
||||||
currentPage: 1
|
currentPage: 1
|
||||||
}), [result]));
|
}), [result]));
|
||||||
}
|
},
|
||||||
|
delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||||
|
return createSuccessfulRemoteDataObject$({});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
dsoDataServiceStub = {
|
dsoDataServiceStub = {
|
||||||
findByHref(href: string): Observable<RemoteData<DSpaceObject>> {
|
findByHref(href: string): Observable<RemoteData<DSpaceObject>> {
|
||||||
@@ -301,4 +305,29 @@ describe('GroupRegistryComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('delete', () => {
|
||||||
|
let deleteButton;
|
||||||
|
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
spyOn(groupsDataServiceStub, 'delete').and.callThrough();
|
||||||
|
|
||||||
|
setIsAuthorized(true, true);
|
||||||
|
|
||||||
|
// force rerender after setup changes
|
||||||
|
component.search({ query: '' });
|
||||||
|
tick();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
// only mockGroup[0] is deletable, so we should only get one button
|
||||||
|
deleteButton = fixture.debugElement.query(By.css('.btn-delete')).nativeElement;
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should call GroupDataService.delete', () => {
|
||||||
|
deleteButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(groupsDataServiceStub.delete).toHaveBeenCalledWith(mockGroups[0].id);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -9,7 +9,7 @@ import {
|
|||||||
of as observableOf,
|
of as observableOf,
|
||||||
Subscription
|
Subscription
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import { catchError, map, switchMap, take, tap } from 'rxjs/operators';
|
import { catchError, map, switchMap, tap } from 'rxjs/operators';
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||||
@@ -199,7 +199,6 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
|||||||
if (rd.hasSucceeded) {
|
if (rd.hasSucceeded) {
|
||||||
this.deletedGroupsIds = [...this.deletedGroupsIds, group.group.id];
|
this.deletedGroupsIds = [...this.deletedGroupsIds, group.group.id];
|
||||||
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: group.group.name }));
|
this.notificationsService.success(this.translateService.get(this.messagePrefix + 'notification.deleted.success', { name: group.group.name }));
|
||||||
this.reset();
|
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(
|
this.notificationsService.error(
|
||||||
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: group.group.name }),
|
this.translateService.get(this.messagePrefix + 'notification.deleted.failure.title', { name: group.group.name }),
|
||||||
@@ -209,17 +208,6 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will set everything to stale, which will cause the lists on this page to update.
|
|
||||||
*/
|
|
||||||
reset() {
|
|
||||||
this.groupService.getBrowseEndpoint().pipe(
|
|
||||||
take(1)
|
|
||||||
).subscribe((href: string) => {
|
|
||||||
this.requestService.setStaleByHrefSubstring(href);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the members (epersons embedded value of a group)
|
* Get the members (epersons embedded value of a group)
|
||||||
* @param group
|
* @param group
|
||||||
|
@@ -1,6 +1,17 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h2 id="header">{{'admin.metadata-import.page.header' | translate}}</h2>
|
<h2 id="header">{{'admin.metadata-import.page.header' | translate}}</h2>
|
||||||
<p>{{'admin.metadata-import.page.help' | translate}}</p>
|
<p>{{'admin.metadata-import.page.help' | translate}}</p>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="validateOnly" [(ngModel)]="validateOnly">
|
||||||
|
<label class="form-check-label" for="validateOnly">
|
||||||
|
{{'admin.metadata-import.page.validateOnly' | translate}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<small id="validateOnlyHelpBlock" class="form-text text-muted">
|
||||||
|
{{'admin.metadata-import.page.validateOnly.hint' | translate}}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ds-file-dropzone-no-uploader
|
<ds-file-dropzone-no-uploader
|
||||||
(onFileAdded)="setFile($event)"
|
(onFileAdded)="setFile($event)"
|
||||||
@@ -8,8 +19,10 @@
|
|||||||
[dropMessageLabelReplacement]="'admin.metadata-import.page.dropMsgReplace'">
|
[dropMessageLabelReplacement]="'admin.metadata-import.page.dropMsgReplace'">
|
||||||
</ds-file-dropzone-no-uploader>
|
</ds-file-dropzone-no-uploader>
|
||||||
|
|
||||||
|
<div class="space-children-mr">
|
||||||
<button class="btn btn-secondary" id="backButton"
|
<button class="btn btn-secondary" id="backButton"
|
||||||
(click)="this.onReturn();">{{'admin.metadata-import.page.button.return' | translate}}</button>
|
(click)="this.onReturn();">{{'admin.metadata-import.page.button.return' | translate}}</button>
|
||||||
<button class="btn btn-primary" id="proceedButton"
|
<button class="btn btn-primary" id="proceedButton"
|
||||||
(click)="this.importMetadata();">{{'admin.metadata-import.page.button.proceed' | translate}}</button>
|
(click)="this.importMetadata();">{{'admin.metadata-import.page.button.proceed' | translate}}</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -87,8 +87,9 @@ describe('MetadataImportPageComponent', () => {
|
|||||||
comp.setFile(fileMock);
|
comp.setFile(fileMock);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('if proceed button is pressed', () => {
|
describe('if proceed button is pressed without validate only', () => {
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
|
comp.validateOnly = false;
|
||||||
const proceed = fixture.debugElement.query(By.css('#proceedButton')).nativeElement;
|
const proceed = fixture.debugElement.query(By.css('#proceedButton')).nativeElement;
|
||||||
proceed.click();
|
proceed.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -107,6 +108,28 @@ describe('MetadataImportPageComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('if proceed button is pressed with validate only', () => {
|
||||||
|
beforeEach(fakeAsync(() => {
|
||||||
|
comp.validateOnly = true;
|
||||||
|
const proceed = fixture.debugElement.query(By.css('#proceedButton')).nativeElement;
|
||||||
|
proceed.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
it('metadata-import script is invoked with -f fileName and the mockFile and -v validate-only', () => {
|
||||||
|
const parameterValues: ProcessParameter[] = [
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-f', value: 'filename.txt' }),
|
||||||
|
Object.assign(new ProcessParameter(), { name: '-v', value: true }),
|
||||||
|
];
|
||||||
|
expect(scriptService.invoke).toHaveBeenCalledWith(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [fileMock]);
|
||||||
|
});
|
||||||
|
it('success notification is shown', () => {
|
||||||
|
expect(notificationService.success).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
it('redirected to process page', () => {
|
||||||
|
expect(router.navigateByUrl).toHaveBeenCalledWith('/processes/45');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('if proceed is pressed; but script invoke fails', () => {
|
describe('if proceed is pressed; but script invoke fails', () => {
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
jasmine.getEnv().allowRespy(true);
|
jasmine.getEnv().allowRespy(true);
|
||||||
|
@@ -30,6 +30,11 @@ export class MetadataImportPageComponent {
|
|||||||
*/
|
*/
|
||||||
fileObject: File;
|
fileObject: File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The validate only flag
|
||||||
|
*/
|
||||||
|
validateOnly = true;
|
||||||
|
|
||||||
public constructor(private location: Location,
|
public constructor(private location: Location,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
@@ -62,6 +67,9 @@ export class MetadataImportPageComponent {
|
|||||||
const parameterValues: ProcessParameter[] = [
|
const parameterValues: ProcessParameter[] = [
|
||||||
Object.assign(new ProcessParameter(), { name: '-f', value: this.fileObject.name }),
|
Object.assign(new ProcessParameter(), { name: '-f', value: this.fileObject.name }),
|
||||||
];
|
];
|
||||||
|
if (this.validateOnly) {
|
||||||
|
parameterValues.push(Object.assign(new ProcessParameter(), { name: '-v', value: true }));
|
||||||
|
}
|
||||||
|
|
||||||
this.scriptDataService.invoke(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [this.fileObject]).pipe(
|
this.scriptDataService.invoke(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [this.fileObject]).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
|
@@ -128,7 +128,6 @@ export class MetadataRegistryComponent {
|
|||||||
* Delete all the selected metadata schemas
|
* Delete all the selected metadata schemas
|
||||||
*/
|
*/
|
||||||
deleteSchemas() {
|
deleteSchemas() {
|
||||||
this.registryService.clearMetadataSchemaRequests().subscribe();
|
|
||||||
this.registryService.getSelectedMetadataSchemas().pipe(take(1)).subscribe(
|
this.registryService.getSelectedMetadataSchemas().pipe(take(1)).subscribe(
|
||||||
(schemas) => {
|
(schemas) => {
|
||||||
const tasks$ = [];
|
const tasks$ = [];
|
||||||
@@ -148,7 +147,6 @@ export class MetadataRegistryComponent {
|
|||||||
}
|
}
|
||||||
this.registryService.deselectAllMetadataSchema();
|
this.registryService.deselectAllMetadataSchema();
|
||||||
this.registryService.cancelEditMetadataSchema();
|
this.registryService.cancelEditMetadataSchema();
|
||||||
this.forceUpdateSchemas();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -174,15 +174,12 @@ export class MetadataSchemaComponent implements OnInit {
|
|||||||
const failedResponses = responses.filter((response: RemoteData<NoContent>) => response.hasFailed);
|
const failedResponses = responses.filter((response: RemoteData<NoContent>) => response.hasFailed);
|
||||||
if (successResponses.length > 0) {
|
if (successResponses.length > 0) {
|
||||||
this.showNotification(true, successResponses.length);
|
this.showNotification(true, successResponses.length);
|
||||||
this.registryService.clearMetadataFieldRequests();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (failedResponses.length > 0) {
|
if (failedResponses.length > 0) {
|
||||||
this.showNotification(false, failedResponses.length);
|
this.showNotification(false, failedResponses.length);
|
||||||
}
|
}
|
||||||
this.registryService.deselectAllMetadataField();
|
this.registryService.deselectAllMetadataField();
|
||||||
this.registryService.cancelEditMetadataField();
|
this.registryService.cancelEditMetadataField();
|
||||||
this.forceUpdateFields();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -18,6 +18,8 @@ import { ItemAdminSearchResultGridElementComponent } from './item-admin-search-r
|
|||||||
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/remote-data.utils';
|
||||||
import { getMockThemeService } from '../../../../../shared/mocks/theme-service.mock';
|
import { getMockThemeService } from '../../../../../shared/mocks/theme-service.mock';
|
||||||
import { ThemeService } from '../../../../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../../../../shared/theme-support/theme.service';
|
||||||
|
import { AccessStatusDataService } from '../../../../../core/data/access-status-data.service';
|
||||||
|
import { AccessStatusObject } from '../../../../../shared/object-list/access-status-badge/access-status.model';
|
||||||
|
|
||||||
describe('ItemAdminSearchResultGridElementComponent', () => {
|
describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||||
let component: ItemAdminSearchResultGridElementComponent;
|
let component: ItemAdminSearchResultGridElementComponent;
|
||||||
@@ -31,6 +33,12 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockAccessStatusDataService = {
|
||||||
|
findAccessStatusFor(item: Item): Observable<RemoteData<AccessStatusObject>> {
|
||||||
|
return createSuccessfulRemoteDataObject$(new AccessStatusObject());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const mockThemeService = getMockThemeService();
|
const mockThemeService = getMockThemeService();
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@@ -55,6 +63,7 @@ describe('ItemAdminSearchResultGridElementComponent', () => {
|
|||||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||||
{ provide: ThemeService, useValue: mockThemeService },
|
{ provide: ThemeService, useValue: mockThemeService },
|
||||||
|
{ provide: AccessStatusDataService, useValue: mockAccessStatusDataService },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
|
@@ -182,176 +182,4 @@ describe('AdminSidebarComponent', () => {
|
|||||||
expect(menuService.collapseMenuPreview).toHaveBeenCalled();
|
expect(menuService.collapseMenuPreview).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('menu', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
spyOn(menuService, 'addSection');
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('for regular user', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
authorizationService.isAuthorized = createSpy('isAuthorized').and.callFake(() => {
|
|
||||||
return observableOf(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
comp.createMenu();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show site admin section', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'admin_search', visible: false,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'registries', visible: false,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
parentID: 'registries', visible: false,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'curation_tasks', visible: false,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'workflow', visible: false,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show edit_community', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'edit_community', visible: false,
|
|
||||||
}));
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show edit_collection', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'edit_collection', visible: false,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show access control section', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'access_control', visible: false,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
parentID: 'access_control', visible: false,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
// We check that the menu section has not been called with visible set to true
|
|
||||||
// The reason why we don't check if it has been called with visible set to false
|
|
||||||
// Is because the function does not get called unless a user is authorised
|
|
||||||
it('should not show the import section', () => {
|
|
||||||
expect(menuService.addSection).not.toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'import', visible: true,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
// We check that the menu section has not been called with visible set to true
|
|
||||||
// The reason why we don't check if it has been called with visible set to false
|
|
||||||
// Is because the function does not get called unless a user is authorised
|
|
||||||
it('should not show the export section', () => {
|
|
||||||
expect(menuService.addSection).not.toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'export', visible: true,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('for site admin', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
authorizationService.isAuthorized = createSpy('isAuthorized').and.callFake((featureID: FeatureID) => {
|
|
||||||
return observableOf(featureID === FeatureID.AdministratorOf);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
comp.createMenu();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should contain site admin section', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'admin_search', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'registries', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
parentID: 'registries', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'curation_tasks', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'workflow', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'workflow', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'import', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'export', visible: true,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('for community admin', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
authorizationService.isAuthorized = createSpy('isAuthorized').and.callFake((featureID: FeatureID) => {
|
|
||||||
return observableOf(featureID === FeatureID.IsCommunityAdmin);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
comp.createMenu();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show edit_community', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'edit_community', visible: true,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('for collection admin', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
authorizationService.isAuthorized = createSpy('isAuthorized').and.callFake((featureID: FeatureID) => {
|
|
||||||
return observableOf(featureID === FeatureID.IsCollectionAdmin);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
comp.createMenu();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show edit_collection', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'edit_collection', visible: true,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('for group admin', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
authorizationService.isAuthorized = createSpy('isAuthorized').and.callFake((featureID: FeatureID) => {
|
|
||||||
return observableOf(featureID === FeatureID.CanManageGroups);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
comp.createMenu();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show access control section', () => {
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
id: 'access_control', visible: true,
|
|
||||||
}));
|
|
||||||
expect(menuService.addSection).toHaveBeenCalledWith(comp.menuID, jasmine.objectContaining({
|
|
||||||
parentID: 'access_control', visible: true,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@@ -1,45 +1,13 @@
|
|||||||
import { Component, HostListener, Injector, OnInit } from '@angular/core';
|
import { Component, HostListener, Injector, OnInit } from '@angular/core';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
|
||||||
import { BehaviorSubject, combineLatest as observableCombineLatest, combineLatest, Observable } from 'rxjs';
|
import { debounceTime, distinctUntilChanged, first, map, withLatestFrom } from 'rxjs/operators';
|
||||||
import { debounceTime, distinctUntilChanged, filter, first, map, take, withLatestFrom } from 'rxjs/operators';
|
|
||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
import {
|
|
||||||
METADATA_EXPORT_SCRIPT_NAME,
|
|
||||||
METADATA_IMPORT_SCRIPT_NAME,
|
|
||||||
ScriptDataService
|
|
||||||
} from '../../core/data/processes/script-data.service';
|
|
||||||
import { slideHorizontal, slideSidebar } from '../../shared/animations/slide';
|
import { slideHorizontal, slideSidebar } from '../../shared/animations/slide';
|
||||||
import {
|
|
||||||
CreateCollectionParentSelectorComponent
|
|
||||||
} from '../../shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component';
|
|
||||||
import {
|
|
||||||
CreateCommunityParentSelectorComponent
|
|
||||||
} from '../../shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component';
|
|
||||||
import {
|
|
||||||
CreateItemParentSelectorComponent
|
|
||||||
} from '../../shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component';
|
|
||||||
import {
|
|
||||||
EditCollectionSelectorComponent
|
|
||||||
} from '../../shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component';
|
|
||||||
import {
|
|
||||||
EditCommunitySelectorComponent
|
|
||||||
} from '../../shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component';
|
|
||||||
import {
|
|
||||||
EditItemSelectorComponent
|
|
||||||
} from '../../shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component';
|
|
||||||
import {
|
|
||||||
ExportMetadataSelectorComponent
|
|
||||||
} from '../../shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component';
|
|
||||||
import { LinkMenuItemModel } from '../../shared/menu/menu-item/models/link.model';
|
|
||||||
import { OnClickMenuItemModel } from '../../shared/menu/menu-item/models/onclick.model';
|
|
||||||
import { TextMenuItemModel } from '../../shared/menu/menu-item/models/text.model';
|
|
||||||
import { MenuComponent } from '../../shared/menu/menu.component';
|
import { MenuComponent } from '../../shared/menu/menu.component';
|
||||||
import { MenuService } from '../../shared/menu/menu.service';
|
import { MenuService } from '../../shared/menu/menu.service';
|
||||||
import { CSSVariableService } from '../../shared/sass-helper/sass-helper.service';
|
import { CSSVariableService } from '../../shared/sass-helper/sass-helper.service';
|
||||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
|
||||||
import { MenuID } from '../../shared/menu/menu-id.model';
|
import { MenuID } from '../../shared/menu/menu-id.model';
|
||||||
import { MenuItemType } from '../../shared/menu/menu-item-type.model';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,11 +53,9 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
protected menuService: MenuService,
|
protected menuService: MenuService,
|
||||||
protected injector: Injector,
|
protected injector: Injector,
|
||||||
protected variableService: CSSVariableService,
|
private variableService: CSSVariableService,
|
||||||
protected authService: AuthService,
|
private authService: AuthService,
|
||||||
protected modalService: NgbModal,
|
|
||||||
public authorizationService: AuthorizationDataService,
|
public authorizationService: AuthorizationDataService,
|
||||||
protected scriptDataService: ScriptDataService,
|
|
||||||
public route: ActivatedRoute
|
public route: ActivatedRoute
|
||||||
) {
|
) {
|
||||||
super(menuService, injector, authorizationService, route);
|
super(menuService, injector, authorizationService, route);
|
||||||
@@ -105,7 +71,6 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
this.authService.isAuthenticated()
|
this.authService.isAuthenticated()
|
||||||
.subscribe((loggedIn: boolean) => {
|
.subscribe((loggedIn: boolean) => {
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
this.createMenu();
|
|
||||||
this.menuService.showMenu(this.menuID);
|
this.menuService.showMenu(this.menuID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -135,503 +100,6 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize all menu sections and items for this menu
|
|
||||||
*/
|
|
||||||
createMenu() {
|
|
||||||
this.createMainMenuSections();
|
|
||||||
this.createSiteAdministratorMenuSections();
|
|
||||||
this.createExportMenuSections();
|
|
||||||
this.createImportMenuSections();
|
|
||||||
this.createAccessControlMenuSections();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the main menu sections.
|
|
||||||
* edit_community / edit_collection is only included if the current user is a Community or Collection admin
|
|
||||||
*/
|
|
||||||
createMainMenuSections() {
|
|
||||||
combineLatest([
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.IsCollectionAdmin),
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.IsCommunityAdmin),
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf)
|
|
||||||
]).subscribe(([isCollectionAdmin, isCommunityAdmin, isSiteAdmin]) => {
|
|
||||||
const menuList = [
|
|
||||||
/* News */
|
|
||||||
{
|
|
||||||
id: 'new',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.new'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'plus',
|
|
||||||
index: 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'new_community',
|
|
||||||
parentID: 'new',
|
|
||||||
active: false,
|
|
||||||
visible: isCommunityAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'menu.section.new_community',
|
|
||||||
function: () => {
|
|
||||||
this.modalService.open(CreateCommunityParentSelectorComponent);
|
|
||||||
}
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'new_collection',
|
|
||||||
parentID: 'new',
|
|
||||||
active: false,
|
|
||||||
visible: isCommunityAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'menu.section.new_collection',
|
|
||||||
function: () => {
|
|
||||||
this.modalService.open(CreateCollectionParentSelectorComponent);
|
|
||||||
}
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'new_item',
|
|
||||||
parentID: 'new',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'menu.section.new_item',
|
|
||||||
function: () => {
|
|
||||||
this.modalService.open(CreateItemParentSelectorComponent);
|
|
||||||
}
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'new_process',
|
|
||||||
parentID: 'new',
|
|
||||||
active: false,
|
|
||||||
visible: isCollectionAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.new_process',
|
|
||||||
link: '/processes/new'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'new_item_version',
|
|
||||||
// parentID: 'new',
|
|
||||||
// active: false,
|
|
||||||
// visible: true,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.new_item_version',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// },
|
|
||||||
|
|
||||||
/* Edit */
|
|
||||||
{
|
|
||||||
id: 'edit',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.edit'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'pencil-alt',
|
|
||||||
index: 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'edit_community',
|
|
||||||
parentID: 'edit',
|
|
||||||
active: false,
|
|
||||||
visible: isCommunityAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'menu.section.edit_community',
|
|
||||||
function: () => {
|
|
||||||
this.modalService.open(EditCommunitySelectorComponent);
|
|
||||||
}
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'edit_collection',
|
|
||||||
parentID: 'edit',
|
|
||||||
active: false,
|
|
||||||
visible: isCollectionAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'menu.section.edit_collection',
|
|
||||||
function: () => {
|
|
||||||
this.modalService.open(EditCollectionSelectorComponent);
|
|
||||||
}
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'edit_item',
|
|
||||||
parentID: 'edit',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'menu.section.edit_item',
|
|
||||||
function: () => {
|
|
||||||
this.modalService.open(EditItemSelectorComponent);
|
|
||||||
}
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Statistics */
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'statistics_task',
|
|
||||||
// active: false,
|
|
||||||
// visible: true,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.statistics_task',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// icon: 'chart-bar',
|
|
||||||
// index: 8
|
|
||||||
// },
|
|
||||||
|
|
||||||
/* Control Panel */
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'control_panel',
|
|
||||||
// active: false,
|
|
||||||
// visible: isSiteAdmin,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.control_panel',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// icon: 'cogs',
|
|
||||||
// index: 9
|
|
||||||
// },
|
|
||||||
|
|
||||||
/* Processes */
|
|
||||||
{
|
|
||||||
id: 'processes',
|
|
||||||
active: false,
|
|
||||||
visible: isSiteAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.processes',
|
|
||||||
link: '/processes'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
icon: 'terminal',
|
|
||||||
index: 10
|
|
||||||
},
|
|
||||||
];
|
|
||||||
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, Object.assign(menuSection, {
|
|
||||||
shouldPersistOnRouteChange: true
|
|
||||||
})));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create menu sections dependent on whether or not the current user is a site administrator and on whether or not
|
|
||||||
* the export scripts exist and the current user is allowed to execute them
|
|
||||||
*/
|
|
||||||
createExportMenuSections() {
|
|
||||||
const menuList = [
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'export_community',
|
|
||||||
// parentID: 'export',
|
|
||||||
// active: false,
|
|
||||||
// visible: true,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.export_community',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// shouldPersistOnRouteChange: true
|
|
||||||
// },
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'export_collection',
|
|
||||||
// parentID: 'export',
|
|
||||||
// active: false,
|
|
||||||
// visible: true,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.export_collection',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// shouldPersistOnRouteChange: true
|
|
||||||
// },
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'export_item',
|
|
||||||
// parentID: 'export',
|
|
||||||
// active: false,
|
|
||||||
// visible: true,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.export_item',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// shouldPersistOnRouteChange: true
|
|
||||||
// },
|
|
||||||
];
|
|
||||||
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection));
|
|
||||||
|
|
||||||
observableCombineLatest([
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
|
||||||
this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_EXPORT_SCRIPT_NAME)
|
|
||||||
]).pipe(
|
|
||||||
filter(([authorized, metadataExportScriptExists]: boolean[]) => authorized && metadataExportScriptExists),
|
|
||||||
take(1)
|
|
||||||
).subscribe(() => {
|
|
||||||
// Hides the export menu for unauthorised people
|
|
||||||
// If in the future more sub-menus are added,
|
|
||||||
// it should be reviewed if they need to be in this subscribe
|
|
||||||
this.menuService.addSection(this.menuID, {
|
|
||||||
id: 'export',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.export'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'file-export',
|
|
||||||
index: 3,
|
|
||||||
shouldPersistOnRouteChange: true
|
|
||||||
});
|
|
||||||
this.menuService.addSection(this.menuID, {
|
|
||||||
id: 'export_metadata',
|
|
||||||
parentID: 'export',
|
|
||||||
active: true,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.ONCLICK,
|
|
||||||
text: 'menu.section.export_metadata',
|
|
||||||
function: () => {
|
|
||||||
this.modalService.open(ExportMetadataSelectorComponent);
|
|
||||||
}
|
|
||||||
} as OnClickMenuItemModel,
|
|
||||||
shouldPersistOnRouteChange: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create menu sections dependent on whether or not the current user is a site administrator and on whether or not
|
|
||||||
* the import scripts exist and the current user is allowed to execute them
|
|
||||||
*/
|
|
||||||
createImportMenuSections() {
|
|
||||||
const menuList = [
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'import_batch',
|
|
||||||
// parentID: 'import',
|
|
||||||
// active: false,
|
|
||||||
// visible: true,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.import_batch',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// }
|
|
||||||
];
|
|
||||||
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, Object.assign(menuSection, {
|
|
||||||
shouldPersistOnRouteChange: true
|
|
||||||
})));
|
|
||||||
|
|
||||||
observableCombineLatest([
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
|
||||||
this.scriptDataService.scriptWithNameExistsAndCanExecute(METADATA_IMPORT_SCRIPT_NAME)
|
|
||||||
]).pipe(
|
|
||||||
filter(([authorized, metadataImportScriptExists]: boolean[]) => authorized && metadataImportScriptExists),
|
|
||||||
take(1)
|
|
||||||
).subscribe(() => {
|
|
||||||
// Hides the import menu for unauthorised people
|
|
||||||
// If in the future more sub-menus are added,
|
|
||||||
// it should be reviewed if they need to be in this subscribe
|
|
||||||
this.menuService.addSection(this.menuID, {
|
|
||||||
id: 'import',
|
|
||||||
active: false,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.import'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'file-import',
|
|
||||||
index: 2
|
|
||||||
});
|
|
||||||
this.menuService.addSection(this.menuID, {
|
|
||||||
id: 'import_metadata',
|
|
||||||
parentID: 'import',
|
|
||||||
active: true,
|
|
||||||
visible: true,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.import_metadata',
|
|
||||||
link: '/admin/metadata-import'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
shouldPersistOnRouteChange: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create menu sections dependent on whether or not the current user is a site administrator
|
|
||||||
*/
|
|
||||||
createSiteAdministratorMenuSections() {
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf).subscribe((authorized) => {
|
|
||||||
const menuList = [
|
|
||||||
/* Admin Search */
|
|
||||||
{
|
|
||||||
id: 'admin_search',
|
|
||||||
active: false,
|
|
||||||
visible: authorized,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.admin_search',
|
|
||||||
link: '/admin/search'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
icon: 'search',
|
|
||||||
index: 5
|
|
||||||
},
|
|
||||||
/* Registries */
|
|
||||||
{
|
|
||||||
id: 'registries',
|
|
||||||
active: false,
|
|
||||||
visible: authorized,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.registries'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'list',
|
|
||||||
index: 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'registries_metadata',
|
|
||||||
parentID: 'registries',
|
|
||||||
active: false,
|
|
||||||
visible: authorized,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.registries_metadata',
|
|
||||||
link: 'admin/registries/metadata'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'registries_format',
|
|
||||||
parentID: 'registries',
|
|
||||||
active: false,
|
|
||||||
visible: authorized,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.registries_format',
|
|
||||||
link: 'admin/registries/bitstream-formats'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Curation tasks */
|
|
||||||
{
|
|
||||||
id: 'curation_tasks',
|
|
||||||
active: false,
|
|
||||||
visible: authorized,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.curation_task',
|
|
||||||
link: 'admin/curation-tasks'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
icon: 'filter',
|
|
||||||
index: 7
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Workflow */
|
|
||||||
{
|
|
||||||
id: 'workflow',
|
|
||||||
active: false,
|
|
||||||
visible: authorized,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.workflow',
|
|
||||||
link: '/admin/workflow'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
icon: 'user-check',
|
|
||||||
index: 11
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, Object.assign(menuSection, {
|
|
||||||
shouldPersistOnRouteChange: true
|
|
||||||
})));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create menu sections dependent on whether or not the current user can manage access control groups
|
|
||||||
*/
|
|
||||||
createAccessControlMenuSections() {
|
|
||||||
observableCombineLatest([
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf),
|
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanManageGroups)
|
|
||||||
]).subscribe(([isSiteAdmin, canManageGroups]) => {
|
|
||||||
const menuList = [
|
|
||||||
/* Access Control */
|
|
||||||
{
|
|
||||||
id: 'access_control_people',
|
|
||||||
parentID: 'access_control',
|
|
||||||
active: false,
|
|
||||||
visible: isSiteAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.access_control_people',
|
|
||||||
link: '/access-control/epeople'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'access_control_groups',
|
|
||||||
parentID: 'access_control',
|
|
||||||
active: false,
|
|
||||||
visible: canManageGroups,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.LINK,
|
|
||||||
text: 'menu.section.access_control_groups',
|
|
||||||
link: '/access-control/groups'
|
|
||||||
} as LinkMenuItemModel,
|
|
||||||
},
|
|
||||||
// TODO: enable this menu item once the feature has been implemented
|
|
||||||
// {
|
|
||||||
// id: 'access_control_authorizations',
|
|
||||||
// parentID: 'access_control',
|
|
||||||
// active: false,
|
|
||||||
// visible: authorized,
|
|
||||||
// model: {
|
|
||||||
// type: MenuItemType.LINK,
|
|
||||||
// text: 'menu.section.access_control_authorizations',
|
|
||||||
// link: ''
|
|
||||||
// } as LinkMenuItemModel,
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
id: 'access_control',
|
|
||||||
active: false,
|
|
||||||
visible: canManageGroups || isSiteAdmin,
|
|
||||||
model: {
|
|
||||||
type: MenuItemType.TEXT,
|
|
||||||
text: 'menu.section.access_control'
|
|
||||||
} as TextMenuItemModel,
|
|
||||||
icon: 'key',
|
|
||||||
index: 4
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, Object.assign(menuSection, {
|
|
||||||
shouldPersistOnRouteChange: true,
|
|
||||||
})));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostListener('focusin')
|
@HostListener('focusin')
|
||||||
public handleFocusIn() {
|
public handleFocusIn() {
|
||||||
this.inFocus$.next(true);
|
this.inFocus$.next(true);
|
||||||
|
@@ -70,6 +70,12 @@ export function getWorkflowItemModuleRoute() {
|
|||||||
return `/${WORKFLOW_ITEM_MODULE_PATH}`;
|
return `/${WORKFLOW_ITEM_MODULE_PATH}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const WORKSPACE_ITEM_MODULE_PATH = 'workspaceitems';
|
||||||
|
|
||||||
|
export function getWorkspaceItemModuleRoute() {
|
||||||
|
return `/${WORKSPACE_ITEM_MODULE_PATH}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function getDSORoute(dso: DSpaceObject): string {
|
export function getDSORoute(dso: DSpaceObject): string {
|
||||||
if (hasValue(dso)) {
|
if (hasValue(dso)) {
|
||||||
switch ((dso as any).type) {
|
switch ((dso as any).type) {
|
||||||
@@ -101,6 +107,8 @@ export function getPageInternalServerErrorRoute() {
|
|||||||
return `/${INTERNAL_SERVER_ERROR}`;
|
return `/${INTERNAL_SERVER_ERROR}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ERROR_PAGE = 'error';
|
||||||
|
|
||||||
export const INFO_MODULE_PATH = 'info';
|
export const INFO_MODULE_PATH = 'info';
|
||||||
export function getInfoModulePath() {
|
export function getInfoModulePath() {
|
||||||
return `/${INFO_MODULE_PATH}`;
|
return `/${INFO_MODULE_PATH}`;
|
||||||
@@ -116,3 +124,5 @@ export const REQUEST_COPY_MODULE_PATH = 'request-a-copy';
|
|||||||
export function getRequestCopyModulePath() {
|
export function getRequestCopyModulePath() {
|
||||||
return `/${REQUEST_COPY_MODULE_PATH}`;
|
return `/${REQUEST_COPY_MODULE_PATH}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const HEALTH_PAGE_PATH = 'health';
|
||||||
|
@@ -1,15 +1,19 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule, NoPreloading } from '@angular/router';
|
||||||
import { AuthBlockingGuard } from './core/auth/auth-blocking.guard';
|
import { AuthBlockingGuard } from './core/auth/auth-blocking.guard';
|
||||||
|
|
||||||
import { AuthenticatedGuard } from './core/auth/authenticated.guard';
|
import { AuthenticatedGuard } from './core/auth/authenticated.guard';
|
||||||
import { SiteAdministratorGuard } from './core/data/feature-authorization/feature-authorization-guard/site-administrator.guard';
|
import {
|
||||||
|
SiteAdministratorGuard
|
||||||
|
} from './core/data/feature-authorization/feature-authorization-guard/site-administrator.guard';
|
||||||
import {
|
import {
|
||||||
ACCESS_CONTROL_MODULE_PATH,
|
ACCESS_CONTROL_MODULE_PATH,
|
||||||
ADMIN_MODULE_PATH,
|
ADMIN_MODULE_PATH,
|
||||||
BITSTREAM_MODULE_PATH,
|
BITSTREAM_MODULE_PATH,
|
||||||
|
ERROR_PAGE,
|
||||||
FORBIDDEN_PATH,
|
FORBIDDEN_PATH,
|
||||||
FORGOT_PASSWORD_PATH,
|
FORGOT_PASSWORD_PATH,
|
||||||
|
HEALTH_PAGE_PATH,
|
||||||
INFO_MODULE_PATH,
|
INFO_MODULE_PATH,
|
||||||
INTERNAL_SERVER_ERROR,
|
INTERNAL_SERVER_ERROR,
|
||||||
LEGACY_BITSTREAM_MODULE_PATH,
|
LEGACY_BITSTREAM_MODULE_PATH,
|
||||||
@@ -27,18 +31,26 @@ import { EndUserAgreementCurrentUserGuard } from './core/end-user-agreement/end-
|
|||||||
import { SiteRegisterGuard } from './core/data/feature-authorization/feature-authorization-guard/site-register.guard';
|
import { SiteRegisterGuard } from './core/data/feature-authorization/feature-authorization-guard/site-register.guard';
|
||||||
import { ThemedPageNotFoundComponent } from './pagenotfound/themed-pagenotfound.component';
|
import { ThemedPageNotFoundComponent } from './pagenotfound/themed-pagenotfound.component';
|
||||||
import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component';
|
import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component';
|
||||||
import { GroupAdministratorGuard } from './core/data/feature-authorization/feature-authorization-guard/group-administrator.guard';
|
import {
|
||||||
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
|
GroupAdministratorGuard
|
||||||
|
} from './core/data/feature-authorization/feature-authorization-guard/group-administrator.guard';
|
||||||
|
import {
|
||||||
|
ThemedPageInternalServerErrorComponent
|
||||||
|
} from './page-internal-server-error/themed-page-internal-server-error.component';
|
||||||
import { ServerCheckGuard } from './core/server-check/server-check.guard';
|
import { ServerCheckGuard } from './core/server-check/server-check.guard';
|
||||||
|
import { MenuResolver } from './menu.resolver';
|
||||||
|
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forRoot([
|
RouterModule.forRoot([
|
||||||
{ path: INTERNAL_SERVER_ERROR, component: ThemedPageInternalServerErrorComponent },
|
{ path: INTERNAL_SERVER_ERROR, component: ThemedPageInternalServerErrorComponent },
|
||||||
|
{ path: ERROR_PAGE , component: ThemedPageErrorComponent },
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
canActivate: [AuthBlockingGuard],
|
canActivate: [AuthBlockingGuard],
|
||||||
canActivateChild: [ServerCheckGuard],
|
canActivateChild: [ServerCheckGuard],
|
||||||
|
resolve: [MenuResolver],
|
||||||
children: [
|
children: [
|
||||||
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
{ path: '', redirectTo: '/home', pathMatch: 'full' },
|
||||||
{
|
{
|
||||||
@@ -208,6 +220,11 @@ import { ServerCheckGuard } from './core/server-check/server-check.guard';
|
|||||||
loadChildren: () => import('./statistics-page/statistics-page-routing.module')
|
loadChildren: () => import('./statistics-page/statistics-page-routing.module')
|
||||||
.then((m) => m.StatisticsPageRoutingModule)
|
.then((m) => m.StatisticsPageRoutingModule)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: HEALTH_PAGE_PATH,
|
||||||
|
loadChildren: () => import('./health-page/health-page.module')
|
||||||
|
.then((m) => m.HealthPageModule)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: ACCESS_CONTROL_MODULE_PATH,
|
path: ACCESS_CONTROL_MODULE_PATH,
|
||||||
loadChildren: () => import('./access-control/access-control.module').then((m) => m.AccessControlModule),
|
loadChildren: () => import('./access-control/access-control.module').then((m) => m.AccessControlModule),
|
||||||
@@ -217,6 +234,12 @@ import { ServerCheckGuard } from './core/server-check/server-check.guard';
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
], {
|
], {
|
||||||
|
// enableTracing: true,
|
||||||
|
useHash: false,
|
||||||
|
scrollPositionRestoration: 'enabled',
|
||||||
|
anchorScrolling: 'enabled',
|
||||||
|
initialNavigation: 'enabledBlocking',
|
||||||
|
preloadingStrategy: NoPreloading,
|
||||||
onSameUrlNavigation: 'reload',
|
onSameUrlNavigation: 'reload',
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
@@ -4,7 +4,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|||||||
import { CommonModule, DOCUMENT } from '@angular/common';
|
import { CommonModule, DOCUMENT } from '@angular/common';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
|
import { Angulartics2GoogleAnalytics } from 'angulartics2';
|
||||||
|
|
||||||
// Load the implementations that should be tested
|
// Load the implementations that should be tested
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
@@ -187,7 +187,7 @@ describe('App component', () => {
|
|||||||
link.setAttribute('rel', 'stylesheet');
|
link.setAttribute('rel', 'stylesheet');
|
||||||
link.setAttribute('type', 'text/css');
|
link.setAttribute('type', 'text/css');
|
||||||
link.setAttribute('class', 'theme-css');
|
link.setAttribute('class', 'theme-css');
|
||||||
link.setAttribute('href', '/custom-theme.css');
|
link.setAttribute('href', 'custom-theme.css');
|
||||||
|
|
||||||
expect(headSpy.appendChild).toHaveBeenCalledWith(link);
|
expect(headSpy.appendChild).toHaveBeenCalledWith(link);
|
||||||
});
|
});
|
||||||
|
@@ -12,6 +12,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
ActivatedRouteSnapshot,
|
ActivatedRouteSnapshot,
|
||||||
|
ActivationEnd,
|
||||||
NavigationCancel,
|
NavigationCancel,
|
||||||
NavigationEnd,
|
NavigationEnd,
|
||||||
NavigationStart, ResolveEnd,
|
NavigationStart, ResolveEnd,
|
||||||
@@ -21,9 +22,9 @@ import {
|
|||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
import { BehaviorSubject, Observable, of } from 'rxjs';
|
||||||
import { select, Store } from '@ngrx/store';
|
import { select, Store } from '@ngrx/store';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal, NgbModalConfig } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
|
import { Angulartics2GoogleAnalytics } from 'angulartics2';
|
||||||
|
|
||||||
import { MetadataService } from './core/metadata/metadata.service';
|
import { MetadataService } from './core/metadata/metadata.service';
|
||||||
import { HostWindowResizeAction } from './shared/host-window.actions';
|
import { HostWindowResizeAction } from './shared/host-window.actions';
|
||||||
@@ -48,6 +49,7 @@ import { BreadcrumbsService } from './breadcrumbs/breadcrumbs.service';
|
|||||||
import { IdleModalComponent } from './shared/idle-modal/idle-modal.component';
|
import { IdleModalComponent } from './shared/idle-modal/idle-modal.component';
|
||||||
import { getDefaultThemeConfig } from '../config/config.util';
|
import { getDefaultThemeConfig } from '../config/config.util';
|
||||||
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
|
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
|
||||||
|
import { ModalBeforeDismiss } from './shared/interfaces/modal-before-dismiss.interface';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-app',
|
selector: 'ds-app',
|
||||||
@@ -72,7 +74,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
/**
|
/**
|
||||||
* Whether or not the app is in the process of rerouting
|
* Whether or not the app is in the process of rerouting
|
||||||
*/
|
*/
|
||||||
isRouteLoading$: BehaviorSubject<boolean> = new BehaviorSubject(true);
|
isRouteLoading$: BehaviorSubject<boolean> = new BehaviorSubject(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the theme is in the process of being swapped
|
* Whether or not the theme is in the process of being swapped
|
||||||
@@ -105,6 +107,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
private localeService: LocaleService,
|
private localeService: LocaleService,
|
||||||
private breadcrumbsService: BreadcrumbsService,
|
private breadcrumbsService: BreadcrumbsService,
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal,
|
||||||
|
private modalConfig: NgbModalConfig,
|
||||||
@Optional() private cookiesService: KlaroService,
|
@Optional() private cookiesService: KlaroService,
|
||||||
@Optional() private googleAnalyticsService: GoogleAnalyticsService,
|
@Optional() private googleAnalyticsService: GoogleAnalyticsService,
|
||||||
) {
|
) {
|
||||||
@@ -121,7 +124,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
this.themeService.getThemeName$().subscribe((themeName: string) => {
|
this.themeService.getThemeName$().subscribe((themeName: string) => {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
if (isPlatformBrowser(this.platformId)) {
|
||||||
// the theme css will never download server side, so this should only happen on the browser
|
// the theme css will never download server side, so this should only happen on the browser
|
||||||
this.isThemeCSSLoading$.next(true);
|
this.distinctNext(this.isThemeCSSLoading$, true);
|
||||||
}
|
}
|
||||||
if (hasValue(themeName)) {
|
if (hasValue(themeName)) {
|
||||||
this.loadGlobalThemeConfig(themeName);
|
this.loadGlobalThemeConfig(themeName);
|
||||||
@@ -165,6 +168,16 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
/** Implement behavior for interface {@link ModalBeforeDismiss} */
|
||||||
|
this.modalConfig.beforeDismiss = async function () {
|
||||||
|
if (typeof this?.componentInstance?.beforeDismiss === 'function') {
|
||||||
|
return this.componentInstance.beforeDismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
// fall back to default behavior
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
this.isAuthBlocking$ = this.store.pipe(select(isAuthenticationBlocking)).pipe(
|
this.isAuthBlocking$ = this.store.pipe(select(isAuthenticationBlocking)).pipe(
|
||||||
distinctUntilChanged()
|
distinctUntilChanged()
|
||||||
);
|
);
|
||||||
@@ -196,15 +209,45 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
let resolveEndFound = false;
|
let updatingTheme = false;
|
||||||
|
let snapshot: ActivatedRouteSnapshot;
|
||||||
|
|
||||||
this.router.events.subscribe((event) => {
|
this.router.events.subscribe((event) => {
|
||||||
if (event instanceof NavigationStart) {
|
if (event instanceof NavigationStart) {
|
||||||
resolveEndFound = false;
|
updatingTheme = false;
|
||||||
this.isRouteLoading$.next(true);
|
this.distinctNext(this.isRouteLoading$, true);
|
||||||
} else if (event instanceof ResolveEnd) {
|
} else if (event instanceof ResolveEnd) {
|
||||||
resolveEndFound = true;
|
// this is the earliest point where we have all the information we need
|
||||||
const activatedRouteSnapShot: ActivatedRouteSnapshot = event.state.root;
|
// to update the theme, but this event is not emitted on first load
|
||||||
this.themeService.updateThemeOnRouteChange$(event.urlAfterRedirects, activatedRouteSnapShot).pipe(
|
this.updateTheme(event.urlAfterRedirects, event.state.root);
|
||||||
|
updatingTheme = true;
|
||||||
|
} else if (!updatingTheme && event instanceof ActivationEnd) {
|
||||||
|
// if there was no ResolveEnd, keep track of the snapshot...
|
||||||
|
snapshot = event.snapshot;
|
||||||
|
} else if (event instanceof NavigationEnd) {
|
||||||
|
if (!updatingTheme) {
|
||||||
|
// ...and use it to update the theme on NavigationEnd instead
|
||||||
|
this.updateTheme(event.urlAfterRedirects, snapshot);
|
||||||
|
updatingTheme = true;
|
||||||
|
}
|
||||||
|
this.distinctNext(this.isRouteLoading$, false);
|
||||||
|
} else if (event instanceof NavigationCancel) {
|
||||||
|
if (!updatingTheme) {
|
||||||
|
this.distinctNext(this.isThemeLoading$, false);
|
||||||
|
}
|
||||||
|
this.distinctNext(this.isRouteLoading$, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the theme according to the current route, if applicable.
|
||||||
|
* @param urlAfterRedirects the current URL after redirects
|
||||||
|
* @param snapshot the current route snapshot
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
private updateTheme(urlAfterRedirects: string, snapshot: ActivatedRouteSnapshot): void {
|
||||||
|
this.themeService.updateThemeOnRouteChange$(urlAfterRedirects, snapshot).pipe(
|
||||||
switchMap((changed) => {
|
switchMap((changed) => {
|
||||||
if (changed) {
|
if (changed) {
|
||||||
return this.isThemeCSSLoading$;
|
return this.isThemeCSSLoading$;
|
||||||
@@ -213,17 +256,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
).subscribe((changed) => {
|
).subscribe((changed) => {
|
||||||
this.isThemeLoading$.next(changed);
|
this.distinctNext(this.isThemeLoading$, changed);
|
||||||
});
|
|
||||||
} else if (
|
|
||||||
event instanceof NavigationEnd ||
|
|
||||||
event instanceof NavigationCancel
|
|
||||||
) {
|
|
||||||
if (!resolveEndFound) {
|
|
||||||
this.isThemeLoading$.next(false);
|
|
||||||
}
|
|
||||||
this.isRouteLoading$.next(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +301,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
link.setAttribute('rel', 'stylesheet');
|
link.setAttribute('rel', 'stylesheet');
|
||||||
link.setAttribute('type', 'text/css');
|
link.setAttribute('type', 'text/css');
|
||||||
link.setAttribute('class', 'theme-css');
|
link.setAttribute('class', 'theme-css');
|
||||||
link.setAttribute('href', `/${encodeURIComponent(themeName)}-theme.css`);
|
link.setAttribute('href', `${encodeURIComponent(themeName)}-theme.css`);
|
||||||
// wait for the new css to download before removing the old one to prevent a
|
// wait for the new css to download before removing the old one to prevent a
|
||||||
// flash of unstyled content
|
// flash of unstyled content
|
||||||
link.onload = () => {
|
link.onload = () => {
|
||||||
@@ -280,7 +313,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// the fact that this callback is used, proves we're on the browser.
|
// the fact that this callback is used, proves we're on the browser.
|
||||||
this.isThemeCSSLoading$.next(false);
|
this.distinctNext(this.isThemeCSSLoading$, false);
|
||||||
};
|
};
|
||||||
head.appendChild(link);
|
head.appendChild(link);
|
||||||
}
|
}
|
||||||
@@ -375,4 +408,17 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use nextValue to update a given BehaviorSubject, only if it differs from its current value
|
||||||
|
*
|
||||||
|
* @param bs a BehaviorSubject
|
||||||
|
* @param nextValue the next value for that BehaviorSubject
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
protected distinctNext<T>(bs: BehaviorSubject<T>, nextValue: T): void {
|
||||||
|
if (bs.getValue() !== nextValue) {
|
||||||
|
bs.next(nextValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { APP_BASE_HREF, CommonModule } from '@angular/common';
|
import { APP_BASE_HREF, CommonModule, DOCUMENT } from '@angular/common';
|
||||||
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
||||||
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||||
import { AbstractControl } from '@angular/forms';
|
import { AbstractControl } from '@angular/forms';
|
||||||
@@ -15,10 +15,6 @@ import {
|
|||||||
} from '@ng-dynamic-forms/core';
|
} from '@ng-dynamic-forms/core';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ScrollToModule } from '@nicky-lenaers/ngx-scroll-to';
|
import { ScrollToModule } from '@nicky-lenaers/ngx-scroll-to';
|
||||||
|
|
||||||
import { AdminSidebarSectionComponent } from './admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component';
|
|
||||||
import { AdminSidebarComponent } from './admin/admin-sidebar/admin-sidebar.component';
|
|
||||||
import { ExpandableAdminSidebarSectionComponent } from './admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component';
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { appEffects } from './app.effects';
|
import { appEffects } from './app.effects';
|
||||||
@@ -27,48 +23,30 @@ import { appReducers, AppState, storeModuleConfig } from './app.reducer';
|
|||||||
import { CheckAuthenticationTokenAction } from './core/auth/auth.actions';
|
import { CheckAuthenticationTokenAction } from './core/auth/auth.actions';
|
||||||
import { CoreModule } from './core/core.module';
|
import { CoreModule } from './core/core.module';
|
||||||
import { ClientCookieService } from './core/services/client-cookie.service';
|
import { ClientCookieService } from './core/services/client-cookie.service';
|
||||||
import { FooterComponent } from './footer/footer.component';
|
|
||||||
import { HeaderNavbarWrapperComponent } from './header-nav-wrapper/header-navbar-wrapper.component';
|
|
||||||
import { HeaderComponent } from './header/header.component';
|
|
||||||
import { NavbarModule } from './navbar/navbar.module';
|
import { NavbarModule } from './navbar/navbar.module';
|
||||||
import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component';
|
|
||||||
import { DSpaceRouterStateSerializer } from './shared/ngrx/dspace-router-state-serializer';
|
import { DSpaceRouterStateSerializer } from './shared/ngrx/dspace-router-state-serializer';
|
||||||
import { NotificationComponent } from './shared/notifications/notification/notification.component';
|
|
||||||
import { NotificationsBoardComponent } from './shared/notifications/notifications-board/notifications-board.component';
|
|
||||||
import { SharedModule } from './shared/shared.module';
|
import { SharedModule } from './shared/shared.module';
|
||||||
import { BreadcrumbsComponent } from './breadcrumbs/breadcrumbs.component';
|
|
||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
import { ForbiddenComponent } from './forbidden/forbidden.component';
|
|
||||||
import { AuthInterceptor } from './core/auth/auth.interceptor';
|
import { AuthInterceptor } from './core/auth/auth.interceptor';
|
||||||
import { LocaleInterceptor } from './core/locale/locale.interceptor';
|
import { LocaleInterceptor } from './core/locale/locale.interceptor';
|
||||||
import { XsrfInterceptor } from './core/xsrf/xsrf.interceptor';
|
import { XsrfInterceptor } from './core/xsrf/xsrf.interceptor';
|
||||||
import { LogInterceptor } from './core/log/log.interceptor';
|
import { LogInterceptor } from './core/log/log.interceptor';
|
||||||
import { RootComponent } from './root/root.component';
|
import { EagerThemesModule } from '../themes/eager-themes.module';
|
||||||
import { ThemedRootComponent } from './root/themed-root.component';
|
|
||||||
import { ThemedEntryComponentModule } from '../themes/themed-entry-component.module';
|
|
||||||
import { ThemedPageNotFoundComponent } from './pagenotfound/themed-pagenotfound.component';
|
|
||||||
import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component';
|
|
||||||
import { ThemedHeaderComponent } from './header/themed-header.component';
|
|
||||||
import { ThemedFooterComponent } from './footer/themed-footer.component';
|
|
||||||
import { ThemedBreadcrumbsComponent } from './breadcrumbs/themed-breadcrumbs.component';
|
|
||||||
import { ThemedHeaderNavbarWrapperComponent } from './header-nav-wrapper/themed-header-navbar-wrapper.component';
|
|
||||||
import { IdleModalComponent } from './shared/idle-modal/idle-modal.component';
|
|
||||||
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
|
|
||||||
import { PageInternalServerErrorComponent } from './page-internal-server-error/page-internal-server-error.component';
|
|
||||||
import { ThemedAdminSidebarComponent } from './admin/admin-sidebar/themed-admin-sidebar.component';
|
|
||||||
|
|
||||||
import { APP_CONFIG, AppConfig } from '../config/app-config.interface';
|
import { APP_CONFIG, AppConfig } from '../config/app-config.interface';
|
||||||
import { NgxMaskModule } from 'ngx-mask';
|
import { NgxMaskModule } from 'ngx-mask';
|
||||||
|
|
||||||
import { StoreDevModules } from '../config/store/devtools';
|
import { StoreDevModules } from '../config/store/devtools';
|
||||||
|
import { RootModule } from './root.module';
|
||||||
|
|
||||||
export function getConfig() {
|
export function getConfig() {
|
||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBase(appConfig: AppConfig) {
|
const getBaseHref = (document: Document, appConfig: AppConfig): string => {
|
||||||
return appConfig.ui.nameSpace;
|
const baseTag = document.querySelector('head > base');
|
||||||
}
|
baseTag.setAttribute('href', `${appConfig.ui.nameSpace}${appConfig.ui.nameSpace.endsWith('/') ? '' : '/'}`);
|
||||||
|
return baseTag.getAttribute('href');
|
||||||
|
};
|
||||||
|
|
||||||
export function getMetaReducers(appConfig: AppConfig): MetaReducer<AppState>[] {
|
export function getMetaReducers(appConfig: AppConfig): MetaReducer<AppState>[] {
|
||||||
return appConfig.debug ? [...appMetaReducers, ...debugMetaReducers] : appMetaReducers;
|
return appConfig.debug ? [...appMetaReducers, ...debugMetaReducers] : appMetaReducers;
|
||||||
@@ -96,8 +74,9 @@ const IMPORTS = [
|
|||||||
EffectsModule.forRoot(appEffects),
|
EffectsModule.forRoot(appEffects),
|
||||||
StoreModule.forRoot(appReducers, storeModuleConfig),
|
StoreModule.forRoot(appReducers, storeModuleConfig),
|
||||||
StoreRouterConnectingModule.forRoot(),
|
StoreRouterConnectingModule.forRoot(),
|
||||||
ThemedEntryComponentModule.withEntryComponents(),
|
|
||||||
StoreDevModules,
|
StoreDevModules,
|
||||||
|
EagerThemesModule,
|
||||||
|
RootModule,
|
||||||
];
|
];
|
||||||
|
|
||||||
const PROVIDERS = [
|
const PROVIDERS = [
|
||||||
@@ -107,8 +86,8 @@ const PROVIDERS = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: APP_BASE_HREF,
|
provide: APP_BASE_HREF,
|
||||||
useFactory: getBase,
|
useFactory: getBaseHref,
|
||||||
deps: [APP_CONFIG]
|
deps: [DOCUMENT, APP_CONFIG]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: USER_PROVIDED_META_REDUCERS,
|
provide: USER_PROVIDED_META_REDUCERS,
|
||||||
@@ -162,29 +141,6 @@ const PROVIDERS = [
|
|||||||
|
|
||||||
const DECLARATIONS = [
|
const DECLARATIONS = [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
RootComponent,
|
|
||||||
ThemedRootComponent,
|
|
||||||
HeaderComponent,
|
|
||||||
ThemedHeaderComponent,
|
|
||||||
HeaderNavbarWrapperComponent,
|
|
||||||
ThemedHeaderNavbarWrapperComponent,
|
|
||||||
AdminSidebarComponent,
|
|
||||||
ThemedAdminSidebarComponent,
|
|
||||||
AdminSidebarSectionComponent,
|
|
||||||
ExpandableAdminSidebarSectionComponent,
|
|
||||||
FooterComponent,
|
|
||||||
ThemedFooterComponent,
|
|
||||||
PageNotFoundComponent,
|
|
||||||
ThemedPageNotFoundComponent,
|
|
||||||
NotificationComponent,
|
|
||||||
NotificationsBoardComponent,
|
|
||||||
BreadcrumbsComponent,
|
|
||||||
ThemedBreadcrumbsComponent,
|
|
||||||
ForbiddenComponent,
|
|
||||||
ThemedForbiddenComponent,
|
|
||||||
IdleModalComponent,
|
|
||||||
ThemedPageInternalServerErrorComponent,
|
|
||||||
PageInternalServerErrorComponent
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const EXPORTS = [
|
const EXPORTS = [
|
||||||
|
@@ -10,6 +10,9 @@ import { ResourcePolicyResolver } from '../shared/resource-policies/resolvers/re
|
|||||||
import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component';
|
import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component';
|
||||||
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
|
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
|
||||||
import { LegacyBitstreamUrlResolver } from './legacy-bitstream-url.resolver';
|
import { LegacyBitstreamUrlResolver } from './legacy-bitstream-url.resolver';
|
||||||
|
import { BitstreamBreadcrumbResolver } from '../core/breadcrumbs/bitstream-breadcrumb.resolver';
|
||||||
|
import { BitstreamBreadcrumbsService } from '../core/breadcrumbs/bitstream-breadcrumbs.service';
|
||||||
|
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
|
|
||||||
const EDIT_BITSTREAM_PATH = ':id/edit';
|
const EDIT_BITSTREAM_PATH = ':id/edit';
|
||||||
const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
||||||
@@ -48,7 +51,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
|||||||
path: EDIT_BITSTREAM_PATH,
|
path: EDIT_BITSTREAM_PATH,
|
||||||
component: EditBitstreamPageComponent,
|
component: EditBitstreamPageComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
bitstream: BitstreamPageResolver
|
bitstream: BitstreamPageResolver,
|
||||||
|
breadcrumb: BitstreamBreadcrumbResolver,
|
||||||
},
|
},
|
||||||
canActivate: [AuthenticatedGuard]
|
canActivate: [AuthenticatedGuard]
|
||||||
},
|
},
|
||||||
@@ -67,15 +71,17 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
|||||||
{
|
{
|
||||||
path: 'edit',
|
path: 'edit',
|
||||||
resolve: {
|
resolve: {
|
||||||
|
breadcrumb: I18nBreadcrumbResolver,
|
||||||
resourcePolicy: ResourcePolicyResolver
|
resourcePolicy: ResourcePolicyResolver
|
||||||
},
|
},
|
||||||
component: ResourcePolicyEditComponent,
|
component: ResourcePolicyEditComponent,
|
||||||
data: { title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
|
data: { breadcrumbKey: 'item.edit', title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
resolve: {
|
resolve: {
|
||||||
bitstream: BitstreamPageResolver
|
bitstream: BitstreamPageResolver,
|
||||||
|
breadcrumb: BitstreamBreadcrumbResolver,
|
||||||
},
|
},
|
||||||
component: BitstreamAuthorizationsComponent,
|
component: BitstreamAuthorizationsComponent,
|
||||||
data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true }
|
data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true }
|
||||||
@@ -86,6 +92,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
BitstreamPageResolver,
|
BitstreamPageResolver,
|
||||||
|
BitstreamBreadcrumbResolver,
|
||||||
|
BitstreamBreadcrumbsService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class BitstreamPageRoutingModule {
|
export class BitstreamPageRoutingModule {
|
||||||
|
@@ -7,6 +7,15 @@ import { BitstreamDataService } from '../core/data/bitstream-data.service';
|
|||||||
import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model';
|
import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model';
|
||||||
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The self links defined in this list are expected to be requested somewhere in the near future
|
||||||
|
* Requesting them as embeds will limit the number of requests
|
||||||
|
*/
|
||||||
|
export const BITSTREAM_PAGE_LINKS_TO_FOLLOW: FollowLinkConfig<Bitstream>[] = [
|
||||||
|
followLink('bundle', {}, followLink('item')),
|
||||||
|
followLink('format')
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a resolver that requests a specific bitstream before the route is activated
|
* This class represents a resolver that requests a specific bitstream before the route is activated
|
||||||
*/
|
*/
|
||||||
@@ -34,9 +43,6 @@ export class BitstreamPageResolver implements Resolve<RemoteData<Bitstream>> {
|
|||||||
* Requesting them as embeds will limit the number of requests
|
* Requesting them as embeds will limit the number of requests
|
||||||
*/
|
*/
|
||||||
get followLinks(): FollowLinkConfig<Bitstream>[] {
|
get followLinks(): FollowLinkConfig<Bitstream>[] {
|
||||||
return [
|
return BITSTREAM_PAGE_LINKS_TO_FOLLOW;
|
||||||
followLink('bundle', {}, followLink('item')),
|
|
||||||
followLink('format')
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,13 @@
|
|||||||
<section class="comcol-page-browse-section">
|
<section class="comcol-page-browse-section">
|
||||||
<div class="browse-by-metadata w-100">
|
<div class="browse-by-metadata w-100">
|
||||||
<ds-browse-by *ngIf="startsWithOptions" class="col-xs-12 w-100"
|
<ds-browse-by *ngIf="startsWithOptions" class="col-xs-12 w-100"
|
||||||
title="{{'browse.title' | translate:{collection: (parent$ | async)?.payload?.name || '', field: 'browse.metadata.' + browseId | translate, value: (value)? '"' + value + '"': ''} }}"
|
title="{{'browse.title' | translate:
|
||||||
|
{
|
||||||
|
collection: (parent$ | async)?.payload?.name || '',
|
||||||
|
field: 'browse.metadata.' + browseId | translate,
|
||||||
|
startsWith: (startsWith)? ('browse.startsWith' | translate: { startsWith: '"' + startsWith + '"' }) : '',
|
||||||
|
value: (value)? '"' + value + '"': ''
|
||||||
|
} }}"
|
||||||
parentname="{{(parent$ | async)?.payload?.name || ''}}"
|
parentname="{{(parent$ | async)?.payload?.name || ''}}"
|
||||||
[objects$]="(items$ !== undefined)? items$ : browseEntries$"
|
[objects$]="(items$ !== undefined)? items$ : browseEntries$"
|
||||||
[paginationConfig]="(currentPagination$ |async)"
|
[paginationConfig]="(currentPagination$ |async)"
|
||||||
|
@@ -17,7 +17,7 @@ import { ThemedBrowseBySwitcherComponent } from './browse-by-switcher/themed-bro
|
|||||||
component: ThemedBrowseBySwitcherComponent,
|
component: ThemedBrowseBySwitcherComponent,
|
||||||
canActivate: [BrowseByGuard],
|
canActivate: [BrowseByGuard],
|
||||||
resolve: { breadcrumb: BrowseByI18nBreadcrumbResolver },
|
resolve: { breadcrumb: BrowseByI18nBreadcrumbResolver },
|
||||||
data: { title: 'browse.title', breadcrumbKey: 'browse.metadata' }
|
data: { title: 'browse.title.page', breadcrumbKey: 'browse.metadata' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}])
|
}])
|
||||||
|
@@ -45,6 +45,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
|||||||
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
|
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
|
||||||
})
|
})
|
||||||
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
|
).subscribe(([params, currentPage, currentSort]: [Params, PaginationComponentOptions, SortOptions]) => {
|
||||||
|
this.startsWith = +params.startsWith || params.startsWith;
|
||||||
this.browseId = params.id || this.defaultBrowseId;
|
this.browseId = params.id || this.defaultBrowseId;
|
||||||
this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId), undefined, undefined);
|
this.updatePageWithItems(browseParamsToOptions(params, currentPage, currentSort, this.browseId), undefined, undefined);
|
||||||
this.updateParent(params.scope);
|
this.updateParent(params.scope);
|
||||||
|
@@ -43,6 +43,10 @@ import { createPaginatedList } from '../../shared/testing/utils.test';
|
|||||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { MyDSpacePageComponent, SEARCH_CONFIG_SERVICE } from '../../my-dspace-page/my-dspace-page.component';
|
import { MyDSpacePageComponent, SEARCH_CONFIG_SERVICE } from '../../my-dspace-page/my-dspace-page.component';
|
||||||
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
||||||
|
import { GroupDataService } from '../../core/eperson/group-data.service';
|
||||||
|
import { LinkHeadService } from '../../core/services/link-head.service';
|
||||||
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
|
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
||||||
|
|
||||||
describe('CollectionItemMapperComponent', () => {
|
describe('CollectionItemMapperComponent', () => {
|
||||||
let comp: CollectionItemMapperComponent;
|
let comp: CollectionItemMapperComponent;
|
||||||
@@ -143,6 +147,25 @@ describe('CollectionItemMapperComponent', () => {
|
|||||||
isAuthorized: observableOf(true)
|
isAuthorized: observableOf(true)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const linkHeadService = jasmine.createSpyObj('linkHeadService', {
|
||||||
|
addTag: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||||
|
findAllByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||||
|
getGroupRegistryRouterLink: '',
|
||||||
|
getUUIDFromString: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const configurationDataService = jasmine.createSpyObj('configurationDataService', {
|
||||||
|
findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), {
|
||||||
|
name: 'test',
|
||||||
|
values: [
|
||||||
|
'org.dspace.ctask.general.ProfileFormats = test'
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
imports: [CommonModule, FormsModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||||
@@ -159,7 +182,10 @@ describe('CollectionItemMapperComponent', () => {
|
|||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||||
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() },
|
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() },
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
{ provide: RouteService, useValue: routeServiceStub },
|
||||||
{ provide: AuthorizationDataService, useValue: authorizationDataService }
|
{ provide: AuthorizationDataService, useValue: authorizationDataService },
|
||||||
|
{ provide: GroupDataService, useValue: groupDataService },
|
||||||
|
{ provide: LinkHeadService, useValue: linkHeadService },
|
||||||
|
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||||
]
|
]
|
||||||
}).overrideComponent(CollectionItemMapperComponent, {
|
}).overrideComponent(CollectionItemMapperComponent, {
|
||||||
set: {
|
set: {
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
<!-- Collection logo -->
|
<!-- Collection logo -->
|
||||||
<ds-comcol-page-logo *ngIf="logoRD$"
|
<ds-comcol-page-logo *ngIf="logoRD$"
|
||||||
[logo]="(logoRD$ | async)?.payload"
|
[logo]="(logoRD$ | async)?.payload"
|
||||||
[alternateText]="'Collection Logo'"
|
|
||||||
[alternateText]="'Collection Logo'">
|
[alternateText]="'Collection Logo'">
|
||||||
</ds-comcol-page-logo>
|
</ds-comcol-page-logo>
|
||||||
|
|
||||||
|
@@ -5,7 +5,6 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
|
|||||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
import { CollectionDataService } from '../../core/data/collection-data.service';
|
||||||
import { Collection } from '../../core/shared/collection.model';
|
import { Collection } from '../../core/shared/collection.model';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { RequestService } from '../../core/data/request.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that represents the page where a user can delete an existing Collection
|
* Component that represents the page where a user can delete an existing Collection
|
||||||
@@ -24,8 +23,7 @@ export class DeleteCollectionPageComponent extends DeleteComColPageComponent<Col
|
|||||||
protected route: ActivatedRoute,
|
protected route: ActivatedRoute,
|
||||||
protected notifications: NotificationsService,
|
protected notifications: NotificationsService,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected requestService: RequestService
|
|
||||||
) {
|
) {
|
||||||
super(dsoDataService, router, route, notifications, translate, requestService);
|
super(dsoDataService, router, route, notifications, translate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@ import { NotificationsService } from '../../../shared/notifications/notification
|
|||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { ItemTemplateDataService } from '../../../core/data/item-template-data.service';
|
import { ItemTemplateDataService } from '../../../core/data/item-template-data.service';
|
||||||
import { Collection } from '../../../core/shared/collection.model';
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
|
||||||
import { RequestService } from '../../../core/data/request.service';
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { getCollectionItemTemplateRoute } from '../../collection-page-routing-paths';
|
import { getCollectionItemTemplateRoute } from '../../collection-page-routing-paths';
|
||||||
@@ -49,9 +48,6 @@ describe('CollectionMetadataComponent', () => {
|
|||||||
success: {},
|
success: {},
|
||||||
error: {}
|
error: {}
|
||||||
});
|
});
|
||||||
const objectCache = jasmine.createSpyObj('objectCache', {
|
|
||||||
remove: {}
|
|
||||||
});
|
|
||||||
const requestService = jasmine.createSpyObj('requestService', {
|
const requestService = jasmine.createSpyObj('requestService', {
|
||||||
setStaleByHrefSubstring: {}
|
setStaleByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -65,8 +61,7 @@ describe('CollectionMetadataComponent', () => {
|
|||||||
{ provide: ItemTemplateDataService, useValue: itemTemplateServiceStub },
|
{ provide: ItemTemplateDataService, useValue: itemTemplateServiceStub },
|
||||||
{ provide: ActivatedRoute, useValue: { parent: { data: observableOf({ dso: createSuccessfulRemoteDataObject(collection) }) } } },
|
{ provide: ActivatedRoute, useValue: { parent: { data: observableOf({ dso: createSuccessfulRemoteDataObject(collection) }) } } },
|
||||||
{ provide: NotificationsService, useValue: notificationsService },
|
{ provide: NotificationsService, useValue: notificationsService },
|
||||||
{ provide: ObjectCacheService, useValue: objectCache },
|
{ provide: RequestService, useValue: requestService },
|
||||||
{ provide: RequestService, useValue: requestService }
|
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
@@ -95,20 +90,18 @@ describe('CollectionMetadataComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('deleteItemTemplate', () => {
|
describe('deleteItemTemplate', () => {
|
||||||
describe('when delete returns a success', () => {
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(itemTemplateService.deleteByCollectionID as jasmine.Spy).and.returnValue(observableOf(true));
|
(itemTemplateService.deleteByCollectionID as jasmine.Spy).and.returnValue(observableOf(true));
|
||||||
comp.deleteItemTemplate();
|
comp.deleteItemTemplate();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display a success notification', () => {
|
it('should call ItemTemplateService.deleteByCollectionID', () => {
|
||||||
expect(notificationsService.success).toHaveBeenCalled();
|
expect(itemTemplateService.deleteByCollectionID).toHaveBeenCalledWith(template, 'collection-id');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset related object and request cache', () => {
|
describe('when delete returns a success', () => {
|
||||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledWith(collectionTemplateHref);
|
it('should display a success notification', () => {
|
||||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledWith(template.self);
|
expect(notificationsService.success).toHaveBeenCalled();
|
||||||
expect(requestService.setStaleByHrefSubstring).toHaveBeenCalledWith(collection.self);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -8,10 +8,9 @@ import { combineLatest as combineLatestObservable, Observable } from 'rxjs';
|
|||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
||||||
import { switchMap, tap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
|
||||||
import { RequestService } from '../../../core/data/request.service';
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
import { getCollectionItemTemplateRoute } from '../../collection-page-routing-paths';
|
import { getCollectionItemTemplateRoute } from '../../collection-page-routing-paths';
|
||||||
|
|
||||||
@@ -38,8 +37,7 @@ export class CollectionMetadataComponent extends ComcolMetadataComponent<Collect
|
|||||||
protected route: ActivatedRoute,
|
protected route: ActivatedRoute,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected objectCache: ObjectCacheService,
|
protected requestService: RequestService,
|
||||||
protected requestService: RequestService
|
|
||||||
) {
|
) {
|
||||||
super(collectionDataService, router, route, notificationsService, translate);
|
super(collectionDataService, router, route, notificationsService, translate);
|
||||||
}
|
}
|
||||||
@@ -93,23 +91,9 @@ export class CollectionMetadataComponent extends ComcolMetadataComponent<Collect
|
|||||||
getFirstSucceededRemoteDataPayload(),
|
getFirstSucceededRemoteDataPayload(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
const templateHref$ = collection$.pipe(
|
combineLatestObservable(collection$, template$).pipe(
|
||||||
switchMap((collection) => this.itemTemplateService.getCollectionEndpoint(collection.id)),
|
switchMap(([collection, template]) => {
|
||||||
);
|
return this.itemTemplateService.deleteByCollectionID(template, collection.uuid);
|
||||||
|
|
||||||
combineLatestObservable(collection$, template$, templateHref$).pipe(
|
|
||||||
switchMap(([collection, template, templateHref]) => {
|
|
||||||
return this.itemTemplateService.deleteByCollectionID(template, collection.uuid).pipe(
|
|
||||||
tap((success: boolean) => {
|
|
||||||
if (success) {
|
|
||||||
this.objectCache.remove(templateHref);
|
|
||||||
this.objectCache.remove(template.self);
|
|
||||||
this.requestService.setStaleByHrefSubstring(template.self);
|
|
||||||
this.requestService.setStaleByHrefSubstring(templateHref);
|
|
||||||
this.requestService.setStaleByHrefSubstring(collection.self);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
).subscribe((success: boolean) => {
|
).subscribe((success: boolean) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
|
@@ -13,6 +13,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { ComcolModule } from '../../../shared/comcol/comcol.module';
|
import { ComcolModule } from '../../../shared/comcol/comcol.module';
|
||||||
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||||
|
|
||||||
describe('CollectionRolesComponent', () => {
|
describe('CollectionRolesComponent', () => {
|
||||||
|
|
||||||
@@ -79,6 +81,7 @@ describe('CollectionRolesComponent', () => {
|
|||||||
{ provide: ActivatedRoute, useValue: route },
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
{ provide: RequestService, useValue: requestService },
|
{ provide: RequestService, useValue: requestService },
|
||||||
{ provide: GroupDataService, useValue: groupDataService },
|
{ provide: GroupDataService, useValue: groupDataService },
|
||||||
|
{ provide: NotificationsService, useClass: NotificationsServiceStub }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
@@ -6,7 +6,7 @@ import { CollectionPageComponent } from './collection-page.component';
|
|||||||
* Themed wrapper for CollectionPageComponent
|
* Themed wrapper for CollectionPageComponent
|
||||||
*/
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-themed-community-page',
|
selector: 'ds-themed-collection-page',
|
||||||
styleUrls: [],
|
styleUrls: [],
|
||||||
templateUrl: '../shared/theme-support/themed.component.html',
|
templateUrl: '../shared/theme-support/themed.component.html',
|
||||||
})
|
})
|
||||||
|
@@ -5,7 +5,6 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { DeleteComColPageComponent } from '../../shared/comcol/comcol-forms/delete-comcol-page/delete-comcol-page.component';
|
import { DeleteComColPageComponent } from '../../shared/comcol/comcol-forms/delete-comcol-page/delete-comcol-page.component';
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { RequestService } from '../../core/data/request.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that represents the page where a user can delete an existing Community
|
* Component that represents the page where a user can delete an existing Community
|
||||||
@@ -24,9 +23,8 @@ export class DeleteCommunityPageComponent extends DeleteComColPageComponent<Comm
|
|||||||
protected route: ActivatedRoute,
|
protected route: ActivatedRoute,
|
||||||
protected notifications: NotificationsService,
|
protected notifications: NotificationsService,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected requestService: RequestService
|
|
||||||
) {
|
) {
|
||||||
super(dsoDataService, router, route, notifications, translate, requestService);
|
super(dsoDataService, router, route, notifications, translate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { ComcolModule } from '../../../shared/comcol/comcol.module';
|
import { ComcolModule } from '../../../shared/comcol/comcol.module';
|
||||||
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||||
|
|
||||||
describe('CommunityRolesComponent', () => {
|
describe('CommunityRolesComponent', () => {
|
||||||
|
|
||||||
@@ -64,6 +66,7 @@ describe('CommunityRolesComponent', () => {
|
|||||||
{ provide: ActivatedRoute, useValue: route },
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
{ provide: RequestService, useValue: requestService },
|
{ provide: RequestService, useValue: requestService },
|
||||||
{ provide: GroupDataService, useValue: groupDataService },
|
{ provide: GroupDataService, useValue: groupDataService },
|
||||||
|
{ provide: NotificationsService, useClass: NotificationsServiceStub }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
@@ -25,6 +25,14 @@ import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
|
|||||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../shared/theme-support/theme.service';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../core/data/find-list-options.model';
|
import { FindListOptions } from '../../core/data/find-list-options.model';
|
||||||
|
import { GroupDataService } from '../../core/eperson/group-data.service';
|
||||||
|
import { LinkHeadService } from '../../core/services/link-head.service';
|
||||||
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
|
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
||||||
|
import { SearchServiceStub } from '../../shared/testing/search-service.stub';
|
||||||
|
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
||||||
|
import { createPaginatedList } from '../../shared/testing/utils.test';
|
||||||
|
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
||||||
|
|
||||||
describe('CommunityPageSubCollectionList Component', () => {
|
describe('CommunityPageSubCollectionList Component', () => {
|
||||||
let comp: CommunityPageSubCollectionListComponent;
|
let comp: CommunityPageSubCollectionListComponent;
|
||||||
@@ -122,6 +130,25 @@ describe('CommunityPageSubCollectionList Component', () => {
|
|||||||
|
|
||||||
themeService = getMockThemeService();
|
themeService = getMockThemeService();
|
||||||
|
|
||||||
|
const linkHeadService = jasmine.createSpyObj('linkHeadService', {
|
||||||
|
addTag: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||||
|
findAllByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||||
|
getGroupRegistryRouterLink: '',
|
||||||
|
getUUIDFromString: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const configurationDataService = jasmine.createSpyObj('configurationDataService', {
|
||||||
|
findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), {
|
||||||
|
name: 'test',
|
||||||
|
values: [
|
||||||
|
'org.dspace.ctask.general.ProfileFormats = test'
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -138,6 +165,10 @@ describe('CommunityPageSubCollectionList Component', () => {
|
|||||||
{ provide: PaginationService, useValue: paginationService },
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
{ provide: SelectableListService, useValue: {} },
|
{ provide: SelectableListService, useValue: {} },
|
||||||
{ provide: ThemeService, useValue: themeService },
|
{ provide: ThemeService, useValue: themeService },
|
||||||
|
{ provide: GroupDataService, useValue: groupDataService },
|
||||||
|
{ provide: LinkHeadService, useValue: linkHeadService },
|
||||||
|
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||||
|
{ provide: SearchConfigurationService, useValue: new SearchConfigurationServiceStub() },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
@@ -25,6 +25,13 @@ import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
|
|||||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
import { ThemeService } from '../../shared/theme-support/theme.service';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../core/data/find-list-options.model';
|
import { FindListOptions } from '../../core/data/find-list-options.model';
|
||||||
|
import { GroupDataService } from '../../core/eperson/group-data.service';
|
||||||
|
import { LinkHeadService } from '../../core/services/link-head.service';
|
||||||
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
|
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
||||||
|
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
||||||
|
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
||||||
|
import { createPaginatedList } from '../../shared/testing/utils.test';
|
||||||
|
|
||||||
describe('CommunityPageSubCommunityListComponent Component', () => {
|
describe('CommunityPageSubCommunityListComponent Component', () => {
|
||||||
let comp: CommunityPageSubCommunityListComponent;
|
let comp: CommunityPageSubCommunityListComponent;
|
||||||
@@ -119,6 +126,25 @@ describe('CommunityPageSubCommunityListComponent Component', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const linkHeadService = jasmine.createSpyObj('linkHeadService', {
|
||||||
|
addTag: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||||
|
findAllByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||||
|
getGroupRegistryRouterLink: '',
|
||||||
|
getUUIDFromString: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const configurationDataService = jasmine.createSpyObj('configurationDataService', {
|
||||||
|
findByPropertyName: createSuccessfulRemoteDataObject$(Object.assign(new ConfigurationProperty(), {
|
||||||
|
name: 'test',
|
||||||
|
values: [
|
||||||
|
'org.dspace.ctask.general.ProfileFormats = test'
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
});
|
||||||
|
|
||||||
const paginationService = new PaginationServiceStub();
|
const paginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
themeService = getMockThemeService();
|
themeService = getMockThemeService();
|
||||||
@@ -139,6 +165,10 @@ describe('CommunityPageSubCommunityListComponent Component', () => {
|
|||||||
{ provide: PaginationService, useValue: paginationService },
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
{ provide: SelectableListService, useValue: {} },
|
{ provide: SelectableListService, useValue: {} },
|
||||||
{ provide: ThemeService, useValue: themeService },
|
{ provide: ThemeService, useValue: themeService },
|
||||||
|
{ provide: GroupDataService, useValue: groupDataService },
|
||||||
|
{ provide: LinkHeadService, useValue: linkHeadService },
|
||||||
|
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||||
|
{ provide: SearchConfigurationService, useValue: new SearchConfigurationServiceStub() },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
@@ -12,13 +12,13 @@ import { AuthStatus } from './models/auth-status.model';
|
|||||||
import { ShortLivedToken } from './models/short-lived-token.model';
|
import { ShortLivedToken } from './models/short-lived-token.model';
|
||||||
import { URLCombiner } from '../url-combiner/url-combiner';
|
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||||
import { RestRequest } from '../data/rest-request.model';
|
import { RestRequest } from '../data/rest-request.model';
|
||||||
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract service to send authentication requests
|
* Abstract service to send authentication requests
|
||||||
*/
|
*/
|
||||||
export abstract class AuthRequestService {
|
export abstract class AuthRequestService {
|
||||||
protected linkName = 'authn';
|
protected linkName = 'authn';
|
||||||
protected browseEndpoint = '';
|
|
||||||
protected shortlivedtokensEndpoint = 'shortlivedtokens';
|
protected shortlivedtokensEndpoint = 'shortlivedtokens';
|
||||||
|
|
||||||
constructor(protected halService: HALEndpointService,
|
constructor(protected halService: HALEndpointService,
|
||||||
@@ -27,14 +27,21 @@ export abstract class AuthRequestService {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fetchRequest(request: RestRequest): Observable<RemoteData<AuthStatus>> {
|
protected fetchRequest(request: RestRequest, ...linksToFollow: FollowLinkConfig<AuthStatus>[]): Observable<RemoteData<AuthStatus>> {
|
||||||
return this.rdbService.buildFromRequestUUID<AuthStatus>(request.uuid).pipe(
|
return this.rdbService.buildFromRequestUUID<AuthStatus>(request.uuid, ...linksToFollow).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getEndpointByMethod(endpoint: string, method: string): string {
|
protected getEndpointByMethod(endpoint: string, method: string, ...linksToFollow: FollowLinkConfig<AuthStatus>[]): string {
|
||||||
return isNotEmpty(method) ? `${endpoint}/${method}` : `${endpoint}`;
|
let url = isNotEmpty(method) ? `${endpoint}/${method}` : `${endpoint}`;
|
||||||
|
if (linksToFollow?.length > 0) {
|
||||||
|
linksToFollow.forEach((link: FollowLinkConfig<AuthStatus>, index: number) => {
|
||||||
|
url += ((index === 0) ? '?' : '&') + `embed=${link.name}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public postToEndpoint(method: string, body?: any, options?: HttpOptions): Observable<RemoteData<AuthStatus>> {
|
public postToEndpoint(method: string, body?: any, options?: HttpOptions): Observable<RemoteData<AuthStatus>> {
|
||||||
@@ -48,14 +55,14 @@ export abstract class AuthRequestService {
|
|||||||
distinctUntilChanged());
|
distinctUntilChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
public getRequest(method: string, options?: HttpOptions): Observable<RemoteData<AuthStatus>> {
|
public getRequest(method: string, options?: HttpOptions, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<AuthStatus>> {
|
||||||
return this.halService.getEndpoint(this.linkName).pipe(
|
return this.halService.getEndpoint(this.linkName).pipe(
|
||||||
filter((href: string) => isNotEmpty(href)),
|
filter((href: string) => isNotEmpty(href)),
|
||||||
map((endpointURL) => this.getEndpointByMethod(endpointURL, method)),
|
map((endpointURL) => this.getEndpointByMethod(endpointURL, method, ...linksToFollow)),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
map((endpointURL: string) => new GetRequest(this.requestService.generateRequestId(), endpointURL, undefined, options)),
|
map((endpointURL: string) => new GetRequest(this.requestService.generateRequestId(), endpointURL, undefined, options)),
|
||||||
tap((request: GetRequest) => this.requestService.send(request)),
|
tap((request: GetRequest) => this.requestService.send(request)),
|
||||||
mergeMap((request: GetRequest) => this.fetchRequest(request)),
|
mergeMap((request: GetRequest) => this.fetchRequest(request, ...linksToFollow)),
|
||||||
distinctUntilChanged());
|
distinctUntilChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -192,7 +192,7 @@ describe('authReducer', () => {
|
|||||||
state = {
|
state = {
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
blocking: true,
|
blocking: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
idle: false
|
idle: false
|
||||||
};
|
};
|
||||||
@@ -212,7 +212,7 @@ describe('authReducer', () => {
|
|||||||
state = {
|
state = {
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
blocking: true,
|
blocking: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
idle: false
|
idle: false
|
||||||
};
|
};
|
||||||
@@ -558,7 +558,7 @@ describe('authReducer', () => {
|
|||||||
state = {
|
state = {
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
blocking: true,
|
blocking: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
authMethods: [],
|
authMethods: [],
|
||||||
idle: false
|
idle: false
|
||||||
|
@@ -92,11 +92,15 @@ export function authReducer(state: any = initialState, action: AuthActions): Aut
|
|||||||
});
|
});
|
||||||
|
|
||||||
case AuthActionTypes.AUTHENTICATED:
|
case AuthActionTypes.AUTHENTICATED:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
loading: true,
|
||||||
|
blocking: true
|
||||||
|
});
|
||||||
|
|
||||||
case AuthActionTypes.CHECK_AUTHENTICATION_TOKEN:
|
case AuthActionTypes.CHECK_AUTHENTICATION_TOKEN:
|
||||||
case AuthActionTypes.CHECK_AUTHENTICATION_TOKEN_COOKIE:
|
case AuthActionTypes.CHECK_AUTHENTICATION_TOKEN_COOKIE:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
loading: true,
|
loading: true,
|
||||||
blocking: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
case AuthActionTypes.AUTHENTICATED_ERROR:
|
case AuthActionTypes.AUTHENTICATED_ERROR:
|
||||||
@@ -210,7 +214,6 @@ export function authReducer(state: any = initialState, action: AuthActions): Aut
|
|||||||
case AuthActionTypes.RETRIEVE_AUTH_METHODS:
|
case AuthActionTypes.RETRIEVE_AUTH_METHODS:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
loading: true,
|
loading: true,
|
||||||
blocking: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
case AuthActionTypes.RETRIEVE_AUTH_METHODS_SUCCESS:
|
case AuthActionTypes.RETRIEVE_AUTH_METHODS_SUCCESS:
|
||||||
|
@@ -32,6 +32,8 @@ import { TranslateService } from '@ngx-translate/core';
|
|||||||
import { getMockTranslateService } from '../../shared/mocks/translate.service.mock';
|
import { getMockTranslateService } from '../../shared/mocks/translate.service.mock';
|
||||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||||
import { SetUserAsIdleAction, UnsetUserAsIdleAction } from './auth.actions';
|
import { SetUserAsIdleAction, UnsetUserAsIdleAction } from './auth.actions';
|
||||||
|
import { SpecialGroupDataMock, SpecialGroupDataMock$ } from '../../shared/testing/special-group.mock';
|
||||||
|
import { cold } from 'jasmine-marbles';
|
||||||
|
|
||||||
describe('AuthService test', () => {
|
describe('AuthService test', () => {
|
||||||
|
|
||||||
@@ -56,6 +58,13 @@ describe('AuthService test', () => {
|
|||||||
let linkService;
|
let linkService;
|
||||||
let hardRedirectService;
|
let hardRedirectService;
|
||||||
|
|
||||||
|
const AuthStatusWithSpecialGroups = Object.assign(new AuthStatus(), {
|
||||||
|
uuid: 'test',
|
||||||
|
authenticated: true,
|
||||||
|
okay: true,
|
||||||
|
specialGroups: SpecialGroupDataMock$
|
||||||
|
});
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
mockStore = jasmine.createSpyObj('store', {
|
mockStore = jasmine.createSpyObj('store', {
|
||||||
dispatch: {},
|
dispatch: {},
|
||||||
@@ -368,25 +377,25 @@ describe('AuthService test', () => {
|
|||||||
it('should redirect to reload with redirect url', () => {
|
it('should redirect to reload with redirect url', () => {
|
||||||
authService.navigateToRedirectUrl('/collection/123');
|
authService.navigateToRedirectUrl('/collection/123');
|
||||||
// Reload with redirect URL set to /collection/123
|
// Reload with redirect URL set to /collection/123
|
||||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*\\?redirect=' + encodeURIComponent('/collection/123'))));
|
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*\\?redirect=' + encodeURIComponent('/collection/123'))));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should redirect to reload with /home', () => {
|
it('should redirect to reload with /home', () => {
|
||||||
authService.navigateToRedirectUrl('/home');
|
authService.navigateToRedirectUrl('/home');
|
||||||
// Reload with redirect URL set to /home
|
// Reload with redirect URL set to /home
|
||||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*\\?redirect=' + encodeURIComponent('/home'))));
|
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*\\?redirect=' + encodeURIComponent('/home'))));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should redirect to regular reload and not to /login', () => {
|
it('should redirect to regular reload and not to /login', () => {
|
||||||
authService.navigateToRedirectUrl('/login');
|
authService.navigateToRedirectUrl('/login');
|
||||||
// Reload without a redirect URL
|
// Reload without a redirect URL
|
||||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*(?!\\?)$')));
|
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*(?!\\?)$')));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should redirect to regular reload when no redirect url is found', () => {
|
it('should redirect to regular reload when no redirect url is found', () => {
|
||||||
authService.navigateToRedirectUrl(undefined);
|
authService.navigateToRedirectUrl(undefined);
|
||||||
// Reload without a redirect URL
|
// Reload without a redirect URL
|
||||||
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('/reload/[0-9]*(?!\\?)$')));
|
expect(hardRedirectService.redirect).toHaveBeenCalledWith(jasmine.stringMatching(new RegExp('reload/[0-9]*(?!\\?)$')));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('impersonate', () => {
|
describe('impersonate', () => {
|
||||||
@@ -511,6 +520,19 @@ describe('AuthService test', () => {
|
|||||||
expect((authService as any).navigateToRedirectUrl).toHaveBeenCalled();
|
expect((authService as any).navigateToRedirectUrl).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getSpecialGroupsFromAuthStatus', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(authRequest, 'getRequest').and.returnValue(createSuccessfulRemoteDataObject$(AuthStatusWithSpecialGroups));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call navigateToRedirectUrl with no url', () => {
|
||||||
|
const expectRes = cold('(a|)', {
|
||||||
|
a: SpecialGroupDataMock
|
||||||
|
});
|
||||||
|
expect(authService.getSpecialGroupsFromAuthStatus()).toBeObservable(expectRes);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when user is not logged in', () => {
|
describe('when user is not logged in', () => {
|
||||||
|
@@ -44,13 +44,18 @@ import {
|
|||||||
import { NativeWindowRef, NativeWindowService } from '../services/window.service';
|
import { NativeWindowRef, NativeWindowService } from '../services/window.service';
|
||||||
import { RouteService } from '../services/route.service';
|
import { RouteService } from '../services/route.service';
|
||||||
import { EPersonDataService } from '../eperson/eperson-data.service';
|
import { EPersonDataService } from '../eperson/eperson-data.service';
|
||||||
import { getAllSucceededRemoteDataPayload } from '../shared/operators';
|
import { getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData } from '../shared/operators';
|
||||||
import { AuthMethod } from './models/auth.method';
|
import { AuthMethod } from './models/auth.method';
|
||||||
import { HardRedirectService } from '../services/hard-redirect.service';
|
import { HardRedirectService } from '../services/hard-redirect.service';
|
||||||
import { RemoteData } from '../data/remote-data';
|
import { RemoteData } from '../data/remote-data';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { buildPaginatedList, PaginatedList } from '../data/paginated-list.model';
|
||||||
|
import { Group } from '../eperson/models/group.model';
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
|
import { PageInfo } from '../shared/page-info.model';
|
||||||
|
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||||
|
|
||||||
export const LOGIN_ROUTE = '/login';
|
export const LOGIN_ROUTE = '/login';
|
||||||
export const LOGOUT_ROUTE = '/logout';
|
export const LOGOUT_ROUTE = '/logout';
|
||||||
@@ -211,6 +216,22 @@ export class AuthService {
|
|||||||
this.store.dispatch(new CheckAuthenticationTokenAction());
|
this.store.dispatch(new CheckAuthenticationTokenAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the special groups list embedded in the AuthStatus model
|
||||||
|
*/
|
||||||
|
public getSpecialGroupsFromAuthStatus(): Observable<RemoteData<PaginatedList<Group>>> {
|
||||||
|
return this.authRequestService.getRequest('status', null, followLink('specialGroups')).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
switchMap((status: RemoteData<AuthStatus>) => {
|
||||||
|
if (status.hasSucceeded) {
|
||||||
|
return status.payload.specialGroups;
|
||||||
|
} else {
|
||||||
|
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(),[]));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if token is present into storage and is not expired
|
* Checks if token is present into storage and is not expired
|
||||||
*/
|
*/
|
||||||
@@ -447,8 +468,8 @@ export class AuthService {
|
|||||||
*/
|
*/
|
||||||
public navigateToRedirectUrl(redirectUrl: string) {
|
public navigateToRedirectUrl(redirectUrl: string) {
|
||||||
// Don't do redirect if already on reload url
|
// Don't do redirect if already on reload url
|
||||||
if (!hasValue(redirectUrl) || !redirectUrl.includes('/reload/')) {
|
if (!hasValue(redirectUrl) || !redirectUrl.includes('reload/')) {
|
||||||
let url = `/reload/${new Date().getTime()}`;
|
let url = `reload/${new Date().getTime()}`;
|
||||||
if (isNotEmpty(redirectUrl) && !redirectUrl.startsWith(LOGIN_ROUTE)) {
|
if (isNotEmpty(redirectUrl) && !redirectUrl.startsWith(LOGIN_ROUTE)) {
|
||||||
url += `?redirect=${encodeURIComponent(redirectUrl)}`;
|
url += `?redirect=${encodeURIComponent(redirectUrl)}`;
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,8 @@ import { IDToUUIDSerializer } from '../../cache/id-to-uuid-serializer';
|
|||||||
import { RemoteData } from '../../data/remote-data';
|
import { RemoteData } from '../../data/remote-data';
|
||||||
import { EPerson } from '../../eperson/models/eperson.model';
|
import { EPerson } from '../../eperson/models/eperson.model';
|
||||||
import { EPERSON } from '../../eperson/models/eperson.resource-type';
|
import { EPERSON } from '../../eperson/models/eperson.resource-type';
|
||||||
|
import { Group } from '../../eperson/models/group.model';
|
||||||
|
import { GROUP } from '../../eperson/models/group.resource-type';
|
||||||
import { HALLink } from '../../shared/hal-link.model';
|
import { HALLink } from '../../shared/hal-link.model';
|
||||||
import { ResourceType } from '../../shared/resource-type';
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
import { excludeFromEquals } from '../../utilities/equals.decorators';
|
import { excludeFromEquals } from '../../utilities/equals.decorators';
|
||||||
@@ -13,6 +15,7 @@ import { AUTH_STATUS } from './auth-status.resource-type';
|
|||||||
import { AuthTokenInfo } from './auth-token-info.model';
|
import { AuthTokenInfo } from './auth-token-info.model';
|
||||||
import { AuthMethod } from './auth.method';
|
import { AuthMethod } from './auth.method';
|
||||||
import { CacheableObject } from '../../cache/cacheable-object.model';
|
import { CacheableObject } from '../../cache/cacheable-object.model';
|
||||||
|
import { PaginatedList } from '../../data/paginated-list.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object that represents the authenticated status of a user
|
* Object that represents the authenticated status of a user
|
||||||
@@ -61,6 +64,7 @@ export class AuthStatus implements CacheableObject {
|
|||||||
_links: {
|
_links: {
|
||||||
self: HALLink;
|
self: HALLink;
|
||||||
eperson: HALLink;
|
eperson: HALLink;
|
||||||
|
specialGroups: HALLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,6 +74,13 @@ export class AuthStatus implements CacheableObject {
|
|||||||
@link(EPERSON)
|
@link(EPERSON)
|
||||||
eperson?: Observable<RemoteData<EPerson>>;
|
eperson?: Observable<RemoteData<EPerson>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SpecialGroup of this auth status
|
||||||
|
* Will be undefined unless the SpecialGroup {@link HALLink} has been resolved.
|
||||||
|
*/
|
||||||
|
@link(GROUP, true)
|
||||||
|
specialGroups?: Observable<RemoteData<PaginatedList<Group>>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the token is valid, false if there was no token or the token wasn't valid
|
* True if the token is valid, false if there was no token or the token wasn't valid
|
||||||
*/
|
*/
|
||||||
|
@@ -4,5 +4,6 @@ export enum AuthMethodType {
|
|||||||
Ldap = 'ldap',
|
Ldap = 'ldap',
|
||||||
Ip = 'ip',
|
Ip = 'ip',
|
||||||
X509 = 'x509',
|
X509 = 'x509',
|
||||||
Oidc = 'oidc'
|
Oidc = 'oidc',
|
||||||
|
Orcid = 'orcid'
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,11 @@ export class AuthMethod {
|
|||||||
this.location = location;
|
this.location = location;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'orcid': {
|
||||||
|
this.authMethodType = AuthMethodType.Orcid;
|
||||||
|
this.location = location;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
|
31
src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts
Normal file
31
src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { Bitstream } from '../shared/bitstream.model';
|
||||||
|
import { BitstreamDataService } from '../data/bitstream-data.service';
|
||||||
|
import { BITSTREAM_PAGE_LINKS_TO_FOLLOW } from '../../bitstream-page/bitstream-page.resolver';
|
||||||
|
import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver';
|
||||||
|
import { BitstreamBreadcrumbsService } from './bitstream-breadcrumbs.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class that resolves the BreadcrumbConfig object for an Item
|
||||||
|
*/
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BitstreamBreadcrumbResolver extends DSOBreadcrumbResolver<Bitstream> {
|
||||||
|
constructor(
|
||||||
|
protected breadcrumbService: BitstreamBreadcrumbsService, protected dataService: BitstreamDataService) {
|
||||||
|
super(breadcrumbService, dataService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that returns the follow links to already resolve
|
||||||
|
* The self links defined in this list are expected to be requested somewhere in the near future
|
||||||
|
* Requesting them as embeds will limit the number of requests
|
||||||
|
*/
|
||||||
|
get followLinks(): FollowLinkConfig<Bitstream>[] {
|
||||||
|
return BITSTREAM_PAGE_LINKS_TO_FOLLOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
85
src/app/core/breadcrumbs/bitstream-breadcrumbs.service.ts
Normal file
85
src/app/core/breadcrumbs/bitstream-breadcrumbs.service.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { map, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
|
||||||
|
import { DSONameService } from './dso-name.service';
|
||||||
|
import { ChildHALResource } from '../shared/child-hal-resource.model';
|
||||||
|
import { LinkService } from '../cache/builders/link.service';
|
||||||
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
|
import { RemoteData } from '../data/remote-data';
|
||||||
|
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||||
|
import { getDSORoute } from '../../app-routing-paths';
|
||||||
|
import { DSOBreadcrumbsService } from './dso-breadcrumbs.service';
|
||||||
|
import { BitstreamDataService } from '../data/bitstream-data.service';
|
||||||
|
import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../shared/operators';
|
||||||
|
import { Bitstream } from '../shared/bitstream.model';
|
||||||
|
import { Bundle } from '../shared/bundle.model';
|
||||||
|
import { Item } from '../shared/item.model';
|
||||||
|
import { BITSTREAM_PAGE_LINKS_TO_FOLLOW } from '../../bitstream-page/bitstream-page.resolver';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service to calculate DSpaceObject breadcrumbs for a single part of the route
|
||||||
|
*/
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BitstreamBreadcrumbsService extends DSOBreadcrumbsService {
|
||||||
|
constructor(
|
||||||
|
protected bitstreamService: BitstreamDataService,
|
||||||
|
protected linkService: LinkService,
|
||||||
|
protected dsoNameService: DSONameService
|
||||||
|
) {
|
||||||
|
super(linkService, dsoNameService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to recursively calculate the breadcrumbs
|
||||||
|
* This method returns the name and url of the key and all its parent DSOs recursively, top down
|
||||||
|
* @param key The key (a DSpaceObject) used to resolve the breadcrumb
|
||||||
|
* @param url The url to use as a link for this breadcrumb
|
||||||
|
*/
|
||||||
|
getBreadcrumbs(key: ChildHALResource & DSpaceObject, url: string): Observable<Breadcrumb[]> {
|
||||||
|
const label = this.dsoNameService.getName(key);
|
||||||
|
const crumb = new Breadcrumb(label, url);
|
||||||
|
|
||||||
|
return this.getOwningItem(key.uuid).pipe(
|
||||||
|
switchMap((parentRD: RemoteData<ChildHALResource & DSpaceObject>) => {
|
||||||
|
if (isNotEmpty(parentRD) && hasValue(parentRD.payload)) {
|
||||||
|
const parent = parentRD.payload;
|
||||||
|
return super.getBreadcrumbs(parent, getDSORoute(parent));
|
||||||
|
}
|
||||||
|
return observableOf([]);
|
||||||
|
|
||||||
|
}),
|
||||||
|
map((breadcrumbs: Breadcrumb[]) => [...breadcrumbs, crumb])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getOwningItem(uuid: string): Observable<RemoteData<Item>> {
|
||||||
|
return this.bitstreamService.findById(uuid, true, true, ...BITSTREAM_PAGE_LINKS_TO_FOLLOW).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
switchMap((bitstream: Bitstream) => {
|
||||||
|
if (hasValue(bitstream)) {
|
||||||
|
return bitstream.bundle.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
switchMap((bundle: Bundle) => {
|
||||||
|
if (hasValue(bundle)) {
|
||||||
|
return bundle.item.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return observableOf(undefined);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return observableOf(undefined);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -20,8 +20,8 @@ import { getDSORoute } from '../../app-routing-paths';
|
|||||||
})
|
})
|
||||||
export class DSOBreadcrumbsService implements BreadcrumbsProviderService<ChildHALResource & DSpaceObject> {
|
export class DSOBreadcrumbsService implements BreadcrumbsProviderService<ChildHALResource & DSpaceObject> {
|
||||||
constructor(
|
constructor(
|
||||||
private linkService: LinkService,
|
protected linkService: LinkService,
|
||||||
private dsoNameService: DSONameService
|
protected dsoNameService: DSONameService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -78,6 +78,7 @@ describe(`DSONameService`, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe(`factories.Person`, () => {
|
describe(`factories.Person`, () => {
|
||||||
|
describe(`with person.familyName and person.givenName`, () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(mockPerson, 'firstMetadataValue').and.returnValues(...mockPersonName.split(', '));
|
spyOn(mockPerson, 'firstMetadataValue').and.returnValues(...mockPersonName.split(', '));
|
||||||
});
|
});
|
||||||
@@ -87,6 +88,22 @@ describe(`DSONameService`, () => {
|
|||||||
expect(result).toBe(mockPersonName);
|
expect(result).toBe(mockPersonName);
|
||||||
expect(mockPerson.firstMetadataValue).toHaveBeenCalledWith('person.familyName');
|
expect(mockPerson.firstMetadataValue).toHaveBeenCalledWith('person.familyName');
|
||||||
expect(mockPerson.firstMetadataValue).toHaveBeenCalledWith('person.givenName');
|
expect(mockPerson.firstMetadataValue).toHaveBeenCalledWith('person.givenName');
|
||||||
|
expect(mockPerson.firstMetadataValue).not.toHaveBeenCalledWith('dc.title');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(`without person.familyName and person.givenName`, () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(mockPerson, 'firstMetadataValue').and.returnValues(undefined, undefined, mockPersonName);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should return dc.title`, () => {
|
||||||
|
const result = (service as any).factories.Person(mockPerson);
|
||||||
|
expect(result).toBe(mockPersonName);
|
||||||
|
expect(mockPerson.firstMetadataValue).toHaveBeenCalledWith('person.familyName');
|
||||||
|
expect(mockPerson.firstMetadataValue).toHaveBeenCalledWith('person.givenName');
|
||||||
|
expect(mockPerson.firstMetadataValue).toHaveBeenCalledWith('dc.title');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { hasValue } from '../../shared/empty.util';
|
import { hasValue, isEmpty } from '../../shared/empty.util';
|
||||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
@@ -27,7 +27,13 @@ export class DSONameService {
|
|||||||
*/
|
*/
|
||||||
private readonly factories = {
|
private readonly factories = {
|
||||||
Person: (dso: DSpaceObject): string => {
|
Person: (dso: DSpaceObject): string => {
|
||||||
return `${dso.firstMetadataValue('person.familyName')}, ${dso.firstMetadataValue('person.givenName')}`;
|
const familyName = dso.firstMetadataValue('person.familyName');
|
||||||
|
const givenName = dso.firstMetadataValue('person.givenName');
|
||||||
|
if (isEmpty(familyName) && isEmpty(givenName)) {
|
||||||
|
return dso.firstMetadataValue('dc.title') || dso.name;
|
||||||
|
} else {
|
||||||
|
return `${familyName}, ${givenName}`;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
OrgUnit: (dso: DSpaceObject): string => {
|
OrgUnit: (dso: DSpaceObject): string => {
|
||||||
return dso.firstMetadataValue('organization.legalName');
|
return dso.firstMetadataValue('organization.legalName');
|
||||||
|
@@ -41,7 +41,7 @@ describe('objectCacheReducer', () => {
|
|||||||
alternativeLinks: [altLink1, altLink2],
|
alternativeLinks: [altLink1, altLink2],
|
||||||
timeCompleted: new Date().getTime(),
|
timeCompleted: new Date().getTime(),
|
||||||
msToLive: 900000,
|
msToLive: 900000,
|
||||||
requestUUID: requestUUID1,
|
requestUUIDs: [requestUUID1],
|
||||||
patches: [],
|
patches: [],
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
},
|
},
|
||||||
@@ -55,7 +55,7 @@ describe('objectCacheReducer', () => {
|
|||||||
alternativeLinks: [altLink3, altLink4],
|
alternativeLinks: [altLink3, altLink4],
|
||||||
timeCompleted: new Date().getTime(),
|
timeCompleted: new Date().getTime(),
|
||||||
msToLive: 900000,
|
msToLive: 900000,
|
||||||
requestUUID: selfLink2,
|
requestUUIDs: [selfLink2],
|
||||||
patches: [],
|
patches: [],
|
||||||
isDirty: false
|
isDirty: false
|
||||||
}
|
}
|
||||||
|
10
src/app/core/cache/object-cache.reducer.ts
vendored
10
src/app/core/cache/object-cache.reducer.ts
vendored
@@ -63,9 +63,11 @@ export class ObjectCacheEntry implements CacheEntry {
|
|||||||
msToLive: number;
|
msToLive: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The UUID of the request that caused this entry to be added
|
* The UUIDs of the requests that caused this entry to be added
|
||||||
|
* New UUIDs should be added to the front of the array
|
||||||
|
* to make retrieving the latest UUID easier.
|
||||||
*/
|
*/
|
||||||
requestUUID: string;
|
requestUUIDs: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of patches that were made on the client side to this entry, but haven't been sent to the server yet
|
* An array of patches that were made on the client side to this entry, but haven't been sent to the server yet
|
||||||
@@ -156,11 +158,11 @@ function addToObjectCache(state: ObjectCacheState, action: AddToObjectCacheActio
|
|||||||
data: action.payload.objectToCache,
|
data: action.payload.objectToCache,
|
||||||
timeCompleted: action.payload.timeCompleted,
|
timeCompleted: action.payload.timeCompleted,
|
||||||
msToLive: action.payload.msToLive,
|
msToLive: action.payload.msToLive,
|
||||||
requestUUID: action.payload.requestUUID,
|
requestUUIDs: [action.payload.requestUUID, ...(existing.requestUUIDs || [])],
|
||||||
isDirty: isNotEmpty(existing.patches),
|
isDirty: isNotEmpty(existing.patches),
|
||||||
patches: existing.patches || [],
|
patches: existing.patches || [],
|
||||||
alternativeLinks: [...(existing.alternativeLinks || []), ...newAltLinks]
|
alternativeLinks: [...(existing.alternativeLinks || []), ...newAltLinks]
|
||||||
}
|
} as ObjectCacheEntry
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
48
src/app/core/cache/object-cache.service.spec.ts
vendored
48
src/app/core/cache/object-cache.service.spec.ts
vendored
@@ -211,8 +211,8 @@ describe('ObjectCacheService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('has', () => {
|
describe('hasByHref', () => {
|
||||||
|
describe('with requestUUID not specified', () => {
|
||||||
describe('getByHref emits an object', () => {
|
describe('getByHref emits an object', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(service, 'getByHref').and.returnValue(observableOf(cacheEntry));
|
spyOn(service, 'getByHref').and.returnValue(observableOf(cacheEntry));
|
||||||
@@ -234,6 +234,50 @@ describe('ObjectCacheService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('with requestUUID specified', () => {
|
||||||
|
describe('getByHref emits an object that includes the specified requestUUID', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(service, 'getByHref').and.returnValue(observableOf(Object.assign(cacheEntry, {
|
||||||
|
requestUUIDs: [
|
||||||
|
'something',
|
||||||
|
'something-else',
|
||||||
|
'specific-request',
|
||||||
|
]
|
||||||
|
})));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true', () => {
|
||||||
|
expect(service.hasByHref(selfLink, 'specific-request')).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getByHref emits an object that doesn\'t include the specified requestUUID', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(service, 'getByHref').and.returnValue(observableOf(Object.assign(cacheEntry, {
|
||||||
|
requestUUIDs: [
|
||||||
|
'something',
|
||||||
|
'something-else',
|
||||||
|
]
|
||||||
|
})));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true', () => {
|
||||||
|
expect(service.hasByHref(selfLink, 'specific-request')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getByHref emits nothing', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(service, 'getByHref').and.returnValue(empty());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false', () => {
|
||||||
|
expect(service.hasByHref(selfLink, 'specific-request')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('getBySelfLink', () => {
|
describe('getBySelfLink', () => {
|
||||||
it('should return the entry returned by the select method', () => {
|
it('should return the entry returned by the select method', () => {
|
||||||
const state = Object.assign({}, initialState, {
|
const state = Object.assign({}, initialState, {
|
||||||
|
4
src/app/core/cache/object-cache.service.ts
vendored
4
src/app/core/cache/object-cache.service.ts
vendored
@@ -197,7 +197,7 @@ export class ObjectCacheService {
|
|||||||
*/
|
*/
|
||||||
getRequestUUIDBySelfLink(selfLink: string): Observable<string> {
|
getRequestUUIDBySelfLink(selfLink: string): Observable<string> {
|
||||||
return this.getByHref(selfLink).pipe(
|
return this.getByHref(selfLink).pipe(
|
||||||
map((entry: ObjectCacheEntry) => entry.requestUUID),
|
map((entry: ObjectCacheEntry) => entry.requestUUIDs[0]),
|
||||||
distinctUntilChanged());
|
distinctUntilChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ export class ObjectCacheService {
|
|||||||
let result = false;
|
let result = false;
|
||||||
this.getByHref(href).subscribe((entry: ObjectCacheEntry) => {
|
this.getByHref(href).subscribe((entry: ObjectCacheEntry) => {
|
||||||
if (isNotEmpty(requestUUID)) {
|
if (isNotEmpty(requestUUID)) {
|
||||||
result = entry.requestUUID === requestUUID;
|
result = entry.requestUUIDs.includes(requestUUID);
|
||||||
} else {
|
} else {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ import { SubmissionSectionModel } from './config/models/config-submission-sectio
|
|||||||
import { SubmissionUploadsModel } from './config/models/config-submission-uploads.model';
|
import { SubmissionUploadsModel } from './config/models/config-submission-uploads.model';
|
||||||
import { SubmissionFormsConfigService } from './config/submission-forms-config.service';
|
import { SubmissionFormsConfigService } from './config/submission-forms-config.service';
|
||||||
import { coreEffects } from './core.effects';
|
import { coreEffects } from './core.effects';
|
||||||
import { coreReducers} from './core.reducers';
|
import { coreReducers } from './core.reducers';
|
||||||
import { BitstreamFormatDataService } from './data/bitstream-format-data.service';
|
import { BitstreamFormatDataService } from './data/bitstream-format-data.service';
|
||||||
import { CollectionDataService } from './data/collection-data.service';
|
import { CollectionDataService } from './data/collection-data.service';
|
||||||
import { CommunityDataService } from './data/community-data.service';
|
import { CommunityDataService } from './data/community-data.service';
|
||||||
@@ -75,7 +75,6 @@ import { RegistryService } from './registry/registry.service';
|
|||||||
import { RoleService } from './roles/role.service';
|
import { RoleService } from './roles/role.service';
|
||||||
import { FeedbackDataService } from './feedback/feedback-data.service';
|
import { FeedbackDataService } from './feedback/feedback-data.service';
|
||||||
|
|
||||||
import { ApiService } from './services/api.service';
|
|
||||||
import { ServerResponseService } from './services/server-response.service';
|
import { ServerResponseService } from './services/server-response.service';
|
||||||
import { NativeWindowFactory, NativeWindowService } from './services/window.service';
|
import { NativeWindowFactory, NativeWindowService } from './services/window.service';
|
||||||
import { BitstreamFormat } from './shared/bitstream-format.model';
|
import { BitstreamFormat } from './shared/bitstream-format.model';
|
||||||
@@ -133,10 +132,15 @@ import { Feature } from './shared/feature.model';
|
|||||||
import { Authorization } from './shared/authorization.model';
|
import { Authorization } from './shared/authorization.model';
|
||||||
import { FeatureDataService } from './data/feature-authorization/feature-data.service';
|
import { FeatureDataService } from './data/feature-authorization/feature-data.service';
|
||||||
import { AuthorizationDataService } from './data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from './data/feature-authorization/authorization-data.service';
|
||||||
import { SiteAdministratorGuard } from './data/feature-authorization/feature-authorization-guard/site-administrator.guard';
|
import {
|
||||||
|
SiteAdministratorGuard
|
||||||
|
} from './data/feature-authorization/feature-authorization-guard/site-administrator.guard';
|
||||||
import { Registration } from './shared/registration.model';
|
import { Registration } from './shared/registration.model';
|
||||||
import { MetadataSchemaDataService } from './data/metadata-schema-data.service';
|
import { MetadataSchemaDataService } from './data/metadata-schema-data.service';
|
||||||
import { MetadataFieldDataService } from './data/metadata-field-data.service';
|
import { MetadataFieldDataService } from './data/metadata-field-data.service';
|
||||||
|
import {
|
||||||
|
DsDynamicTypeBindRelationService
|
||||||
|
} from '../shared/form/builder/ds-dynamic-form-ui/ds-dynamic-type-bind-relation.service';
|
||||||
import { TokenResponseParsingService } from './auth/token-response-parsing.service';
|
import { TokenResponseParsingService } from './auth/token-response-parsing.service';
|
||||||
import { SubmissionCcLicenseDataService } from './submission/submission-cc-license-data.service';
|
import { SubmissionCcLicenseDataService } from './submission/submission-cc-license-data.service';
|
||||||
import { SubmissionCcLicence } from './submission/models/submission-cc-license.model';
|
import { SubmissionCcLicence } from './submission/models/submission-cc-license.model';
|
||||||
@@ -163,6 +167,12 @@ import { SequenceService } from './shared/sequence.service';
|
|||||||
import { CoreState } from './core-state.model';
|
import { CoreState } from './core-state.model';
|
||||||
import { GroupDataService } from './eperson/group-data.service';
|
import { GroupDataService } from './eperson/group-data.service';
|
||||||
import { SubmissionAccessesModel } from './config/models/config-submission-accesses.model';
|
import { SubmissionAccessesModel } from './config/models/config-submission-accesses.model';
|
||||||
|
import { AccessStatusObject } from '../shared/object-list/access-status-badge/access-status.model';
|
||||||
|
import { AccessStatusDataService } from './data/access-status-data.service';
|
||||||
|
import { LinkHeadService } from './services/link-head.service';
|
||||||
|
import { ResearcherProfileService } from './profile/researcher-profile.service';
|
||||||
|
import { ProfileClaimService } from '../profile-page/profile-claim/profile-claim.service';
|
||||||
|
import { ResearcherProfile } from './profile/model/researcher-profile.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When not in production, endpoint responses can be mocked for testing purposes
|
* When not in production, endpoint responses can be mocked for testing purposes
|
||||||
@@ -187,7 +197,6 @@ const DECLARATIONS = [];
|
|||||||
const EXPORTS = [];
|
const EXPORTS = [];
|
||||||
|
|
||||||
const PROVIDERS = [
|
const PROVIDERS = [
|
||||||
ApiService,
|
|
||||||
AuthenticatedGuard,
|
AuthenticatedGuard,
|
||||||
CommunityDataService,
|
CommunityDataService,
|
||||||
CollectionDataService,
|
CollectionDataService,
|
||||||
@@ -202,6 +211,7 @@ const PROVIDERS = [
|
|||||||
SectionFormOperationsService,
|
SectionFormOperationsService,
|
||||||
FormService,
|
FormService,
|
||||||
EPersonDataService,
|
EPersonDataService,
|
||||||
|
LinkHeadService,
|
||||||
HALEndpointService,
|
HALEndpointService,
|
||||||
HostWindowService,
|
HostWindowService,
|
||||||
ItemDataService,
|
ItemDataService,
|
||||||
@@ -220,6 +230,7 @@ const PROVIDERS = [
|
|||||||
MyDSpaceResponseParsingService,
|
MyDSpaceResponseParsingService,
|
||||||
ServerResponseService,
|
ServerResponseService,
|
||||||
BrowseService,
|
BrowseService,
|
||||||
|
AccessStatusDataService,
|
||||||
SubmissionCcLicenseDataService,
|
SubmissionCcLicenseDataService,
|
||||||
SubmissionCcLicenseUrlDataService,
|
SubmissionCcLicenseUrlDataService,
|
||||||
SubmissionFormsConfigService,
|
SubmissionFormsConfigService,
|
||||||
@@ -250,6 +261,7 @@ const PROVIDERS = [
|
|||||||
ClaimedTaskDataService,
|
ClaimedTaskDataService,
|
||||||
PoolTaskDataService,
|
PoolTaskDataService,
|
||||||
BitstreamDataService,
|
BitstreamDataService,
|
||||||
|
DsDynamicTypeBindRelationService,
|
||||||
EntityTypeService,
|
EntityTypeService,
|
||||||
ContentSourceResponseParsingService,
|
ContentSourceResponseParsingService,
|
||||||
ItemTemplateDataService,
|
ItemTemplateDataService,
|
||||||
@@ -287,6 +299,8 @@ const PROVIDERS = [
|
|||||||
SequenceService,
|
SequenceService,
|
||||||
GroupDataService,
|
GroupDataService,
|
||||||
FeedbackDataService,
|
FeedbackDataService,
|
||||||
|
ResearcherProfileService,
|
||||||
|
ProfileClaimService
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -346,7 +360,9 @@ export const models =
|
|||||||
UsageReport,
|
UsageReport,
|
||||||
Root,
|
Root,
|
||||||
SearchConfig,
|
SearchConfig,
|
||||||
SubmissionAccessesModel
|
SubmissionAccessesModel,
|
||||||
|
AccessStatusObject,
|
||||||
|
ResearcherProfile
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
81
src/app/core/data/access-status-data.service.spec.ts
Normal file
81
src/app/core/data/access-status-data.service.spec.ts
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import { RequestService } from './request.service';
|
||||||
|
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
||||||
|
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
|
||||||
|
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||||
|
import { fakeAsync, tick } from '@angular/core/testing';
|
||||||
|
import { GetRequest } from './request.models';
|
||||||
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { RemoteData } from './remote-data';
|
||||||
|
import { hasNoValue } from '../../shared/empty.util';
|
||||||
|
import { AccessStatusDataService } from './access-status-data.service';
|
||||||
|
import { Item } from '../shared/item.model';
|
||||||
|
|
||||||
|
const url = 'fake-url';
|
||||||
|
|
||||||
|
describe('AccessStatusDataService', () => {
|
||||||
|
let service: AccessStatusDataService;
|
||||||
|
let requestService: RequestService;
|
||||||
|
let notificationsService: any;
|
||||||
|
let rdbService: RemoteDataBuildService;
|
||||||
|
let objectCache: ObjectCacheService;
|
||||||
|
let halService: any;
|
||||||
|
|
||||||
|
const itemId = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
||||||
|
const mockItem: Item = Object.assign(new Item(), {
|
||||||
|
id: itemId,
|
||||||
|
name: 'test-item',
|
||||||
|
_links: {
|
||||||
|
accessStatus: {
|
||||||
|
href: `https://rest.api/items/${itemId}/accessStatus`
|
||||||
|
},
|
||||||
|
self: {
|
||||||
|
href: `https://rest.api/items/${itemId}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the requests are successful', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
createService();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when calling findAccessStatusFor', () => {
|
||||||
|
let contentSource$;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
contentSource$ = service.findAccessStatusFor(mockItem);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should send a new GetRequest', fakeAsync(() => {
|
||||||
|
contentSource$.subscribe();
|
||||||
|
tick();
|
||||||
|
expect(requestService.send).toHaveBeenCalledWith(jasmine.any(GetRequest), true);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an AccessStatusDataService used for testing
|
||||||
|
* @param reponse$ Supply a RemoteData to be returned by the REST API (optional)
|
||||||
|
*/
|
||||||
|
function createService(reponse$?: Observable<RemoteData<any>>) {
|
||||||
|
requestService = getMockRequestService();
|
||||||
|
let buildResponse$ = reponse$;
|
||||||
|
if (hasNoValue(reponse$)) {
|
||||||
|
buildResponse$ = createSuccessfulRemoteDataObject$({});
|
||||||
|
}
|
||||||
|
rdbService = jasmine.createSpyObj('rdbService', {
|
||||||
|
buildFromRequestUUID: buildResponse$,
|
||||||
|
buildSingle: buildResponse$
|
||||||
|
});
|
||||||
|
objectCache = jasmine.createSpyObj('objectCache', {
|
||||||
|
remove: jasmine.createSpy('remove')
|
||||||
|
});
|
||||||
|
halService = new HALEndpointServiceStub(url);
|
||||||
|
notificationsService = new NotificationsServiceStub();
|
||||||
|
service = new AccessStatusDataService(null, halService, null, notificationsService, objectCache, rdbService, requestService, null);
|
||||||
|
}
|
||||||
|
});
|
45
src/app/core/data/access-status-data.service.ts
Normal file
45
src/app/core/data/access-status-data.service.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { dataService } from '../cache/builders/build-decorators';
|
||||||
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
|
import { DataService } from './data.service';
|
||||||
|
import { RequestService } from './request.service';
|
||||||
|
import { DefaultChangeAnalyzer } from './default-change-analyzer.service';
|
||||||
|
import { CoreState } from '../core-state.model';
|
||||||
|
import { AccessStatusObject } from 'src/app/shared/object-list/access-status-badge/access-status.model';
|
||||||
|
import { ACCESS_STATUS } from 'src/app/shared/object-list/access-status-badge/access-status.resource-type';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { RemoteData } from './remote-data';
|
||||||
|
import { Item } from '../shared/item.model';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
@dataService(ACCESS_STATUS)
|
||||||
|
export class AccessStatusDataService extends DataService<AccessStatusObject> {
|
||||||
|
|
||||||
|
protected linkPath = 'accessStatus';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected comparator: DefaultChangeAnalyzer<AccessStatusObject>,
|
||||||
|
protected halService: HALEndpointService,
|
||||||
|
protected http: HttpClient,
|
||||||
|
protected notificationsService: NotificationsService,
|
||||||
|
protected objectCache: ObjectCacheService,
|
||||||
|
protected rdbService: RemoteDataBuildService,
|
||||||
|
protected requestService: RequestService,
|
||||||
|
protected store: Store<CoreState>,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns {@link RemoteData} of {@link AccessStatusObject} that is the access status of the given item
|
||||||
|
* @param item Item we want the access status of
|
||||||
|
*/
|
||||||
|
findAccessStatusFor(item: Item): Observable<RemoteData<AccessStatusObject>> {
|
||||||
|
return this.findByHref(item._links.accessStatus.href);
|
||||||
|
}
|
||||||
|
}
|
@@ -37,7 +37,12 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
}
|
}
|
||||||
} as Store<CoreState>;
|
} as Store<CoreState>;
|
||||||
|
|
||||||
const objectCache = {} as ObjectCacheService;
|
const requestUUIDs = ['some', 'uuid'];
|
||||||
|
|
||||||
|
const objectCache = jasmine.createSpyObj('objectCache', {
|
||||||
|
getByHref: observableOf({ requestUUIDs })
|
||||||
|
}) as ObjectCacheService;
|
||||||
|
|
||||||
const halEndpointService = {
|
const halEndpointService = {
|
||||||
getEndpoint(linkPath: string): Observable<string> {
|
getEndpoint(linkPath: string): Observable<string> {
|
||||||
return cold('a', { a: bitstreamFormatsEndpoint });
|
return cold('a', { a: bitstreamFormatsEndpoint });
|
||||||
@@ -76,6 +81,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -96,6 +102,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -118,6 +125,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -139,6 +147,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -163,6 +172,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -186,6 +196,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -209,6 +220,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -231,6 +243,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -253,6 +266,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: cold('a', { a: responseCacheEntry }),
|
getByUUID: cold('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
@@ -273,6 +287,7 @@ describe('BitstreamFormatDataService', () => {
|
|||||||
send: {},
|
send: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: hot('a', { a: responseCacheEntry }),
|
getByUUID: hot('a', { a: responseCacheEntry }),
|
||||||
|
setStaleByUUID: observableOf(true),
|
||||||
generateRequestId: 'request-id',
|
generateRequestId: 'request-id',
|
||||||
removeByHrefSubstring: {}
|
removeByHrefSubstring: {}
|
||||||
});
|
});
|
||||||
|
@@ -22,6 +22,7 @@ import {
|
|||||||
import { BitstreamDataService } from './bitstream-data.service';
|
import { BitstreamDataService } from './bitstream-data.service';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import { FindListOptions } from './find-list-options.model';
|
import { FindListOptions } from './find-list-options.model';
|
||||||
|
import { Bitstream } from '../shared/bitstream.model';
|
||||||
|
|
||||||
const LINK_NAME = 'test';
|
const LINK_NAME = 'test';
|
||||||
|
|
||||||
@@ -244,4 +245,75 @@ describe('ComColDataService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('deleteLogo', () => {
|
||||||
|
let dso;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
dso = {
|
||||||
|
_links: {
|
||||||
|
logo: {
|
||||||
|
href: 'logo-href'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when DSO has no logo', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
dso.logo = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a failed RD', (done) => {
|
||||||
|
service.deleteLogo(dso).subscribe(rd => {
|
||||||
|
expect(rd.hasFailed).toBeTrue();
|
||||||
|
expect(bitstreamDataService.deleteByHref).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when DSO has a logo', () => {
|
||||||
|
let logo;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
logo = Object.assign(new Bitstream, {
|
||||||
|
id: 'logo-id',
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'logo-href',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('that can be retrieved', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
dso.logo = createSuccessfulRemoteDataObject$(logo);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call BitstreamDataService.deleteByHref', (done) => {
|
||||||
|
service.deleteLogo(dso).subscribe(rd => {
|
||||||
|
expect(rd.hasSucceeded).toBeTrue();
|
||||||
|
expect(bitstreamDataService.deleteByHref).toHaveBeenCalledWith('logo-href');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('that cannot be retrieved', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
dso.logo = createFailedRemoteDataObject$(logo);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not call BitstreamDataService.deleteByHref', (done) => {
|
||||||
|
service.deleteLogo(dso).subscribe(rd => {
|
||||||
|
expect(rd.hasFailed).toBeTrue();
|
||||||
|
expect(bitstreamDataService.deleteByHref).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -11,7 +11,11 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
|||||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import {
|
||||||
|
createFailedRemoteDataObject,
|
||||||
|
createSuccessfulRemoteDataObject,
|
||||||
|
createSuccessfulRemoteDataObject$,
|
||||||
|
} from '../../shared/remote-data.utils';
|
||||||
import { ChangeAnalyzer } from './change-analyzer';
|
import { ChangeAnalyzer } from './change-analyzer';
|
||||||
import { DataService } from './data.service';
|
import { DataService } from './data.service';
|
||||||
import { PatchRequest } from './request.models';
|
import { PatchRequest } from './request.models';
|
||||||
@@ -25,9 +29,12 @@ import { RemoteData } from './remote-data';
|
|||||||
import { RequestEntryState } from './request-entry-state.model';
|
import { RequestEntryState } from './request-entry-state.model';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import { FindListOptions } from './find-list-options.model';
|
import { FindListOptions } from './find-list-options.model';
|
||||||
|
import { fakeAsync, tick } from '@angular/core/testing';
|
||||||
|
|
||||||
const endpoint = 'https://rest.api/core';
|
const endpoint = 'https://rest.api/core';
|
||||||
|
|
||||||
|
const BOOLEAN = { f: false, t: true };
|
||||||
|
|
||||||
class TestService extends DataService<any> {
|
class TestService extends DataService<any> {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -86,6 +93,9 @@ describe('DataService', () => {
|
|||||||
},
|
},
|
||||||
getObjectBySelfLink: () => {
|
getObjectBySelfLink: () => {
|
||||||
/* empty */
|
/* empty */
|
||||||
|
},
|
||||||
|
getByHref: () => {
|
||||||
|
/* empty */
|
||||||
}
|
}
|
||||||
} as any;
|
} as any;
|
||||||
store = {} as Store<CoreState>;
|
store = {} as Store<CoreState>;
|
||||||
@@ -833,4 +843,149 @@ describe('DataService', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('invalidateByHref', () => {
|
||||||
|
let getByHrefSpy: jasmine.Spy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
getByHrefSpy = spyOn(objectCache, 'getByHref').and.returnValue(observableOf({
|
||||||
|
requestUUIDs: ['request1', 'request2', 'request3']
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call setStaleByUUID for every request associated with this DSO', (done) => {
|
||||||
|
service.invalidateByHref('some-href').subscribe((ok) => {
|
||||||
|
expect(ok).toBeTrue();
|
||||||
|
expect(getByHrefSpy).toHaveBeenCalledWith('some-href');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call setStaleByUUID even if not subscribing to returned Observable', fakeAsync(() => {
|
||||||
|
service.invalidateByHref('some-href');
|
||||||
|
tick();
|
||||||
|
|
||||||
|
expect(getByHrefSpy).toHaveBeenCalledWith('some-href');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request1');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request2');
|
||||||
|
expect(requestService.setStaleByUUID).toHaveBeenCalledWith('request3');
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should return an Observable that only emits true once all requests are stale', () => {
|
||||||
|
testScheduler.run(({ cold, expectObservable }) => {
|
||||||
|
requestService.setStaleByUUID.and.callFake((uuid) => {
|
||||||
|
switch (uuid) { // fake requests becoming stale at different times
|
||||||
|
case 'request1':
|
||||||
|
return cold('--(t|)', BOOLEAN);
|
||||||
|
case 'request2':
|
||||||
|
return cold('----(t|)', BOOLEAN);
|
||||||
|
case 'request3':
|
||||||
|
return cold('------(t|)', BOOLEAN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const done$ = service.invalidateByHref('some-href');
|
||||||
|
|
||||||
|
// emit true as soon as the final request is stale
|
||||||
|
expectObservable(done$).toBe('------(t|)', BOOLEAN);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('delete', () => {
|
||||||
|
let MOCK_SUCCEEDED_RD;
|
||||||
|
let MOCK_FAILED_RD;
|
||||||
|
|
||||||
|
let invalidateByHrefSpy: jasmine.Spy;
|
||||||
|
let buildFromRequestUUIDSpy: jasmine.Spy;
|
||||||
|
let getIDHrefObsSpy: jasmine.Spy;
|
||||||
|
let deleteByHrefSpy: jasmine.Spy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
invalidateByHrefSpy = spyOn(service, 'invalidateByHref').and.returnValue(observableOf(true));
|
||||||
|
buildFromRequestUUIDSpy = spyOn(rdbService, 'buildFromRequestUUID').and.callThrough();
|
||||||
|
getIDHrefObsSpy = spyOn(service, 'getIDHrefObs').and.callThrough();
|
||||||
|
deleteByHrefSpy = spyOn(service, 'deleteByHref').and.callThrough();
|
||||||
|
|
||||||
|
MOCK_SUCCEEDED_RD = createSuccessfulRemoteDataObject({});
|
||||||
|
MOCK_FAILED_RD = createFailedRemoteDataObject('something went wrong');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should retrieve href by ID and call deleteByHref', () => {
|
||||||
|
getIDHrefObsSpy.and.returnValue(observableOf('some-href'));
|
||||||
|
buildFromRequestUUIDSpy.and.returnValue(createSuccessfulRemoteDataObject$({}));
|
||||||
|
|
||||||
|
service.delete('some-id', ['a', 'b', 'c']).subscribe(rd => {
|
||||||
|
expect(getIDHrefObsSpy).toHaveBeenCalledWith('some-id');
|
||||||
|
expect(deleteByHrefSpy).toHaveBeenCalledWith('some-href', ['a', 'b', 'c']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('deleteByHref', () => {
|
||||||
|
it('should call invalidateByHref if the DELETE request succeeds', (done) => {
|
||||||
|
buildFromRequestUUIDSpy.and.returnValue(observableOf(MOCK_SUCCEEDED_RD));
|
||||||
|
|
||||||
|
service.deleteByHref('some-href').subscribe(rd => {
|
||||||
|
expect(rd).toBe(MOCK_SUCCEEDED_RD);
|
||||||
|
expect(invalidateByHrefSpy).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call invalidateByHref even if not subscribing to returned Observable', fakeAsync(() => {
|
||||||
|
buildFromRequestUUIDSpy.and.returnValue(observableOf(MOCK_SUCCEEDED_RD));
|
||||||
|
|
||||||
|
service.deleteByHref('some-href');
|
||||||
|
tick();
|
||||||
|
|
||||||
|
expect(invalidateByHrefSpy).toHaveBeenCalled();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not call invalidateByHref if the DELETE request fails', (done) => {
|
||||||
|
buildFromRequestUUIDSpy.and.returnValue(observableOf(MOCK_FAILED_RD));
|
||||||
|
|
||||||
|
service.deleteByHref('some-href').subscribe(rd => {
|
||||||
|
expect(rd).toBe(MOCK_FAILED_RD);
|
||||||
|
expect(invalidateByHrefSpy).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should wait for invalidateByHref before emitting', () => {
|
||||||
|
testScheduler.run(({ cold, expectObservable }) => {
|
||||||
|
buildFromRequestUUIDSpy.and.returnValue(
|
||||||
|
cold('(r|)', { r: MOCK_SUCCEEDED_RD}) // RD emits right away
|
||||||
|
);
|
||||||
|
invalidateByHrefSpy.and.returnValue(
|
||||||
|
cold('----(t|)', BOOLEAN) // but we pretend that setting requests to stale takes longer
|
||||||
|
);
|
||||||
|
|
||||||
|
const done$ = service.deleteByHref('some-href');
|
||||||
|
expectObservable(done$).toBe(
|
||||||
|
'----(r|)', { r: MOCK_SUCCEEDED_RD} // ...and expect the returned Observable to wait until that's done
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should wait for the DELETE request to resolve before emitting', () => {
|
||||||
|
testScheduler.run(({ cold, expectObservable }) => {
|
||||||
|
buildFromRequestUUIDSpy.and.returnValue(
|
||||||
|
cold('----(r|)', { r: MOCK_SUCCEEDED_RD}) // the request takes a while
|
||||||
|
);
|
||||||
|
invalidateByHrefSpy.and.returnValue(
|
||||||
|
cold('(t|)', BOOLEAN) // but we pretend that setting to stale happens sooner
|
||||||
|
); // e.g.: maybe already stale before this call?
|
||||||
|
|
||||||
|
const done$ = service.deleteByHref('some-href');
|
||||||
|
expectObservable(done$).toBe(
|
||||||
|
'----(r|)', { r: MOCK_SUCCEEDED_RD} // ...and expect the returned Observable to wait for the request
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,18 +1,19 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { AsyncSubject, combineLatest, from as observableFrom, Observable, of as observableOf } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
filter,
|
filter,
|
||||||
find,
|
find,
|
||||||
map,
|
map,
|
||||||
mergeMap,
|
mergeMap,
|
||||||
|
skipWhile,
|
||||||
|
switchMap,
|
||||||
take,
|
take,
|
||||||
takeWhile,
|
takeWhile,
|
||||||
switchMap,
|
|
||||||
tap,
|
tap,
|
||||||
skipWhile,
|
toArray
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
|
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
|
||||||
import { NotificationOptions } from '../../shared/notifications/models/notification-options.model';
|
import { NotificationOptions } from '../../shared/notifications/models/notification-options.model';
|
||||||
@@ -21,22 +22,17 @@ import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
|||||||
import { getClassForType } from '../cache/builders/build-decorators';
|
import { getClassForType } from '../cache/builders/build-decorators';
|
||||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
import { RequestParam } from '../cache/models/request-param.model';
|
import { RequestParam } from '../cache/models/request-param.model';
|
||||||
|
import { ObjectCacheEntry } from '../cache/object-cache.reducer';
|
||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
import { DSpaceSerializer } from '../dspace-rest/dspace.serializer';
|
import { DSpaceSerializer } from '../dspace-rest/dspace.serializer';
|
||||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
import { getRemoteDataPayload, getFirstSucceededRemoteData, } from '../shared/operators';
|
import { getFirstCompletedRemoteData, getFirstSucceededRemoteData, getRemoteDataPayload } from '../shared/operators';
|
||||||
import { URLCombiner } from '../url-combiner/url-combiner';
|
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||||
import { ChangeAnalyzer } from './change-analyzer';
|
import { ChangeAnalyzer } from './change-analyzer';
|
||||||
import { PaginatedList } from './paginated-list.model';
|
import { PaginatedList } from './paginated-list.model';
|
||||||
import { RemoteData } from './remote-data';
|
import { RemoteData } from './remote-data';
|
||||||
import {
|
import { CreateRequest, DeleteRequest, GetRequest, PatchRequest, PutRequest } from './request.models';
|
||||||
CreateRequest,
|
|
||||||
GetRequest,
|
|
||||||
PatchRequest,
|
|
||||||
PutRequest,
|
|
||||||
DeleteRequest
|
|
||||||
} from './request.models';
|
|
||||||
import { RequestService } from './request.service';
|
import { RequestService } from './request.service';
|
||||||
import { RestRequestMethod } from './rest-request-method';
|
import { RestRequestMethod } from './rest-request-method';
|
||||||
import { UpdateDataService } from './update-data.service';
|
import { UpdateDataService } from './update-data.service';
|
||||||
@@ -168,7 +164,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
* @return {Observable<string>}
|
* @return {Observable<string>}
|
||||||
* Return an observable that emits created HREF
|
* Return an observable that emits created HREF
|
||||||
*/
|
*/
|
||||||
protected buildHrefWithParams(href: string, params: RequestParam[], ...linksToFollow: FollowLinkConfig<T>[]): string {
|
buildHrefWithParams(href: string, params: RequestParam[], ...linksToFollow: FollowLinkConfig<T>[]): string {
|
||||||
|
|
||||||
let args = [];
|
let args = [];
|
||||||
if (hasValue(params)) {
|
if (hasValue(params)) {
|
||||||
@@ -579,6 +575,38 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
return result$;
|
return result$;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidate an existing DSpaceObject by marking all requests it is included in as stale
|
||||||
|
* @param objectId The id of the object to be invalidated
|
||||||
|
* @return An Observable that will emit `true` once all requests are stale
|
||||||
|
*/
|
||||||
|
invalidate(objectId: string): Observable<boolean> {
|
||||||
|
return this.getIDHrefObs(objectId).pipe(
|
||||||
|
switchMap((href: string) => this.invalidateByHref(href))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidate an existing DSpaceObject by marking all requests it is included in as stale
|
||||||
|
* @param href The self link of the object to be invalidated
|
||||||
|
* @return An Observable that will emit `true` once all requests are stale
|
||||||
|
*/
|
||||||
|
invalidateByHref(href: string): Observable<boolean> {
|
||||||
|
const done$ = new AsyncSubject<boolean>();
|
||||||
|
|
||||||
|
this.objectCache.getByHref(href).pipe(
|
||||||
|
switchMap((oce: ObjectCacheEntry) => observableFrom(oce.requestUUIDs).pipe(
|
||||||
|
mergeMap((requestUUID: string) => this.requestService.setStaleByUUID(requestUUID)),
|
||||||
|
toArray(),
|
||||||
|
)),
|
||||||
|
).subscribe(() => {
|
||||||
|
done$.next(true);
|
||||||
|
done$.complete();
|
||||||
|
});
|
||||||
|
|
||||||
|
return done$;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an existing DSpace Object on the server
|
* Delete an existing DSpace Object on the server
|
||||||
* @param objectId The id of the object to be removed
|
* @param objectId The id of the object to be removed
|
||||||
@@ -600,6 +628,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
* metadata should be saved as real metadata
|
* metadata should be saved as real metadata
|
||||||
* @return A RemoteData observable with an empty payload, but still representing the state of the request: statusCode,
|
* @return A RemoteData observable with an empty payload, but still representing the state of the request: statusCode,
|
||||||
* errorMessage, timeCompleted, etc
|
* errorMessage, timeCompleted, etc
|
||||||
|
* Only emits once all request related to the DSO has been invalidated.
|
||||||
*/
|
*/
|
||||||
deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||||
const requestId = this.requestService.generateRequestId();
|
const requestId = this.requestService.generateRequestId();
|
||||||
@@ -618,7 +647,27 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
|||||||
}
|
}
|
||||||
this.requestService.send(request);
|
this.requestService.send(request);
|
||||||
|
|
||||||
return this.rdbService.buildFromRequestUUID(requestId);
|
const response$ = this.rdbService.buildFromRequestUUID(requestId);
|
||||||
|
|
||||||
|
const invalidated$ = new AsyncSubject<boolean>();
|
||||||
|
response$.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
switchMap((rd: RemoteData<NoContent>) => {
|
||||||
|
if (rd.hasSucceeded) {
|
||||||
|
return this.invalidateByHref(href);
|
||||||
|
} else {
|
||||||
|
return [true];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).subscribe(() => {
|
||||||
|
invalidated$.next(true);
|
||||||
|
invalidated$.complete();
|
||||||
|
});
|
||||||
|
|
||||||
|
return combineLatest([response$, invalidated$]).pipe(
|
||||||
|
filter(([_, invalidated]) => invalidated),
|
||||||
|
map(([response, _]) => response),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -65,9 +65,13 @@ export class AuthorizationDataService extends DataService<Authorization> {
|
|||||||
* @param ePersonUuid UUID of the {@link EPerson} to search {@link Authorization}s for.
|
* @param ePersonUuid UUID of the {@link EPerson} to search {@link Authorization}s for.
|
||||||
* If not provided, the UUID of the currently authenticated {@link EPerson} will be used.
|
* If not provided, the UUID of the currently authenticated {@link EPerson} will be used.
|
||||||
* @param featureId ID of the {@link Feature} to check {@link Authorization} for
|
* @param featureId ID of the {@link Feature} to check {@link Authorization} for
|
||||||
|
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
|
||||||
|
* no valid cached version. Defaults to true
|
||||||
|
* @param reRequestOnStale Whether or not the request should automatically be re-
|
||||||
|
* requested after the response becomes stale
|
||||||
*/
|
*/
|
||||||
isAuthorized(featureId?: FeatureID, objectUrl?: string, ePersonUuid?: string): Observable<boolean> {
|
isAuthorized(featureId?: FeatureID, objectUrl?: string, ePersonUuid?: string, useCachedVersionIfAvailable = true, reRequestOnStale = true): Observable<boolean> {
|
||||||
return this.searchByObject(featureId, objectUrl, ePersonUuid, {}, true, true, followLink('feature')).pipe(
|
return this.searchByObject(featureId, objectUrl, ePersonUuid, {}, useCachedVersionIfAvailable, reRequestOnStale, followLink('feature')).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
map((authorizationRD) => {
|
map((authorizationRD) => {
|
||||||
if (authorizationRD.statusCode !== 401 && hasValue(authorizationRD.payload) && isNotEmpty(authorizationRD.payload.page)) {
|
if (authorizationRD.statusCode !== 401 && hasValue(authorizationRD.payload) && isNotEmpty(authorizationRD.payload.page)) {
|
||||||
|
@@ -28,4 +28,6 @@ export enum FeatureID {
|
|||||||
CanCreateVersion = 'canCreateVersion',
|
CanCreateVersion = 'canCreateVersion',
|
||||||
CanViewUsageStatistics = 'canViewUsageStatistics',
|
CanViewUsageStatistics = 'canViewUsageStatistics',
|
||||||
CanSendFeedback = 'canSendFeedback',
|
CanSendFeedback = 'canSendFeedback',
|
||||||
|
CanClaimItem = 'canClaimItem',
|
||||||
|
CanSynchronizeWithORCID = 'canSynchronizeWithORCID'
|
||||||
}
|
}
|
||||||
|
@@ -10,12 +10,13 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
|||||||
import { RestResponse } from '../cache/response.models';
|
import { RestResponse } from '../cache/response.models';
|
||||||
import { ExternalSourceEntry } from '../shared/external-source-entry.model';
|
import { ExternalSourceEntry } from '../shared/external-source-entry.model';
|
||||||
import { ItemDataService } from './item-data.service';
|
import { ItemDataService } from './item-data.service';
|
||||||
import { DeleteRequest, PostRequest } from './request.models';
|
import { DeleteRequest, GetRequest, PostRequest } from './request.models';
|
||||||
import { RequestService } from './request.service';
|
import { RequestService } from './request.service';
|
||||||
import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock';
|
import { getMockRemoteDataBuildService } from '../../shared/mocks/remote-data-build.service.mock';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import { RequestEntry } from './request-entry.model';
|
import { RequestEntry } from './request-entry.model';
|
||||||
import { FindListOptions } from './find-list-options.model';
|
import { FindListOptions } from './find-list-options.model';
|
||||||
|
import { HALEndpointServiceStub } from 'src/app/shared/testing/hal-endpoint-service.stub';
|
||||||
|
|
||||||
describe('ItemDataService', () => {
|
describe('ItemDataService', () => {
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
@@ -36,13 +37,11 @@ describe('ItemDataService', () => {
|
|||||||
}) as RequestService;
|
}) as RequestService;
|
||||||
const rdbService = getMockRemoteDataBuildService();
|
const rdbService = getMockRemoteDataBuildService();
|
||||||
|
|
||||||
const itemEndpoint = 'https://rest.api/core/items';
|
const itemEndpoint = 'https://rest.api/core';
|
||||||
|
|
||||||
const store = {} as Store<CoreState>;
|
const store = {} as Store<CoreState>;
|
||||||
const objectCache = {} as ObjectCacheService;
|
const objectCache = {} as ObjectCacheService;
|
||||||
const halEndpointService = jasmine.createSpyObj('halService', {
|
const halEndpointService: any = new HALEndpointServiceStub(itemEndpoint);
|
||||||
getEndpoint: observableOf(itemEndpoint)
|
|
||||||
});
|
|
||||||
const bundleService = jasmine.createSpyObj('bundleService', {
|
const bundleService = jasmine.createSpyObj('bundleService', {
|
||||||
findByHref: {}
|
findByHref: {}
|
||||||
});
|
});
|
||||||
|
@@ -8,7 +8,7 @@ import { defaultUUID, getMockUUIDService } from '../../shared/mocks/uuid.service
|
|||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
import { coreReducers} from '../core.reducers';
|
import { coreReducers} from '../core.reducers';
|
||||||
import { UUIDService } from '../shared/uuid.service';
|
import { UUIDService } from '../shared/uuid.service';
|
||||||
import { RequestConfigureAction, RequestExecuteAction } from './request.actions';
|
import { RequestConfigureAction, RequestExecuteAction, RequestStaleAction } from './request.actions';
|
||||||
import {
|
import {
|
||||||
DeleteRequest,
|
DeleteRequest,
|
||||||
GetRequest,
|
GetRequest,
|
||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
PutRequest
|
PutRequest
|
||||||
} from './request.models';
|
} from './request.models';
|
||||||
import { RequestService } from './request.service';
|
import { RequestService } from './request.service';
|
||||||
import { TestBed, waitForAsync } from '@angular/core/testing';
|
import { fakeAsync, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { storeModuleConfig } from '../../app.reducer';
|
import { storeModuleConfig } from '../../app.reducer';
|
||||||
import { MockStore, provideMockStore } from '@ngrx/store/testing';
|
import { MockStore, provideMockStore } from '@ngrx/store/testing';
|
||||||
import { RequestEntryState } from './request-entry-state.model';
|
import { RequestEntryState } from './request-entry-state.model';
|
||||||
@@ -426,7 +426,7 @@ describe('RequestService', () => {
|
|||||||
describe('and it is cached', () => {
|
describe('and it is cached', () => {
|
||||||
describe('in the ObjectCache', () => {
|
describe('in the ObjectCache', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(objectCache.getByHref as any).and.returnValue(observableOf({ requestUUID: 'some-uuid' }));
|
(objectCache.getByHref as any).and.returnValue(observableOf({ requestUUIDs: ['some-uuid'] }));
|
||||||
spyOn(serviceAsAny, 'hasByHref').and.returnValue(false);
|
spyOn(serviceAsAny, 'hasByHref').and.returnValue(false);
|
||||||
spyOn(serviceAsAny, 'hasByUUID').and.returnValue(true);
|
spyOn(serviceAsAny, 'hasByUUID').and.returnValue(true);
|
||||||
});
|
});
|
||||||
@@ -596,4 +596,33 @@ describe('RequestService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('setStaleByUUID', () => {
|
||||||
|
let dispatchSpy: jasmine.Spy;
|
||||||
|
let getByUUIDSpy: jasmine.Spy;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
dispatchSpy = spyOn(store, 'dispatch');
|
||||||
|
getByUUIDSpy = spyOn(service, 'getByUUID').and.callThrough();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should dispatch a RequestStaleAction', () => {
|
||||||
|
service.setStaleByUUID('something');
|
||||||
|
const firstAction = dispatchSpy.calls.argsFor(0)[0];
|
||||||
|
expect(firstAction).toBeInstanceOf(RequestStaleAction);
|
||||||
|
expect(firstAction.payload).toEqual({ uuid: 'something' });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return an Observable that emits true as soon as the request is stale', fakeAsync(() => {
|
||||||
|
dispatchSpy.and.callFake(() => { /* empty */ }); // don't actually set as stale
|
||||||
|
getByUUIDSpy.and.returnValue(cold('a-b--c--d-', { // but fake the state in the cache
|
||||||
|
a: { state: RequestEntryState.ResponsePending },
|
||||||
|
b: { state: RequestEntryState.Success },
|
||||||
|
c: { state: RequestEntryState.SuccessStale },
|
||||||
|
d: { state: RequestEntryState.Error },
|
||||||
|
}));
|
||||||
|
|
||||||
|
const done$ = service.setStaleByUUID('something');
|
||||||
|
expect(done$).toBeObservable(cold('-----(t|)', { t: true }));
|
||||||
|
}));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -311,6 +311,21 @@ export class RequestService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark a request as stale
|
||||||
|
* @param uuid the UUID of the request
|
||||||
|
* @return an Observable that will emit true once the Request becomes stale
|
||||||
|
*/
|
||||||
|
setStaleByUUID(uuid: string): Observable<boolean> {
|
||||||
|
this.store.dispatch(new RequestStaleAction(uuid));
|
||||||
|
|
||||||
|
return this.getByUUID(uuid).pipe(
|
||||||
|
map((request: RequestEntry) => isStale(request.state)),
|
||||||
|
filter((stale: boolean) => stale),
|
||||||
|
take(1),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a GET request is in the cache or if it's still pending
|
* Check if a GET request is in the cache or if it's still pending
|
||||||
* @param {GetRequest} request The request to check
|
* @param {GetRequest} request The request to check
|
||||||
@@ -339,7 +354,7 @@ export class RequestService {
|
|||||||
.subscribe((entry: ObjectCacheEntry) => {
|
.subscribe((entry: ObjectCacheEntry) => {
|
||||||
// if the object cache has a match, check if the request that the object came with is
|
// if the object cache has a match, check if the request that the object came with is
|
||||||
// still valid
|
// still valid
|
||||||
inObjCache = this.hasByUUID(entry.requestUUID);
|
inObjCache = this.hasByUUID(entry.requestUUIDs[0]);
|
||||||
}).unsubscribe();
|
}).unsubscribe();
|
||||||
|
|
||||||
// we should send the request if it isn't cached
|
// we should send the request if it isn't cached
|
||||||
|
@@ -151,7 +151,7 @@ describe('VersionHistoryDataService', () => {
|
|||||||
describe('when getVersionsEndpoint is called', () => {
|
describe('when getVersionsEndpoint is called', () => {
|
||||||
it('should return the correct value', () => {
|
it('should return the correct value', () => {
|
||||||
service.getVersionsEndpoint(versionHistoryId).subscribe((res) => {
|
service.getVersionsEndpoint(versionHistoryId).subscribe((res) => {
|
||||||
expect(res).toBe(url + '/versions');
|
expect(res).toBe(url + '/versionhistories/version-history-id/versions');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -21,7 +21,7 @@ import { EPersonDataService } from './eperson-data.service';
|
|||||||
import { EPerson } from './models/eperson.model';
|
import { EPerson } from './models/eperson.model';
|
||||||
import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson.mock';
|
import { EPersonMock, EPersonMock2 } from '../../shared/testing/eperson.mock';
|
||||||
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
|
import { HALEndpointServiceStub } from '../../shared/testing/hal-endpoint-service.stub';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import { createNoContentRemoteDataObject$, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/remote-data-build.service.mock';
|
import { getMockRemoteDataBuildServiceHrefMap } from '../../shared/mocks/remote-data-build.service.mock';
|
||||||
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
|
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
|
||||||
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
||||||
@@ -287,13 +287,12 @@ describe('EPersonDataService', () => {
|
|||||||
|
|
||||||
describe('deleteEPerson', () => {
|
describe('deleteEPerson', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(service, 'findById').and.returnValue(createSuccessfulRemoteDataObject$(EPersonMock));
|
spyOn(service, 'delete').and.returnValue(createNoContentRemoteDataObject$());
|
||||||
service.deleteEPerson(EPersonMock).subscribe();
|
service.deleteEPerson(EPersonMock).subscribe();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send DeleteRequest', () => {
|
it('should call DataService.delete with the EPerson\'s UUID', () => {
|
||||||
const expected = new DeleteRequest(requestService.generateRequestId(), epersonsEndpoint + '/' + EPersonMock.uuid);
|
expect(service.delete).toHaveBeenCalledWith(EPersonMock.id);
|
||||||
expect(requestService.send).toHaveBeenCalledWith(expected);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -192,7 +192,7 @@ export class LocaleService {
|
|||||||
this.routeService.getCurrentUrl().pipe(take(1)).subscribe((currentURL) => {
|
this.routeService.getCurrentUrl().pipe(take(1)).subscribe((currentURL) => {
|
||||||
// Hard redirect to the reload page with a unique number behind it
|
// Hard redirect to the reload page with a unique number behind it
|
||||||
// so that all state is definitely lost
|
// so that all state is definitely lost
|
||||||
this._window.nativeWindow.location.href = `/reload/${new Date().getTime()}?redirect=` + encodeURIComponent(currentURL);
|
this._window.nativeWindow.location.href = `reload/${new Date().getTime()}?redirect=` + encodeURIComponent(currentURL);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -163,6 +163,22 @@ describe('MetadataService', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('route titles should overwrite dso titles', fakeAsync(() => {
|
||||||
|
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Translated Route Title'));
|
||||||
|
(metadataService as any).processRouteChange({
|
||||||
|
data: {
|
||||||
|
value: {
|
||||||
|
dso: createSuccessfulRemoteDataObject(ItemMock),
|
||||||
|
title: 'route.title.key',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tick();
|
||||||
|
expect(title.setTitle).toHaveBeenCalledTimes(2);
|
||||||
|
expect((title.setTitle as jasmine.Spy).calls.argsFor(0)).toEqual(['Test PowerPoint Document']);
|
||||||
|
expect((title.setTitle as jasmine.Spy).calls.argsFor(1)).toEqual(['DSpace :: Translated Route Title']);
|
||||||
|
}));
|
||||||
|
|
||||||
it('other navigation should add title and description', fakeAsync(() => {
|
it('other navigation should add title and description', fakeAsync(() => {
|
||||||
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Dummy Title'), of('This is a dummy item component for testing!'));
|
(translateService.get as jasmine.Spy).and.returnValues(of('DSpace :: '), of('Dummy Title'), of('This is a dummy item component for testing!'));
|
||||||
(metadataService as any).processRouteChange({
|
(metadataService as any).processRouteChange({
|
||||||
|
@@ -109,6 +109,11 @@ export class MetadataService {
|
|||||||
private processRouteChange(routeInfo: any): void {
|
private processRouteChange(routeInfo: any): void {
|
||||||
this.clearMetaTags();
|
this.clearMetaTags();
|
||||||
|
|
||||||
|
if (hasValue(routeInfo.data.value.dso) && hasValue(routeInfo.data.value.dso.payload)) {
|
||||||
|
this.currentObject.next(routeInfo.data.value.dso.payload);
|
||||||
|
this.setDSOMetaTags();
|
||||||
|
}
|
||||||
|
|
||||||
if (routeInfo.data.value.title) {
|
if (routeInfo.data.value.title) {
|
||||||
const titlePrefix = this.translate.get('repository.title.prefix');
|
const titlePrefix = this.translate.get('repository.title.prefix');
|
||||||
const title = this.translate.get(routeInfo.data.value.title, routeInfo.data.value);
|
const title = this.translate.get(routeInfo.data.value.title, routeInfo.data.value);
|
||||||
@@ -122,11 +127,6 @@ export class MetadataService {
|
|||||||
this.addMetaTag('description', translatedDescription);
|
this.addMetaTag('description', translatedDescription);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasValue(routeInfo.data.value.dso) && hasValue(routeInfo.data.value.dso.payload)) {
|
|
||||||
this.currentObject.next(routeInfo.data.value.dso.payload);
|
|
||||||
this.setDSOMetaTags();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCurrentRoute(route: ActivatedRoute): ActivatedRoute {
|
private getCurrentRoute(route: ActivatedRoute): ActivatedRoute {
|
||||||
|
@@ -7,8 +7,8 @@ import { filter, map, take } from 'rxjs/operators';
|
|||||||
import { SortDirection, SortOptions } from '../cache/models/sort-options.model';
|
import { SortDirection, SortOptions } from '../cache/models/sort-options.model';
|
||||||
import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
|
import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
|
||||||
import { difference } from '../../shared/object.util';
|
import { difference } from '../../shared/object.util';
|
||||||
import { isNumeric } from 'rxjs/internal-compatibility';
|
|
||||||
import { FindListOptions } from '../data/find-list-options.model';
|
import { FindListOptions } from '../data/find-list-options.model';
|
||||||
|
import { isNumeric } from '../../shared/numeric.util';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
61
src/app/core/profile/model/researcher-profile.model.ts
Normal file
61
src/app/core/profile/model/researcher-profile.model.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { autoserialize, deserialize, deserializeAs } from 'cerialize';
|
||||||
|
|
||||||
|
import { link, typedObject } from '../../cache/builders/build-decorators';
|
||||||
|
import { HALLink } from '../../shared/hal-link.model';
|
||||||
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
|
import { excludeFromEquals } from '../../utilities/equals.decorators';
|
||||||
|
import { RESEARCHER_PROFILE } from './researcher-profile.resource-type';
|
||||||
|
import { CacheableObject } from '../../cache/cacheable-object.model';
|
||||||
|
import { RemoteData } from '../../data/remote-data';
|
||||||
|
import { ITEM } from '../../shared/item.resource-type';
|
||||||
|
import { Item } from '../../shared/item.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class the represents a Researcher Profile.
|
||||||
|
*/
|
||||||
|
@typedObject
|
||||||
|
export class ResearcherProfile extends CacheableObject {
|
||||||
|
|
||||||
|
static type = RESEARCHER_PROFILE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The object type
|
||||||
|
*/
|
||||||
|
@excludeFromEquals
|
||||||
|
@autoserialize
|
||||||
|
type: ResourceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier of this Researcher Profile
|
||||||
|
*/
|
||||||
|
@autoserialize
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@deserializeAs('id')
|
||||||
|
uuid: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The visibility of this Researcher Profile
|
||||||
|
*/
|
||||||
|
@autoserialize
|
||||||
|
visible: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link HALLink}s for this Researcher Profile
|
||||||
|
*/
|
||||||
|
@deserialize
|
||||||
|
_links: {
|
||||||
|
self: HALLink,
|
||||||
|
item: HALLink,
|
||||||
|
eperson: HALLink
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The related person Item
|
||||||
|
* Will be undefined unless the item {@link HALLink} has been resolved.
|
||||||
|
*/
|
||||||
|
@link(ITEM)
|
||||||
|
item?: Observable<RemoteData<Item>>;
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,9 @@
|
|||||||
|
import { ResourceType } from '../../shared/resource-type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The resource type for ResearcherProfile
|
||||||
|
*
|
||||||
|
* Needs to be in a separate file to prevent circular
|
||||||
|
* dependencies in webpack.
|
||||||
|
*/
|
||||||
|
export const RESEARCHER_PROFILE = new ResourceType('profile');
|
576
src/app/core/profile/researcher-profile.service.spec.ts
Normal file
576
src/app/core/profile/researcher-profile.service.spec.ts
Normal file
@@ -0,0 +1,576 @@
|
|||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
|
||||||
|
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
|
||||||
|
import { of as observableOf } from 'rxjs';
|
||||||
|
import { TestScheduler } from 'rxjs/testing';
|
||||||
|
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
|
import { RequestService } from '../data/request.service';
|
||||||
|
import { PageInfo } from '../shared/page-info.model';
|
||||||
|
import { buildPaginatedList } from '../data/paginated-list.model';
|
||||||
|
import {
|
||||||
|
createFailedRemoteDataObject$,
|
||||||
|
createNoContentRemoteDataObject$,
|
||||||
|
createSuccessfulRemoteDataObject,
|
||||||
|
createSuccessfulRemoteDataObject$
|
||||||
|
} from '../../shared/remote-data.utils';
|
||||||
|
import { RestResponse } from '../cache/response.models';
|
||||||
|
import { RequestEntry } from '../data/request-entry.model';
|
||||||
|
import { ResearcherProfileService } from './researcher-profile.service';
|
||||||
|
import { RouterMock } from '../../shared/mocks/router.mock';
|
||||||
|
import { ResearcherProfile } from './model/researcher-profile.model';
|
||||||
|
import { Item } from '../shared/item.model';
|
||||||
|
import { AddOperation, RemoveOperation, ReplaceOperation } from 'fast-json-patch';
|
||||||
|
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
|
||||||
|
import { PostRequest } from '../data/request.models';
|
||||||
|
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { ConfigurationProperty } from '../shared/configuration-property.model';
|
||||||
|
import { ConfigurationDataService } from '../data/configuration-data.service';
|
||||||
|
import { createPaginatedList } from '../../shared/testing/utils.test';
|
||||||
|
import { NativeWindowRefMock } from '../../shared/mocks/mock-native-window-ref';
|
||||||
|
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||||
|
|
||||||
|
describe('ResearcherProfileService', () => {
|
||||||
|
let scheduler: TestScheduler;
|
||||||
|
let service: ResearcherProfileService;
|
||||||
|
let serviceAsAny: any;
|
||||||
|
let requestService: RequestService;
|
||||||
|
let rdbService: RemoteDataBuildService;
|
||||||
|
let objectCache: ObjectCacheService;
|
||||||
|
let halService: HALEndpointService;
|
||||||
|
let responseCacheEntry: RequestEntry;
|
||||||
|
let configurationDataService: ConfigurationDataService;
|
||||||
|
let nativeWindowService: NativeWindowRefMock;
|
||||||
|
let routerStub: any;
|
||||||
|
|
||||||
|
const researcherProfileId = 'beef9946-rt56-479e-8f11-b90cbe9f7241';
|
||||||
|
const itemId = 'beef9946-rt56-479e-8f11-b90cbe9f7241';
|
||||||
|
const researcherProfileItem: Item = Object.assign(new Item(), {
|
||||||
|
id: itemId,
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: `https://rest.api/rest/api/items/${itemId}`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const researcherProfile: ResearcherProfile = Object.assign(new ResearcherProfile(), {
|
||||||
|
id: researcherProfileId,
|
||||||
|
visible: false,
|
||||||
|
type: 'profile',
|
||||||
|
_links: {
|
||||||
|
item: {
|
||||||
|
href: `https://rest.api/rest/api/profiles/${researcherProfileId}/item`
|
||||||
|
},
|
||||||
|
self: {
|
||||||
|
href: `https://rest.api/rest/api/profiles/${researcherProfileId}`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const researcherProfilePatched: ResearcherProfile = Object.assign(new ResearcherProfile(), {
|
||||||
|
id: researcherProfileId,
|
||||||
|
visible: true,
|
||||||
|
type: 'profile',
|
||||||
|
_links: {
|
||||||
|
item: {
|
||||||
|
href: `https://rest.api/rest/api/profiles/${researcherProfileId}/item`
|
||||||
|
},
|
||||||
|
self: {
|
||||||
|
href: `https://rest.api/rest/api/profiles/${researcherProfileId}`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const researcherProfileId2 = 'agbf9946-f4ce-479e-8f11-b90cbe9f7241';
|
||||||
|
const anotherResearcherProfile: ResearcherProfile = Object.assign(new ResearcherProfile(), {
|
||||||
|
id: researcherProfileId2,
|
||||||
|
visible: false,
|
||||||
|
type: 'profile',
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: `https://rest.api/rest/api/profiles/${researcherProfileId2}`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemUnlinkedToOrcid: Item = Object.assign(new Item(), {
|
||||||
|
id: 'mockItemUnlinkedToOrcid',
|
||||||
|
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [{
|
||||||
|
value: 'test person'
|
||||||
|
}],
|
||||||
|
'dspace.entity.type': [{
|
||||||
|
'value': 'Person'
|
||||||
|
}],
|
||||||
|
'dspace.object.owner': [{
|
||||||
|
'value': 'test person',
|
||||||
|
'language': null,
|
||||||
|
'authority': 'researcher-profile-id',
|
||||||
|
'confidence': 600,
|
||||||
|
'place': 0
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockItemLinkedToOrcid: Item = Object.assign(new Item(), {
|
||||||
|
bundles: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||||
|
metadata: {
|
||||||
|
'dc.title': [{
|
||||||
|
value: 'test person'
|
||||||
|
}],
|
||||||
|
'dspace.entity.type': [{
|
||||||
|
'value': 'Person'
|
||||||
|
}],
|
||||||
|
'dspace.object.owner': [{
|
||||||
|
'value': 'test person',
|
||||||
|
'language': null,
|
||||||
|
'authority': 'researcher-profile-id',
|
||||||
|
'confidence': 600,
|
||||||
|
'place': 0
|
||||||
|
}],
|
||||||
|
'dspace.orcid.authenticated': [{
|
||||||
|
'value': '2022-06-10T15:15:12.952872',
|
||||||
|
'language': null,
|
||||||
|
'authority': null,
|
||||||
|
'confidence': -1,
|
||||||
|
'place': 0
|
||||||
|
}],
|
||||||
|
'dspace.orcid.scope': [{
|
||||||
|
'value': '/authenticate',
|
||||||
|
'language': null,
|
||||||
|
'authority': null,
|
||||||
|
'confidence': -1,
|
||||||
|
'place': 0
|
||||||
|
}, {
|
||||||
|
'value': '/read-limited',
|
||||||
|
'language': null,
|
||||||
|
'authority': null,
|
||||||
|
'confidence': -1,
|
||||||
|
'place': 1
|
||||||
|
}, {
|
||||||
|
'value': '/activities/update',
|
||||||
|
'language': null,
|
||||||
|
'authority': null,
|
||||||
|
'confidence': -1,
|
||||||
|
'place': 2
|
||||||
|
}, {
|
||||||
|
'value': '/person/update',
|
||||||
|
'language': null,
|
||||||
|
'authority': null,
|
||||||
|
'confidence': -1,
|
||||||
|
'place': 3
|
||||||
|
}],
|
||||||
|
'person.identifier.orcid': [{
|
||||||
|
'value': 'orcid-id',
|
||||||
|
'language': null,
|
||||||
|
'authority': null,
|
||||||
|
'confidence': -1,
|
||||||
|
'place': 0
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const disconnectionAllowAdmin = {
|
||||||
|
uuid: 'orcid.disconnection.allowed-users',
|
||||||
|
name: 'orcid.disconnection.allowed-users',
|
||||||
|
values: ['only_admin']
|
||||||
|
} as ConfigurationProperty;
|
||||||
|
|
||||||
|
const disconnectionAllowAdminOwner = {
|
||||||
|
uuid: 'orcid.disconnection.allowed-users',
|
||||||
|
name: 'orcid.disconnection.allowed-users',
|
||||||
|
values: ['admin_and_owner']
|
||||||
|
} as ConfigurationProperty;
|
||||||
|
|
||||||
|
const authorizeUrl = {
|
||||||
|
uuid: 'orcid.authorize-url',
|
||||||
|
name: 'orcid.authorize-url',
|
||||||
|
values: ['orcid.authorize-url']
|
||||||
|
} as ConfigurationProperty;
|
||||||
|
const appClientId = {
|
||||||
|
uuid: 'orcid.application-client-id',
|
||||||
|
name: 'orcid.application-client-id',
|
||||||
|
values: ['orcid.application-client-id']
|
||||||
|
} as ConfigurationProperty;
|
||||||
|
const orcidScope = {
|
||||||
|
uuid: 'orcid.scope',
|
||||||
|
name: 'orcid.scope',
|
||||||
|
values: ['/authenticate', '/read-limited']
|
||||||
|
} as ConfigurationProperty;
|
||||||
|
|
||||||
|
const endpointURL = `https://rest.api/rest/api/profiles`;
|
||||||
|
const endpointURLWithEmbed = 'https://rest.api/rest/api/profiles?embed=item';
|
||||||
|
const sourceUri = `https://rest.api/rest/api/external-source/profile`;
|
||||||
|
const requestURL = `https://rest.api/rest/api/profiles/${researcherProfileId}`;
|
||||||
|
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
||||||
|
|
||||||
|
const pageInfo = new PageInfo();
|
||||||
|
const array = [researcherProfile, anotherResearcherProfile];
|
||||||
|
const paginatedList = buildPaginatedList(pageInfo, array);
|
||||||
|
const researcherProfileRD = createSuccessfulRemoteDataObject(researcherProfile);
|
||||||
|
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
scheduler = getTestScheduler();
|
||||||
|
|
||||||
|
halService = jasmine.createSpyObj('halService', {
|
||||||
|
getEndpoint: cold('a', { a: endpointURL })
|
||||||
|
});
|
||||||
|
|
||||||
|
responseCacheEntry = new RequestEntry();
|
||||||
|
responseCacheEntry.request = { href: 'https://rest.api/' } as any;
|
||||||
|
responseCacheEntry.response = new RestResponse(true, 200, 'Success');
|
||||||
|
|
||||||
|
requestService = jasmine.createSpyObj('requestService', {
|
||||||
|
generateRequestId: requestUUID,
|
||||||
|
send: true,
|
||||||
|
removeByHrefSubstring: {},
|
||||||
|
getByHref: observableOf(responseCacheEntry),
|
||||||
|
getByUUID: observableOf(responseCacheEntry),
|
||||||
|
setStaleByHrefSubstring: jasmine.createSpy('setStaleByHrefSubstring')
|
||||||
|
});
|
||||||
|
rdbService = jasmine.createSpyObj('rdbService', {
|
||||||
|
buildSingle: hot('a|', {
|
||||||
|
a: researcherProfileRD
|
||||||
|
}),
|
||||||
|
buildList: hot('a|', {
|
||||||
|
a: paginatedListRD
|
||||||
|
}),
|
||||||
|
buildFromRequestUUID: hot('a|', {
|
||||||
|
a: researcherProfileRD
|
||||||
|
})
|
||||||
|
});
|
||||||
|
objectCache = {} as ObjectCacheService;
|
||||||
|
const notificationsService = {} as NotificationsService;
|
||||||
|
const http = {} as HttpClient;
|
||||||
|
const comparator = {} as any;
|
||||||
|
routerStub = new RouterMock();
|
||||||
|
const itemService = jasmine.createSpyObj('ItemService', {
|
||||||
|
findByHref: jasmine.createSpy('findByHref')
|
||||||
|
});
|
||||||
|
configurationDataService = jasmine.createSpyObj('configurationDataService', {
|
||||||
|
findByPropertyName: jasmine.createSpy('findByPropertyName')
|
||||||
|
});
|
||||||
|
nativeWindowService = new NativeWindowRefMock();
|
||||||
|
|
||||||
|
service = new ResearcherProfileService(
|
||||||
|
nativeWindowService,
|
||||||
|
requestService,
|
||||||
|
rdbService,
|
||||||
|
objectCache,
|
||||||
|
halService,
|
||||||
|
notificationsService,
|
||||||
|
http,
|
||||||
|
routerStub,
|
||||||
|
comparator,
|
||||||
|
itemService,
|
||||||
|
configurationDataService
|
||||||
|
);
|
||||||
|
serviceAsAny = service;
|
||||||
|
|
||||||
|
spyOn((service as any).dataService, 'create').and.callThrough();
|
||||||
|
spyOn((service as any).dataService, 'delete').and.callThrough();
|
||||||
|
spyOn((service as any).dataService, 'update').and.callThrough();
|
||||||
|
spyOn((service as any).dataService, 'findById').and.callThrough();
|
||||||
|
spyOn((service as any).dataService, 'findByHref').and.callThrough();
|
||||||
|
spyOn((service as any).dataService, 'searchBy').and.callThrough();
|
||||||
|
spyOn((service as any).dataService, 'getLinkPath').and.returnValue(observableOf(endpointURL));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findById', () => {
|
||||||
|
it('should proxy the call to dataservice.findById with eperson UUID', () => {
|
||||||
|
scheduler.schedule(() => service.findById(researcherProfileId));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).dataService.findById).toHaveBeenCalledWith(researcherProfileId, true, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a ResearcherProfile object with the given id', () => {
|
||||||
|
const result = service.findById(researcherProfileId);
|
||||||
|
const expected = cold('a|', {
|
||||||
|
a: researcherProfileRD
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('create', () => {
|
||||||
|
it('should proxy the call to dataservice.create with eperson UUID', () => {
|
||||||
|
scheduler.schedule(() => service.create());
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).dataService.create).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the RemoteData<ResearcherProfile> created', () => {
|
||||||
|
const result = service.create();
|
||||||
|
const expected = cold('a|', {
|
||||||
|
a: researcherProfileRD
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('delete', () => {
|
||||||
|
it('should proxy the call to dataservice.delete', () => {
|
||||||
|
scheduler.schedule(() => service.delete(researcherProfile));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).dataService.delete).toHaveBeenCalledWith(researcherProfile.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findRelatedItemId', () => {
|
||||||
|
describe('with a related item', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
(service as any).itemService.findByHref.and.returnValue(createSuccessfulRemoteDataObject$(researcherProfileItem));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should proxy the call to dataservice.findById with eperson UUID', () => {
|
||||||
|
scheduler.schedule(() => service.findRelatedItemId(researcherProfile));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).itemService.findByHref).toHaveBeenCalledWith(researcherProfile._links.item.href, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a ResearcherProfile object with the given id', () => {
|
||||||
|
const result = service.findRelatedItemId(researcherProfile);
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: itemId
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('without a related item', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
(service as any).itemService.findByHref.and.returnValue(createNoContentRemoteDataObject$());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should proxy the call to dataservice.findById with eperson UUID', () => {
|
||||||
|
scheduler.schedule(() => service.findRelatedItemId(researcherProfile));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).itemService.findByHref).toHaveBeenCalledWith(researcherProfile._links.item.href, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not return a ResearcherProfile object with the given id', () => {
|
||||||
|
const result = service.findRelatedItemId(researcherProfile);
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: null
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('setVisibility', () => {
|
||||||
|
let patchSpy;
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn((service as any).dataService, 'patch').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfilePatched));
|
||||||
|
spyOn((service as any), 'findById').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfilePatched));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should proxy the call to dataservice.patch', () => {
|
||||||
|
const replaceOperation: ReplaceOperation<boolean> = {
|
||||||
|
path: '/visible',
|
||||||
|
op: 'replace',
|
||||||
|
value: true
|
||||||
|
};
|
||||||
|
|
||||||
|
scheduler.schedule(() => service.setVisibility(researcherProfile, true));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).dataService.patch).toHaveBeenCalledWith(researcherProfile, [replaceOperation]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('createFromExternalSource', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn((service as any).dataService, 'patch').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfilePatched));
|
||||||
|
spyOn((service as any), 'findById').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfilePatched));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should proxy the call to dataservice.patch', () => {
|
||||||
|
const options: HttpOptions = Object.create({});
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.append('Content-Type', 'text/uri-list');
|
||||||
|
options.headers = headers;
|
||||||
|
const request = new PostRequest(requestUUID, endpointURLWithEmbed, sourceUri, options);
|
||||||
|
|
||||||
|
scheduler.schedule(() => service.createFromExternalSource(sourceUri));
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).requestService.send).toHaveBeenCalledWith(request);
|
||||||
|
expect((service as any).rdbService.buildFromRequestUUID).toHaveBeenCalledWith(requestUUID, followLink('item'));
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('isLinkedToOrcid', () => {
|
||||||
|
it('should return true when item has metadata', () => {
|
||||||
|
const result = service.isLinkedToOrcid(mockItemLinkedToOrcid);
|
||||||
|
expect(result).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true when item has no metadata', () => {
|
||||||
|
const result = service.isLinkedToOrcid(mockItemUnlinkedToOrcid);
|
||||||
|
expect(result).toBeFalse();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('onlyAdminCanDisconnectProfileFromOrcid', () => {
|
||||||
|
it('should return true when property is only_admin', () => {
|
||||||
|
spyOn((service as any), 'getOrcidDisconnectionAllowedUsersConfiguration').and.returnValue(createSuccessfulRemoteDataObject$(disconnectionAllowAdmin));
|
||||||
|
const result = service.onlyAdminCanDisconnectProfileFromOrcid();
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: true
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false on faild', () => {
|
||||||
|
spyOn((service as any), 'getOrcidDisconnectionAllowedUsersConfiguration').and.returnValue(createFailedRemoteDataObject$());
|
||||||
|
const result = service.onlyAdminCanDisconnectProfileFromOrcid();
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: false
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('ownerCanDisconnectProfileFromOrcid', () => {
|
||||||
|
it('should return true when property is admin_and_owner', () => {
|
||||||
|
spyOn((service as any), 'getOrcidDisconnectionAllowedUsersConfiguration').and.returnValue(createSuccessfulRemoteDataObject$(disconnectionAllowAdminOwner));
|
||||||
|
const result = service.ownerCanDisconnectProfileFromOrcid();
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: true
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return false on faild', () => {
|
||||||
|
spyOn((service as any), 'getOrcidDisconnectionAllowedUsersConfiguration').and.returnValue(createFailedRemoteDataObject$());
|
||||||
|
const result = service.ownerCanDisconnectProfileFromOrcid();
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: false
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('linkOrcidByItem', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
scheduler = getTestScheduler();
|
||||||
|
spyOn((service as any).dataService, 'patch').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfilePatched));
|
||||||
|
spyOn((service as any), 'findById').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfile));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call patch method properly', () => {
|
||||||
|
const operations: AddOperation<string>[] = [{
|
||||||
|
path: '/orcid',
|
||||||
|
op: 'add',
|
||||||
|
value: 'test-code'
|
||||||
|
}];
|
||||||
|
|
||||||
|
scheduler.schedule(() => service.linkOrcidByItem(mockItemUnlinkedToOrcid, 'test-code').subscribe());
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).dataService.patch).toHaveBeenCalledWith(researcherProfile, operations);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('unlinkOrcidByItem', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
scheduler = getTestScheduler();
|
||||||
|
spyOn((service as any).dataService, 'patch').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfilePatched));
|
||||||
|
spyOn((service as any), 'findById').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfile));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call patch method properly', () => {
|
||||||
|
const operations: RemoveOperation[] = [{
|
||||||
|
path: '/orcid',
|
||||||
|
op: 'remove'
|
||||||
|
}];
|
||||||
|
|
||||||
|
scheduler.schedule(() => service.unlinkOrcidByItem(mockItemLinkedToOrcid).subscribe());
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).dataService.patch).toHaveBeenCalledWith(researcherProfile, operations);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getOrcidAuthorizeUrl', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
routerStub.setRoute('/entities/person/uuid/orcid');
|
||||||
|
(service as any).configurationService.findByPropertyName.and.returnValues(
|
||||||
|
createSuccessfulRemoteDataObject$(authorizeUrl),
|
||||||
|
createSuccessfulRemoteDataObject$(appClientId),
|
||||||
|
createSuccessfulRemoteDataObject$(orcidScope)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should build the url properly', () => {
|
||||||
|
const result = service.getOrcidAuthorizeUrl(mockItemUnlinkedToOrcid);
|
||||||
|
const redirectUri: string = new URLCombiner(nativeWindowService.nativeWindow.origin, encodeURIComponent(routerStub.url.split('?')[0])).toString();
|
||||||
|
const url = 'orcid.authorize-url?client_id=orcid.application-client-id&redirect_uri=' + redirectUri + '&response_type=code&scope=/authenticate /read-limited';
|
||||||
|
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: url
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('updateByOrcidOperations', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
scheduler = getTestScheduler();
|
||||||
|
spyOn((service as any).dataService, 'patch').and.returnValue(createSuccessfulRemoteDataObject$(researcherProfilePatched));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call patch method properly', () => {
|
||||||
|
scheduler.schedule(() => service.updateByOrcidOperations(researcherProfile, []).subscribe());
|
||||||
|
scheduler.flush();
|
||||||
|
|
||||||
|
expect((service as any).dataService.patch).toHaveBeenCalledWith(researcherProfile, []);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getOrcidAuthorizationScopesByItem', () => {
|
||||||
|
it('should return list of scopes saved in the item', () => {
|
||||||
|
const orcidScopes = [
|
||||||
|
'/authenticate',
|
||||||
|
'/read-limited',
|
||||||
|
'/activities/update',
|
||||||
|
'/person/update'
|
||||||
|
];
|
||||||
|
const result = service.getOrcidAuthorizationScopesByItem(mockItemLinkedToOrcid);
|
||||||
|
expect(result).toEqual(orcidScopes);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getOrcidAuthorizationScopes', () => {
|
||||||
|
it('should return list of scopes by configuration', () => {
|
||||||
|
(service as any).configurationService.findByPropertyName.and.returnValue(
|
||||||
|
createSuccessfulRemoteDataObject$(orcidScope)
|
||||||
|
);
|
||||||
|
const orcidScopes = [
|
||||||
|
'/authenticate',
|
||||||
|
'/read-limited'
|
||||||
|
];
|
||||||
|
const expected = cold('(a|)', {
|
||||||
|
a: orcidScopes
|
||||||
|
});
|
||||||
|
const result = service.getOrcidAuthorizationScopes();
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
319
src/app/core/profile/researcher-profile.service.ts
Normal file
319
src/app/core/profile/researcher-profile.service.ts
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
/* eslint-disable max-classes-per-file */
|
||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { Inject, Injectable } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { AddOperation, Operation, RemoveOperation, ReplaceOperation } from 'fast-json-patch';
|
||||||
|
import { combineLatest, Observable } from 'rxjs';
|
||||||
|
import { find, map, switchMap } from 'rxjs/operators';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
|
import { dataService } from '../cache/builders/build-decorators';
|
||||||
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
|
import { ConfigurationDataService } from '../data/configuration-data.service';
|
||||||
|
import { DataService } from '../data/data.service';
|
||||||
|
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service';
|
||||||
|
import { ItemDataService } from '../data/item-data.service';
|
||||||
|
import { RemoteData } from '../data/remote-data';
|
||||||
|
import { RequestService } from '../data/request.service';
|
||||||
|
import { ConfigurationProperty } from '../shared/configuration-property.model';
|
||||||
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
|
import { NoContent } from '../shared/NoContent.model';
|
||||||
|
import {
|
||||||
|
getAllCompletedRemoteData,
|
||||||
|
getFirstCompletedRemoteData,
|
||||||
|
getFirstSucceededRemoteDataPayload
|
||||||
|
} from '../shared/operators';
|
||||||
|
import { ResearcherProfile } from './model/researcher-profile.model';
|
||||||
|
import { RESEARCHER_PROFILE } from './model/researcher-profile.resource-type';
|
||||||
|
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
|
||||||
|
import { PostRequest } from '../data/request.models';
|
||||||
|
import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
|
||||||
|
import { CoreState } from '../core-state.model';
|
||||||
|
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { Item } from '../shared/item.model';
|
||||||
|
import { createFailedRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
|
import { NativeWindowRef, NativeWindowService } from '../services/window.service';
|
||||||
|
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A private DataService implementation to delegate specific methods to.
|
||||||
|
*/
|
||||||
|
class ResearcherProfileServiceImpl extends DataService<ResearcherProfile> {
|
||||||
|
protected linkPath = 'profiles';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected requestService: RequestService,
|
||||||
|
protected rdbService: RemoteDataBuildService,
|
||||||
|
protected store: Store<CoreState>,
|
||||||
|
protected objectCache: ObjectCacheService,
|
||||||
|
protected halService: HALEndpointService,
|
||||||
|
protected notificationsService: NotificationsService,
|
||||||
|
protected http: HttpClient,
|
||||||
|
protected comparator: DefaultChangeAnalyzer<ResearcherProfile>) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A service that provides methods to make REST requests with researcher profile endpoint.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
@dataService(RESEARCHER_PROFILE)
|
||||||
|
export class ResearcherProfileService {
|
||||||
|
|
||||||
|
protected dataService: ResearcherProfileServiceImpl;
|
||||||
|
|
||||||
|
protected responseMsToLive: number = 10 * 1000;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@Inject(NativeWindowService) protected _window: NativeWindowRef,
|
||||||
|
protected requestService: RequestService,
|
||||||
|
protected rdbService: RemoteDataBuildService,
|
||||||
|
protected objectCache: ObjectCacheService,
|
||||||
|
protected halService: HALEndpointService,
|
||||||
|
protected notificationsService: NotificationsService,
|
||||||
|
protected http: HttpClient,
|
||||||
|
protected router: Router,
|
||||||
|
protected comparator: DefaultChangeAnalyzer<ResearcherProfile>,
|
||||||
|
protected itemService: ItemDataService,
|
||||||
|
protected configurationService: ConfigurationDataService) {
|
||||||
|
|
||||||
|
this.dataService = new ResearcherProfileServiceImpl(requestService, rdbService, null, objectCache, halService,
|
||||||
|
notificationsService, http, comparator);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the researcher profile with the given uuid.
|
||||||
|
*
|
||||||
|
* @param uuid the profile uuid
|
||||||
|
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
|
||||||
|
* no valid cached version. Defaults to true
|
||||||
|
* @param reRequestOnStale Whether or not the request should automatically be re-
|
||||||
|
* requested after the response becomes stale
|
||||||
|
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
|
||||||
|
* {@link HALLink}s should be automatically resolved
|
||||||
|
*/
|
||||||
|
public findById(uuid: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<ResearcherProfile>[]): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
return this.dataService.findById(uuid, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
|
||||||
|
getAllCompletedRemoteData(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new researcher profile for the current user.
|
||||||
|
*/
|
||||||
|
public create(): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
return this.dataService.create(new ResearcherProfile());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a researcher profile.
|
||||||
|
*
|
||||||
|
* @param researcherProfile the profile to delete
|
||||||
|
*/
|
||||||
|
public delete(researcherProfile: ResearcherProfile): Observable<boolean> {
|
||||||
|
return this.dataService.delete(researcherProfile.id).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map((response: RemoteData<NoContent>) => response.isSuccess)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a researcher profile by its own related item
|
||||||
|
*
|
||||||
|
* @param item
|
||||||
|
*/
|
||||||
|
public findByRelatedItem(item: Item): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
const profileId = item.firstMetadata('dspace.object.owner')?.authority;
|
||||||
|
if (isEmpty(profileId)) {
|
||||||
|
return createFailedRemoteDataObject$();
|
||||||
|
} else {
|
||||||
|
return this.findById(profileId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the item id related to the given researcher profile.
|
||||||
|
*
|
||||||
|
* @param researcherProfile the profile to find for
|
||||||
|
*/
|
||||||
|
public findRelatedItemId(researcherProfile: ResearcherProfile): Observable<string> {
|
||||||
|
const relatedItem$ = researcherProfile.item ? researcherProfile.item : this.itemService.findByHref(researcherProfile._links.item.href, false);
|
||||||
|
return relatedItem$.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map((itemRD: RemoteData<Item>) => (itemRD.hasSucceeded && itemRD.payload) ? itemRD.payload.id : null)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the visibility of the given researcher profile setting the given value.
|
||||||
|
*
|
||||||
|
* @param researcherProfile the profile to update
|
||||||
|
* @param visible the visibility value to set
|
||||||
|
*/
|
||||||
|
public setVisibility(researcherProfile: ResearcherProfile, visible: boolean): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
const replaceOperation: ReplaceOperation<boolean> = {
|
||||||
|
path: '/visible',
|
||||||
|
op: 'replace',
|
||||||
|
value: visible
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.dataService.patch(researcherProfile, [replaceOperation]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given item is linked to an ORCID profile.
|
||||||
|
*
|
||||||
|
* @param item the item to check
|
||||||
|
* @returns the check result
|
||||||
|
*/
|
||||||
|
public isLinkedToOrcid(item: Item): boolean {
|
||||||
|
return item.hasMetadata('dspace.orcid.authenticated');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if only the admin users can disconnect a researcher profile from ORCID.
|
||||||
|
*
|
||||||
|
* @returns the check result
|
||||||
|
*/
|
||||||
|
public onlyAdminCanDisconnectProfileFromOrcid(): Observable<boolean> {
|
||||||
|
return this.getOrcidDisconnectionAllowedUsersConfiguration().pipe(
|
||||||
|
map((propertyRD: RemoteData<ConfigurationProperty>) => {
|
||||||
|
return propertyRD.hasSucceeded && propertyRD.payload.values.map((value) => value.toLowerCase()).includes('only_admin');
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the profile's owner can disconnect that profile from ORCID.
|
||||||
|
*
|
||||||
|
* @returns the check result
|
||||||
|
*/
|
||||||
|
public ownerCanDisconnectProfileFromOrcid(): Observable<boolean> {
|
||||||
|
return this.getOrcidDisconnectionAllowedUsersConfiguration().pipe(
|
||||||
|
map((propertyRD: RemoteData<ConfigurationProperty>) => {
|
||||||
|
return propertyRD.hasSucceeded && propertyRD.payload.values.map( (value) => value.toLowerCase()).includes('admin_and_owner');
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a link operation to ORCID profile.
|
||||||
|
*
|
||||||
|
* @param person The person item related to the researcher profile
|
||||||
|
* @param code The auth-code received from orcid
|
||||||
|
*/
|
||||||
|
public linkOrcidByItem(person: Item, code: string): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
const operations: AddOperation<string>[] = [{
|
||||||
|
path: '/orcid',
|
||||||
|
op: 'add',
|
||||||
|
value: code
|
||||||
|
}];
|
||||||
|
|
||||||
|
return this.findById(person.firstMetadata('dspace.object.owner').authority).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
switchMap((profileRD) => this.updateByOrcidOperations(profileRD.payload, operations))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform unlink operation from ORCID profile.
|
||||||
|
*
|
||||||
|
* @param person The person item related to the researcher profile
|
||||||
|
*/
|
||||||
|
public unlinkOrcidByItem(person: Item): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
const operations: RemoveOperation[] = [{
|
||||||
|
path:'/orcid',
|
||||||
|
op:'remove'
|
||||||
|
}];
|
||||||
|
|
||||||
|
return this.findById(person.firstMetadata('dspace.object.owner').authority).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
switchMap((profileRD) => this.updateByOrcidOperations(profileRD.payload, operations))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build and return the url to authenticate with orcid
|
||||||
|
*
|
||||||
|
* @param profile
|
||||||
|
*/
|
||||||
|
public getOrcidAuthorizeUrl(profile: Item): Observable<string> {
|
||||||
|
return combineLatest([
|
||||||
|
this.configurationService.findByPropertyName('orcid.authorize-url').pipe(getFirstSucceededRemoteDataPayload()),
|
||||||
|
this.configurationService.findByPropertyName('orcid.application-client-id').pipe(getFirstSucceededRemoteDataPayload()),
|
||||||
|
this.configurationService.findByPropertyName('orcid.scope').pipe(getFirstSucceededRemoteDataPayload())]
|
||||||
|
).pipe(
|
||||||
|
map(([authorizeUrl, clientId, scopes]) => {
|
||||||
|
console.log(this._window.nativeWindow.origin, this.router.url);
|
||||||
|
const redirectUri = new URLCombiner(this._window.nativeWindow.origin, encodeURIComponent(this.router.url.split('?')[0]));
|
||||||
|
console.log(redirectUri.toString());
|
||||||
|
return authorizeUrl.values[0] + '?client_id=' + clientId.values[0] + '&redirect_uri=' + redirectUri + '&response_type=code&scope='
|
||||||
|
+ scopes.values.join(' ');
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a researcher profile starting from an external source URI
|
||||||
|
* @param sourceUri URI of source item of researcher profile.
|
||||||
|
*/
|
||||||
|
public createFromExternalSource(sourceUri: string): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
const options: HttpOptions = Object.create({});
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.append('Content-Type', 'text/uri-list');
|
||||||
|
options.headers = headers;
|
||||||
|
|
||||||
|
const requestId = this.requestService.generateRequestId();
|
||||||
|
const href$ = this.halService.getEndpoint(this.dataService.getLinkPath());
|
||||||
|
|
||||||
|
href$.pipe(
|
||||||
|
find((href: string) => hasValue(href)),
|
||||||
|
map((href: string) => this.dataService.buildHrefWithParams(href, [], followLink('item')))
|
||||||
|
).subscribe((endpoint: string) => {
|
||||||
|
const request = new PostRequest(requestId, endpoint, sourceUri, options);
|
||||||
|
this.requestService.send(request);
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.rdbService.buildFromRequestUUID(requestId, followLink('item'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update researcher profile by patch orcid operation
|
||||||
|
*
|
||||||
|
* @param researcherProfile
|
||||||
|
* @param operations
|
||||||
|
*/
|
||||||
|
public updateByOrcidOperations(researcherProfile: ResearcherProfile, operations: Operation[]): Observable<RemoteData<ResearcherProfile>> {
|
||||||
|
return this.dataService.patch(researcherProfile, operations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all orcid authorization scopes saved in the given item
|
||||||
|
*
|
||||||
|
* @param item
|
||||||
|
*/
|
||||||
|
public getOrcidAuthorizationScopesByItem(item: Item): string[] {
|
||||||
|
return isNotEmpty(item) ? item.allMetadataValues('dspace.orcid.scope') : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all orcid authorization scopes available by configuration
|
||||||
|
*/
|
||||||
|
public getOrcidAuthorizationScopes(): Observable<string[]> {
|
||||||
|
return this.configurationService.findByPropertyName('orcid.scope').pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getOrcidDisconnectionAllowedUsersConfiguration(): Observable<RemoteData<ConfigurationProperty>> {
|
||||||
|
return this.configurationService.findByPropertyName('orcid.disconnection.allowed-users').pipe(
|
||||||
|
getFirstCompletedRemoteData()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -386,6 +386,10 @@ describe('RegistryService', () => {
|
|||||||
result = registryService.deleteMetadataSchema(mockSchemasList[0].id);
|
result = registryService.deleteMetadataSchema(mockSchemasList[0].id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should defer to MetadataSchemaDataService.delete', () => {
|
||||||
|
expect(metadataSchemaService.delete).toHaveBeenCalledWith(`${mockSchemasList[0].id}`);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return a successful response', () => {
|
it('should return a successful response', () => {
|
||||||
result.subscribe((response: RemoteData<NoContent>) => {
|
result.subscribe((response: RemoteData<NoContent>) => {
|
||||||
expect(response.hasSucceeded).toBe(true);
|
expect(response.hasSucceeded).toBe(true);
|
||||||
@@ -400,6 +404,10 @@ describe('RegistryService', () => {
|
|||||||
result = registryService.deleteMetadataField(mockFieldsList[0].id);
|
result = registryService.deleteMetadataField(mockFieldsList[0].id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should defer to MetadataFieldDataService.delete', () => {
|
||||||
|
expect(metadataFieldService.delete).toHaveBeenCalledWith(`${mockFieldsList[0].id}`);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return a successful response', () => {
|
it('should return a successful response', () => {
|
||||||
result.subscribe((response: RemoteData<NoContent>) => {
|
result.subscribe((response: RemoteData<NoContent>) => {
|
||||||
expect(response.hasSucceeded).toBe(true);
|
expect(response.hasSucceeded).toBe(true);
|
||||||
|
@@ -1,13 +1,17 @@
|
|||||||
import { ReloadGuard } from './reload.guard';
|
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { AppConfig } from '../../../config/app-config.interface';
|
||||||
|
import { DefaultAppConfig } from '../../../config/default-app-config';
|
||||||
|
import { ReloadGuard } from './reload.guard';
|
||||||
|
|
||||||
describe('ReloadGuard', () => {
|
describe('ReloadGuard', () => {
|
||||||
let guard: ReloadGuard;
|
let guard: ReloadGuard;
|
||||||
let router: Router;
|
let router: Router;
|
||||||
|
let appConfig: AppConfig;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
router = jasmine.createSpyObj('router', ['parseUrl', 'createUrlTree']);
|
router = jasmine.createSpyObj('router', ['parseUrl', 'createUrlTree']);
|
||||||
guard = new ReloadGuard(router);
|
appConfig = new DefaultAppConfig();
|
||||||
|
guard = new ReloadGuard(router, appConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('canActivate', () => {
|
describe('canActivate', () => {
|
||||||
@@ -27,7 +31,7 @@ describe('ReloadGuard', () => {
|
|||||||
|
|
||||||
it('should create a UrlTree with the redirect URL', () => {
|
it('should create a UrlTree with the redirect URL', () => {
|
||||||
guard.canActivate(route, undefined);
|
guard.canActivate(route, undefined);
|
||||||
expect(router.parseUrl).toHaveBeenCalledWith(redirectUrl);
|
expect(router.parseUrl).toHaveBeenCalledWith(redirectUrl.substring(1));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
||||||
import { Injectable } from '@angular/core';
|
import { AppConfig, APP_CONFIG } from '../../../config/app-config.interface';
|
||||||
import { isNotEmpty } from '../../shared/empty.util';
|
import { isNotEmpty } from '../../shared/empty.util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,7 +9,10 @@ import { isNotEmpty } from '../../shared/empty.util';
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReloadGuard implements CanActivate {
|
export class ReloadGuard implements CanActivate {
|
||||||
constructor(private router: Router) {
|
constructor(
|
||||||
|
private router: Router,
|
||||||
|
@Inject(APP_CONFIG) private appConfig: AppConfig,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,7 +22,10 @@ export class ReloadGuard implements CanActivate {
|
|||||||
*/
|
*/
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): UrlTree {
|
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): UrlTree {
|
||||||
if (isNotEmpty(route.queryParams.redirect)) {
|
if (isNotEmpty(route.queryParams.redirect)) {
|
||||||
return this.router.parseUrl(route.queryParams.redirect);
|
const url = route.queryParams.redirect.startsWith(this.appConfig.ui.nameSpace)
|
||||||
|
? route.queryParams.redirect.substring(this.appConfig.ui.nameSpace.length)
|
||||||
|
: route.queryParams.redirect;
|
||||||
|
return this.router.parseUrl(url);
|
||||||
} else {
|
} else {
|
||||||
return this.router.createUrlTree(['home']);
|
return this.router.createUrlTree(['home']);
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,8 @@ import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils
|
|||||||
import { RestResponse } from '../cache/response.models';
|
import { RestResponse } from '../cache/response.models';
|
||||||
import { RequestEntry } from '../data/request-entry.model';
|
import { RequestEntry } from '../data/request-entry.model';
|
||||||
import { FindListOptions } from '../data/find-list-options.model';
|
import { FindListOptions } from '../data/find-list-options.model';
|
||||||
|
import { EPersonDataService } from '../eperson/eperson-data.service';
|
||||||
|
import { GroupDataService } from '../eperson/group-data.service';
|
||||||
|
|
||||||
describe('ResourcePolicyService', () => {
|
describe('ResourcePolicyService', () => {
|
||||||
let scheduler: TestScheduler;
|
let scheduler: TestScheduler;
|
||||||
@@ -28,6 +30,8 @@ describe('ResourcePolicyService', () => {
|
|||||||
let objectCache: ObjectCacheService;
|
let objectCache: ObjectCacheService;
|
||||||
let halService: HALEndpointService;
|
let halService: HALEndpointService;
|
||||||
let responseCacheEntry: RequestEntry;
|
let responseCacheEntry: RequestEntry;
|
||||||
|
let ePersonService: EPersonDataService;
|
||||||
|
let groupService: GroupDataService;
|
||||||
|
|
||||||
const resourcePolicy: any = {
|
const resourcePolicy: any = {
|
||||||
id: '1',
|
id: '1',
|
||||||
@@ -88,6 +92,8 @@ describe('ResourcePolicyService', () => {
|
|||||||
const resourcePolicyRD = createSuccessfulRemoteDataObject(resourcePolicy);
|
const resourcePolicyRD = createSuccessfulRemoteDataObject(resourcePolicy);
|
||||||
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
||||||
|
|
||||||
|
const ePersonEndpoint = 'EPERSON_EP';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
|
|
||||||
@@ -105,6 +111,7 @@ describe('ResourcePolicyService', () => {
|
|||||||
removeByHrefSubstring: {},
|
removeByHrefSubstring: {},
|
||||||
getByHref: observableOf(responseCacheEntry),
|
getByHref: observableOf(responseCacheEntry),
|
||||||
getByUUID: observableOf(responseCacheEntry),
|
getByUUID: observableOf(responseCacheEntry),
|
||||||
|
setStaleByHrefSubstring: {},
|
||||||
});
|
});
|
||||||
rdbService = jasmine.createSpyObj('rdbService', {
|
rdbService = jasmine.createSpyObj('rdbService', {
|
||||||
buildSingle: hot('a|', {
|
buildSingle: hot('a|', {
|
||||||
@@ -117,6 +124,11 @@ describe('ResourcePolicyService', () => {
|
|||||||
a: resourcePolicyRD
|
a: resourcePolicyRD
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
ePersonService = jasmine.createSpyObj('ePersonService', {
|
||||||
|
getBrowseEndpoint: hot('a', {
|
||||||
|
a: ePersonEndpoint
|
||||||
|
}),
|
||||||
|
});
|
||||||
objectCache = {} as ObjectCacheService;
|
objectCache = {} as ObjectCacheService;
|
||||||
const notificationsService = {} as NotificationsService;
|
const notificationsService = {} as NotificationsService;
|
||||||
const http = {} as HttpClient;
|
const http = {} as HttpClient;
|
||||||
@@ -129,7 +141,9 @@ describe('ResourcePolicyService', () => {
|
|||||||
halService,
|
halService,
|
||||||
notificationsService,
|
notificationsService,
|
||||||
http,
|
http,
|
||||||
comparator
|
comparator,
|
||||||
|
ePersonService,
|
||||||
|
groupService
|
||||||
);
|
);
|
||||||
|
|
||||||
spyOn((service as any).dataService, 'create').and.callThrough();
|
spyOn((service as any).dataService, 'create').and.callThrough();
|
||||||
@@ -320,4 +334,17 @@ describe('ResourcePolicyService', () => {
|
|||||||
expect(result).toBeObservable(expected);
|
expect(result).toBeObservable(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateTarget', () => {
|
||||||
|
it('should create a new PUT request for eperson', () => {
|
||||||
|
const targetType = 'eperson';
|
||||||
|
|
||||||
|
const result = service.updateTarget(resourcePolicyId, requestURL, epersonUUID, targetType);
|
||||||
|
const expected = cold('a|', {
|
||||||
|
a: resourcePolicyRD
|
||||||
|
});
|
||||||
|
expect(result).toBeObservable(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
/* eslint-disable max-classes-per-file */
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
@@ -23,11 +23,19 @@ import { PaginatedList } from '../data/paginated-list.model';
|
|||||||
import { ActionType } from './models/action-type.model';
|
import { ActionType } from './models/action-type.model';
|
||||||
import { RequestParam } from '../cache/models/request-param.model';
|
import { RequestParam } from '../cache/models/request-param.model';
|
||||||
import { isNotEmpty } from '../../shared/empty.util';
|
import { isNotEmpty } from '../../shared/empty.util';
|
||||||
import { map } from 'rxjs/operators';
|
import { map, take } from 'rxjs/operators';
|
||||||
import { NoContent } from '../shared/NoContent.model';
|
import { NoContent } from '../shared/NoContent.model';
|
||||||
import { getFirstCompletedRemoteData } from '../shared/operators';
|
import { getFirstCompletedRemoteData } from '../shared/operators';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import { FindListOptions } from '../data/find-list-options.model';
|
import { FindListOptions } from '../data/find-list-options.model';
|
||||||
|
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
|
||||||
|
import { PutRequest } from '../data/request.models';
|
||||||
|
import { GenericConstructor } from '../shared/generic-constructor';
|
||||||
|
import { ResponseParsingService } from '../data/parsing.service';
|
||||||
|
import { StatusCodeOnlyResponseParsingService } from '../data/status-code-only-response-parsing.service';
|
||||||
|
import { HALLink } from '../shared/hal-link.model';
|
||||||
|
import { EPersonDataService } from '../eperson/eperson-data.service';
|
||||||
|
import { GroupDataService } from '../eperson/group-data.service';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +52,8 @@ class DataServiceImpl extends DataService<ResourcePolicy> {
|
|||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected http: HttpClient,
|
protected http: HttpClient,
|
||||||
protected comparator: ChangeAnalyzer<ResourcePolicy>) {
|
protected comparator: ChangeAnalyzer<ResourcePolicy>,
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +77,10 @@ export class ResourcePolicyService {
|
|||||||
protected halService: HALEndpointService,
|
protected halService: HALEndpointService,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected http: HttpClient,
|
protected http: HttpClient,
|
||||||
protected comparator: DefaultChangeAnalyzer<ResourcePolicy>) {
|
protected comparator: DefaultChangeAnalyzer<ResourcePolicy>,
|
||||||
|
protected ePersonService: EPersonDataService,
|
||||||
|
protected groupService: GroupDataService,
|
||||||
|
) {
|
||||||
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
|
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,4 +233,44 @@ export class ResourcePolicyService {
|
|||||||
return this.dataService.searchBy(this.searchByResourceMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
|
return this.dataService.searchBy(this.searchByResourceMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the target of the resource policy
|
||||||
|
* @param resourcePolicyId the ID of the resource policy
|
||||||
|
* @param resourcePolicyHref the link to the resource policy
|
||||||
|
* @param targetUUID the UUID of the target to which the permission is being granted
|
||||||
|
* @param targetType the type of the target (eperson or group) to which the permission is being granted
|
||||||
|
*/
|
||||||
|
updateTarget(resourcePolicyId: string, resourcePolicyHref: string, targetUUID: string, targetType: string): Observable<RemoteData<any>> {
|
||||||
|
|
||||||
|
const targetService = targetType === 'eperson' ? this.ePersonService : this.groupService;
|
||||||
|
|
||||||
|
const targetEndpoint$ = targetService.getBrowseEndpoint().pipe(
|
||||||
|
take(1),
|
||||||
|
map((endpoint: string) =>`${endpoint}/${targetUUID}`),
|
||||||
|
);
|
||||||
|
|
||||||
|
const options: HttpOptions = Object.create({});
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.append('Content-Type', 'text/uri-list');
|
||||||
|
options.headers = headers;
|
||||||
|
|
||||||
|
const requestId = this.requestService.generateRequestId();
|
||||||
|
|
||||||
|
this.requestService.setStaleByHrefSubstring(`${this.dataService.getLinkPath()}/${resourcePolicyId}/${targetType}`);
|
||||||
|
|
||||||
|
targetEndpoint$.subscribe((targetEndpoint) => {
|
||||||
|
const resourceEndpoint = resourcePolicyHref + '/' + targetType;
|
||||||
|
const request = new PutRequest(requestId, resourceEndpoint, targetEndpoint, options);
|
||||||
|
Object.assign(request, {
|
||||||
|
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||||
|
return StatusCodeOnlyResponseParsingService;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.requestService.send(request);
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.rdbService.buildFromRequestUUID(requestId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
import { throwError as observableThrowError } from 'rxjs';
|
|
||||||
import { catchError } from 'rxjs/operators';
|
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ApiService {
|
|
||||||
constructor(public _http: HttpClient) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* whatever domain/feature method name
|
|
||||||
*/
|
|
||||||
get(url: string, options?: any) {
|
|
||||||
return this._http.get(url, options).pipe(
|
|
||||||
catchError((err) => {
|
|
||||||
console.log('Error: ', err);
|
|
||||||
return observableThrowError(err);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
45
src/app/core/services/link-head.service.spec.ts
Normal file
45
src/app/core/services/link-head.service.spec.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
import { Renderer2, RendererFactory2 } from '@angular/core';
|
||||||
|
import { TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
|
import { MockProvider } from 'ng-mocks';
|
||||||
|
import { LinkHeadService } from './link-head.service';
|
||||||
|
|
||||||
|
describe('LinkHeadService', () => {
|
||||||
|
|
||||||
|
let service: LinkHeadService;
|
||||||
|
|
||||||
|
const renderer2: Renderer2 = {
|
||||||
|
createRenderer: jasmine.createSpy('createRenderer'),
|
||||||
|
createElement: jasmine.createSpy('createElement'),
|
||||||
|
setAttribute: jasmine.createSpy('setAttribute'),
|
||||||
|
appendChild: jasmine.createSpy('appendChild')
|
||||||
|
} as unknown as Renderer2;
|
||||||
|
|
||||||
|
beforeEach(waitForAsync(() => {
|
||||||
|
return TestBed.configureTestingModule({
|
||||||
|
providers: [
|
||||||
|
MockProvider(RendererFactory2, {
|
||||||
|
createRenderer: () => renderer2
|
||||||
|
}),
|
||||||
|
{ provide: Document, useExisting: DOCUMENT },
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
service = new LinkHeadService(TestBed.inject(RendererFactory2), TestBed.inject(DOCUMENT));
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('link', () => {
|
||||||
|
it('should create a link tag', () => {
|
||||||
|
const link = service.addTag({
|
||||||
|
href: 'test',
|
||||||
|
type: 'application/atom+xml',
|
||||||
|
rel: 'alternate',
|
||||||
|
title: 'Sitewide Atom feed'
|
||||||
|
});
|
||||||
|
expect(link).not.toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
90
src/app/core/services/link-head.service.ts
Normal file
90
src/app/core/services/link-head.service.ts
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import { Injectable, RendererFactory2, ViewEncapsulation, Inject } from '@angular/core';
|
||||||
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LinkHead Service injects <link> tag into the head element during runtime.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class LinkHeadService {
|
||||||
|
constructor(
|
||||||
|
private rendererFactory: RendererFactory2,
|
||||||
|
@Inject(DOCUMENT) private document
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to create a Link tag in the HEAD of the html.
|
||||||
|
* @param tag LinkDefition is the paramaters to define a link tag.
|
||||||
|
* @returns Link tag that was created
|
||||||
|
*/
|
||||||
|
addTag(tag: LinkDefinition) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
const renderer = this.rendererFactory.createRenderer(this.document, {
|
||||||
|
id: '-1',
|
||||||
|
encapsulation: ViewEncapsulation.None,
|
||||||
|
styles: [],
|
||||||
|
data: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
const link = renderer.createElement('link');
|
||||||
|
const head = this.document.head;
|
||||||
|
|
||||||
|
if (head === null) {
|
||||||
|
throw new Error('<head> not found within DOCUMENT.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(tag).forEach((prop: string) => {
|
||||||
|
return renderer.setAttribute(link, prop, tag[prop]);
|
||||||
|
});
|
||||||
|
|
||||||
|
renderer.appendChild(head, link);
|
||||||
|
return renderer;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error within linkService : ', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a link tag in header based on the given attrSelector.
|
||||||
|
* @param attrSelector The attr assigned to a link tag which will be used to determine what link to remove.
|
||||||
|
*/
|
||||||
|
removeTag(attrSelector: string) {
|
||||||
|
if (attrSelector) {
|
||||||
|
try {
|
||||||
|
const renderer = this.rendererFactory.createRenderer(this.document, {
|
||||||
|
id: '-1',
|
||||||
|
encapsulation: ViewEncapsulation.None,
|
||||||
|
styles: [],
|
||||||
|
data: {}
|
||||||
|
});
|
||||||
|
const head = this.document.head;
|
||||||
|
if (head === null) {
|
||||||
|
throw new Error('<head> not found within DOCUMENT.');
|
||||||
|
}
|
||||||
|
const linkTags = this.document.querySelectorAll('link[' + attrSelector + ']');
|
||||||
|
for (const link of linkTags) {
|
||||||
|
renderer.removeChild(head, link);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Error while removing tag ' + e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export declare type LinkDefinition = {
|
||||||
|
charset?: string;
|
||||||
|
crossorigin?: string;
|
||||||
|
href?: string;
|
||||||
|
hreflang?: string;
|
||||||
|
media?: string;
|
||||||
|
rel?: string;
|
||||||
|
rev?: string;
|
||||||
|
sizes?: string;
|
||||||
|
target?: string;
|
||||||
|
type?: string;
|
||||||
|
} & {
|
||||||
|
[prop: string]: string;
|
||||||
|
};
|
@@ -7,13 +7,13 @@ import { BITSTREAM_FORMAT } from './bitstream-format.resource-type';
|
|||||||
import { BITSTREAM } from './bitstream.resource-type';
|
import { BITSTREAM } from './bitstream.resource-type';
|
||||||
import { DSpaceObject } from './dspace-object.model';
|
import { DSpaceObject } from './dspace-object.model';
|
||||||
import { HALLink } from './hal-link.model';
|
import { HALLink } from './hal-link.model';
|
||||||
import { HALResource } from './hal-resource.model';
|
|
||||||
import {BUNDLE} from './bundle.resource-type';
|
import {BUNDLE} from './bundle.resource-type';
|
||||||
import {Bundle} from './bundle.model';
|
import {Bundle} from './bundle.model';
|
||||||
|
import { ChildHALResource } from './child-hal-resource.model';
|
||||||
|
|
||||||
@typedObject
|
@typedObject
|
||||||
@inheritSerialization(DSpaceObject)
|
@inheritSerialization(DSpaceObject)
|
||||||
export class Bitstream extends DSpaceObject implements HALResource {
|
export class Bitstream extends DSpaceObject implements ChildHALResource {
|
||||||
static type = BITSTREAM;
|
static type = BITSTREAM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,4 +66,8 @@ export class Bitstream extends DSpaceObject implements HALResource {
|
|||||||
*/
|
*/
|
||||||
@link(BUNDLE)
|
@link(BUNDLE)
|
||||||
bundle?: Observable<RemoteData<Bundle>>;
|
bundle?: Observable<RemoteData<Bundle>>;
|
||||||
|
|
||||||
|
getParentLinkKey(): keyof this['_links'] {
|
||||||
|
return 'format';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ import { getMockRequestService } from '../../shared/mocks/request.service.mock';
|
|||||||
import { RequestService } from '../data/request.service';
|
import { RequestService } from '../data/request.service';
|
||||||
import { HALEndpointService } from './hal-endpoint.service';
|
import { HALEndpointService } from './hal-endpoint.service';
|
||||||
import { EndpointMapRequest } from '../data/request.models';
|
import { EndpointMapRequest } from '../data/request.models';
|
||||||
import { combineLatest as observableCombineLatest, of as observableOf } from 'rxjs';
|
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||||
@@ -162,9 +162,9 @@ describe('HALEndpointService', () => {
|
|||||||
return observableOf(endpointMaps[param]);
|
return observableOf(endpointMaps[param]);
|
||||||
});
|
});
|
||||||
|
|
||||||
observableCombineLatest([
|
observableCombineLatest<string[]>([
|
||||||
(service as any).getEndpointAt(start, 'one'),
|
(service as any).getEndpointAt(start, 'one'),
|
||||||
(service as any).getEndpointAt(start, 'one', 'two')
|
(service as any).getEndpointAt(start, 'one', 'two'),
|
||||||
]).subscribe(([endpoint1, endpoint2]) => {
|
]).subscribe(([endpoint1, endpoint2]) => {
|
||||||
expect(endpoint1).toEqual(one);
|
expect(endpoint1).toEqual(one);
|
||||||
expect(endpoint2).toEqual(two);
|
expect(endpoint2).toEqual(two);
|
||||||
|
@@ -21,6 +21,8 @@ import { Version } from './version.model';
|
|||||||
import { VERSION } from './version.resource-type';
|
import { VERSION } from './version.resource-type';
|
||||||
import { BITSTREAM } from './bitstream.resource-type';
|
import { BITSTREAM } from './bitstream.resource-type';
|
||||||
import { Bitstream } from './bitstream.model';
|
import { Bitstream } from './bitstream.model';
|
||||||
|
import { ACCESS_STATUS } from 'src/app/shared/object-list/access-status-badge/access-status.resource-type';
|
||||||
|
import { AccessStatusObject } from 'src/app/shared/object-list/access-status-badge/access-status.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a DSpace Item
|
* Class representing a DSpace Item
|
||||||
@@ -72,6 +74,7 @@ export class Item extends DSpaceObject implements ChildHALResource {
|
|||||||
templateItemOf: HALLink;
|
templateItemOf: HALLink;
|
||||||
version: HALLink;
|
version: HALLink;
|
||||||
thumbnail: HALLink;
|
thumbnail: HALLink;
|
||||||
|
accessStatus: HALLink;
|
||||||
self: HALLink;
|
self: HALLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,6 +113,13 @@ export class Item extends DSpaceObject implements ChildHALResource {
|
|||||||
@link(BITSTREAM, false, 'thumbnail')
|
@link(BITSTREAM, false, 'thumbnail')
|
||||||
thumbnail?: Observable<RemoteData<Bitstream>>;
|
thumbnail?: Observable<RemoteData<Bitstream>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The access status for this Item
|
||||||
|
* Will be undefined unless the access status {@link HALLink} has been resolved.
|
||||||
|
*/
|
||||||
|
@link(ACCESS_STATUS)
|
||||||
|
accessStatus?: Observable<RemoteData<AccessStatusObject>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that returns as which type of object this object should be rendered
|
* Method that returns as which type of object this object should be rendered
|
||||||
*/
|
*/
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
import { combineLatest as observableCombineLatest, Observable, interval } from 'rxjs';
|
||||||
import { debounceTime, filter, find, map, switchMap, take, takeWhile } from 'rxjs/operators';
|
import { filter, find, map, switchMap, take, takeWhile, debounce, debounceTime } from 'rxjs/operators';
|
||||||
import { hasNoValue, hasValue, hasValueOperator, isNotEmpty } from '../../shared/empty.util';
|
import { hasNoValue, hasValue, hasValueOperator, isNotEmpty } from '../../shared/empty.util';
|
||||||
import { SearchResult } from '../../shared/search/models/search-result.model';
|
import { SearchResult } from '../../shared/search/models/search-result.model';
|
||||||
import { PaginatedList } from '../data/paginated-list.model';
|
import { PaginatedList } from '../data/paginated-list.model';
|
||||||
@@ -9,6 +9,17 @@ import { MetadataSchema } from '../metadata/metadata-schema.model';
|
|||||||
import { BrowseDefinition } from './browse-definition.model';
|
import { BrowseDefinition } from './browse-definition.model';
|
||||||
import { DSpaceObject } from './dspace-object.model';
|
import { DSpaceObject } from './dspace-object.model';
|
||||||
import { InjectionToken } from '@angular/core';
|
import { InjectionToken } from '@angular/core';
|
||||||
|
import { MonoTypeOperatorFunction, SchedulerLike } from 'rxjs/internal/types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method instead of the RxJs debounceTime if you're waiting for debouncing in tests;
|
||||||
|
* debounceTime doesn't work with fakeAsync/tick anymore as of Angular 13.2.6 & RxJs 7.5.5
|
||||||
|
* Workaround suggested in https://github.com/angular/angular/issues/44351#issuecomment-1107454054
|
||||||
|
* todo: remove once the above issue is fixed
|
||||||
|
*/
|
||||||
|
export const debounceTimeWorkaround = <T>(dueTime: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T> => {
|
||||||
|
return debounce(() => interval(dueTime, scheduler));
|
||||||
|
};
|
||||||
|
|
||||||
export const DEBOUNCE_TIME_OPERATOR = new InjectionToken<<T>(dueTime: number) => (source: Observable<T>) => Observable<T>>('debounceTime', {
|
export const DEBOUNCE_TIME_OPERATOR = new InjectionToken<<T>(dueTime: number) => (source: Observable<T>) => Observable<T>>('debounceTime', {
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
@@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* An interface to represent an access condition.
|
||||||
|
*/
|
||||||
|
export class SherpaPoliciesDetailsObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sherpa policies error
|
||||||
|
*/
|
||||||
|
error: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sherpa policies journal details
|
||||||
|
*/
|
||||||
|
journals: Journal[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sherpa policies message
|
||||||
|
*/
|
||||||
|
message: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sherpa policies metadata
|
||||||
|
*/
|
||||||
|
metadata: Metadata;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface Metadata {
|
||||||
|
id: number;
|
||||||
|
uri: string;
|
||||||
|
dateCreated: string;
|
||||||
|
dateModified: string;
|
||||||
|
inDOAJ: boolean;
|
||||||
|
publiclyVisible: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface Journal {
|
||||||
|
titles: string[];
|
||||||
|
url: string;
|
||||||
|
issns: string[];
|
||||||
|
romeoPub: string;
|
||||||
|
zetoPub: string;
|
||||||
|
inDOAJ: boolean;
|
||||||
|
publisher: Publisher;
|
||||||
|
publishers: Publisher[];
|
||||||
|
policies: Policy[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Publisher {
|
||||||
|
name: string;
|
||||||
|
relationshipType: string;
|
||||||
|
country: string;
|
||||||
|
uri: string;
|
||||||
|
identifier: string;
|
||||||
|
paidAccessDescription: string;
|
||||||
|
paidAccessUrl: string;
|
||||||
|
publicationCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Policy {
|
||||||
|
id: number;
|
||||||
|
openAccessPermitted: boolean;
|
||||||
|
uri: string;
|
||||||
|
internalMoniker: string;
|
||||||
|
permittedVersions: PermittedVersions[];
|
||||||
|
urls: any;
|
||||||
|
publicationCount: number;
|
||||||
|
preArchiving: string;
|
||||||
|
postArchiving: string;
|
||||||
|
pubArchiving: string;
|
||||||
|
openAccessProhibited: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PermittedVersions {
|
||||||
|
articleVersion: string;
|
||||||
|
option: number;
|
||||||
|
conditions: string[];
|
||||||
|
prerequisites: string[];
|
||||||
|
locations: string[];
|
||||||
|
licenses: string[];
|
||||||
|
embargo: Embargo;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Embargo {
|
||||||
|
units: any;
|
||||||
|
amount: any;
|
||||||
|
}
|
@@ -0,0 +1,22 @@
|
|||||||
|
import { SherpaPoliciesDetailsObject } from './sherpa-policies-details.model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An interface to represent the submission's item accesses condition.
|
||||||
|
*/
|
||||||
|
export interface WorkspaceitemSectionSherpaPoliciesObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The access condition id
|
||||||
|
*/
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sherpa policies retrievalTime
|
||||||
|
*/
|
||||||
|
retrievalTime: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sherpa policies details
|
||||||
|
*/
|
||||||
|
sherpaResponse: SherpaPoliciesDetailsObject;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user