2020-03-31 10:45:41 +02:00
< template >
< div >
< div class = "ui inline form" >
< div class = "fields" >
< div class = "ui six wide field" >
2020-08-01 11:11:51 +02:00
< label for = "channel-search" > < translate translate -context = " Content / Search / Input.Label / Noun " > Search < / translate > < / label >
2020-03-31 10:45:41 +02:00
< form @submit.prevent ="search.query = $refs.search.value" >
2021-12-06 11:35:20 +01:00
< input
id = "channel-search"
ref = "search"
name = "search"
type = "text"
: value = "search.query"
: placeholder = "labels.searchPlaceholder"
>
2020-03-31 10:45:41 +02:00
< / form >
< / div >
< div class = "field" >
2020-08-01 11:11:51 +02:00
< label for = "channel-category" > < translate translate -context = " * / * / * " > Category < / translate > < / label >
2021-12-06 11:35:20 +01:00
< select
id = "channel-category"
class = "ui dropdown"
: value = "getTokenValue('category', '')"
@ change = "addSearchToken('category', $event.target.value)"
>
< option value = "" >
< translate translate -context = " Content / * / Dropdown " >
All
< / translate >
< / option >
< option value = "podcast" >
{ { sharedLabels . fields . content _category . choices . podcast } }
< / option >
< option value = "music" >
{ { sharedLabels . fields . content _category . choices . music } }
< / option >
< option value = "other" >
{ { sharedLabels . fields . content _category . choices . other } }
< / option >
2020-03-31 10:45:41 +02:00
< / select >
< / div >
< div class = "field" >
2020-08-01 11:11:51 +02:00
< label for = "channel-ordering" > < translate translate -context = " Content / Search / Dropdown.Label / Noun " > Ordering < / translate > < / label >
2021-12-06 11:35:20 +01:00
< select
id = "channel-ordering"
v - model = "ordering"
class = "ui dropdown"
>
< option
v - for = "(option, key) in orderingOptions"
: key = "key"
: value = "option[0]"
>
2020-03-31 10:45:41 +02:00
{ { sharedLabels . filters [ option [ 1 ] ] } }
< / option >
< / select >
< / div >
< div class = "field" >
2020-08-01 11:11:51 +02:00
< label for = "channel-ordering-direction" > < translate translate -context = " Content / Search / Dropdown.Label / Noun " > Ordering direction < / translate > < / label >
2021-12-06 11:35:20 +01:00
< select
id = "channel-ordering-direction"
v - model = "orderingDirection"
class = "ui dropdown"
>
< option value = "+" >
< translate translate -context = " Content / Search / Dropdown " >
Ascending
< / translate >
< / option >
< option value = "-" >
< translate translate -context = " Content / Search / Dropdown " >
Descending
< / translate >
< / option >
2020-03-31 10:45:41 +02:00
< / select >
< / div >
< / div >
2021-12-06 11:35:20 +01:00
< / div >
2020-03-31 10:45:41 +02:00
< div class = "dimmable" >
2021-12-06 11:35:20 +01:00
< div
v - if = "isLoading"
class = "ui active inverted dimmer"
>
< div class = "ui loader" / >
2020-03-31 10:45:41 +02:00
< / div >
< action-table
v - if = "result"
: objects - data = "result"
: actions = "actions"
action - url = "manage/library/artists/action/"
2021-12-06 11:35:20 +01:00
: filters = "actionFilters"
@ action - launched = "fetchData"
>
2022-05-01 15:24:23 +02:00
< template # header -cells >
2021-12-06 11:35:20 +01:00
< th >
< translate translate -context = " * / * / * / Noun " >
Name
< / translate >
< / th >
< th >
< translate translate -context = " * / * / * / Noun " >
Account
< / translate >
< / th >
< th >
< translate translate -context = " Content / Moderation / * / Noun " >
Domain
< / translate >
< / th >
< th >
< translate translate -context = " * / * / * " >
Albums
< / translate >
< / th >
< th >
< translate translate -context = " * / * / * " >
Tracks
< / translate >
< / th >
< th >
< translate translate -context = " Content / * / * / Noun " >
Creation date
< / translate >
< / th >
2020-03-31 10:45:41 +02:00
< / template >
2021-12-06 11:35:20 +01:00
< template
2022-05-01 15:24:23 +02:00
# row - cells = "scope"
2021-12-06 11:35:20 +01:00
>
2020-03-31 10:45:41 +02:00
< td >
2021-12-06 11:35:20 +01:00
< router-link : to = "{name: 'manage.channels.detail', params: {id: scope.obj.actor.full_username }}" >
{ { scope . obj . artist . name } }
< / router-link >
2020-03-31 10:45:41 +02:00
< / td >
< td >
< router-link : to = "{name: 'manage.moderation.accounts.detail', params: {id: scope.obj.attributed_to.full_username }}" >
2021-12-06 11:35:20 +01:00
< i class = "wrench icon" / >
2020-08-01 11:11:51 +02:00
< span class = "visually-hidden" > { { labels . openModeration } } < / span >
2020-03-31 10:45:41 +02:00
< / router-link >
2021-12-06 11:35:20 +01:00
< a
href = ""
class = "discrete link"
@ click . prevent = "addSearchToken('account', scope.obj.attributed_to.full_username)"
> { { scope . obj . attributed _to . preferred _username } } < / a >
2020-03-31 10:45:41 +02:00
< / td >
< td >
< template v-if = "!scope.obj.is_local" >
< router-link : to = "{name: 'manage.moderation.domains.detail', params: {id: scope.obj.attributed_to.domain }}" >
2021-12-06 11:35:20 +01:00
< i class = "wrench icon" / >
2020-08-01 11:11:51 +02:00
< span class = "visually-hidden" > { { labels . openModeration } } < / span >
2020-03-31 10:45:41 +02:00
< / router-link >
2021-12-06 11:35:20 +01:00
< a
href = ""
class = "discrete link"
@ click . prevent = "addSearchToken('domain', scope.obj.attributed_to.domain)"
> { { scope . obj . attributed _to . domain } } < / a >
2020-03-31 10:45:41 +02:00
< / template >
2021-12-06 11:35:20 +01:00
< a
v - else
href = ""
class = "ui tiny accent icon link label"
@ click . prevent = "addSearchToken('domain', scope.obj.attributed_to.domain)"
>
< i class = "home icon" / >
2020-03-31 10:45:41 +02:00
< translate translate -context = " Content / Moderation / * / Short , Noun " > Local < / translate >
2020-08-11 14:07:06 +02:00
< / a >
2020-03-31 10:45:41 +02:00
< / td >
< td >
{ { scope . obj . artist . albums _count } }
< / td >
< td >
{ { scope . obj . artist . tracks _count } }
< / td >
< td >
2021-12-06 11:35:20 +01:00
< human-date :date = "scope.obj.creation_date" / >
2020-03-31 10:45:41 +02:00
< / td >
< / template >
< / action-table >
< / div >
< div >
< pagination
v - if = "result && result.count > paginateBy"
: compact = "true"
: current = "page"
: paginate - by = "paginateBy"
: total = "result.count"
2021-12-06 11:35:20 +01:00
@ page - changed = "selectPage"
/ >
2020-03-31 10:45:41 +02:00
< span v-if = "result && result.results.length > 0" >
2021-12-06 11:35:20 +01:00
< translate
translate - context = "Content/*/Paragraph"
: translate - params = "{start: ((page-1) * paginateBy) + 1, end: ((page-1) * paginateBy) + result.results.length, total: result.count}"
>
2020-03-31 10:45:41 +02:00
Showing results % { start } - % { end } on % { total }
< / translate >
< / span >
< / div >
< / div >
< / template >
< script >
import axios from 'axios'
2022-04-18 00:43:58 +02:00
import { merge } from 'lodash-es'
2022-04-23 09:37:43 +02:00
import time from '~/utils/time'
2022-05-02 17:06:44 +02:00
import { normalizeQuery , parseTokens } from '~/utils/search'
2022-05-08 23:52:44 +00:00
import Pagination from '~/components/vui/Pagination.vue'
2022-04-23 09:37:43 +02:00
import ActionTable from '~/components/common/ActionTable.vue'
import OrderingMixin from '~/components/mixins/Ordering.vue'
import SmartSearchMixin from '~/components/mixins/SmartSearch.vue'
2022-05-02 17:06:44 +02:00
import useSharedLabels from '~/composables/locale/useSharedLabels'
2020-03-31 10:45:41 +02:00
export default {
components : {
Pagination ,
ActionTable
} ,
2022-05-01 18:46:27 +02:00
mixins : [ OrderingMixin , SmartSearchMixin ] ,
2021-12-06 11:35:20 +01:00
props : {
filters : { type : Object , required : false , default : ( ) => { return { } } }
} ,
2022-05-01 18:46:27 +02:00
setup ( ) {
const sharedLabels = useSharedLabels ( )
return { sharedLabels }
} ,
2020-03-31 10:45:41 +02:00
data ( ) {
return {
time ,
isLoading : false ,
result : null ,
page : 1 ,
search : {
query : this . defaultQuery ,
tokens : parseTokens ( normalizeQuery ( this . defaultQuery ) )
} ,
orderingOptions : [
[ 'creation_date' , 'creation_date' ] ,
2021-12-06 11:35:20 +01:00
[ 'name' , 'name' ]
2020-03-31 10:45:41 +02:00
]
}
} ,
computed : {
labels ( ) {
return {
2020-08-01 11:11:51 +02:00
searchPlaceholder : this . $pgettext ( 'Content/Search/Input.Placeholder' , 'Search by domain, name, account…' ) ,
openModeration : this . $pgettext ( 'Content/Moderation/Verb' , 'Open in moderation interface' )
2020-03-31 10:45:41 +02:00
}
} ,
actionFilters ( ) {
2021-12-06 11:35:20 +01:00
const currentFilters = {
2020-03-31 10:45:41 +02:00
q : this . search . query
}
if ( this . filters ) {
2022-04-18 00:43:58 +02:00
return merge ( currentFilters , this . filters )
2020-03-31 10:45:41 +02:00
} else {
return currentFilters
}
} ,
actions ( ) {
// let deleteLabel = this.$pgettext('*/*/*/Verb', 'Delete')
// let confirmationMessage = this.$pgettext('Popup/*/Paragraph', 'The selected artist will be removed, as well as associated uploads, tracks, albums, favorites and listening history. This action is irreversible.')
return [
// {
// name: 'delete',
// label: deleteLabel,
// confirmationMessage: confirmationMessage,
// isDangerous: true,
// allowAll: false,
2020-05-15 14:12:36 +02:00
// confirmColor: 'danger',
2020-03-31 10:45:41 +02:00
// },
]
}
} ,
watch : {
search ( newValue ) {
this . page = 1
this . fetchData ( )
} ,
page ( ) {
this . fetchData ( )
} ,
ordering ( ) {
this . fetchData ( )
} ,
orderingDirection ( ) {
this . fetchData ( )
}
2021-12-06 11:35:20 +01:00
} ,
created ( ) {
this . fetchData ( )
} ,
methods : {
fetchData ( ) {
2022-04-18 00:43:58 +02:00
const params = merge ( {
2021-12-06 11:35:20 +01:00
page : this . page ,
page _size : this . paginateBy ,
q : this . search . query ,
ordering : this . getOrderingAsString ( )
} , this . filters )
const self = this
self . isLoading = true
self . checked = [ ]
axios . get ( '/manage/channels/' , { params : params } ) . then ( ( response ) => {
self . result = response . data
self . isLoading = false
} , error => {
self . isLoading = false
self . errors = error . backendErrors
} )
} ,
selectPage : function ( page ) {
this . page = page
}
2020-03-31 10:45:41 +02:00
}
}
< / script >