Merge branch 'issue-315-csv-export' into 'develop'

#315 - export all follows as CSV

See merge request pleroma/pleroma-fe!538
This commit is contained in:
Shpuld Shpludson 2019-02-07 15:42:18 +00:00
commit 05ef0432d3
3 changed files with 16 additions and 1 deletions

View File

@ -238,7 +238,9 @@ const UserSettings = {
exportFollows () { exportFollows () {
this.enableFollowsExport = false this.enableFollowsExport = false
this.$store.state.api.backendInteractor this.$store.state.api.backendInteractor
.fetchFriends({id: this.$store.state.users.currentUser.id}) .exportFriends({
id: this.$store.state.users.currentUser.id
})
.then((friendList) => { .then((friendList) => {
this.exportPeople(friendList, 'friends.csv') this.exportPeople(friendList, 'friends.csv')
setTimeout(() => { this.enableFollowsExport = true }, 2000) setTimeout(() => { this.enableFollowsExport = true }, 2000)

View File

@ -257,6 +257,13 @@ const fetchFriends = ({id, page, credentials}) => {
.then((data) => data.map(parseUser)) .then((data) => data.map(parseUser))
} }
const exportFriends = ({id, credentials}) => {
let url = `${FRIENDS_URL}?user_id=${id}&export=true`
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => data.json())
.then((data) => data.map(parseUser))
}
const fetchFollowers = ({id, page, credentials}) => { const fetchFollowers = ({id, page, credentials}) => {
let url = `${FOLLOWERS_URL}?user_id=${id}` let url = `${FOLLOWERS_URL}?user_id=${id}`
if (page) { if (page) {
@ -536,6 +543,7 @@ const apiService = {
fetchConversation, fetchConversation,
fetchStatus, fetchStatus,
fetchFriends, fetchFriends,
exportFriends,
fetchFollowers, fetchFollowers,
followUser, followUser,
unfollowUser, unfollowUser,

View File

@ -14,6 +14,10 @@ const backendInteractorService = (credentials) => {
return apiService.fetchFriends({id, page, credentials}) return apiService.fetchFriends({id, page, credentials})
} }
const exportFriends = ({id}) => {
return apiService.exportFriends({id, credentials})
}
const fetchFollowers = ({id, page}) => { const fetchFollowers = ({id, page}) => {
return apiService.fetchFollowers({id, page, credentials}) return apiService.fetchFollowers({id, page, credentials})
} }
@ -78,6 +82,7 @@ const backendInteractorService = (credentials) => {
fetchStatus, fetchStatus,
fetchConversation, fetchConversation,
fetchFriends, fetchFriends,
exportFriends,
fetchFollowers, fetchFollowers,
followUser, followUser,
unfollowUser, unfollowUser,