diff --git a/frontend/src/routes/search/Search.svelte b/frontend/src/routes/search/Search.svelte index 14d6ee60..86623260 100644 --- a/frontend/src/routes/search/Search.svelte +++ b/frontend/src/routes/search/Search.svelte @@ -9,7 +9,7 @@ import Bookmark from '../bookmark/Template.svelte'; const router = useTinyRouter(); - let counter = 9; + let counter = 10; let bookmarks = $state(null); let companies = $state(null); let documents = $state(null); @@ -18,14 +18,13 @@ let pages = $state(null); let projects = $state(null); let stock = $state(null); + let tags = $state(null); let tasks = $state(null); let times = $state(null); - - function doSearch(key){ warn(t('searching…')); - + console.log("doSearch"); const data = { key : key, fulltext : fulltext }; post(api('bookmark/search'),data).then(handleBookmarks); post(api('company/search '),data).then(handleCompanies); @@ -34,6 +33,7 @@ post(api('project/search' ),data).then(handleProjects); post(api('task/search' ),data).then(handleTasks); post(api('stock/search' ),data).then(handleStock); + post(api('tags/search' ),data).then(handleTags); post(api('time/search' ),data).then(handleTimes); post(api('wiki/search' ),data).then(handleWikiPages); } @@ -110,6 +110,20 @@ } } + async function handleTags(resp){ + quitOne(); + if (resp.ok){ + const res = await resp.json(); + tags = Object.keys(res).length ? res : null; + for (let [module, ids] of Object.entries(tags)){ + console.log("found "+module+" with tags:"); + // TODO: load entities from module + } + } else { + error(resp); + } + } + async function handleTasks(resp){ quitOne(); if (resp.ok){ @@ -364,3 +378,24 @@ {/if} +{#if tags} +
+{/if} +
+
+ {JSON.stringify(tags,null,2)}
+
+
\ No newline at end of file
diff --git a/tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java b/tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java
index c06c5a20..ebc701fe 100644
--- a/tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java
+++ b/tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java
@@ -4,6 +4,7 @@ package de.srsoftware.umbrella.tags;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
+import static de.srsoftware.umbrella.core.constants.Field.KEY;
import static de.srsoftware.umbrella.core.constants.Field.USER_LIST;
import static de.srsoftware.umbrella.core.constants.Path.SEARCH;
import static de.srsoftware.umbrella.core.constants.Path.USES;
@@ -94,7 +95,18 @@ public class TagModule extends BaseHandler implements TagService {
var user = userService().loadUser(token);
if (user.isEmpty()) return unauthorized(ex);
var module = path.pop();
- if (module == null) throw unprocessable("Module missing in path.");
+ return switch (module) {
+ case null -> throw unprocessable("Module missing in path.");
+ case SEARCH -> postSearch(ex, path, user.get());
+ default -> postTag(ex, module, path);
+ };
+ } catch (UmbrellaException e) {
+ return send(ex, e);
+ }
+ }
+
+ private boolean postTag(HttpExchange ex, String module, Path path) throws IOException {
+ try {
var head = path.pop();
long entityId = Long.parseLong(head);
var json = json(ex);
@@ -102,7 +114,7 @@ public class TagModule extends BaseHandler implements TagService {
List