2024-01-03 01:36:56 +01:00
|
|
|
<template>
|
|
|
|
<modals-modal ref="modal" v-model="show" name="custom-metadata-provider" :width="600" :height="'unset'" :processing="processing">
|
|
|
|
<template #outer>
|
|
|
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
|
|
|
<p class="text-3xl text-white truncate">Add custom metadata provider</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<form @submit.prevent="submitForm">
|
2024-02-11 23:48:16 +01:00
|
|
|
<div class="px-4 w-full flex items-center text-sm py-6 rounded-lg bg-bg shadow-lg border border-black-300 overflow-y-auto overflow-x-hidden" style="min-height: 400px; max-height: 80vh">
|
2024-01-03 01:36:56 +01:00
|
|
|
<div class="w-full p-8">
|
2024-02-11 23:48:16 +01:00
|
|
|
<div class="flex mb-2">
|
|
|
|
<div class="w-3/4 p-1">
|
|
|
|
<ui-text-input-with-label v-model="newName" :label="$strings.LabelName" />
|
|
|
|
</div>
|
|
|
|
<div class="w-1/4 p-1">
|
|
|
|
<ui-text-input-with-label value="Book" readonly :label="$strings.LabelMediaType" />
|
|
|
|
</div>
|
2024-01-03 01:36:56 +01:00
|
|
|
</div>
|
2024-02-11 23:48:16 +01:00
|
|
|
<div class="w-full mb-2 p-1">
|
|
|
|
<ui-text-input-with-label v-model="newUrl" label="URL" />
|
2024-01-03 01:36:56 +01:00
|
|
|
</div>
|
2024-02-11 23:48:16 +01:00
|
|
|
<div class="w-full mb-2 p-1">
|
|
|
|
<ui-text-input-with-label v-model="newAuthHeaderValue" :label="'Authorization Header Value'" type="password" />
|
2024-01-03 01:36:56 +01:00
|
|
|
</div>
|
2024-02-11 23:48:16 +01:00
|
|
|
<div class="flex px-1 pt-4">
|
2024-01-03 01:36:56 +01:00
|
|
|
<div class="flex-grow" />
|
|
|
|
<ui-btn color="success" type="submit">{{ $strings.ButtonAdd }}</ui-btn>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</modals-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2024-02-11 23:48:16 +01:00
|
|
|
value: Boolean
|
2024-01-03 01:36:56 +01:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
processing: false,
|
2024-02-11 23:48:16 +01:00
|
|
|
newName: '',
|
|
|
|
newUrl: '',
|
|
|
|
newAuthHeaderValue: ''
|
2024-01-03 01:36:56 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
show: {
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
2024-02-11 23:48:16 +01:00
|
|
|
}
|
2024-01-03 01:36:56 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submitForm() {
|
2024-02-11 23:48:16 +01:00
|
|
|
if (!this.newName || !this.newUrl) {
|
|
|
|
this.$toast.error('Must add name and url')
|
2024-01-03 01:36:56 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.processing = true
|
|
|
|
this.$axios
|
2024-02-11 23:48:16 +01:00
|
|
|
.$post('/api/custom-metadata-providers', {
|
|
|
|
name: this.newName,
|
|
|
|
url: this.newUrl,
|
|
|
|
mediaType: 'book', // Currently only supporting book mediaType
|
|
|
|
authHeaderValue: this.newAuthHeaderValue
|
|
|
|
})
|
|
|
|
.then((data) => {
|
|
|
|
this.$emit('added', data.provider)
|
|
|
|
this.$toast.success('New provider added')
|
|
|
|
this.show = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
const errorMsg = error.response?.data || 'Unknown error'
|
|
|
|
console.error('Failed to add provider', error)
|
|
|
|
this.$toast.error('Failed to add provider: ' + errorMsg)
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.processing = false
|
|
|
|
})
|
2024-01-03 01:36:56 +01:00
|
|
|
},
|
|
|
|
init() {
|
|
|
|
this.processing = false
|
2024-02-11 23:48:16 +01:00
|
|
|
this.newName = ''
|
|
|
|
this.newUrl = ''
|
|
|
|
this.newAuthHeaderValue = ''
|
2024-01-03 01:36:56 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|