Skip to content
Snippets Groups Projects
Commit aa23e65f authored by Hanna Führ's avatar Hanna Führ Committed by Petar Hristov
Browse files

Update: Overhaul PID handling

parent ef7b06ac
No related branches found
No related tags found
2 merge requests!17Release: Sprint/2022 17 :robot:,!16Update: Overhaul PID handling
{
"eslint.nodePath": "../../.yarn/sdks",
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"typescript.tsdk": "../../.yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"cSpell.words": [
"Shacl"
]
}
......@@ -14,17 +14,17 @@ packageExtensions:
"typescript": "*"
"vue-i18n@*":
dependencies:
"vue": "^2.6.12"
"vue": "^2.7.10"
"vue-material-design-icons@*":
dependencies:
"vue": "^2.6.12"
"vue": "^2.7.10"
"vue-router@*":
dependencies:
"vue": "^2.6.12"
"vue": "^2.7.10"
"vuex@*":
dependencies:
"vue": "^2.6.12"
"vue": "^2.7.10"
"bootstrap-vue@*":
dependencies:
"vue": "^2.6.12"
"vue": "^2.7.10"
"jquery": "*"
<template>
<div id="wrap">
<coscine-page-header
:coscineImage="coscineImage"
:coscineImageBlack="coscineImageBlack"
:coscineImage="'.' + coscineImage"
:locale="this.$root.$i18n.locale"
@changeLocale="changeLocale"
/>
......@@ -46,6 +45,7 @@
:state="$v.form.name.$dirty ? !$v.form.name.$error : null"
:placeholder="$t('name')"
required="required"
:disabled="!validPID"
/>
</coscine-form-group>
<coscine-form-group :mandatory="true" labelFor="email" :label="$t('emailLabel')">
......@@ -56,6 +56,7 @@
:state="$v.form.email.$dirty ? !$v.form.email.$error : null"
:placeholder="$t('email')"
required="required"
:disabled="!validPID"
/>
</coscine-form-group>
<coscine-form-group :mandatory="true" labelFor="message" :label="$t('messageLabel')">
......@@ -68,6 +69,7 @@
:state="$v.form.message.$dirty ? !$v.form.message.$error : null"
:placeholder="$t('message')"
:required="true"
:disabled="!validPID"
/>
</coscine-form-group>
<b-row>
......@@ -84,7 +86,7 @@
type="submit"
variant="primary"
id="sendButton"
:disabled="$v.$invalid || !$v.$anyDirty"
:disabled="$v.$invalid || !$v.$anyDirty || !validPID"
name="send"
@click.prevent="sendMail"
style="display: inline"
......@@ -105,7 +107,8 @@
<script lang="ts">
import Vue from 'vue';
import { GuidUtil } from '@coscine/app-util';
import { PIDApi } from '@coscine/api-connection';
import { PidApi } from '@coscine/api-client';
import type { MessageObject } from "@coscine/api-client/dist/types/Coscine.Api.Pid";
import {
CoscinePageHeader,
CoscineFormGroup,
......@@ -114,7 +117,7 @@ import {
import '@coscine/component-library/dist/index.css';
import { validationMixin } from 'vuelidate';
import { required, minLength, maxLength, email } from 'vuelidate/lib/validators';
import { required, maxLength, email } from 'vuelidate/lib/validators';
import coscineImagePath from './assets/logo-rwth.svg';
import linkWhitePath from './assets/link_white.svg';
......@@ -126,11 +129,6 @@ import { ToastPlugin, BIconClipboard } from 'bootstrap-vue';
Vue.use(ToastPlugin);
let scriptPath = '';
let imageEnabled = false;
if (document.currentScript !== undefined) {
scriptPath = (document.currentScript as any).src as string;
imageEnabled = true;
}
const scriptUrl = scriptPath === '' ? '/' : scriptPath.substring(0, scriptPath.indexOf('app.js'));
const rootUrl = scriptPath.indexOf('/js') !== -1 ? scriptUrl.replace('/js', '') : scriptUrl;
......@@ -179,7 +177,8 @@ export default Vue.extend({
name: '',
email: '',
message: '',
},
} as MessageObject,
validPID: true,
};
},
methods: {
......@@ -193,23 +192,20 @@ export default Vue.extend({
copyPID() {
navigator.clipboard.writeText(this.form.pid);
},
sendMail() {
PIDApi.sendMailToOwner(
this.form,
(response: any) => {
async sendMail() {
try {
await PidApi.pidSendMailToOwner(this.form);
this.makeToast(
this.$t('toastMessageSuccessBody').toString(),
this.$t('toastMessageSuccessHeader').toString(),
);
this.resetForm();
},
(error: any) => {
} catch {
this.makeToast(
this.$t('toastMessageFailureBody').toString(),
this.$t('toastMessageFailureHeader').toString(),
);
},
);
}
},
makeToast(text: string = 'Message', givenTitle: string = 'Title') {
this.$bvToast.toast(text, {
......@@ -226,9 +222,26 @@ export default Vue.extend({
this.$v.$reset();
},
},
created() {
async created() {
this.form.guid = GuidUtil.getPIDSuffix();
this.form.pid = GuidUtil.getPID();
try {
const response = await PidApi.pidIsValid(this.form.pid);
} catch (e) {
if (e.response.status === 403) {
this.makeToast(
this.$t('toastMessageDeletedBody').toString(),
this.$t('toastMessageDeletedHeader').toString(),
);
this.validPID = false;
} else if (e.response.status !== 200) {
this.makeToast(
this.$t('toastMessageNotValidBody').toString(),
this.$t('toastMessageNotValidHeader').toString(),
);
this.validPID = false;
}
}
},
});
</script>
......
......@@ -9,7 +9,7 @@ export default {
pidInformationHeadline: 'PID Informationen:',
pidInformationDescription: 'Diese PID gehört zu Daten in einer CoScInE-Ressource. Die referenzierten Daten sind Teil eines Forschungsprojekts in CoScInE',
pidInformationDescription: 'Diese PID gehört zu Daten in einer Coscine-Ressource. Die referenzierten Daten sind Teil eines Forschungsprojekts in Coscine',
pid: 'Persistent Identifier (PID)',
pidLabel: 'Persistent Identifier (PID):',
......@@ -17,7 +17,7 @@ export default {
pidToClipboard: 'PID in Zwischenablage kopiert.',
contactHeadline: 'Kontakt zu PID-Besitzer aufnehmen:',
contactDescription: 'In den meisten Fällen sind die referenzierten Daten nicht öffentlich zugänglich. Sie können sich daher an den Besitzer der Daten wenden und um Zugang bitten. Der Besitzer dieser Ressource wird dann von CoScInE kontaktiert. Die Informationen, die Sie im Formular angeben, werden so an den Besitzer weitergeleitet.',
contactDescription: 'In den meisten Fällen sind die referenzierten Daten nicht öffentlich zugänglich. Sie können sich daher an den Besitzer der Daten wenden und um Zugang bitten. Der Besitzer dieser Ressource wird dann von Coscine kontaktiert. Die Informationen, die Sie im Formular angeben, werden so an den Besitzer weitergeleitet.',
name: 'Ihr Name',
nameLabel: 'Ihr Name:',
......@@ -41,5 +41,11 @@ export default {
toastMessageFailureHeader: 'Fehler beim Senden',
toastMessageFailureBody: 'Die Nachricht konnte nicht gesendet werden. Bitte versuchen Sie es erneut. Falls der Fehler wieder Auftritt, wenden Sie sich bitte an servicedesk@itc.rwth-aachen.de',
toastMessageNotValidHeader: 'Keine valide PID',
toastMessageNotValidBody: 'Die erhaltene PID ist nicht valide.',
toastMessageDeletedHeader: 'Projekt/Ressource de PID gelöscht',
toastMessageDeletedBody: 'Das/Die zugewiesene Projekt/Ressource dieser PID wurde gelöscht.',
character: 'Zeichen',
};
......@@ -9,7 +9,7 @@ export default {
pidInformationHeadline: 'PID Information:',
pidInformationDescription: 'This PID belongs to data stored in a CoScInE resource. The data referenced by this PID is part of a research project in CoScInE',
pidInformationDescription: 'This PID belongs to data stored in a Coscine resource. The data referenced by this PID is part of a research project in Coscine',
pid: 'Persistent Identifier (PID)',
pidLabel: 'Persistent Identifier (PID):',
......@@ -41,5 +41,11 @@ export default {
toastMessageFailureHeader: 'Failed to send message',
toastMessageFailureBody: 'The message could not be sent. Please try again. If the problem persists contact servicedesk@itc.rwth-aachen.de',
toastMessageNotValidHeader: 'Not a valid PID',
toastMessageNotValidBody: 'The received PID is not valid.',
toastMessageDeletedHeader: 'Project/Resource of PID deleted',
toastMessageDeletedBody: 'The assigned Project/Resource of this PID has been deleted.',
character: 'Character',
};
......@@ -3,7 +3,6 @@ declare module '*.vue' {
export default Vue;
}
declare module '@coscine/api-connection';
declare module '@coscine/app-util';
declare module '@coscine/component-library';
......
......@@ -39,5 +39,8 @@
],
"exclude": [
"node_modules"
]
],
"vueCompilerOptions": {
"target": 2.7
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment