-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webui): add server settings configuration screen, add remember-m…
…e checkbox for login
- Loading branch information
Showing
12 changed files
with
347 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<SettingsDto> { | ||
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) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export interface SettingsDto { | ||
deleteEmptyCollections: boolean, | ||
deleteEmptyReadLists: boolean, | ||
rememberMeDurationDays: number, | ||
} | ||
|
||
export interface SettingsUpdateDto { | ||
deleteEmptyCollections?: boolean, | ||
deleteEmptyReadLists?: boolean, | ||
rememberMeDurationDays?: number, | ||
renewRememberMeKey?: boolean, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<template> | ||
<v-container fluid class="pa-6"> | ||
<v-row> | ||
<v-col><span class="text-h5">{{ $t('server.server_management.section_title') }}</span></v-col> | ||
</v-row> | ||
<v-row> | ||
<v-col cols="auto"> | ||
<v-btn @click="scanAllLibraries(false)">{{ $t('server.server_management.button_scan_libraries') }}</v-btn> | ||
</v-col> | ||
<v-col cols="auto"> | ||
<v-btn @click="scanAllLibraries(true)" | ||
color="warning" | ||
>{{ $t('server.server_management.button_scan_libraries_deep') }} | ||
</v-btn> | ||
</v-col> | ||
<v-col cols="auto"> | ||
<v-btn @click="confirmEmptyTrash = true">{{ $t('server.server_management.button_empty_trash') }}</v-btn> | ||
</v-col> | ||
<v-col cols="auto"> | ||
<v-btn @click="cancelAllTasks" | ||
color="warning" | ||
>{{ $t('server.server_management.button_cancel_all_tasks') }} | ||
</v-btn> | ||
</v-col> | ||
<v-col cols="auto"> | ||
<v-btn @click="modalStopServer = true" | ||
color="error" | ||
>{{ $t('server.server_management.button_shutdown') }} | ||
</v-btn> | ||
</v-col> | ||
</v-row> | ||
|
||
<confirmation-dialog | ||
v-model="confirmEmptyTrash" | ||
:title="$t('dialog.empty_trash.title')" | ||
:body="$t('dialog.empty_trash.body')" | ||
:button-confirm="$t('dialog.empty_trash.button_confirm')" | ||
@confirm="emptyTrash" | ||
/> | ||
|
||
<confirmation-dialog | ||
v-model="modalStopServer" | ||
:title="$t('dialog.server_stop.dialog_title')" | ||
:body="$t('dialog.server_stop.confirmation_message')" | ||
:button-confirm="$t('dialog.server_stop.button_confirm')" | ||
button-confirm-color="error" | ||
@confirm="stopServer" | ||
/> | ||
|
||
</v-container> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
import ConfirmationDialog from '@/components/dialogs/ConfirmationDialog.vue' | ||
import {ERROR, ErrorEvent, NOTIFICATION, NotificationEvent} from '@/types/events' | ||
import {LibraryDto} from '@/types/komga-libraries' | ||
export default Vue.extend({ | ||
name: 'ServerManagement', | ||
components: {ConfirmationDialog}, | ||
data: () => ({ | ||
modalStopServer: false, | ||
confirmEmptyTrash: false, | ||
}), | ||
computed: { | ||
libraries(): LibraryDto[] { | ||
return this.$store.state.komgaLibraries.libraries | ||
}, | ||
}, | ||
methods: { | ||
emptyTrash() { | ||
this.libraries.forEach(library => { | ||
this.$komgaLibraries.emptyTrash(library) | ||
}) | ||
}, | ||
scanAllLibraries(scanDeep: boolean) { | ||
this.libraries.forEach(library => { | ||
this.$komgaLibraries.scanLibrary(library, scanDeep) | ||
}) | ||
}, | ||
async cancelAllTasks() { | ||
const count = await this.$komgaTasks.deleteAllTasks() | ||
this.$eventHub.$emit(NOTIFICATION, { | ||
message: this.$tc('server.server_management.notification_tasks_cancelled', count), | ||
} as NotificationEvent) | ||
}, | ||
async stopServer() { | ||
try { | ||
await this.$actuator.shutdown() | ||
} catch (e) { | ||
this.$eventHub.$emit(ERROR, {message: e.message} as ErrorEvent) | ||
} | ||
}, | ||
}, | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
Oops, something went wrong.