Skip to content

Commit c82c8b0

Browse files
committed
feat(webui): add UI setting to stretch poster to fit card
Closes: #1825
1 parent 961832e commit c82c8b0

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

komga-webui/src/components/ItemCard.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
:src="thumbnailUrl"
1313
:lazy-src="thumbnailError ? coverBase64 : undefined"
1414
aspect-ratio="0.7071"
15-
contain
15+
:contain="!isStretch"
16+
:position="isStretch ? 'top' : undefined"
1617
@error="thumbnailError = true"
1718
@load="thumbnailError = false"
1819
>
@@ -272,6 +273,9 @@ export default Vue.extend({
272273
this.$eventHub.$off(THUMBNAILCOLLECTION_DELETED, this.thumbnailCollectionChanged)
273274
},
274275
computed: {
276+
isStretch(): boolean {
277+
return this.$store.getters.getClientSettingPosterStretch
278+
},
275279
canReadPages(): boolean {
276280
return this.$store.getters.mePageStreaming && this.computedItem.type() === ItemTypes.BOOK
277281
},

komga-webui/src/locales/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,7 @@
10271027
"ui_settings": {
10281028
"label_oauth2_auto_login": "Automatic OAuth2 login",
10291029
"label_oauth2_hide_login": "Hide login fields if OAuth2 is enabled",
1030+
"label_poster_stretch": "Stretch poster to fit card",
10301031
"tooltip_oauth2_auto_login": "Requires a single OAuth2 provider, and 'hide login fields' enabled"
10311032
},
10321033
"updates": {

komga-webui/src/plugins/komga-settings.plugin.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import _Vue from 'vue'
33
import KomgaSettingsService from '@/services/komga-settings.service'
44
import {Module} from 'vuex'
55
import {LibraryDto} from '@/types/komga-libraries'
6-
import {ClientSettingDto} from '@/types/komga-clientsettings'
6+
import {CLIENT_SETTING, ClientSettingDto} from '@/types/komga-clientsettings'
77

88
let service = KomgaSettingsService
99

@@ -15,6 +15,9 @@ const vuexModule: Module<any, any> = {
1515
getClientSettingByKey: (state) => (key: string) => {
1616
return state.clientSettings.find((it: ClientSettingDto) => it.key === key)
1717
},
18+
getClientSettingPosterStretch(state): boolean {
19+
return state.clientSettings.find((it: ClientSettingDto) => it.key === CLIENT_SETTING.WEBUI_POSTER_STRETCH)?.value === 'true'
20+
},
1821
},
1922
mutations: {
2023
setClientSettings(state, settings) {

komga-webui/src/types/komga-clientsettings.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ export interface ClientSettingUserUpdateDto {
1919
export enum CLIENT_SETTING {
2020
WEBUI_OAUTH2_HIDE_LOGIN = 'webui.oauth2.hide_login',
2121
WEBUI_OAUTH2_AUTO_LOGIN = 'webui.oauth2.auto_login',
22+
WEBUI_POSTER_STRETCH = 'webui.poster.stretch'
2223
}

komga-webui/src/views/UISettings.vue

+17-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
</template>
2727

2828
</v-checkbox>
29+
30+
<v-checkbox
31+
v-model="form.posterStretch"
32+
@change="$v.form.posterStretch.$touch()"
33+
:label="$t('ui_settings.label_poster_stretch')"
34+
hide-details
35+
/>
2936
</v-col>
3037
</v-row>
3138
<v-row>
@@ -48,27 +55,26 @@
4855

4956
<script lang="ts">
5057
import Vue from 'vue'
51-
import {helpers} from 'vuelidate/lib/validators'
5258
import ConfirmationDialog from '@/components/dialogs/ConfirmationDialog.vue'
5359
import FileBrowserDialog from '@/components/dialogs/FileBrowserDialog.vue'
5460
import {CLIENT_SETTING, ClientSettingDto} from '@/types/komga-clientsettings'
5561
56-
const contextPath = helpers.regex('contextPath', /^\/[-a-zA-Z0-9_\/]*[a-zA-Z0-9]$/)
57-
5862
export default Vue.extend({
5963
name: 'UISettings',
6064
components: {FileBrowserDialog, ConfirmationDialog},
6165
data: () => ({
6266
form: {
6367
oauth2HideLogin: false,
6468
oauth2AutoLogin: false,
69+
posterStretch: false,
6570
},
6671
existingSettings: [] as ClientSettingDto[],
6772
}),
6873
validations: {
6974
form: {
7075
oauth2HideLogin: {},
7176
oauth2AutoLogin: {},
77+
posterStretch: {},
7278
},
7379
},
7480
mounted() {
@@ -87,6 +93,7 @@ export default Vue.extend({
8793
await this.$store.dispatch('getClientSettings')
8894
this.form.oauth2HideLogin = this.$store.getters.getClientSettingByKey(CLIENT_SETTING.WEBUI_OAUTH2_HIDE_LOGIN)?.value === 'true'
8995
this.form.oauth2AutoLogin = this.$store.getters.getClientSettingByKey(CLIENT_SETTING.WEBUI_OAUTH2_AUTO_LOGIN)?.value === 'true'
96+
this.form.posterStretch = this.$store.getters.getClientSettingByKey(CLIENT_SETTING.WEBUI_POSTER_STRETCH)?.value === 'true'
9097
this.$v.form.$reset()
9198
},
9299
async saveSettings() {
@@ -104,6 +111,13 @@ export default Vue.extend({
104111
allowUnauthorized: true,
105112
})
106113
114+
if (this.$v.form?.posterStretch?.$dirty)
115+
await this.$komgaSettings.updateClientSettingGlobal({
116+
key: CLIENT_SETTING.WEBUI_POSTER_STRETCH,
117+
value: this.form.posterStretch ? 'true' : 'false',
118+
allowUnauthorized: false,
119+
})
120+
107121
await this.refreshSettings()
108122
},
109123
},

0 commit comments

Comments
 (0)