feat: filter uploads by mime types from stats menu

This commit is contained in:
Bobby 2022-10-06 03:57:47 +07:00
parent 10c2618ef6
commit c35fd3057c
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09
3 changed files with 23 additions and 3 deletions

View File

@ -158,6 +158,7 @@ self.getUploadsStats = async db => {
},
'Mime Types': {
value: {},
valueAction: 'filter-uploads-by-type',
type: Type.DETAILED
}
}

View File

@ -162,7 +162,11 @@ li[data-action="page-ellipsis"] {
}
&[data-action] {
cursor: pointer
cursor: pointer;
&:hover {
text-decoration: dotted underline
}
}
}
}

View File

@ -377,6 +377,8 @@ page.domClick = event => {
return page.filterUploads(element)
case 'sort-uploads':
return page.sortUploads(element)
case 'filter-uploads-by-type':
return page.filterUploadsByType(element)
// Manage your albums
case 'submit-album':
return page.submitAlbum(element)
@ -1337,12 +1339,25 @@ page.sortUploads = element => {
}))
}
page.filterUploadsByType = element => {
// Wrap type in quotes if it contains whitespaces
const type = /\s/.test(element.innerText)
? `"${element.innerText}"`
: element.innerText
page.getUploads({
all: true,
filters: `type:${type}`,
pageNum: 0,
trigger: document.querySelector('#itemManageUploads')
})
}
page.viewUserUploads = (id, element) => {
const user = page.cache[id]
if (!user) return
element.classList.add('is-loading')
// Wrap username in quotes if it contains whitespaces
const username = user.username.includes(' ')
const username = /\s/.test(user.username)
? `"${user.username}"`
: user.username
page.getUploads({
@ -3161,7 +3176,7 @@ page.getStatistics = (params = {}) => {
${Object.keys(value).map(type => {
return `
<tr>
<td>${type}</td>
<td${data.valueAction ? ` data-action="${data.valueAction}"` : ''}>${type}</td>
<td>${value[type]}</td>
</tr>
`