mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 07:26:18 -05:00
FileBrowser files can be tagged. A Tag icon is displayed on each file row in the browser.
This commit is contained in:
parent
655e944960
commit
ae2b6daa33
29 changed files with 356 additions and 219 deletions
|
|
@ -681,9 +681,18 @@ export async function getTags() {
|
|||
}
|
||||
|
||||
export async function addTag(fileGroup, name) {
|
||||
const {id} = fileGroup;
|
||||
const body = {tag_name: name};
|
||||
|
||||
const {id, primary_path, path} = fileGroup;
|
||||
if (id) {
|
||||
body['file_group_id'] = id;
|
||||
} else if (primary_path) {
|
||||
body['file_group_primary_path'] = primary_path;
|
||||
} else if (path) {
|
||||
body['file_group_primary_path'] = path;
|
||||
}
|
||||
|
||||
const uri = `${API_URI}/files/tag`;
|
||||
const body = {file_group_id: id, tag_name: name};
|
||||
let response = await apiPost(uri, body);
|
||||
if (response.status !== 201) {
|
||||
console.error('Failed to add tag');
|
||||
|
|
@ -691,9 +700,18 @@ export async function addTag(fileGroup, name) {
|
|||
}
|
||||
|
||||
export async function removeTag(fileGroup, name) {
|
||||
const {id} = fileGroup;
|
||||
const body = {tag_name: name};
|
||||
|
||||
const {id, primary_path, path} = fileGroup;
|
||||
if (id) {
|
||||
body['file_group_id'] = id;
|
||||
} else if (primary_path) {
|
||||
body['file_group_primary_path'] = primary_path;
|
||||
} else if (path) {
|
||||
body['file_group_primary_path'] = path;
|
||||
}
|
||||
|
||||
const uri = `${API_URI}/files/untag`;
|
||||
const body = {file_group_id: id, tag_name: name};
|
||||
let response = await apiPost(uri, body)
|
||||
if (response.status !== 204) {
|
||||
console.error('Failed to remove tag');
|
||||
|
|
@ -740,3 +758,15 @@ export async function deleteTag(id, name) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchFile(path) {
|
||||
const uri = `${API_URI}/files/file`;
|
||||
const body = {file: path};
|
||||
const response = await apiPost(uri, body);
|
||||
if (response.status === 200) {
|
||||
const content = await response.json();
|
||||
return content['file'];
|
||||
} else {
|
||||
console.error('Unable to fetch file dict! See client logs.');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue