mirror of
https://github.com/gotson/komga.git
synced 2026-05-09 05:10:19 +02:00
parent
272b52d14d
commit
bf1903bc3a
7 changed files with 24 additions and 23 deletions
|
|
@ -34,12 +34,11 @@
|
|||
<v-row>
|
||||
<v-col>
|
||||
<v-btn
|
||||
v-if="matchCount"
|
||||
@click="$emit('matches-clicked')"
|
||||
outlined
|
||||
rounded
|
||||
>
|
||||
{{ $tc('duplicate_pages.matches_n', matchCount) }}
|
||||
{{ $tc('duplicate_pages.matches_n', hash.matchCount) }}
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
|
@ -55,6 +54,11 @@
|
|||
v-if="hash.size && hash.deleteCount"
|
||||
>{{ $t('duplicate_pages.saved_size', {size: getFileSize(hash.size * hash.deleteCount)}) }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="hash.size && hash.matchCount"
|
||||
><br/>{{ $t('duplicate_pages.delete_to_save', {size: getFileSize(hash.size * hash.matchCount)}) }}
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
|
|
@ -66,7 +70,7 @@
|
|||
<v-card-actions>
|
||||
<v-btn v-if="hash.action === PageHashAction.DELETE_MANUAL"
|
||||
:color="deleteRequested ? 'success': 'primary'"
|
||||
:disabled="!matchCount"
|
||||
:disabled="hash.matchCount == 0"
|
||||
@click="deleteMatches"
|
||||
>
|
||||
<v-icon left v-if="deleteRequested">mdi-check</v-icon>
|
||||
|
|
@ -106,7 +110,6 @@ export default Vue.extend({
|
|||
pageHashKnownThumbnailUrl,
|
||||
getFileSize,
|
||||
PageHashAction,
|
||||
matchCount: undefined as number | undefined,
|
||||
deleteRequested: false,
|
||||
}
|
||||
},
|
||||
|
|
@ -122,26 +125,15 @@ export default Vue.extend({
|
|||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getMatchCount()
|
||||
},
|
||||
watch: {
|
||||
hash: {
|
||||
handler() {
|
||||
this.deleteRequested = false
|
||||
this.matchCount = undefined
|
||||
this.getMatchCount()
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async getMatchCount() {
|
||||
if (this.hash?.action === PageHashAction.DELETE_MANUAL)
|
||||
this.matchCount = (await this.$komgaPageHashes.getPageHashMatches(this.hash, {size: 0})).totalElements
|
||||
else
|
||||
this.matchCount = undefined
|
||||
},
|
||||
async deleteMatches() {
|
||||
if(!this.deleteRequested) {
|
||||
await this.$komgaPageHashes.deleteAllMatches(this.hash)
|
||||
|
|
@ -161,7 +153,6 @@ export default Vue.extend({
|
|||
try {
|
||||
const p = {
|
||||
hash: this.hash.hash,
|
||||
mediaType: this.hash.mediaType,
|
||||
size: this.hash.size,
|
||||
action: action,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -591,7 +591,8 @@
|
|||
"delete_count": "Deletion count",
|
||||
"delete_size": "Space saved",
|
||||
"size": "Size",
|
||||
"total_size": "Total size"
|
||||
"total_size": "Total size",
|
||||
"match_count": "Match count"
|
||||
},
|
||||
"info": "Deleting duplicate pages will modify your files. Backup your files and use manual deletion before using automatic deletion.",
|
||||
"known": "Known",
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ import {PageHashAction} from '@/types/enum-pagehashes'
|
|||
export interface PageHashDto {
|
||||
hash: string,
|
||||
size?: number,
|
||||
matchCount: number,
|
||||
}
|
||||
|
||||
export interface PageHashUnknownDto extends PageHashDto {
|
||||
matchCount: number,
|
||||
}
|
||||
|
||||
export interface PageHashMatchDto {
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ export default Vue.extend({
|
|||
{name: this.$t('duplicate_pages.filter.delete_size').toString(), key: 'deleteSize'},
|
||||
{name: this.$t('duplicate_pages.filter.size').toString(), key: 'fileSize'},
|
||||
{name: this.$t('duplicate_pages.filter.delete_count').toString(), key: 'deleteCount'},
|
||||
{name: this.$t('duplicate_pages.filter.match_count').toString(), key: 'matchCount'},
|
||||
]
|
||||
},
|
||||
paginationVisible(): number {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class PageHashKnown(
|
|||
size: Long? = null,
|
||||
val action: Action,
|
||||
val deleteCount: Int = 0,
|
||||
val matchCount: Int = 0,
|
||||
|
||||
override val createdDate: LocalDateTime = LocalDateTime.now(),
|
||||
override val lastModifiedDate: LocalDateTime = createdDate,
|
||||
|
|
@ -22,10 +23,12 @@ class PageHashKnown(
|
|||
size: Long? = this.size,
|
||||
action: Action = this.action,
|
||||
deleteCount: Int = this.deleteCount,
|
||||
matchCount: Int = this.matchCount,
|
||||
) = PageHashKnown(
|
||||
hash = hash,
|
||||
size = size,
|
||||
action = action,
|
||||
deleteCount = deleteCount,
|
||||
matchCount = matchCount,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ class PageHashDao(
|
|||
|
||||
private val sortsKnown = mapOf(
|
||||
"hash" to ph.HASH,
|
||||
"mediatype" to ph.MEDIA_TYPE,
|
||||
"fileSize" to ph.SIZE,
|
||||
"matchCount" to DSL.field("count"),
|
||||
"deleteCount" to ph.DELETE_COUNT,
|
||||
"deleteSize" to ph.SIZE * ph.DELETE_COUNT,
|
||||
)
|
||||
|
|
@ -55,8 +54,11 @@ class PageHashDao(
|
|||
?.toDomain()
|
||||
|
||||
override fun findAllKnown(actions: List<PageHashKnown.Action>?, pageable: Pageable): Page<PageHashKnown> {
|
||||
val query = dsl.selectFrom(ph)
|
||||
val query = dsl.select(*ph.fields(), DSL.count(p.FILE_HASH).`as`("count"))
|
||||
.from(ph)
|
||||
.leftJoin(p).on(ph.HASH.eq(p.FILE_HASH))
|
||||
.apply { actions?.let { where(ph.ACTION.`in`(actions)) } }
|
||||
.groupBy(*ph.fields())
|
||||
|
||||
val count = dsl.fetchCount(query)
|
||||
|
||||
|
|
@ -65,7 +67,7 @@ class PageHashDao(
|
|||
.orderBy(orderBy)
|
||||
.apply { if (pageable.isPaged) limit(pageable.pageSize).offset(pageable.offset) }
|
||||
.fetch()
|
||||
.map { it.toDomain() }
|
||||
.map { it.into(ph).toDomain(it.get("count", Int::class.java)) }
|
||||
|
||||
val pageSort = if (orderBy.isNotEmpty()) pageable.sort else Sort.unsorted()
|
||||
return PageImpl(
|
||||
|
|
@ -198,11 +200,12 @@ class PageHashDao(
|
|||
}
|
||||
}
|
||||
|
||||
private fun PageHashRecord.toDomain() =
|
||||
private fun PageHashRecord.toDomain(matchCount: Int = 0) =
|
||||
PageHashKnown(
|
||||
hash = hash,
|
||||
size = size,
|
||||
deleteCount = deleteCount,
|
||||
matchCount = matchCount,
|
||||
action = PageHashKnown.Action.valueOf(action),
|
||||
createdDate = createdDate.toCurrentTimeZone(),
|
||||
lastModifiedDate = lastModifiedDate.toCurrentTimeZone(),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ data class PageHashKnownDto(
|
|||
val size: Long?,
|
||||
val action: PageHashKnown.Action,
|
||||
val deleteCount: Int,
|
||||
val matchCount: Int,
|
||||
|
||||
val created: LocalDateTime,
|
||||
val lastModified: LocalDateTime,
|
||||
|
|
@ -19,6 +20,7 @@ fun PageHashKnown.toDto() = PageHashKnownDto(
|
|||
size = size,
|
||||
action = action,
|
||||
deleteCount = deleteCount,
|
||||
matchCount = matchCount,
|
||||
created = createdDate.toUTC(),
|
||||
lastModified = lastModifiedDate.toUTC(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue