mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 12:56:24 -05:00
Reworking tag endpoints in a more restful way.
This commit is contained in:
parent
d222ba4d32
commit
1dd19a8f5e
9 changed files with 292 additions and 168 deletions
|
|
@ -698,26 +698,32 @@ export async function removeTag(fileGroup, name) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function postTag(name, color) {
|
||||
export async function saveTag(name, color, id) {
|
||||
const body = {name: name, color: color};
|
||||
const uri = `${API_URI}/tag/new`;
|
||||
let uri = `${API_URI}/tag`;
|
||||
if (id) {
|
||||
uri = `${uri}/${id}`;
|
||||
}
|
||||
let response = await apiPost(uri, body);
|
||||
if (response.status !== 201) {
|
||||
if (id && response.status === 200) {
|
||||
toast({
|
||||
type: 'info', title: 'Saved tag', description: `Saved tag: ${name}`, time: 2000,
|
||||
});
|
||||
} else if (response.status === 201) {
|
||||
toast({
|
||||
type: 'info', title: 'Created new tag', description: `Created new tag: ${name}`, time: 2000,
|
||||
});
|
||||
} else {
|
||||
console.error('Failed to create new tag');
|
||||
toast({
|
||||
type: 'error', title: 'Error!', description: 'Unable to save tag', time: 5000,
|
||||
})
|
||||
} else {
|
||||
toast({
|
||||
type: 'info', title: 'Created new tag', description: `Created new tag: ${name}`, time: 2000,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteTag(name) {
|
||||
const body = {name: name};
|
||||
const uri = `${API_URI}/tag/delete`;
|
||||
let response = await apiPost(uri, body);
|
||||
export async function deleteTag(id, name) {
|
||||
const uri = `${API_URI}/tag/${id}`;
|
||||
let response = await apiDelete(uri);
|
||||
if (response.status === 400) {
|
||||
const content = await response.json();
|
||||
if (content['code'] === 38) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue