-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only hash pages for cbz delete non-cbz page hashes store page hashes
- Loading branch information
Showing
34 changed files
with
1,189 additions
and
165 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,163 @@ | ||
<template> | ||
<v-card> | ||
<v-container fluid> | ||
<v-row> | ||
<v-col> | ||
<v-img | ||
width="200" | ||
height="300" | ||
contain | ||
@click="$emit('image-clicked')" | ||
:src="pageHashKnownThumbnailUrl(hash)" | ||
style="cursor: zoom-in" | ||
/> | ||
|
||
</v-col> | ||
<v-col> | ||
<v-card-text style="min-width: 200px"> | ||
<v-container> | ||
<v-row> | ||
<v-col> | ||
<v-chip label small :color="actionColor"> | ||
{{ $t(`enums.page_hash_action.${hash.action}`) }} | ||
</v-chip> | ||
</v-col> | ||
</v-row> | ||
|
||
<v-row> | ||
<v-col> | ||
<div>{{ hash.mediaType }}</div> | ||
<div>{{ getFileSize(hash.size) || $t('duplicate_pages.unknown_size') }}</div> | ||
</v-col> | ||
</v-row> | ||
|
||
|
||
<v-row> | ||
<v-col> | ||
<v-btn | ||
v-if="matchCount" | ||
@click="$emit('matches-clicked')" | ||
outlined | ||
rounded | ||
> | ||
{{ $tc('duplicate_pages.matches_n', matchCount) }} | ||
</v-btn> | ||
</v-col> | ||
</v-row> | ||
|
||
<v-row> | ||
<v-col> | ||
<div | ||
v-if="hash.deleteCount" | ||
>{{ $t('duplicate_pages.deleted_count', {count: hash.deleteCount}) }} | ||
</div> | ||
|
||
<div | ||
v-if="hash.deleteCount" | ||
>{{ $t('duplicate_pages.saved_size', {size: getFileSize(hash.size * hash.deleteCount)}) }} | ||
</div> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
</v-card-text> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
|
||
<v-card-actions> | ||
<v-btn v-if="hash.action === PageHashAction.DELETE_MANUAL" color="primary" @click="deleteMatches"> | ||
{{ $t('duplicate_pages.action_delete_matches') }} | ||
</v-btn> | ||
<v-btn v-if="hash.action !== PageHashAction.IGNORE" text @click="ignore">{{ | ||
$t('duplicate_pages.action_ignore') | ||
}} | ||
</v-btn> | ||
<v-btn v-if="hash.action !== PageHashAction.DELETE_MANUAL" text @click="deleteManual"> | ||
{{ $t('duplicate_pages.action_delete_manual') }} | ||
</v-btn> | ||
<v-btn v-if="hash.action !== PageHashAction.DELETE_AUTO" text @click="deleteAuto" :disabled="!hash.size"> | ||
{{ $t('duplicate_pages.action_delete_auto') }} | ||
</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue, {PropType} from 'vue' | ||
import {pageHashKnownThumbnailUrl} from '@/functions/urls' | ||
import {PageHashKnownDto} from '@/types/komga-pagehashes' | ||
import {PageHashAction} from '@/types/enum-pagehashes' | ||
import {getFileSize} from '@/functions/file' | ||
export default Vue.extend({ | ||
name: 'PageHashKnownCard', | ||
props: { | ||
hash: { | ||
type: Object as PropType<PageHashKnownDto>, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
pageHashKnownThumbnailUrl, | ||
getFileSize, | ||
PageHashAction, | ||
matchCount: undefined as number | undefined, | ||
} | ||
}, | ||
computed: { | ||
actionColor(): string { | ||
switch (this.hash.action) { | ||
case PageHashAction.DELETE_AUTO: | ||
return 'success' | ||
case PageHashAction.DELETE_MANUAL: | ||
return 'warning' | ||
default: | ||
return 'grey' | ||
} | ||
}, | ||
}, | ||
mounted() { | ||
this.getMatchCount() | ||
}, | ||
watch: { | ||
hash: { | ||
handler() { | ||
this.getMatchCount() | ||
}, | ||
deep: true, | ||
}, | ||
}, | ||
methods: { | ||
async getMatchCount() { | ||
if (this.hash?.action === PageHashAction.DELETE_MANUAL) | ||
this.matchCount = (await this.$komgaPageHashes.getUnknownPageHashMatches(this.hash, {size: 0})).totalElements | ||
else | ||
this.matchCount = undefined | ||
}, | ||
deleteMatches() { | ||
}, | ||
ignore() { | ||
this.updatePageHash(PageHashAction.IGNORE) | ||
}, | ||
deleteManual() { | ||
this.updatePageHash(PageHashAction.DELETE_MANUAL) | ||
}, | ||
deleteAuto() { | ||
this.updatePageHash(PageHashAction.DELETE_AUTO) | ||
}, | ||
async updatePageHash(action: PageHashAction) { | ||
try { | ||
const p = { | ||
hash: this.hash.hash, | ||
mediaType: this.hash.mediaType, | ||
size: this.hash.size, | ||
action: action, | ||
} | ||
await this.$komgaPageHashes.createOrUpdatePageHash(p) | ||
this.$emit('updated', p) | ||
} catch (e) { | ||
} | ||
}, | ||
}, | ||
}) | ||
</script> |
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,105 @@ | ||
<template> | ||
<v-card> | ||
<v-container fluid> | ||
<v-row> | ||
<v-col> | ||
<v-img | ||
width="200" | ||
height="300" | ||
contain | ||
@click="$emit('image-clicked')" | ||
:src="pageHashUnknownThumbnailUrl(hash, 500)" | ||
style="cursor: zoom-in" | ||
/> | ||
|
||
</v-col> | ||
<v-col> | ||
<v-card-text style="min-width: 200px"> | ||
<v-container> | ||
<v-row> | ||
<v-col> | ||
<div>{{ hash.mediaType }}</div> | ||
<div>{{ getFileSize(hash.size) || $t('duplicate_pages.unknown_size') }}</div> | ||
</v-col> | ||
</v-row> | ||
|
||
<v-row> | ||
<v-col> | ||
<v-btn | ||
@click="$emit('matches-clicked')" | ||
outlined | ||
rounded | ||
> | ||
{{ $tc('duplicate_pages.matches_n', hash.matchCount) }} | ||
</v-btn> | ||
</v-col> | ||
</v-row> | ||
|
||
<v-row> | ||
<v-col> | ||
<div | ||
v-if="hash.size" | ||
>{{ $t('duplicate_pages.delete_to_save', {size: getFileSize(hash.size * hash.matchCount)}) }} | ||
</div> | ||
</v-col> | ||
</v-row> | ||
|
||
</v-container> | ||
</v-card-text> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
|
||
<v-card-actions> | ||
<v-btn text @click="ignore">{{ $t('duplicate_pages.action_ignore') }}</v-btn> | ||
<v-btn text @click="deleteManual">{{ $t('duplicate_pages.action_delete_manual') }}</v-btn> | ||
<v-btn text @click="deleteAuto" :disabled="!hash.size">{{ $t('duplicate_pages.action_delete_auto') }}</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue, {PropType} from 'vue' | ||
import {pageHashUnknownThumbnailUrl} from '@/functions/urls' | ||
import {PageHashUnknownDto} from '@/types/komga-pagehashes' | ||
import {PageHashAction} from '@/types/enum-pagehashes' | ||
import {getFileSize} from '@/functions/file' | ||
export default Vue.extend({ | ||
name: 'PageHashUnknownCard', | ||
props: { | ||
hash: { | ||
type: Object as PropType<PageHashUnknownDto>, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
pageHashUnknownThumbnailUrl, | ||
getFileSize, | ||
} | ||
}, | ||
methods: { | ||
ignore() { | ||
this.createPageHash(PageHashAction.IGNORE) | ||
}, | ||
deleteManual() { | ||
this.createPageHash(PageHashAction.DELETE_MANUAL) | ||
}, | ||
deleteAuto() { | ||
this.createPageHash(PageHashAction.DELETE_AUTO) | ||
}, | ||
async createPageHash(action: PageHashAction) { | ||
try { | ||
await this.$komgaPageHashes.createOrUpdatePageHash({ | ||
hash: this.hash.hash, | ||
mediaType: this.hash.mediaType, | ||
size: this.hash.size, | ||
action: action, | ||
}) | ||
this.$emit('created') | ||
} catch (e) { | ||
} | ||
}, | ||
}, | ||
}) | ||
</script> |
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 |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import filesize from 'filesize' | ||
|
||
export async function getFileFromUrl(url: string, name: string = url, defaultType = 'image/jpeg') { | ||
const response = await fetch(url) | ||
const data = await response.blob() | ||
return new File([data], name, { | ||
type: data.type || defaultType, | ||
}) | ||
} | ||
|
||
|
||
const filesizePartial = filesize.partial({round: 1}) | ||
|
||
export function getFileSize(n?: number): string | undefined { | ||
if(!n) return undefined | ||
return filesizePartial(n) | ||
} |
Oops, something went wrong.