Skip to content

Commit

Permalink
Merge pull request #18 from ufal/dataquest/dtq-dev
Browse files Browse the repository at this point in the history
merging dataquest-dev/dtq-dev
  • Loading branch information
kosarko authored Dec 4, 2024
2 parents 7899a88 + 7dc1ec8 commit 1a90e54
Show file tree
Hide file tree
Showing 61 changed files with 6,765 additions and 224 deletions.
12 changes: 8 additions & 4 deletions .github/disabled-workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
working-directory: build-scripts/run/
run: |
./start.sh dspace-$INSTANCE
cd ../..
# use customized docker-compose file for the `85` port because the server is exposed with the namespace `repository`
# `/repository/server`
docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f /opt/dspace-envs/5/docker-compose-rest.yml -f /opt/dspace-envs/5/docker-compose.yml up -d --no-build
deploy-8:
if: inputs.INSTANCE == '*' || inputs.INSTANCE == '8'
Expand Down Expand Up @@ -147,7 +151,7 @@ jobs:
playwright-after-deploy8:
runs-on: ubuntu-latest
needs: deploy-8
timeout-minutes: 15
timeout-minutes: 45
if: '!inputs.IMPORT'
steps:
- name: run playwright
Expand Down Expand Up @@ -184,7 +188,7 @@ jobs:
rest-tests-after-deploy8:
runs-on: ubuntu-latest
needs: playwright-after-deploy8
timeout-minutes: 15
timeout-minutes: 45
steps:
- name: run rest-tests
run: |
Expand Down Expand Up @@ -219,7 +223,7 @@ jobs:
runs-on: ubuntu-latest
needs: import-8
if: inputs.IMPORT
timeout-minutes: 15
timeout-minutes: 45
steps:
- name: run playwright
run: |
Expand Down Expand Up @@ -256,7 +260,7 @@ jobs:
rest-tests-after-import8:
runs-on: ubuntu-latest
needs: playwright-after-import8
timeout-minutes: 15
timeout-minutes: 45
steps:
- name: run rest-tests
run: |
Expand Down
4 changes: 4 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,7 @@ vocabularies:
comcolSelectionSort:
sortField: 'dc.title'
sortDirection: 'ASC'

matomo:
hostUrl: http://localhost:8135/
siteId: 1
22 changes: 0 additions & 22 deletions cypress/e2e/submission-ui.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,6 @@ describe('Create a new submission', () => {
createItemProcess.showErrorNotSupportedLicense();
});

// Author field should consist of two input fields
it('Author field should consist of two input fields', {
retries: {
runMode: 6,
openMode: 6,
},
defaultCommandTimeout: 10000
},() => {
createItemProcess.checkAuthorFirstnameField();
createItemProcess.checkAuthorLastnameField();
});

it('The submission should not have the Notice Step', {
retries: {
runMode: 6,
Expand All @@ -261,16 +249,6 @@ describe('Create a new submission in the clariah collection', () => {
// This page is restricted, so we will be shown the login form. Fill it out & submit.
cy.loginViaForm(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
});

it('The submission should have the Notice Step', {
retries: {
runMode: 6,
openMode: 6,
},
defaultCommandTimeout: 10000
},() => {
createItemProcess.checkClarinNoticeStep();
});
});

function addEUSponsor(euSponsorOrder) {
Expand Down
12 changes: 8 additions & 4 deletions docker/docker-compose-rest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ services:
# BE server port
- published: 808${INSTANCE}
target: 8080
host_ip: 127.0.0.1
host_ip: ${HOST_IP:-127.0.0.1}
# original debug port
- published: 800${INSTANCE}
target: 8000
host_ip: 127.0.0.1
host_ip: ${HOST_IP:-127.0.0.1}
# handle binary port as per https://www.handle.net/hnr_support.html (5th paragraph)
- published: 264${INSTANCE}
target: 2641
Expand All @@ -92,6 +92,10 @@ services:
entrypoint:
- /bin/bash
- '-c'
# When customizing the namespace, add the following command to the entrypoint command below (after `while ...`):
# `pushd ../webapps && unlink server && ln -s /dspace/webapps/server/ 'repository#server' && popd`
# This will create a symlink from the webapps directory to the server directory with the custom namespace
# (e.g. /dspace/webapps/server -> /dspace/webapps/repository#server)
- |
while (!</dev/tcp/dspacedb/543${INSTANCE}) > /dev/null 2>&1; do sleep 1; done;
/dspace/bin/dspace database migrate force
Expand All @@ -111,7 +115,7 @@ services:
ports:
- published: 543${INSTANCE}
target: 543${INSTANCE}
host_ip: 127.0.0.1
host_ip: ${HOST_IP:-127.0.0.1}
stdin_open: true
tty: true
volumes:
Expand All @@ -132,7 +136,7 @@ services:
ports:
- published: 898${INSTANCE}
target: 898${INSTANCE}
host_ip: 127.0.0.1
host_ip: ${HOST_IP:-127.0.0.1}
stdin_open: true
tty: true
working_dir: /var/solr/data
Expand Down
12 changes: 7 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ services:
TZ: ${TIMEZONE:-Europe/Bratislava}
DSPACE_UI_SSL: 'false'
DSPACE_UI_HOST: dspace-angular
# Use only `4000`, not the {UI_PORT} from the .env because in the container it is always `4000`
DSPACE_UI_PORT: 4000
DSPACE_UI_NAMESPACE: /
DSPACE_UI_NAMESPACE: ${DSPACE_UI_NAMESPACE:-/}
DSPACE_REST_SSL: ${DSPACE_SSL:-false}
DSPACE_REST_HOST: ${DSPACE_HOST:-localhost}
DSPACE_REST_PORT: ${DSPACE_REST_PORT}
DSPACE_REST_NAMESPACE: /server
DSPACE_REST_PORT: ${DSPACE_REST_PORT:-8080}
DSPACE_REST_NAMESPACE: ${DSPACE_REST_NAMESPACE:-/server}
image: ${DSPACE_UI_IMAGE:-ufal/dspace-angular:dspace-7_x}
volumes:
- ./config.prod.yml:/app/config/config.prod.yml
# - ./aai.js:/app/dist/browser/aai.js
# - ./dspace-ui.json:/app/docker/dspace-ui.json:rw
build:
context: ..
Expand All @@ -35,9 +37,9 @@ services:
ports:
- published: 400${INSTANCE}
target: 4000
host_ip: 127.0.0.1
host_ip: ${HOST_IP:-127.0.0.1}
- published: 987${INSTANCE}
target: 987${INSTANCE}
host_ip: 127.0.0.1
host_ip: ${HOST_IP:-127.0.0.1}
stdin_open: true
tty: true
7 changes: 7 additions & 0 deletions docker/matomo-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Matomo settings for tracking statistics. This file could be mounted in the docker container.
*/
export const matomoSettings = {
hostUrl: 'http://localhost:8135/',
siteId: '1'
};
19 changes: 18 additions & 1 deletion src/aai/aai.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@

if (redirectUrlFromLogin != null && redirectUrlFromLogin !== '') {
// Redirect from the login page with retrieved redirect URL
redirectUrl = window.location.origin + (namespace === '' ? namespace : '/' + namespace) + redirectUrlFromLogin;
var baseUrl = window.location.origin + formatNamespace(namespace);
var redirectPath = ensureLeadingSlash(redirectUrlFromLogin);

redirectUrl = baseUrl + redirectPath;
}

// Encode the redirect URL
Expand Down Expand Up @@ -129,6 +132,20 @@
var cookieString = name + '=' + value + ';expires=' + expirationDate.toUTCString() + ';path=/';
document.cookie = cookieString;
}

/**
* Return empty string if namespace is empty, otherwise return namespace with leading slash.
*/
function formatNamespace(namespace) {
return namespace === '' ? '' : ensureLeadingSlash(namespace);
}

/**
* Ensure that the path starts with a leading slash.
*/
function ensureLeadingSlash(path) {
return path.startsWith('/') ? path : '/' + path;
}
}

if (!window.aai) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2 id="header" class="border-bottom pb-2">{{'clarin.license.agreement.title' |
<div class="card bg-clarin-yellow border-clarin-yellow">
<div class="card-body text-center">
<a [href]="clarinLicense?.definition">{{clarinLicense?.name}}</a>
<div *ngIf="clarinLicense?.name === LICENSE_NAME_SEZNAM && loadLicenseContentSeznam()"
<div *ngIf="clarinLicense?.name === LICENSE_NAME_SEZNAM"
class="pt-3"
[innerHTML]="(licenseContentSeznam | async) | dsSafeHtml">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export class ClarinLicenseAgreementPageComponent implements OnInit {
// The user is signed in and has record in the userRegistration
// Load userRegistration and userMetadata from userRegistration repository
this.loadUserRegistrationAndUserMetadata();

// Load the Seznam dataset license content
this.loadLicenseContentSeznam();
}

/**
Expand Down
33 changes: 25 additions & 8 deletions src/app/change-submitter-page/change-submitter-page.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
<div class="container pt-2 pb-4" *ngVar="submitter | async as sub">
<h3>{{'share.submission.page.title' | translate}}</h3>
<span>{{'change.submitter.page.message' | translate}}</span>
<span>{{getSubmitterName(sub)}}</span>
<span> ({{sub?.email}})</span>
<div class="pt-4">
<button class="btn btn-info" (click)="changeSubmitter()">
<div *ngVar="item | async as item" >
<h3>{{'share.submission.page.title' | translate}}</h3>
<div *ngIf="sub">
<span>{{'change.submitter.page.message' | translate}}</span>
<span class="font-weight-bold">{{getName(sub)}}</span>
<span class="font-weight-bold"> ({{sub?.email}})</span>
</div>
<div *ngIf="sub == null">
<span>{{'change.submitter.page.cannot.see.submitter.message' | translate}}</span>
</div>

<div>
<span>{{'change.submitter.page.items.handle.message' | translate}}</span>
<span class="font-weight-bold">{{item?.handle}}</span>
</div>
<div>
<span>{{'change.submitter.page.items.name.message' | translate}}</span>
<span class="font-weight-bold">{{getName(item)}}</span>
</div>

<div class="pt-4">
<button class="btn btn-info" (click)="changeSubmitter()">
<span *ngIf="changeSubmitterSpinner"
class="spinner-border spinner-border-sm spinner-button mr-1" role="status" aria-hidden="true">
</span>
<span>{{'change.submitter.page.button.take-it' | translate}}</span>
</button>
<span>{{'change.submitter.page.button.take-it' | translate}}</span>
</button>
</div>
</div>
</div>

Expand Down
60 changes: 48 additions & 12 deletions src/app/change-submitter-page/change-submitter-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ import { isNullOrUndef } from 'chart.js/helpers';
import { HALEndpointService } from '../core/shared/hal-endpoint.service';
import { RemoteDataBuildService } from '../core/cache/builders/remote-data-build.service';
import { RequestService } from '../core/data/request.service';
import { PostRequest } from '../core/data/request.models';
import { GetRequest } from '../core/data/request.models';
import { RemoteData } from '../core/data/remote-data';
import { NotificationsService } from '../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { HttpHeaders } from '@angular/common/http';
import { HttpOptions } from '../core/dspace-rest/dspace-rest.service';
import { Item } from '../core/shared/item.model';

@Component({
selector: 'ds-change-submitter-page',
Expand All @@ -34,11 +37,22 @@ export class ChangeSubmitterPageComponent implements OnInit {
*/
private shareToken = '';

/**
* WorkspaceItem id from the url.
* This id is used to get authorization rights to call REST API to change the submitter.
*/
private workspaceitemid = '';

/**
* BehaviorSubject that contains the submitter of the WorkspaceItem.
*/
submitter: BehaviorSubject<EPerson> = new BehaviorSubject(null);

/**
* BehaviorSubject that contains the Item.
*/
item: BehaviorSubject<Item> = new BehaviorSubject(null);

/**
* BehaviorSubject that contains the WorkspaceItem.
*/
Expand All @@ -61,6 +75,8 @@ export class ChangeSubmitterPageComponent implements OnInit {
ngOnInit(): void {
// Load `share_token` param value from the url
this.shareToken = this.route.snapshot.queryParams.share_token;
// Load `workspaceitem_id` param value from the url
this.workspaceitemid = this.route.snapshot.queryParams.workspaceitemid;
this.loadWorkspaceItemAndAssignSubmitter(this.shareToken);
}

Expand All @@ -70,17 +86,36 @@ export class ChangeSubmitterPageComponent implements OnInit {
loadWorkspaceItemAndAssignSubmitter(shareToken: string) {
this.findWorkspaceItemByShareToken(shareToken)?.subscribe((workspaceItem: WorkspaceItem) => {
this.workspaceItem.next(workspaceItem);
this.loadItemFromWorkspaceItem(workspaceItem);
this.loadAndAssignSubmitter(workspaceItem);
});
}

/**
* Load the Item from the WorkspaceItem and assign it to the item BehaviorSubject.
*/
loadItemFromWorkspaceItem(workspaceItem: WorkspaceItem) {
if (workspaceItem.item instanceof Observable<Item>) {
workspaceItem.item
.pipe(getFirstSucceededRemoteDataPayload())
.subscribe((item: Item) => {
this.item.next(item);
});
}
}

/**
* Find a WorkspaceItem by its shareToken.
*/
findWorkspaceItemByShareToken(shareToken: string): Observable<WorkspaceItem> {
let requestHeaders = new HttpHeaders();
const requestOptions: HttpOptions = Object.create({});
requestHeaders = requestHeaders.append('shareToken', shareToken);
requestOptions.headers = requestHeaders;

return this.workspaceItemService.searchBy('shareToken', {
searchParams: [Object.assign(new RequestParam('shareToken', shareToken))]
}, false, false, followLink('submitter')).pipe(getFirstSucceededRemoteListPayload(),
}, false, false, followLink('item'), followLink('submitter')).pipe(getFirstSucceededRemoteListPayload(),
map((workspaceItems: WorkspaceItem[]) => workspaceItems?.[0]));
}

Expand Down Expand Up @@ -112,27 +147,28 @@ export class ChangeSubmitterPageComponent implements OnInit {
}

/**
* Get the name of the submitter using the DSONameService.
* @param submitter
* Get the name of the submitter or item using the DSONameService.
*/
getSubmitterName(submitter: EPerson): string {
if (isNullOrUndef(submitter)) {
getName(object: EPerson | Item) {
if (isNullOrUndef(object)) {
return '';
}
return this.dsoNameService.getName(submitter);
return this.dsoNameService.getName(object);
}

/**
* Change the submitter of the WorkspaceItem using the shareToken. This will send a POST request to the backend when
* Change the submitter of the WorkspaceItem using the shareToken. This will send a GET request to the backend when
* the submitter of the Item is changed.
*/
changeSubmitter() {
const requestId = this.requestService.generateRequestId();

const url = this.halService.getRootHref() + '/submission/setOwner?shareToken=' + this.shareToken;
const postRequest = new PostRequest(requestId, url);
// Send POST request
this.requestService.send(postRequest);
const url = this.halService.getRootHref() + '/submission/setOwner?shareToken=' + this.shareToken +
'&workspaceitemid=' + this.workspaceitemid;

const getRequest = new GetRequest(requestId, url);
// Send GET request
this.requestService.send(getRequest);
this.changeSubmitterSpinner = true;
// Get response
const response = this.rdbService.buildFromRequestUUID(requestId);
Expand Down
Loading

0 comments on commit 1a90e54

Please sign in to comment.