forked from AkkomaGang/admin-fe
Add api for fetching a list of tags
This commit is contained in:
parent
457264b72c
commit
37b2fb3199
3 changed files with 67 additions and 48 deletions
|
@ -22,6 +22,26 @@ export async function addRight(nicknames, right, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function approveUserAccount(nicknames, authHost, token) {
|
||||||
|
return await request({
|
||||||
|
baseURL: baseName(authHost),
|
||||||
|
url: '/api/pleroma/admin/users/approve',
|
||||||
|
method: 'patch',
|
||||||
|
headers: authHeaders(token),
|
||||||
|
data: { nicknames }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function confirmUserEmail(nicknames, authHost, token) {
|
||||||
|
return await request({
|
||||||
|
baseURL: baseName(authHost),
|
||||||
|
url: '/api/pleroma/admin/users/confirm_email',
|
||||||
|
method: 'patch',
|
||||||
|
headers: authHeaders(token),
|
||||||
|
data: { nicknames }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function createNewAccount(nickname, email, password, authHost, token) {
|
export async function createNewAccount(nickname, email, password, authHost, token) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
|
@ -81,6 +101,15 @@ export async function fetchUser(id, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchUsers(filters, authHost, token, page = 1) {
|
||||||
|
return await request({
|
||||||
|
baseURL: baseName(authHost),
|
||||||
|
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`,
|
||||||
|
method: 'get',
|
||||||
|
headers: authHeaders(token)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchUserCredentials(nickname, authHost, token) {
|
export async function fetchUserCredentials(nickname, authHost, token) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
|
@ -90,22 +119,22 @@ export async function fetchUserCredentials(nickname, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateUserCredentials(nickname, credentials, authHost, token) {
|
export async function fetchUserStatuses(id, authHost, godmode, token) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
url: `/api/pleroma/admin/users/${nickname}/credentials`,
|
url: `/api/pleroma/admin/users/${id}/statuses?godmode=${godmode}`,
|
||||||
method: 'patch',
|
method: 'get',
|
||||||
headers: authHeaders(token),
|
headers: authHeaders(token)
|
||||||
data: credentials
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchUsers(filters, authHost, token, page = 1) {
|
export async function forcePasswordReset(nicknames, authHost, token) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`,
|
url: `/api/pleroma/admin/users/force_password_reset`,
|
||||||
method: 'get',
|
method: 'patch',
|
||||||
headers: authHeaders(token)
|
headers: authHeaders(token),
|
||||||
|
data: { nicknames }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +147,19 @@ export async function getPasswordResetToken(nickname, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function forcePasswordReset(nicknames, authHost, token) {
|
export async function listAllTags(authHost, token) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
url: `/api/pleroma/admin/users/force_password_reset`,
|
url: `/api/pleroma/admin/users/tag`,
|
||||||
|
method: 'get',
|
||||||
|
headers: authHeaders(token)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resendConfirmationEmail(nicknames, authHost, token) {
|
||||||
|
return await request({
|
||||||
|
baseURL: baseName(authHost),
|
||||||
|
url: '/api/pleroma/admin/users/resend_confirmation_email',
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
headers: authHeaders(token),
|
headers: authHeaders(token),
|
||||||
data: { nicknames }
|
data: { nicknames }
|
||||||
|
@ -157,42 +195,13 @@ export async function untagUser(nicknames, tags, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchUserStatuses(id, authHost, godmode, token) {
|
export async function updateUserCredentials(nickname, credentials, authHost, token) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
url: `/api/pleroma/admin/users/${id}/statuses?godmode=${godmode}`,
|
url: `/api/pleroma/admin/users/${nickname}/credentials`,
|
||||||
method: 'get',
|
|
||||||
headers: authHeaders(token)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function approveUserAccount(nicknames, authHost, token) {
|
|
||||||
return await request({
|
|
||||||
baseURL: baseName(authHost),
|
|
||||||
url: '/api/pleroma/admin/users/approve',
|
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
headers: authHeaders(token),
|
headers: authHeaders(token),
|
||||||
data: { nicknames }
|
data: credentials
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function confirmUserEmail(nicknames, authHost, token) {
|
|
||||||
return await request({
|
|
||||||
baseURL: baseName(authHost),
|
|
||||||
url: '/api/pleroma/admin/users/confirm_email',
|
|
||||||
method: 'patch',
|
|
||||||
headers: authHeaders(token),
|
|
||||||
data: { nicknames }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function resendConfirmationEmail(nicknames, authHost, token) {
|
|
||||||
return await request({
|
|
||||||
baseURL: baseName(authHost),
|
|
||||||
url: '/api/pleroma/admin/users/resend_confirmation_email',
|
|
||||||
method: 'patch',
|
|
||||||
headers: authHeaders(token),
|
|
||||||
data: { nicknames }
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,21 @@ import i18n from '@/lang'
|
||||||
import {
|
import {
|
||||||
activateUsers,
|
activateUsers,
|
||||||
addRight,
|
addRight,
|
||||||
|
approveUserAccount,
|
||||||
|
confirmUserEmail,
|
||||||
createNewAccount,
|
createNewAccount,
|
||||||
deactivateUsers,
|
deactivateUsers,
|
||||||
deleteRight,
|
deleteRight,
|
||||||
deleteUsers,
|
deleteUsers,
|
||||||
disableMfa,
|
disableMfa,
|
||||||
fetchUsers,
|
fetchUsers,
|
||||||
|
forcePasswordReset,
|
||||||
getPasswordResetToken,
|
getPasswordResetToken,
|
||||||
|
listAllTags,
|
||||||
|
resendConfirmationEmail,
|
||||||
searchUsers,
|
searchUsers,
|
||||||
tagUser,
|
tagUser,
|
||||||
untagUser,
|
untagUser,
|
||||||
forcePasswordReset,
|
|
||||||
approveUserAccount,
|
|
||||||
confirmUserEmail,
|
|
||||||
resendConfirmationEmail,
|
|
||||||
updateUserCredentials
|
updateUserCredentials
|
||||||
} from '@/api/users'
|
} from '@/api/users'
|
||||||
import { fetchSettings, updateSettings } from '@/api/settings'
|
import { fetchSettings, updateSettings } from '@/api/settings'
|
||||||
|
@ -40,7 +41,8 @@ const users = {
|
||||||
passwordResetToken: {
|
passwordResetToken: {
|
||||||
token: '',
|
token: '',
|
||||||
link: ''
|
link: ''
|
||||||
}
|
},
|
||||||
|
tags: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
SET_USERS: (state, users) => {
|
SET_USERS: (state, users) => {
|
||||||
|
@ -83,6 +85,9 @@ const users = {
|
||||||
SET_TAG_POLICY: (state, mrfPolicies) => {
|
SET_TAG_POLICY: (state, mrfPolicies) => {
|
||||||
state.mrfPolicies = mrfPolicies
|
state.mrfPolicies = mrfPolicies
|
||||||
},
|
},
|
||||||
|
SET_TAGS: (state, tags) => {
|
||||||
|
state.tags = tags
|
||||||
|
},
|
||||||
SET_USERS_FILTERS: (state, filters) => {
|
SET_USERS_FILTERS: (state, filters) => {
|
||||||
state.filters = filters
|
state.filters = filters
|
||||||
}
|
}
|
||||||
|
@ -246,6 +251,10 @@ const users = {
|
||||||
RemovePasswordToken({ commit }) {
|
RemovePasswordToken({ commit }) {
|
||||||
commit('SET_PASSWORD_RESET_TOKEN', { link: '', token: '' })
|
commit('SET_PASSWORD_RESET_TOKEN', { link: '', token: '' })
|
||||||
},
|
},
|
||||||
|
async ListTags({ commit, getters }) {
|
||||||
|
const { data } = await listAllTags(getters.authHost, getters.token)
|
||||||
|
commit('SET_TAGS', data)
|
||||||
|
},
|
||||||
async RemoveTag({ dispatch, getters }, { users, tag, _userId, _statusId }) {
|
async RemoveTag({ dispatch, getters }, { users, tag, _userId, _statusId }) {
|
||||||
const updatedUsers = users.map(user => {
|
const updatedUsers = users.map(user => {
|
||||||
return { ...user, tags: user.tags.filter(userTag => userTag !== tag) }
|
return { ...user, tags: user.tags.filter(userTag => userTag !== tag) }
|
||||||
|
|
|
@ -226,6 +226,7 @@ export default {
|
||||||
this.$store.dispatch('NeedReboot')
|
this.$store.dispatch('NeedReboot')
|
||||||
this.$store.dispatch('FetchTagPolicySetting')
|
this.$store.dispatch('FetchTagPolicySetting')
|
||||||
this.$store.dispatch('FetchUsers', { page: 1 })
|
this.$store.dispatch('FetchUsers', { page: 1 })
|
||||||
|
this.$store.dispatch('ListTags')
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
this.$store.dispatch('ClearUsersState')
|
this.$store.dispatch('ClearUsersState')
|
||||||
|
|
Loading…
Reference in a new issue