Skip to content

Commit

Permalink
Merge pull request #3010 from nichwall/ereader_settings_update
Browse files Browse the repository at this point in the history
Ereader settings update
  • Loading branch information
advplyr authored May 25, 2024
2 parents 5bbcb9c + 6fad452 commit 38ba7fb
Show file tree
Hide file tree
Showing 28 changed files with 111 additions and 32 deletions.
34 changes: 11 additions & 23 deletions client/components/modals/emails/EReaderDeviceModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export default {
ereaderDevice: {
type: Object,
default: () => null
}
},
users: {
type: Array,
default: () => []
},
loadUsers: Function
},
data() {
return {
Expand All @@ -56,8 +61,7 @@ export default {
email: '',
availabilityOption: 'adminAndUp',
users: []
},
users: []
}
}
},
watch: {
Expand Down Expand Up @@ -108,25 +112,13 @@ export default {
methods: {
availabilityOptionChanged(option) {
if (option === 'specificUsers' && !this.users.length) {
this.loadUsers()
this.callLoadUsers()
}
},
async loadUsers() {
async callLoadUsers() {
this.processing = true
this.users = await this.$axios
.$get('/api/users')
.then((res) => {
return res.users.sort((a, b) => {
return a.createdAt - b.createdAt
})
})
.catch((error) => {
console.error('Failed', error)
return []
})
.finally(() => {
this.processing = false
})
await this.loadUsers()
this.processing = false
},
submitForm() {
this.$refs.ereaderNameInput.blur()
Expand Down Expand Up @@ -226,10 +218,6 @@ export default {
this.newDevice.email = this.ereaderDevice.email
this.newDevice.availabilityOption = this.ereaderDevice.availabilityOption || 'adminOrUp'
this.newDevice.users = this.ereaderDevice.users || []
if (this.newDevice.availabilityOption === 'specificUsers' && !this.users.length) {
this.loadUsers()
}
} else {
this.newDevice.name = ''
this.newDevice.email = ''
Expand Down
47 changes: 43 additions & 4 deletions client/pages/config/email.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>
</app-settings-content>

<app-settings-content :header-text="$strings.HeaderEreaderDevices" :description="''">
<app-settings-content :header-text="$strings.HeaderEreaderDevices" :description="$strings.MessageEreaderDevices">
<template #header-items>
<div class="flex-grow" />

Expand All @@ -70,6 +70,7 @@
<tr>
<th class="text-left">{{ $strings.LabelName }}</th>
<th class="text-left">{{ $strings.LabelEmail }}</th>
<th class="text-left">{{ $strings.LabelAccessibleBy }}</th>
<th class="w-40"></th>
</tr>
<tr v-for="device in existingEReaderDevices" :key="device.name">
Expand All @@ -79,6 +80,9 @@
<td class="text-left">
<p class="text-sm md:text-base text-gray-100">{{ device.email }}</p>
</td>
<td class="text-left">
<p class="text-sm md:text-base text-gray-100">{{ getAccessibleBy(device) }}</p>
</td>
<td class="w-40">
<div class="flex justify-end items-center h-10">
<ui-icon-btn icon="edit" borderless :size="8" icon-font-size="1.1rem" :disabled="deletingDeviceName === device.name" class="mx-1" @click="editDeviceClick(device)" />
Expand All @@ -87,12 +91,12 @@
</td>
</tr>
</table>
<div v-else class="text-center py-4">
<div v-else-if="!loading" class="text-center py-4">
<p class="text-lg text-gray-100">No Devices</p>
</div>
</app-settings-content>

<modals-emails-e-reader-device-modal v-model="showEReaderDeviceModal" :existing-devices="existingEReaderDevices" :ereader-device="selectedEReaderDevice" @update="ereaderDevicesUpdated" />
<modals-emails-e-reader-device-modal v-model="showEReaderDeviceModal" :users="users" :existing-devices="existingEReaderDevices" :ereader-device="selectedEReaderDevice" @update="ereaderDevicesUpdated" :loadUsers="loadUsers" />
</div>
</template>

Expand All @@ -105,6 +109,7 @@ export default {
},
data() {
return {
users: [],
loading: false,
savingSettings: false,
sendingTest: false,
Expand Down Expand Up @@ -146,6 +151,30 @@ export default {
...this.settings
}
},
async loadUsers() {
if (this.users.length) return
this.users = await this.$axios
.$get('/api/users')
.then((res) => {
return res.users.sort((a, b) => {
return a.createdAt - b.createdAt
})
})
.catch((error) => {
console.error('Failed', error)
this.$toast.error(this.$strings.ToastFailedToLoadData)
return []
})
},
getAccessibleBy(device) {
const user = device.availabilityOption
if (user === 'userOrUp') return 'Users (excluding Guests)'
if (user === 'guestOrUp') return 'Users (including Guests)'
if (user === 'specificUsers') {
return device.users.map((id) => this.users.find((u) => u.id === id)?.username).join(', ')
}
return 'Admins Only'
},
editDeviceClick(device) {
this.selectedEReaderDevice = device
this.showEReaderDeviceModal = true
Expand Down Expand Up @@ -184,6 +213,11 @@ export default {
ereaderDevicesUpdated(ereaderDevices) {
this.settings.ereaderDevices = ereaderDevices
this.newSettings.ereaderDevices = ereaderDevices.map((d) => ({ ...d }))
// Load users if a device has availability set to specific users
if (ereaderDevices.some((device) => device.availabilityOption === 'specificUsers')) {
this.loadUsers()
}
},
addNewDeviceClick() {
this.selectedEReaderDevice = null
Expand Down Expand Up @@ -251,7 +285,12 @@ export default {
this.$axios
.$get(`/api/emails/settings`)
.then((data) => {
.then(async (data) => {
// Load users if a device has availability set to specific users
if (data.settings.ereaderDevices.some((device) => device.availabilityOption === 'specificUsers')) {
await this.loadUsers()
}
this.settings = data.settings
this.newSettings = {
...this.settings
Expand Down
2 changes: 2 additions & 0 deletions client/strings/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Съкратен",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Тип на Профила",
"LabelAccountTypeAdmin": "Администратор",
"LabelAccountTypeGuest": "Гост",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Плъзнете файлове в правилния ред на каналите",
"MessageEmbedFinished": "Вграждането завърши!",
"MessageEpisodesQueuedForDownload": "{0} епизод(и) в опашка за изтегляне",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "Feed URL-a ще бъде {0}",
"MessageFetching": "Взимане...",
"MessageForceReScanDescription": "ще сканира всички файлове отново като прясно сканиране. Аудио файлове ID3 тагове, OPF файлове и текстови файлове ще бъдат сканирани като нови.",
Expand Down
2 changes: 2 additions & 0 deletions client/strings/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "সংক্ষিপ্ত",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "অ্যাকাউন্টের প্রকার",
"LabelAccountTypeAdmin": "প্রশাসন",
"LabelAccountTypeGuest": "অতিথি",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "সঠিক ট্র্যাক অর্ডারে ফাইল টেনে আনুন",
"MessageEmbedFinished": "এম্বেড করা শেষ!",
"MessageEpisodesQueuedForDownload": "{0} পর্ব(গুলি) ডাউনলোডের জন্য সারিবদ্ধ",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "ফিড URL হবে {0}",
"MessageFetching": "আনয় হচ্ছে...",
"MessageForceReScanDescription": "সকল ফাইল আবার নতুন স্ক্যানের মত স্ক্যান করবে। অডিও ফাইল ID3 ট্যাগ, OPF ফাইল, এবং টেক্সট ফাইলগুলি নতুন হিসাবে স্ক্যান করা হবে।",
Expand Down
2 changes: 2 additions & 0 deletions client/strings/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Zkráceno",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Typ účtu",
"LabelAccountTypeAdmin": "Správce",
"LabelAccountTypeGuest": "Host",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Přetáhněte soubory do správného pořadí stop",
"MessageEmbedFinished": "Vložení dokončeno!",
"MessageEpisodesQueuedForDownload": "{0} epizody zařazené do fronty ke stažení",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "URL zdroje bude {0}",
"MessageFetching": "Stahování...",
"MessageForceReScanDescription": "znovu prohledá všechny soubory jako při novém skenování. ID3 tagy zvukových souborů OPF soubory a textové soubory budou skenovány jako nové.",
Expand Down
2 changes: 2 additions & 0 deletions client/strings/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Abridged",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Kontotype",
"LabelAccountTypeAdmin": "Administrator",
"LabelAccountTypeGuest": "Gæst",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Træk filer ind i korrekt spororden",
"MessageEmbedFinished": "Indlejring færdig!",
"MessageEpisodesQueuedForDownload": "{0} episoder er sat i kø til download",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "Feed-URL vil være {0}",
"MessageFetching": "Henter...",
"MessageForceReScanDescription": "vil scanne alle filer igen som en frisk scanning. Lydfilens ID3-tags, OPF-filer og tekstfiler scannes som nye.",
Expand Down
2 changes: 2 additions & 0 deletions client/strings/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Gekürzt",
"LabelAbridgedChecked": "Gekürzt (angehakt)",
"LabelAbridgedUnchecked": "Ungekürzt (nicht angehakt)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Kontoart",
"LabelAccountTypeAdmin": "Admin",
"LabelAccountTypeGuest": "Gast",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Verschiebe die Dateien in die richtige Reihenfolge",
"MessageEmbedFinished": "Einbettung abgeschlossen!",
"MessageEpisodesQueuedForDownload": "{0} Episode(n) in der Warteschlange zum Herunterladen",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "Feed-URL wird {0} sein",
"MessageFetching": "Abrufen...",
"MessageForceReScanDescription": "Durchsucht alle Dateien erneut, wie bei einem frischen Scan. ID3-Tags von Audiodateien, OPF-Dateien und Textdateien werden neu durchsucht.",
Expand Down
2 changes: 2 additions & 0 deletions client/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Abridged",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Account Type",
"LabelAccountTypeAdmin": "Admin",
"LabelAccountTypeGuest": "Guest",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Drag files into correct track order",
"MessageEmbedFinished": "Embed Finished!",
"MessageEpisodesQueuedForDownload": "{0} Episode(s) queued for download",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "Feed URL will be {0}",
"MessageFetching": "Fetching...",
"MessageForceReScanDescription": "will scan all files again like a fresh scan. Audio file ID3 tags, OPF files, and text files will be scanned as new.",
Expand Down
6 changes: 4 additions & 2 deletions client/strings/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Abreviado",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Tipo de Cuenta",
"LabelAccountTypeAdmin": "Administrador",
"LabelAccountTypeGuest": "Invitado",
Expand Down Expand Up @@ -479,7 +480,7 @@
"LabelSettingsHomePageBookshelfView": "Usar la vista de librero en la página principal",
"LabelSettingsLibraryBookshelfView": "Usar la vista de librero en la biblioteca",
"LabelSettingsOnlyShowLaterBooksInContinueSeries": "Skip earlier books in Continue Series",
"LabelSettingsOnlyShowLaterBooksInContinueSeriesHelp":"El estante de la página de inicio de Continuar Serie muestra el primer libro no iniciado de una serie que tenga por lo menos un libro finalizado y no tenga libros en progreso. Habilitar esta opción le permitirá continuar series desde el último libro que ha completado en vez del primer libro que no ha empezado.",
"LabelSettingsOnlyShowLaterBooksInContinueSeriesHelp": "El estante de la página de inicio de Continuar Serie muestra el primer libro no iniciado de una serie que tenga por lo menos un libro finalizado y no tenga libros en progreso. Habilitar esta opción le permitirá continuar series desde el último libro que ha completado en vez del primer libro que no ha empezado.",
"LabelSettingsParseSubtitles": "Extraer Subtítulos",
"LabelSettingsParseSubtitlesHelp": "Extraer subtítulos de los nombres de las carpetas de los audiolibros.<br>Los subtítulos deben estar separados por \" - \"<br>Por ejemplo: \"Ejemplo de Título - Subtítulo Aquí\" tiene el subtítulo \"Subtítulo Aquí\"",
"LabelSettingsPreferMatchedMetadata": "Preferir metadatos encontrados",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Arrastra los archivos al orden correcto de las pistas.",
"MessageEmbedFinished": "Incrustación Terminada!",
"MessageEpisodesQueuedForDownload": "{0} Episodio(s) en cola para descargar",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "URL de la fuente será {0}",
"MessageFetching": "Buscando...",
"MessageForceReScanDescription": "Escaneará todos los archivos como un nuevo escaneo. Archivos de audio con etiquetas ID3, archivos OPF y archivos de texto serán escaneados como nuevos.",
Expand Down Expand Up @@ -803,4 +805,4 @@
"ToastSortingPrefixesUpdateSuccess": "Prefijos de ordenar actualizaron ({0} items)",
"ToastUserDeleteFailed": "Error al eliminar el usuario",
"ToastUserDeleteSuccess": "Usuario eliminado"
}
}
2 changes: 2 additions & 0 deletions client/strings/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Kärbitud",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Konto tüüp",
"LabelAccountTypeAdmin": "Administraator",
"LabelAccountTypeGuest": "Külaline",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Lohistage failid õigesse järjekorda",
"MessageEmbedFinished": "Manustamine lõpetatud!",
"MessageEpisodesQueuedForDownload": "{0} Episood(i) on allalaadimiseks järjekorras",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "Toite URL saab olema {0}",
"MessageFetching": "Hangitakse...",
"MessageForceReScanDescription": "skaneerib kõik failid uuesti nagu värsket skannimist. Heli faili ID3 silte, OPF faile ja tekstifaile skaneeritakse uuesti.",
Expand Down
4 changes: 3 additions & 1 deletion client/strings/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Version courte",
"LabelAbridgedChecked": "Abrégé (vérifié)",
"LabelAbridgedUnchecked": "Intégral (non vérifié)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Type de compte",
"LabelAccountTypeAdmin": "Admin",
"LabelAccountTypeGuest": "Invité",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Faites glisser les fichiers dans l’ordre correct des pistes",
"MessageEmbedFinished": "Intégration terminée !",
"MessageEpisodesQueuedForDownload": "{0} épisode(s) mis en file pour téléchargement",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "L’URL du flux sera {0}",
"MessageFetching": "Récupération…",
"MessageForceReScanDescription": "analysera de nouveau tous les fichiers. Les étiquettes ID3 des fichiers audio, les fichiers OPF et les fichiers texte seront analysés comme s’ils étaient nouveaux.",
Expand Down Expand Up @@ -803,4 +805,4 @@
"ToastSortingPrefixesUpdateSuccess": "Mise à jour des préfixes de tri ({0} élément)",
"ToastUserDeleteFailed": "Échec de la suppression de l’utilisateur",
"ToastUserDeleteSuccess": "Utilisateur supprimé"
}
}
2 changes: 2 additions & 0 deletions client/strings/gu.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Abridged",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Account Type",
"LabelAccountTypeAdmin": "Admin",
"LabelAccountTypeGuest": "Guest",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Drag files into correct track order",
"MessageEmbedFinished": "Embed Finished!",
"MessageEpisodesQueuedForDownload": "{0} Episode(s) queued for download",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "Feed URL will be {0}",
"MessageFetching": "Fetching...",
"MessageForceReScanDescription": "will scan all files again like a fresh scan. Audio file ID3 tags, OPF files, and text files will be scanned as new.",
Expand Down
2 changes: 2 additions & 0 deletions client/strings/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "מקוצר",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "סוג חשבון",
"LabelAccountTypeAdmin": "מנהל",
"LabelAccountTypeGuest": "אורח",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "גרור קבצים לסדר ההשמעה נכון",
"MessageEmbedFinished": "ההטמעה הושלמה!",
"MessageEpisodesQueuedForDownload": "{0} פרקים בתור להורדה",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "כתובת URL של העדכון תהיה {0}",
"MessageFetching": "מושך...",
"MessageForceReScanDescription": "תבוצע סריקה מחדש כמו סריקה חדש מאפס, תגי ID3 של קבצי קול, קבצי OPF, וקבצי טקסט ייסרקו כחדשים.",
Expand Down
2 changes: 2 additions & 0 deletions client/strings/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"LabelAbridged": "Abridged",
"LabelAbridgedChecked": "Abridged (checked)",
"LabelAbridgedUnchecked": "Unabridged (unchecked)",
"LabelAccessibleBy": "Accessible by",
"LabelAccountType": "Account Type",
"LabelAccountTypeAdmin": "Admin",
"LabelAccountTypeGuest": "Guest",
Expand Down Expand Up @@ -630,6 +631,7 @@
"MessageDragFilesIntoTrackOrder": "Drag files into correct track order",
"MessageEmbedFinished": "Embed Finished!",
"MessageEpisodesQueuedForDownload": "{0} Episode(s) queued for download",
"MessageEreaderDevices": "To ensure delivery of ebooks, you may need to add the above email address as a valid sender for each device listed below.",
"MessageFeedURLWillBe": "Feed URL will be {0}",
"MessageFetching": "Fetching...",
"MessageForceReScanDescription": "will scan all files again like a fresh scan. Audio file ID3 tags, OPF files, and text files will be scanned as new.",
Expand Down
Loading

0 comments on commit 38ba7fb

Please sign in to comment.