Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
interfect
funkwhale
Commits
c2a2321b
Verified
Commit
c2a2321b
authored
Oct 02, 2018
by
Eliot Berriot
Browse files
Removed dead library federation code
parent
a865fcdc
Changes
11
Hide whitespace changes
Inline
Side-by-side
front/src/components/federation/LibraryCard.vue
deleted
100644 → 0
View file @
a865fcdc
<
template
>
<div
class=
"ui card"
>
<div
class=
"content"
>
<div
class=
"header ellipsis"
>
<router-link
v-if=
"library"
:title=
"displayName"
:to=
"
{name: 'federation.libraries.detail', params: {id: library.uuid }}">
{{
displayName
}}
</router-link>
<span
:title=
"displayName"
v-else
>
{{
displayName
}}
</span>
</div>
</div>
<div
class=
"content"
>
<span
class=
"right floated"
v-if=
"following"
>
<i
class=
"check icon"
></i><translate>
Following
</translate>
</span>
<span
class=
"right floated"
v-else-if=
"manuallyApprovesFollowers"
>
<i
class=
"lock icon"
></i><translate>
Followers only
</translate>
</span>
<span
class=
"right floated"
v-else
>
<i
class=
"open lock icon"
></i><translate>
Open
</translate>
</span>
<span
v-if=
"totalItems"
>
<i
class=
"music icon"
></i>
<translate
translate-plural=
"%
{ count } tracks"
:translate-n="totalItems"
:translate-params="{count: totalItems}">
1 track
</translate>
</span>
</div>
<div
class=
"extra content"
>
<template
v-if=
"awaitingApproval"
>
<i
class=
"clock icon"
></i>
<translate>
Follow request pending approval
</translate>
</
template
>
<div
v-if=
"!library"
@
click=
"follow"
:disabled=
"isLoading"
:class=
"['ui', 'basic', {loading: isLoading}, 'green', 'button']"
>
<translate
v-if=
"manuallyApprovesFollowers"
>
Send a follow request
</translate>
<translate
v-else
>
Follow
</translate>
</div>
<router-link
v-else
class=
"ui basic button"
:to=
"{name: 'federation.libraries.detail', params: {id: library.uuid }}"
>
<translate>
Detail
</translate>
</router-link>
</div>
</div>
</template>
<
script
>
import
axios
from
'
axios
'
export
default
{
props
:
[
'
libraryData
'
,
'
libraryInstance
'
],
data
()
{
return
{
library
:
this
.
libraryInstance
,
isLoading
:
false
,
data
:
null
,
errors
:
[]
}
},
methods
:
{
follow
()
{
let
params
=
{
'
actor
'
:
this
.
libraryData
[
'
actor
'
][
'
id
'
],
'
autoimport
'
:
false
,
'
download_files
'
:
false
,
'
federation_enabled
'
:
true
}
let
self
=
this
self
.
isLoading
=
true
axios
.
post
(
'
/federation/libraries/
'
,
params
).
then
((
response
)
=>
{
self
.
$emit
(
'
follow
'
,
{
data
:
self
.
libraryData
,
library
:
response
.
data
})
self
.
library
=
response
.
data
self
.
isLoading
=
false
},
error
=>
{
self
.
isLoading
=
false
self
.
errors
=
error
.
backendErrors
})
}
},
computed
:
{
displayName
()
{
if
(
this
.
libraryData
)
{
return
this
.
libraryData
.
display_name
}
else
{
return
`
${
this
.
library
.
actor
.
preferred_username
}
@
${
this
.
library
.
actor
.
domain
}
`
}
},
manuallyApprovesFollowers
()
{
if
(
this
.
libraryData
)
{
return
this
.
libraryData
.
actor
.
manuallyApprovesFollowers
}
else
{
return
this
.
library
.
actor
.
manually_approves_followers
}
},
totalItems
()
{
if
(
this
.
libraryData
)
{
return
this
.
libraryData
.
library
.
totalItems
}
else
{
return
this
.
library
.
tracks_count
}
},
awaitingApproval
()
{
if
(
this
.
libraryData
)
{
return
this
.
libraryData
.
local
.
awaiting_approval
}
else
{
return
this
.
library
.
follow
.
approved
===
null
}
},
following
()
{
if
(
this
.
libraryData
)
{
return
this
.
libraryData
.
local
.
following
}
else
{
return
this
.
library
.
follow
.
approved
}
}
}
}
</
script
>
front/src/components/federation/LibraryFollowTable.vue
deleted
100644 → 0
View file @
a865fcdc
<
template
>
<div>
<div
class=
"ui form"
>
<div
class=
"fields"
>
<div
class=
"ui six wide field"
>
<input
type=
"text"
v-model=
"search"
:placeholder=
"labels.searchPlaceholder"
/>
</div>
<div
class=
"ui four wide inline field"
>
<div
class=
"ui checkbox"
>
<input
v-model=
"pending"
type=
"checkbox"
>
<label>
<translate>
Pending approval
</translate>
</label>
</div>
</div>
</div>
</div>
<div
class=
"ui hidden divider"
></div>
<table
v-if=
"result"
class=
"ui very basic single line unstackable table"
>
<thead>
<tr>
<th><translate>
Actor
</translate></th>
<th><translate>
Creation date
</translate></th>
<th><translate>
Status
</translate></th>
<th><translate>
Actions
</translate></th>
</tr>
</thead>
<tbody>
<tr
v-for=
"follow in result.results"
>
<td>
{{
follow
.
actor
.
preferred_username
}}
@
{{
follow
.
actor
.
domain
}}
</td>
<td>
<human-date
:date=
"follow.creation_date"
></human-date>
</td>
<td>
<template
v-if=
"follow.approved === true"
>
<i
class=
"check icon"
></i>
<translate>
Approved
</translate>
</
template
>
<
template
v-else-if=
"follow.approved === false"
>
<i
class=
"x icon"
></i>
<translate>
Refused
</translate>
</
template
>
<
template
v-else
>
<i
class=
"clock icon"
></i>
<translate>
Pending
</translate>
</
template
>
</td>
<td>
<dangerous-button
v-if=
"follow.approved !== false"
class=
"tiny basic labeled icon"
color=
'red'
@
confirm=
"updateFollow(follow, false)"
>
<i
class=
"x icon"
></i>
<translate>
Deny
</translate>
<p
slot=
"modal-header"
>
<translate>
Deny access?
</translate>
</p>
<p
slot=
"modal-content"
>
<translate
:translate-params=
"{username: follow.actor.preferred_username + '@' + follow.actor.domain}"
>
By confirming, %{ username } will be denied access to your library.
</translate>
</p>
<p
slot=
"modal-confirm"
>
<translate>
Deny
</translate>
</p>
</dangerous-button>
<dangerous-button
v-if=
"follow.approved !== true"
class=
"tiny basic labeled icon"
color=
'green'
@
confirm=
"updateFollow(follow, true)"
>
<i
class=
"check icon"
></i>
<translate>
Approve
</translate>
<p
slot=
"modal-header"
>
<translate>
Approve access?
</translate>
</p>
<p
slot=
"modal-content"
>
<translate
:translate-params=
"{username: follow.actor.preferred_username + '@' + follow.actor.domain}"
>
By confirming, %{ username } will be granted access to your library.
</translate>
<p
slot=
"modal-confirm"
>
<translate>
Approve
</translate>
</p>
</dangerous-button>
</td>
</tr>
</tbody>
<tfoot
class=
"full-width"
>
<tr>
<th>
<pagination
v-if=
"result && result.count > paginateBy"
@
page-changed=
"selectPage"
:compact=
"true"
:current=
"page"
:paginate-by=
"paginateBy"
:total=
"result.count"
></pagination>
</th>
<th
v-if=
"result && result.results.length > 0"
>
<translate
:translate-params=
"{start: ((page-1) * paginateBy) + 1, end: ((page-1) * paginateBy) + result.results.length, total: result.count}"
>
Showing results %{ start }-%{ end } on %{ total }
</translate>
</th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</template>
<
script
>
import
axios
from
'
axios
'
import
_
from
'
lodash
'
import
Pagination
from
'
@/components/Pagination
'
export
default
{
props
:
{
filters
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
{}}
},
components
:
{
Pagination
},
data
()
{
return
{
isLoading
:
false
,
result
:
null
,
page
:
1
,
paginateBy
:
25
,
search
:
''
,
pending
:
false
}
},
created
()
{
this
.
fetchData
()
},
computed
:
{
labels
()
{
return
{
searchPlaceholder
:
this
.
$gettext
(
'
Search by username, domain...
'
)
}
}
},
methods
:
{
fetchData
()
{
let
params
=
_
.
merge
({
'
page
'
:
this
.
page
,
'
page_size
'
:
this
.
paginateBy
,
'
q
'
:
this
.
search
},
this
.
filters
)
if
(
this
.
pending
)
{
params
.
pending
=
true
}
let
self
=
this
self
.
isLoading
=
true
axios
.
get
(
'
/federation/libraries/followers/
'
,
{
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
},
updateFollow
(
follow
,
approved
)
{
let
payload
=
{
follow
:
follow
.
id
,
approved
:
approved
}
let
self
=
this
axios
.
patch
(
'
/federation/libraries/followers/
'
,
payload
).
then
((
response
)
=>
{
follow
.
approved
=
response
.
data
.
approved
self
.
isLoading
=
false
},
error
=>
{
self
.
isLoading
=
false
self
.
errors
=
error
.
backendErrors
})
}
},
watch
:
{
search
(
newValue
)
{
if
(
newValue
.
length
>
0
)
{
this
.
fetchData
()
}
},
page
()
{
this
.
fetchData
()
},
pending
()
{
this
.
fetchData
()
}
}
}
</
script
>
front/src/components/federation/LibraryForm.vue
deleted
100644 → 0
View file @
a865fcdc
<
template
>
<form
class=
"ui form"
@
submit.prevent=
"fetchInstanceInfo"
>
<h3
class=
"ui header"
>
<translate>
Federate with a new instance
</translate>
</h3>
<p>
<translate>
Use this form to scan an instance and setup federation.
</translate>
</p>
<div
v-if=
"errors.length > 0 || scanErrors.length > 0"
class=
"ui negative message"
>
<div
class=
"header"
>
<translate>
Error while scanning library
</translate>
</div>
<ul
class=
"list"
>
<li
v-for=
"error in errors"
>
{{
error
}}
</li>
<li
v-for=
"error in scanErrors"
>
{{
error
}}
</li>
</ul>
</div>
<div
class=
"ui two fields"
>
<div
class=
"ui field"
>
<label>
<translate>
Library name
</translate>
</label>
<input
v-model=
"libraryUsername"
type=
"text"
:placeholder=
"labels.namePlaceholder"
/>
</div>
<div
class=
"ui field"
>
<label>
</label>
<button
type=
"submit"
:disabled=
"isLoading"
:class=
"['ui', 'icon',
{loading: isLoading}, 'button']">
<i
class=
"search icon"
></i>
<translate>
Launch scan
</translate>
</button>
</div>
</div>
</form>
</
template
>
<
script
>
import
axios
from
'
axios
'
import
TrackTable
from
'
@/components/audio/track/Table
'
import
RadioButton
from
'
@/components/radios/Button
'
import
Pagination
from
'
@/components/Pagination
'
export
default
{
components
:
{
TrackTable
,
RadioButton
,
Pagination
},
data
()
{
return
{
isLoading
:
false
,
libraryUsername
:
''
,
result
:
null
,
errors
:
[]
}
},
methods
:
{
follow
()
{
let
params
=
{
'
actor
'
:
this
.
result
[
'
actor
'
][
'
id
'
],
'
autoimport
'
:
false
,
'
download_files
'
:
false
,
'
federation_enabled
'
:
true
}
let
self
=
this
self
.
isFollowing
=
false
axios
.
post
(
'
/federation/libraries/
'
,
params
).
then
((
response
)
=>
{
self
.
$emit
(
'
follow
'
,
{
data
:
self
.
result
,
library
:
response
.
data
})
self
.
result
=
response
.
data
self
.
isFollowing
=
false
},
error
=>
{
self
.
isFollowing
=
false
self
.
errors
=
error
.
backendErrors
})
},
fetchInstanceInfo
()
{
let
self
=
this
this
.
isLoading
=
true
self
.
errors
=
[]
self
.
result
=
null
axios
.
get
(
'
/federation/libraries/fetch/
'
,
{
params
:
{
account
:
this
.
libraryUsername
.
trim
()}}).
then
((
response
)
=>
{
self
.
result
=
response
.
data
self
.
result
.
display_name
=
self
.
libraryUsername
self
.
isLoading
=
false
},
error
=>
{
self
.
isLoading
=
false
self
.
errors
=
error
.
backendErrors
})
}
},
computed
:
{
labels
()
{
return
{
namePlaceholder
:
this
.
$gettext
(
'
library@demo.funkwhale.audio
'
)
}
},
scanErrors
()
{
let
errors
=
[]
if
(
!
this
.
result
)
{
return
errors
}
let
keys
=
[
'
webfinger
'
,
'
actor
'
,
'
library
'
]
keys
.
forEach
(
k
=>
{
if
(
this
.
result
[
k
])
{
if
(
this
.
result
[
k
].
errors
)
{
this
.
result
[
k
].
errors
.
forEach
(
e
=>
{
errors
.
push
(
e
)
})
}
}
})
return
errors
}
},
watch
:
{
result
(
newValue
,
oldValue
)
{
this
.
$emit
(
'
scanned
'
,
newValue
)
}
}
}
</
script
>
front/src/components/federation/LibraryTrackTable.vue
deleted
100644 → 0
View file @
a865fcdc
<
template
>
<div>
<div
class=
"ui inline form"
>
<div
class=
"fields"
>
<div
class=
"ui six wide field"
>
<label><translate>
Search
</translate></label>
<input
type=
"text"
v-model=
"search"
:placeholder=
"labels.searchPlaceholder"
/>
</div>
<div
class=
"ui field"
>
<label><translate>
Import status
</translate></label>
<select
class=
"ui dropdown"
v-model=
"importedFilter"
>
<option
:value=
"null"
><translate>
Any
</translate></option>
<option
:value=
"'imported'"
><translate>
Imported
</translate></option>
<option
:value=
"'not_imported'"
><translate>
Not imported
</translate></option>
<option
:value=
"'import_pending'"
><translate>
Import pending
</translate></option>
</select>
</div>
<div
class=
"field"
>
<label><translate>
Ordering
</translate></label>
<select
class=
"ui dropdown"
v-model=
"ordering"
>
<option
v-for=
"option in orderingOptions"
:value=
"option[0]"
>
{{
option
[
1
]
}}
</option>
</select>
</div>
<div
class=
"field"
>
<label><translate>
Ordering direction
</translate></label>
<select
class=
"ui dropdown"
v-model=
"orderingDirection"
>
<option
value=
"+"
><translate>
Ascending
</translate></option>
<option
value=
"-"
><translate>
Descending
</translate></option>
</select>
</div>
</div>
</div>
<div
class=
"dimmable"
>
<div
v-if=
"isLoading"
class=
"ui active inverted dimmer"
>
<div
class=
"ui loader"
></div>
</div>
<action-table
v-if=
"result"
@
action-launched=
"fetchData"
:objects-data=
"result"
:actions=
"actions"
:action-url=
"'federation/library-tracks/action/'"
:filters=
"actionFilters"
>
<template
slot=
"header-cells"
>
<th><translate>
Status
</translate></th>
<th><translate>
Title
</translate></th>
<th><translate>
Artist
</translate></th>
<th><translate>
Album
</translate></th>
<th><translate>
Published date
</translate></th>
<th
v-if=
"showLibrary"
><translate>
Library
</translate></th>
</
template
>
<
template
slot=
"action-success-footer"
slot-scope=
"scope"
>
<router-link
v-if=
"scope.result.action === 'import'"
:to=
"
{name: 'library.import.batches.detail', params: {id: scope.result.result.batch.id }}">
<translate
:translate-params=
"
{id: scope.result.result.batch.id}">
Import #%{ id } launched
</translate>
</router-link>
</
template
>
<
template
slot=
"row-cells"
slot-scope=
"scope"
>
<td>
<span
v-if=
"scope.obj.status === 'imported'"
class=
"ui basic green label"
><translate>
In library
</translate></span>
<span
v-else-if=
"scope.obj.status === 'import_pending'"
class=
"ui basic yellow label"
><translate>
Import pending
</translate></span>
<span
v-else
class=
"ui basic label"
><translate>
Not imported
</translate></span>
</td>
<td>
<span
:title=
"scope.obj.title"
>
{{
scope
.
obj
.
title
|
truncate
(
30
)
}}
</span>
</td>
<td>
<span
class=
"discrete link"
@
click=
"updateSearch(
{key: 'artist', value: scope.obj.artist_name})" :title="scope.obj.artist_name">
{{
scope
.
obj
.
artist_name
|
truncate
(
30
)
}}
</span>
</td>
<td>
<span
class=
"discrete link"
@
click=
"updateSearch(
{key: 'album', value: scope.obj.album_title})" :title="scope.obj.album_title">
{{
scope
.
obj
.
album_title
|
truncate
(
20
)
}}
</span>
</td>
<td>
<human-date
:date=
"scope.obj.published_date"
></human-date>
</td>
<td
v-if=
"showLibrary"
>
<span
class=
"discrete link"
@
click=
"updateSearch(
{key: 'domain', value: scope.obj.library.actor.domain})">
{{
scope
.
obj
.
library
.
actor
.
domain
}}
</span>
</td>
</
template
>
</action-table>
</div>
<div>
<pagination
v-if=
"result && result.count > paginateBy"
@
page-changed=
"selectPage"
:compact=
"true"
:current=
"page"
:paginate-by=
"paginateBy"
:total=
"result.count"
></pagination>
<span
v-if=
"result && result.results.length > 0"
>
<translate
:translate-params=
"{start: ((page-1) * paginateBy) + 1, end: ((page-1) * paginateBy) + result.results.length, total: result.count}"
>
Showing results %{ start }-%{ end } on %{ total }
</translate>
</span>
</div>
</div>
</template>
<
script
>
import
axios
from
'
axios
'
import
_
from
'
lodash
'
import
Pagination
from
'
@/components/Pagination
'
import
ActionTable
from
'
@/components/common/ActionTable
'
import
OrderingMixin
from
'
@/components/mixins/Ordering
'
export
default
{
mixins
:
[
OrderingMixin
],
props
:
{
filters
:
{
type
:
Object
,
required
:
false
},
showLibrary
:
{
type
:
Boolean
,
default
:
false
}
},
components
:
{
Pagination
,
ActionTable
},
data
()
{
return
{
isLoading
:
false
,
result
:
null
,
page
:
1
,
paginateBy
:
25
,
search
:
''
,
importedFilter
:
null
,
orderingDirection
:
'
-
'
,
ordering
:
'
published_date
'
,
orderingOptions
:
[
[
'
published_date
'
,
'
Published date
'
],
[
'
title
'
,
'
Title
'
],
[
'
album_title
'
,
'
Album title
'
],
[
'
artist_name
'
,
'
Artist name
'
]
]
}
},
created
()
{
this
.
fetchData
()
},
methods
:
{
updateSearch
({
key
,
value
})
{