Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@
"packageNotExist": "Ein Paket mit dieser UUID existiert anscheinend nicht in der gewählten Importquelle",
"packageExists": "Ein Paket mit diesem Namen existiert bereits in der GOKB. Prüfen Sie bitte, ob es sich um das selbe Paket handelt.",
"platformExists": "Die Plattform ist in dieser Form noch nicht in der GOKB vorhanden. Wählen Sie in dem Suchfeld entweder eine schon existierende Plattform oder übernehmen Sie die Plattform von der Importquelle.",
"providerExists": "Der Anbieter des Pakets ist in dieser Form noch nicht in der GOKB vorhanden. Wählen Sie in dem Suchfeld entweder einen schon existierenden Anbieter oder übernehmen Sie den Anbieter von der Importquelle."
"providerExists": "Der Anbieter des Pakets ist in dieser Form noch nicht in der GOKB vorhanden. Wählen Sie in dem Suchfeld entweder einen schon existierenden Anbieter oder übernehmen Sie den Anbieter von der Importquelle.",
"wrongImportSource": "Ein Import aus der gewählten Quelle ist aktuell nicht möglich."
},
"adaptSource": "Quelle übernehmen",
"packageName": "Paketname",
Expand Down Expand Up @@ -307,7 +308,9 @@
"missingStartVolume": "Die Angabe eines letzten Bands erfordert ein Anfangsband.",
"refdataLookup": "Unbekannter Wert konnte nicht gespeichert werden.",
"yearFormat": "Bitte geben Sie ein vierstelliges Jahr an.",
"missingStart": "Bitte geben Sie einen Startwert an."
"missingStart": "Bitte geben Sie einen Startwert an.",
"ftpUrlRejected": "Konfigurieren Sie eine FTP-Verbindung unter Transfer-Methode.",
"urlEmpty": "Bitte geben Sie eine URL an."
},
"job": {
"label": "Import | Importe",
Expand Down Expand Up @@ -1907,6 +1910,31 @@
"enableUpdate": "Aktiviert",
"ignoreSizeLimit": "Dateigröße ignorieren",
"url": "URL",
"filePath": "Dateipfad",
"completePath": "Vollständiger FTP-Pfad",
"testFtpConnection": {
"label": "Verbindung testen",
"message": {
"success": "Verbindung erfolgreich",
"partlySuccessful": "Die Verbindung zum Server konnte hergestellt werden, die Datei ist (derzeit) aber nicht vorhanden.",
"connectError": "Es konnte keine Verbindung zum FTP-Server hergestellt werden.",
"configurationError": "Die Konfiguration ist fehlerhaft.",
"dateMaskFound": "Eine Datei mit diesem Namen und einem Datumszusatz wurde gefunden.",
"dateMaskNotFound": "Eine Datei mit diesem Namen und einem Datumszusatz ist derzeit nicht vorhanden."
}
},
"transferMethod": {
"label": "Transfer-Methode",
"HTTP": {
"label": "HTTP"
},
"FTP": {
"label": "FTP"
}
},
"endpointConfiguration": {
"label": "Konfiguration"
},
"frequency": {
"label": "Update-Zyklus",
"Daily": {
Expand Down
32 changes: 30 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@
"packageNotExist": "A package with this UUID does not seem to exist in the chosen import repository",
"packageExists": "A package with this name already exists in the GOKB. Please check if this is a unique package you are trying to import.",
"platformExists": "The platform doesn't exist in the GOKB yet. Choose an existing platform in the search field or adopt the platform from the import source.",
"providerExists": "The provider doesn't exist in the GOKB yet. Choose an existing provider in the search field or adopt the provider from the import source."
"providerExists": "The provider doesn't exist in the GOKB yet. Choose an existing provider in the search field or adopt the provider from the import source.",
"wrongImportSource": "An import from the selected source is not possible."
},
"adaptSource": "Adopt from source",
"packageName": "Package name",
Expand Down Expand Up @@ -307,7 +308,9 @@
"missingStartVolume": "An end volume requires a set start volume!",
"refdataLookup": "Unable to save unrecognized value!",
"yearFormat": "Please enter a four digit year.",
"missingStart": "Please first provide a start value."
"missingStart": "Please first provide a start value.",
"ftpUrlRejected": "Configure an FTP connection under Transfer method.",
"urlEmpty": "Please provide a URL."
},
"job": {
"label": "Import | Imports",
Expand Down Expand Up @@ -1898,6 +1901,31 @@
"enableUpdate": "Activated",
"ignoreSizeLimit": "Ignore Size Limit",
"url": "URL",
"filePath": "File Path",
"completePath": "Complete FTP Path",
"testFtpConnection": {
"label": "Test Connection",
"message": {
"success": "Connection successful",
"partlySuccessful": "Could connect to FTP Server but the File does not exist (at the moment).",
"connectError": "Could not connect to FTP Server.",
"configurationError": "The Configuration is incorrect.",
"dateMaskFound": "A File with this name and a date addition was found.",
"dateMaskNotFound": "A File with this name and a date addition was not found."
}
},
"transferMethod": {
"label": "Transfer Method",
"HTTP": {
"label": "HTTP"
},
"FTP": {
"label": "FTP"
}
},
"endpointConfiguration": {
"label": "Configuration"
},
"frequency": {
"label": "Update Cycle",
"Daily": {
Expand Down
163 changes: 160 additions & 3 deletions src/shared/components/complex/gokb-source-field/gokb-source-field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,68 @@
:hide-default="!expanded"
:sub-title="$tc('component.source.label')"
>

<v-row>
<v-col cols="3">
<gokb-state-field
v-model="item.transferMethod"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When HTTP is selected, ftpUrl and webEndpoint are not cleared, and an existing url can be invisibly present for FTP sources. May not be that problematic right now, but it might cause issues in future.

When HTTP is selected, URLs starting with ftp should no longer be valid for url. Needs adjustment to backend validation.

:init-item="item.transferMethod"
url="refdata/categories/Source.TransferMethod"
:label="$t('component.source.transferMethod.label')"
message-path="component.source.transferMethod"
return-object
dense
/>
</v-col>
</v-row>

<v-row v-if="isFTPTransfer">
<v-col cols="3">
<gokb-webendpoint-field
v-model="item.webEndpoint"
filter-by-protocol="FTP"
:label="$t('component.source.endpointConfiguration.label')"
width="100%"
return-object
/>
</v-col>
<v-col cols="6">
<gokb-text-field
v-model="item.ftpPath"
:label="$t('component.source.filePath')"
:disabled="readonly"

/>

<span >
{{ $t('component.source.completePath') }}: <i>{{ fullFtpUrl }}</i>
<v-icon color="success" v-if="ftpTestSuccessful" >
mdi-check-circle
</v-icon>
</span>
</v-col>
<v-col cols="2">
<gokb-button
v-if="isFTPTransfer && item.webEndpoint && item.ftpPath"
@click.prevent="testFTPConnection"
append-icon="mdi-access-point"
:disabled="ftpTestSuccessful"
>
{{ $t('component.source.testFtpConnection.label') }}
</gokb-button>

<span :style="{ 'color': ftpTestSuccessful ? 'green' : 'red' }"><br/><br/>{{ ftpTestMessage }}</span>

</v-col>
</v-row>

<gokb-url-field
v-else
v-model="item.url"
:label="$t('component.source.url')"
:readonly="readonly || isImportFromExternalSource"
replace-date
reject-ftp-url
/>
<v-row>
<v-col cols="3">
Expand Down Expand Up @@ -130,6 +187,7 @@
import providerServices from '@/shared/services/provider-services'
import BaseComponent from '@/shared/components/base-component'
import account from '@/shared/models/account-model'
import webendpointServices from "@/shared/services/webendpoint-services"

export default {
name: 'GokbSourceField',
Expand Down Expand Up @@ -187,27 +245,36 @@
automaticUpdates: undefined,
importConfig: undefined,
ignoreSizeLimit: false,
update: false
update: false,
webEndpoint: undefined,
transferMethod: undefined,
ftpPath: undefined,
},
errors: [],
mixedContent: false,
isExpanded: true,
serialVisible: true,
monographVisible: true,
mixedContentVisible: true,
ignoreLegacyTitleID: true
ignoreLegacyTitleID: true,
isFTPTransfer: false,
ftpTestSuccessful: false,
ftpTestMessage: undefined
}
},
computed: {
importNowDisabled () {
return !this.readonly && !this.item.url
return !this.readonly && (!this.item.url && !(this.isFTPTransfer && !!this.item.ftpPath))
},
activatedDisabled () {
return !this.readonly && (!this.item.url || !this.item.frequency) && !this.item.automaticUpdates
},
activatedErrorMessage () {
return !this.readonly && (!this.item.url || !this.item.frequency) && this.item.automaticUpdates ? this.$i18n.t("component.source.error.activatedNoInfo") : undefined
},
fullFtpUrl () {
return this.formatFtpPath(this.item.ftpPath)
},
isAdmin() {
return account.loggedIn() && account.hasRole('ROLE_ADMIN')
}
Expand Down Expand Up @@ -266,6 +333,23 @@
},
mixedContent () {
this.setVisibleStatusForTitleIdFields()
},
'item.transferMethod': {
handler(val) {
if (!!val && (this.item?.transferMethod?.value === 'FTP' || this.item?.transferMethod?.name === 'FTP')) {
this.isFTPTransfer = true
}
else {
this.isFTPTransfer = false
}
this.resetTestConnectionProps()
}
},
'item.ftpPath'() {
this.resetTestConnectionProps()
},
'item.webEndpoint'() {
this.resetTestConnectionProps()
}
},
async mounted () {
Expand All @@ -286,8 +370,49 @@
} else if (!!this.provider){
this.fetchDefaultNamespace()
}

if (this.item?.transferMethod?.value === 'FTP') {
this.isFTPTransfer = true
}

},
created () {

},
methods: {
resetTestConnectionProps () {
this.ftpTestSuccessful = false
this.ftpTestMessage = undefined
},
formatFtpPath (filepath) {
let hostname = this.item.webEndpoint?.url
let filename = ""
let directory = "/"

if (hostname?.includes("/")) {
let parts = hostname.split("/")
hostname = parts[0]
for(var i = 1; i < parts.length; i++){
directory = directory.concat(parts[i] + "/")
}
}

let ftpPath = this.item.ftpPath
if (ftpPath?.startsWith("/")) {
ftpPath = ftpPath.substring(1)
}

if(ftpPath?.includes("/")){
let parts = ftpPath.split("/")
filename = parts[parts.length - 1]
directory = directory + ftpPath.substring(0, ftpPath.lastIndexOf("/") + 1)
}
else {
filename = ftpPath
}

return hostname + directory + filename
},
setVisibleStatusForTitleIdFields () {
if (this.mixedContent) {
this.serialVisible = true
Expand Down Expand Up @@ -325,6 +450,26 @@
this.item.titleIdMonograph = result.data.titleIdMonograph
this.item.ignoreSizeLimit = result.data.ignoreSizeLimit === true

this.item.ftpPath = result.data.ftpPath
this.item.transferMethod = result.data.transferMethod
this.item.webEndpoint = result.data.webEndpoint

if (this.item.transferMethod?.value === 'FTP' || this.item.transferMethod?.name === 'FTP') {
this.isFTPTransfer = true

if(!!result.data.webEndpoint?.id) {
// complete webendpoint object must be loaded
const response = await this.catchError({
promise: webendpointServices.get(result.data.webEndpoint.id, this.cancelToken.token),
instance: this
})

this.item.webEndpoint = response.data.data

}

}

if (!!this.item.targetNamespace && !this.item.titleIdSerial && !this.item.titleIdMonograph) {
this.ignoreLegacyTitleID = false
}
Expand All @@ -334,6 +479,7 @@
if (!!this.item.url) {
this.isExpanded = true
}

this.setVisibleStatusForTitleIdFields()
}
}
Expand Down Expand Up @@ -365,6 +511,17 @@
this.setVisibleStatusForTitleIdFields()
}
},
async testFTPConnection () {

const checkResult = await this.catchError({
promise: webendpointServices.check({webhookendpoint: this.item.webEndpoint.id, url: this.item.ftpPath}, this.cancelToken.token),
instance: this
})

this.ftpTestSuccessful = (checkResult?.data?.result === 'success')
this.ftpTestMessage = this.$i18n.t('component.source.testFtpConnection.message.' + checkResult?.data?.message)

}
}
}
</script>
13 changes: 8 additions & 5 deletions src/shared/components/simple/gokb-url-field/gokb-url-field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
type: Boolean,
required: false,
default: false
},
rejectFtpUrl: {
type: Boolean,
required: false,
default: false
}
},
computed: {
Expand All @@ -40,13 +45,11 @@
},
methods: {
async validate () {
const validResult = await genericServices('rest/entities').checkUrl(this.localValue, this.replaceDate, createCancelToken.token)
const validResult = await genericServices('rest/entities').checkUrl(this.localValue, this.replaceDate, this.rejectFtpUrl, createCancelToken.token)

if (validResult.data?.result === 'ERROR') {
if (!this.localErrorMessages || this.localErrorMessages.length === 0) {
this.localErrorMessages = [this.$i18n.t('validation.urlForm')]
this.$emit('valid', false)
}
this.localErrorMessages = [this.$i18n.t(validResult.data?.errors?.value?.messageCode)]
this.$emit('valid', false)
}
else {
if (!!this.localErrorMessages) {
Expand Down
Loading