diff --git a/komga-webui/src/locales/en.json b/komga-webui/src/locales/en.json index 248da4f6ed..e83856212a 100644 --- a/komga-webui/src/locales/en.json +++ b/komga-webui/src/locales/en.json @@ -205,6 +205,7 @@ "collections": "Collections", "create": "Create", "delete": "Delete", + "discard": "Discard", "disk_space": "Disk space", "dismiss": "Dismiss", "download": "Download", @@ -239,6 +240,7 @@ "read_on": "Read on {date}", "readlist": "Read List", "readlists": "Read Lists", + "remember-me": "Remember me", "required": "Required", "reset_filters": "Reset filters", "roles": "Roles", @@ -842,6 +844,10 @@ "tab_title": "Server" }, "server_settings": { + "label_delete_empty_collections": "Delete empty collections after scan", + "label_delete_empty_readlists": "Delete empty read lists after scan", + "label_rememberme_duration": "Remember me duration (in days)", + "requires_restart": "Requires restart to take effect", "server_settings": "Server Settings" }, "settings_user": { @@ -895,6 +901,7 @@ "users": "Users" }, "validation": { + "one_or_more": "Must be 1 or more", "zero_or_more": "Must be 0 or more" }, "welcome": { diff --git a/komga-webui/src/main.ts b/komga-webui/src/main.ts index 60963ac2e5..193229d402 100644 --- a/komga-webui/src/main.ts +++ b/komga-webui/src/main.ts @@ -29,6 +29,7 @@ import komgaPageHashes from './plugins/komga-pagehashes.plugin' import komgaMetrics from './plugins/komga-metrics.plugin' import komgaHistory from './plugins/komga-history.plugin' import komgaAnnouncements from './plugins/komga-announcements.plugin' +import komgaSettings from './plugins/komga-settings.plugin' import vuetify from './plugins/vuetify' import logger from './plugins/logger.plugin' import './public-path' @@ -74,6 +75,7 @@ Vue.use(komgaPageHashes, {http: Vue.prototype.$http}) Vue.use(komgaMetrics, {http: Vue.prototype.$http}) Vue.use(komgaHistory, {http: Vue.prototype.$http}) Vue.use(komgaAnnouncements, {http: Vue.prototype.$http}) +Vue.use(komgaSettings, {http: Vue.prototype.$http}) Vue.config.productionTip = false diff --git a/komga-webui/src/plugins/komga-settings.plugin.ts b/komga-webui/src/plugins/komga-settings.plugin.ts new file mode 100644 index 0000000000..5db167266b --- /dev/null +++ b/komga-webui/src/plugins/komga-settings.plugin.ts @@ -0,0 +1,17 @@ +import {AxiosInstance} from 'axios' +import _Vue from 'vue' +import KomgaSettingsService from '@/services/komga-settings.service' + +export default { + install( + Vue: typeof _Vue, + {http}: { http: AxiosInstance }) { + Vue.prototype.$komgaSettings = new KomgaSettingsService(http) + }, +} + +declare module 'vue/types/vue' { + interface Vue { + $komgaSettings: KomgaSettingsService; + } +} diff --git a/komga-webui/src/plugins/komga-users.plugin.ts b/komga-webui/src/plugins/komga-users.plugin.ts index 1be10d6179..d01ff9ed17 100644 --- a/komga-webui/src/plugins/komga-users.plugin.ts +++ b/komga-webui/src/plugins/komga-users.plugin.ts @@ -27,8 +27,12 @@ const vuexModule: Module = { }, }, actions: { - async getMeWithAuth ({ commit }, { login, password }: { login: string, password: string }) { - commit('setMe', await service.getMeWithAuth(login, password)) + async getMeWithAuth({commit}, {login, password, rememberMe}: { + login: string, + password: string, + rememberMe: boolean + }) { + commit('setMe', await service.getMeWithAuth(login, password, rememberMe)) }, async logout ({ commit }) { try { diff --git a/komga-webui/src/plugins/persisted-state.ts b/komga-webui/src/plugins/persisted-state.ts index 61cc0aca3c..305bf6d943 100644 --- a/komga-webui/src/plugins/persisted-state.ts +++ b/komga-webui/src/plugins/persisted-state.ts @@ -34,6 +34,7 @@ export const persistedModule: Module = { }, importPath: '', duplicatesNewPageSize: 10, + rememberMe: false, }, getters: { getLocaleFirstDay: (state) => () => { @@ -128,5 +129,8 @@ export const persistedModule: Module = { setDuplicatesNewPageSize(state, val) { state.duplicatesNewPageSize = val }, + setRememberMe(state, val) { + state.rememberMe = val + }, }, } diff --git a/komga-webui/src/services/komga-settings.service.ts b/komga-webui/src/services/komga-settings.service.ts new file mode 100644 index 0000000000..5b1cf04025 --- /dev/null +++ b/komga-webui/src/services/komga-settings.service.ts @@ -0,0 +1,36 @@ +import {AxiosInstance} from 'axios' +import {SettingsDto, SettingsUpdateDto} from '@/types/komga-settings' + +const API_SETTINGS = '/api/v1/settings' + +export default class KomgaSettingsService { + private http: AxiosInstance + + constructor(http: AxiosInstance) { + this.http = http + } + + async getSettings(): Promise { + try { + return (await this.http.get(API_SETTINGS)).data + } catch (e) { + let msg = 'An error occurred while trying to retrieve settings' + if (e.response.data.message) { + msg += `: ${e.response.data.message}` + } + throw new Error(msg) + } + } + + async updateSettings(settings: SettingsUpdateDto) { + try { + await this.http.patch(API_SETTINGS, settings) + } catch (e) { + let msg = 'An error occurred while trying to update settings' + if (e.response.data.message) { + msg += `: ${e.response.data.message}` + } + throw new Error(msg) + } + } +} diff --git a/komga-webui/src/services/komga-users.service.ts b/komga-webui/src/services/komga-users.service.ts index 0509eaff5e..e94d634243 100644 --- a/komga-webui/src/services/komga-users.service.ts +++ b/komga-webui/src/services/komga-users.service.ts @@ -18,7 +18,7 @@ export default class KomgaUsersService { this.http = http } - async getMeWithAuth(login: string, password: string): Promise { + async getMeWithAuth(login: string, password: string, rememberMe: boolean): Promise { try { return (await this.http.get( `${API_USERS}/me`, @@ -27,6 +27,9 @@ export default class KomgaUsersService { username: login, password: password, }, + params: { + 'remember-me': rememberMe, + }, }, )).data } catch (e) { diff --git a/komga-webui/src/types/komga-settings.ts b/komga-webui/src/types/komga-settings.ts new file mode 100644 index 0000000000..9a5d181c0c --- /dev/null +++ b/komga-webui/src/types/komga-settings.ts @@ -0,0 +1,12 @@ +export interface SettingsDto { + deleteEmptyCollections: boolean, + deleteEmptyReadLists: boolean, + rememberMeDurationDays: number, +} + +export interface SettingsUpdateDto { + deleteEmptyCollections?: boolean, + deleteEmptyReadLists?: boolean, + rememberMeDurationDays?: number, + renewRememberMeKey?: boolean, +} diff --git a/komga-webui/src/views/LoginView.vue b/komga-webui/src/views/LoginView.vue index 7f7c162f6b..57fe074b14 100644 --- a/komga-webui/src/views/LoginView.vue +++ b/komga-webui/src/views/LoginView.vue @@ -47,6 +47,16 @@ + + + + + + + + + {{ $t('server.server_management.section_title') }} + + + + {{ $t('server.server_management.button_scan_libraries') }} + + + {{ $t('server.server_management.button_scan_libraries_deep') }} + + + + {{ $t('server.server_management.button_empty_trash') }} + + + {{ $t('server.server_management.button_cancel_all_tasks') }} + + + + {{ $t('server.server_management.button_shutdown') }} + + + + + + + + + + + + + + diff --git a/komga-webui/src/views/ServerSettings.vue b/komga-webui/src/views/ServerSettings.vue new file mode 100644 index 0000000000..ea75383eff --- /dev/null +++ b/komga-webui/src/views/ServerSettings.vue @@ -0,0 +1,130 @@ + + + + + diff --git a/komga-webui/src/views/SettingsServer.vue b/komga-webui/src/views/SettingsServer.vue index 2757afe201..065c24d832 100644 --- a/komga-webui/src/views/SettingsServer.vue +++ b/komga-webui/src/views/SettingsServer.vue @@ -1,98 +1,26 @@