feat: code cleanup, new features and v2.0

We're merging this to continue https://github.com/filebrowser/filebrowser/pull/575 and setup translations auto-updating.
This commit is contained in:
Henrique Dias
2019-01-05 16:12:09 +00:00
committed by GitHub
parent 2642333928
commit 39be89780e
155 changed files with 16499 additions and 6583 deletions

52
src/api/users.js Normal file
View File

@@ -0,0 +1,52 @@
import { fetchURL, fetchJSON } from './utils'
export async function getAll () {
return fetchJSON(`/api/users`, {})
}
export async function get (id) {
return fetchJSON(`/api/users/${id}`, {})
}
export async function create (user) {
const res = await fetchURL(`/api/users`, {
method: 'POST',
body: JSON.stringify({
what: 'user',
which: [],
data: user
})
})
if (res.status === 201) {
return res.headers.get('Location')
} else {
throw new Error(res.status)
}
}
export async function update (user, which = ['all']) {
const res = await fetchURL(`/api/users/${user.id}`, {
method: 'PUT',
body: JSON.stringify({
what: 'user',
which: which,
data: user
})
})
if (res.status !== 200) {
throw new Error(res.status)
}
}
export async function remove (id) {
const res = await fetchURL(`/api/users/${id}`, {
method: 'DELETE'
})
if (res.status !== 200) {
throw new Error(res.status)
}
}