Add tag display and file search
Signed-off-by: trivernis <trivernis@protonmail.com>pull/4/head
parent
e0a42b1b0f
commit
aeac1e2e36
@ -0,0 +1,21 @@
|
||||
use crate::commands::get_ipc;
|
||||
use crate::context::Context;
|
||||
use crate::error::AppResult;
|
||||
use mediarepo::requests::FileIdentifier;
|
||||
use mediarepo::responses::TagResponse;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_tags_for_file(
|
||||
hash: String,
|
||||
context: tauri::State<'_, Context>,
|
||||
) -> AppResult<Vec<TagResponse>> {
|
||||
let ipc = get_ipc(context).await?;
|
||||
let response = ipc
|
||||
.emitter
|
||||
.emit_to("tags", "tags_for_file", FileIdentifier::Hash(hash))
|
||||
.await?
|
||||
.await_reply(&ipc)
|
||||
.await?;
|
||||
|
||||
Ok(response.data::<Vec<TagResponse>>()?)
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
export type Tag = {
|
||||
id: number,
|
||||
name: string,
|
||||
namespace: string | undefined,
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TagService } from './tag.service';
|
||||
|
||||
describe('TagService', () => {
|
||||
let service: TagService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(TagService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {invoke} from "@tauri-apps/api/tauri";
|
||||
import {Tag} from "../../models/Tag";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TagService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
public async getTagsForFile(hash: string): Promise<Tag[]> {
|
||||
return await invoke<Tag[]>("get_tags_for_file", {hash});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue