Merge branch 'main' into module/timetracking

This commit is contained in:
2025-08-26 09:07:38 +02:00
23 changed files with 310 additions and 62 deletions

View File

@@ -5,6 +5,7 @@ import static de.srsoftware.umbrella.bookmarks.Constants.*;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Paths.LIST;
import static de.srsoftware.umbrella.core.Paths.SEARCH;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
@@ -21,6 +22,7 @@ import de.srsoftware.umbrella.core.model.Token;
import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Optional;
import org.json.JSONArray;
@@ -71,6 +73,7 @@ public class BookmarkApi extends BaseHandler implements BookmarkService {
if (user.isEmpty()) return unauthorized(ex);
var head = path.pop();
return switch (head) {
case SEARCH -> postSearch(user.get(),ex);
case null -> postBookmark(user.get(),ex);
default -> super.doPost(path,ex);
};
@@ -118,4 +121,13 @@ public class BookmarkApi extends BaseHandler implements BookmarkService {
}
return sendContent(ex,bookmark);
}
private boolean postSearch(UmbrellaUser user, HttpExchange ex) throws IOException {
var json = json(ex);
if (!(json.has(KEY) && json.get(KEY) instanceof String key)) throw missingFieldException(KEY);
var keys = Arrays.asList(key.split(" "));
var fulltext = json.has(FULLTEXT) && json.get(FULLTEXT) instanceof Boolean val && val;
var bookmarks = db.find(user.id(),keys);
return sendContent(ex,mapValues(bookmarks));
}
}

View File

@@ -7,7 +7,9 @@ import java.util.Collection;
import java.util.Map;
public interface BookmarkDb {
Map<Long, Bookmark> list(long userId, long offset, long limit);
Map<Long, Bookmark> find(long userId, Collection<String> key);
Map<Long, Bookmark> list(long userId, Long offset, Long limit);
Bookmark load(long id, long userId);

View File

@@ -2,6 +2,7 @@
package de.srsoftware.umbrella.bookmarks;
import static de.srsoftware.tools.jdbc.Condition.equal;
import static de.srsoftware.tools.jdbc.Condition.like;
import static de.srsoftware.tools.jdbc.Query.*;
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
import static de.srsoftware.umbrella.bookmarks.Constants.*;
@@ -69,7 +70,26 @@ CREATE TABLE IF NOT EXISTS {0} (
}
@Override
public Map<Long, Bookmark> list(long userId, long offset, long limit) {
public Map<Long, Bookmark> find(long userId, Collection<String> keys) {
try {
var map = new HashMap<Long,Bookmark>();
var query = select(ALL).from(TABLE_URL_COMMENTS).leftJoin(URL_ID,TABLE_URLS,ID)
.where(USER_ID, equal(userId));
for (var key : keys) query.where(COMMENT,like("%"+key+"%"));
var rs = query.sort(format("{0} DESC",TIMESTAMP)).exec(db);
while (rs.next()){
var bookmark = Bookmark.of(rs);
map.put(bookmark.urlId(),bookmark);
}
rs.close();;
return map;
} catch (SQLException e) {
throw new UmbrellaException("Failed to load bookmark list");
}
}
@Override
public Map<Long, Bookmark> list(long userId, Long offset, Long limit) {
try {
var map = new HashMap<Long,Bookmark>();
var rs = select(ALL).from(TABLE_URL_COMMENTS).leftJoin(URL_ID,TABLE_URLS,ID).where(USER_ID, equal(userId)).sort(format("{0} DESC",TIMESTAMP)).skip(offset).limit(limit).exec(db);

View File

@@ -98,6 +98,7 @@ public class Constants {
public static final String FIELD_TYPE_PREFIX = "type_prefix";
public static final String FIELD_TYPE_SUFFIX = "type_suffix";
public static final String FIELD_UNIT = "unit";
public static final String FULLTEXT = "fulltext";
public static final String GET = "GET";

View File

@@ -31,7 +31,7 @@ public class Project implements Mappable {
this.companyId = companyId;
this.showClosed = showClosed;
this.members = members;
this.allowedStates = allowedStates;
this.allowedStates = new ArrayList<>(allowedStates);
}
public Collection<Status> allowedStates(){

View File

@@ -17,7 +17,7 @@ public record Status(String name, int code) implements Mappable {
public static final Status STARTED = new Status("STARTED",40); // was 20
public static final Status COMPLETE = new Status("COMPLETE",60);
public static final Status CANCELLED = new Status("CANCELLED", 100);
public static final List<Status> PREDEFINED = new ArrayList<>(List.of(OPEN, STARTED, PENDING, COMPLETE, CANCELLED));
public static final List<Status> PREDEFINED = List.of(OPEN, STARTED, PENDING, COMPLETE, CANCELLED);
public static Status of(int code){
return switch (code){

View File

@@ -5,6 +5,7 @@ import { useTinyRouter } from 'svelte-tiny-router';
import { logout, user } from '../user.svelte.js';
import { t } from '../translations.svelte.js';
let key = $state(null);
const router = useTinyRouter();
const modules = $state([]);
@@ -27,6 +28,12 @@ function go(path){
return false;
}
async function search(e){
e.preventDefault();
router.navigate(`/search?key=${key}`);
return false;
}
onMount(fetchModules);
</script>
@@ -37,6 +44,10 @@ onMount(fetchModules);
</style>
<nav>
<form onsubmit={search}>
<input type="text" bind:value={key} />
<button type="submit">{t('search')}</button>
</form>
<a href="#" onclick={() => go('/user')}>{t('users')}</a>
<a href="#" onclick={() => go('/company')}>{t('companies')}</a>
<a href="#" onclick={() => go('/project')}>{t('projects')}</a>

View File

@@ -7,8 +7,6 @@
import TypeSelector from './TypeSelector.svelte';
let error = null;
let companies = {};
let router = useTinyRouter();
@@ -27,7 +25,7 @@
}
if (company_id) {
for (let comp of Object.keys(companies)){
for (let comp of companies){
if (comp.id == company_id){
load(comp);
break;

View File

@@ -22,6 +22,8 @@
let tasks = $state({});
let users = {};
let columns = $derived(project.allowed_states?Object.keys(project.allowed_states).length+1:1);
const controller = new AbortController();
const signal = controller.signal;
$effect(() => updateUrl(filter_input));
@@ -91,15 +93,20 @@
}
async function load(){
try {
await loadProject();
await loadTasks({project_id:+id,parent_task_id:0});
ready = true;
loadTags();
} catch (ignored) {}
}
async function loadProject(){
const url = api(`project/${id}`);
const resp = await fetch(url,{credentials:'include'});
const resp = await fetch(url,{
credentials:'include',
signal: signal
});
if (resp.ok){
project = await resp.json();
for (var uid of Object.keys(project.members)){
@@ -114,12 +121,17 @@
}
async function loadTag(task){
try {
const url = api(`tags/task/${task.id}`);
const resp = await fetch(url,{credentials:'include'});
const resp = await fetch(url,{
credentials:'include',
signal: signal
});
if (resp.ok) {
const tags = await resp.json();
if (tags.length) task.tags = tags.sort();
}
} catch (ignored) {}
}
function loadTags(){
@@ -138,7 +150,8 @@
selector.show_closed = true;
selector.no_index = true;
var resp = await fetch(url,{
credentials : 'include',
credentials :'include',
signal : signal,
method : 'POST',
body : JSON.stringify(selector)
});
@@ -146,6 +159,7 @@
var json = await resp.json();
for (var task_id of Object.keys(json)) {
let task = json[task_id];
if (task.no_index) continue;
let state = task.status;
let owner = null;
let assignee = null;
@@ -172,6 +186,11 @@
highlight = {user:user_id,state:state};
}
function openTask(task_id){
controller.abort();
router.navigate(`/task/${task_id}/view`)
}
onMount(load);
</script>
@@ -201,12 +220,12 @@
{#if stateList[state]}
{#each Object.values(stateList[state]).sort((a,b) => a.name.localeCompare(b.name)) as task}
{#if !filter || task.name.toLowerCase().includes(filter) || (task.tags && task.tags.filter(tag => tag.toLowerCase().includes(filter)).length)}
<Card onclick={() => router.navigate(`/task/${task.id}/view`)} ondragstart={ev => dragged=task} {task} />
<Card onclick={e => openTask(task.id)} ondragstart={ev => dragged=task} {task} />
{/if}
{/each}
{/if}
<div class="add_task">
<LineEditor value={t('add_task')} editable={true} onSet={(name) => create(name,uid,state)}/>
<LineEditor value={t('add_object',{object:t('task')})} editable={true} onSet={(name) => create(name,uid,state)}/>
</div>
</div>
{/each}

View File

@@ -1,40 +1,93 @@
<script>
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
let fulltext = false;
let html = "";
let key = "";
import Bookmark from '../bookmark/Template.svelte';
async function doSearch(ev){
const router = useTinyRouter();
console.log(router);
let bookmarks = $state(null);
let error = $state(null);
let fulltext = false;
let key = $state(router.getQueryParam('key'));
let input = $state(router.getQueryParam('key'));
let projects = $state(null);
let tasks = $state(null);
async function setKey(ev){
if (ev) ev.preventDefault();
const url = `${location.protocol}//${location.host.replace('5173','8080')}/legacy/search`;
const resp = await fetch(url,{
credentials : 'include',
method : 'POST',
body : JSON.stringify({key:key,fulltext:fulltext?'on':'off'})
});
if (resp.ok){
html = await resp.text();
if (!html) html = t('nothing_found');
}
key = input;
}
onMount(() => {
let params = new URLSearchParams(location.search);
key = params.get('key');
if (key) doSearch();
});
function doSearch(ignored){
let url = window.location.origin + window.location.pathname;
if (key) url += '?key=' + encodeURI(key);
window.history.replaceState(history.state, '', url);
const data = { key : key, fulltext : fulltext };
const options = {
credentials:'include',
method: 'POST',
body: JSON.stringify(data)
};
fetch(api('bookmark/search'),options).then(handleBookmarks);
fetch(api('project/search'),options).then(handleProjects);
fetch(api('task/search'),options).then(handleTasks);
}
function go(path){
router.navigate(path);
return false;
}
async function handleBookmarks(resp){
if (resp.ok){
const res = await resp.json();
bookmarks = Object.keys(res).length ? res : null;
} else {
error = await resp.text();
}
}
async function handleProjects(resp){
if (resp.ok){
const res = await resp.json();
projects = Object.keys(res).length ? res : null;
} else {
error = await resp.text();
}
}
async function handleTasks(resp){
if (resp.ok){
const res = await resp.json();
tasks = Object.keys(res).length ? res : null;
} else {
error = await resp.text();
}
}
$effect(() => doSearch(key))
</script>
<fieldset class="search">
<legend>{t('search')}</legend>
<form onsubmit={doSearch}>
{#if error}
<span class="error">{error}</span>
{/if}
<form onsubmit={setKey}>
<label>
{t('key')}
<input type="text" bind:value={key} />
<input type="text" bind:value={input} />
</label>
<label>
<input type="checkbox" bind:checked={fulltext} />
@@ -43,11 +96,45 @@
<button type="submit">{t('go')}</button>
</form>
</fieldset>
{#if html}
{#if projects}
<fieldset>
<legend>
{t('results')}
{t('projects')}
</legend>
{@html html}
<ul>
{#each Object.values(projects) as project}
<li>
<a href="#" onclick={e=>go(`/project/${project.id}/view`)} >{project.name}</a>
</li>
{/each}
</ul>
</fieldset>
{/if}
{#if tasks}
<fieldset>
<legend>
{t('tasks')}
</legend>
<ul>
{#each Object.values(tasks) as task}
<li>
<a href="#" onclick={e=>go(`/task/${task.id}/view`)} >{task.name}</a>
</li>
{/each}
</ul>
</fieldset>
{/if}
{#if bookmarks}
<fieldset>
<legend>
{t('bookmarks')}
</legend>
<ul>
{#each Object.values(bookmarks) as bookmark}
<li>
<a href={bookmark.url} target="_blank">{@html bookmark.comment.rendered}</a>
</li>
{/each}
</ul>
</fieldset>
{/if}

View File

@@ -17,6 +17,7 @@
let router = useTinyRouter();
async function addTag(){
if (!newTag) return;
if (!id) {
// when creating elements, they don`t have an id, yet
tags.push(newTag);

View File

@@ -46,7 +46,6 @@
function updateOn(id){
task = null;
loadTask();
console.log(router);
}
function addChild(){

View File

@@ -5,13 +5,18 @@ import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.Permission;
import de.srsoftware.umbrella.core.model.Project;
import de.srsoftware.umbrella.core.model.Status;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface ProjectDb {
void dropMember(long projectId, long userId);
Map<Long, Project> find(long userId, Collection<String> keys, boolean fulltext);
Map<Long, Permission> getMembers(Project project);
Project load(long projectId) throws UmbrellaException;
Map<Long, Project> ofCompany(long companyId, boolean includeClosed) throws UmbrellaException;
Map<Long, Project> ofUser(long userId, boolean includeClosed) throws UmbrellaException;
Project save(Project prj) throws UmbrellaException;

View File

@@ -4,6 +4,7 @@ package de.srsoftware.umbrella.project;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Paths.LIST;
import static de.srsoftware.umbrella.core.Paths.SEARCH;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
import static de.srsoftware.umbrella.core.model.Permission.*;
@@ -29,12 +30,12 @@ import org.json.JSONObject;
public class ProjectModule extends BaseHandler implements ProjectService {
private final ProjectDb projects;
private final ProjectDb projectDb;
public ProjectModule(ModuleRegistry registry, Configuration config) throws UmbrellaException {
super(registry);
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
projects = new SqliteDb(connect(dbFile));
projectDb = new SqliteDb(connect(dbFile));
}
private void addMember(Project project, long userId) {
@@ -53,7 +54,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
if (user.isEmpty()) return unauthorized(ex);
var head = path.pop();
return switch (head) {
case null -> postProject(ex,user.get());
case null -> super.doGet(path, ex);
default -> {
var projectId = Long.parseLong(head);
head = path.pop();
@@ -82,7 +83,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
head = path.pop();
yield switch (head){
case null -> patchProject(ex,projectId,user.get());
default -> super.doGet(path,ex);
default -> super.doPatch(path,ex);
};
}
};
@@ -101,6 +102,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
var head = path.pop();
return switch (head) {
case LIST -> postProjectList(ex, user.get());
case SEARCH -> postSearch(user.get(),ex);
case null -> postProject(ex, user.get());
default -> {
var projectId = Long.parseLong(head);
@@ -120,12 +122,12 @@ public class ProjectModule extends BaseHandler implements ProjectService {
private void dropMember(Project project, long userId) {
if (project.members().get(userId).permission() == OWNER) throw forbidden("You may not remove the owner of the project");
projects.dropMember(project.id(),userId);
projectDb.dropMember(project.id(),userId);
project.members().remove(userId);
}
private boolean getProject(HttpExchange ex, long projectId, UmbrellaUser user) throws IOException, UmbrellaException {
var project = loadMembers(projects.load(projectId));
var project = loadMembers(projectDb.load(projectId));
if (!project.hasMember(user)) throw forbidden("You are not a member of {0}",project.name());
var map = project.toMap();
project.companyId().map(companyService()::get).map(Company::toMap).ifPresent(data -> map.put(COMPANY,data));
@@ -133,7 +135,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
}
public Map<Long, Project> listCompanyProjects(long companyId, boolean includeClosed) throws UmbrellaException {
var projectList = projects.ofCompany(companyId, includeClosed);
var projectList = projectDb.ofCompany(companyId, includeClosed);
loadMembers(projectList.values());
return projectList;
}
@@ -147,7 +149,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
@Override
public Map<Long, Project> listUserProjects(long userId, boolean includeClosed) throws UmbrellaException {
var projectMap = projects.ofUser(userId, includeClosed);
var projectMap = projectDb.ofUser(userId, includeClosed);
loadMembers(projectMap.values());
return projectMap;
}
@@ -159,14 +161,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
@Override
public Project load(long projectId) {
return projects.load(projectId);
return projectDb.load(projectId);
}
@Override
public Collection<Project> loadMembers(Collection<Project> projectList) {
var userMap = new HashMap<Long,UmbrellaUser>();
for (var project : projectList){
for (var entry : projects.getMembers(project).entrySet()){
for (var entry : projectDb.getMembers(project).entrySet()){
var userId = entry.getKey();
var permission = entry.getValue();
var user = userMap.computeIfAbsent(userId,k -> userService().loadUser(userId));
@@ -199,14 +201,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
}
private boolean patchProject(HttpExchange ex, long projectId, UmbrellaUser user) throws IOException, UmbrellaException {
var project = loadMembers(projects.load(projectId));
var project = loadMembers(projectDb.load(projectId));
if (!project.hasMember(user)) throw forbidden("You are not a member of {0}",project.name());
var json = json(ex);
if (json.has(DROP_MEMBER) && json.get(DROP_MEMBER) instanceof Number id) dropMember(project,id.longValue());
if (json.has(MEMBERS) && json.get(MEMBERS) instanceof JSONObject memberJson) patchMembers(project,memberJson);
if (json.has(NEW_MEMBER) && json.get(NEW_MEMBER) instanceof Number num) addMember(project,num.longValue());
projects.save(project.patch(json));
projectDb.save(project.patch(json));
return sendContent(ex,project.toMap());
}
@@ -218,7 +220,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
if (!(json.has(CODE) && json.get(CODE) instanceof Number code)) throw missingFieldException(CODE);
if (!(json.has(NAME) && json.get(NAME) instanceof String name)) throw missingFieldException(NAME);
var newState = new Status(name,code.intValue());
return sendContent(ex,projects.save(projectId,newState));
return sendContent(ex, projectDb.save(projectId,newState));
}
private boolean postProject(HttpExchange ex, UmbrellaUser user) throws IOException, UmbrellaException {
@@ -241,7 +243,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
}
var owner = Map.of(user.id(),new Member(user,OWNER));
var prj = new Project(0,name,description, OPEN.code(),companyId,showClosed, owner, PREDEFINED);
prj = projects.save(prj);
prj = projectDb.save(prj);
if (json.has(TAGS) && json.get(TAGS) instanceof JSONArray arr){
var tagList = arr.toList().stream().filter(elem -> elem instanceof String).map(String.class::cast).toList();
@@ -257,4 +259,14 @@ public class ProjectModule extends BaseHandler implements ProjectService {
if (json.has(COMPANY_ID) && json.get(COMPANY_ID) instanceof Number companyId) return listCompanyProjects(ex, user, companyId.longValue());
return listUserProjects(ex,user,showClosed);
}
private boolean postSearch(UmbrellaUser user, HttpExchange ex) throws IOException {
var json = json(ex);
if (!(json.has(KEY) && json.get(KEY) instanceof String key)) throw missingFieldException(KEY);
var keys = Arrays.asList(key.split(" "));
var fulltext = json.has(FULLTEXT) && json.get(FULLTEXT) instanceof Boolean val && val;
var projects = projectDb.find(user.id(),keys,fulltext);
return sendContent(ex,mapValues(projects));
}
}

View File

@@ -9,6 +9,7 @@ import static de.srsoftware.umbrella.core.model.Status.COMPLETE;
import static de.srsoftware.umbrella.core.model.Status.OPEN;
import static de.srsoftware.umbrella.project.Constants.*;
import static java.lang.System.Logger.Level.ERROR;
import static java.lang.System.Logger.Level.WARNING;
import static java.text.MessageFormat.format;
import de.srsoftware.umbrella.core.BaseDb;
@@ -18,6 +19,7 @@ import de.srsoftware.umbrella.core.model.Project;
import de.srsoftware.umbrella.core.model.Status;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -163,7 +165,24 @@ CREATE TABLE IF NOT EXISTS {0} (
}
}
@Override
public Map<Long, Project> find(long userId, Collection<String> keys, boolean fulltext) {
try {
var projects = new HashMap<Long,Project>();
var query = select(ALL).from(TABLE_PROJECTS).leftJoin(ID,TABLE_PROJECT_USERS,PROJECT_ID).where(USER_ID, equal(userId));
for (var key : keys) query.where(NAME,like("%"+key+"%"));
LOG.log(WARNING,"Full-text search not implemented for projects");
var rs = query.exec(db);
while (rs.next()){
var project = Project.of(rs);
projects.put(project.id(),project);
}
rs.close();
return projects;
} catch (SQLException e) {
throw new UmbrellaException("Failed to load items from database");
}
}
@Override
public Map<Long, Project> ofUser(long userId, boolean includeClosed) throws UmbrellaException {

6
search/build.gradle.kts Normal file
View File

@@ -0,0 +1,6 @@
description = "Umbrella : Search"
dependencies{
implementation(project(":core"))
}

View File

@@ -0,0 +1,14 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.search;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry;
public class SearchModule extends BaseHandler {
public SearchModule(ModuleRegistry registry) {
super(registry);
}
}

View File

@@ -12,6 +12,7 @@ include("messages")
include("markdown")
include("notes")
include("project")
include("search")
include("tags")
include("task")
include("time")

View File

@@ -93,7 +93,7 @@ public class TagModule extends BaseHandler implements TagService {
var head = path.pop();
long entityId = Long.parseLong(head);
var json = json(ex);
if (!(json.has(TAG) && json.get(TAG) instanceof String tag)) throw missingFieldException(TAG);
if (!(json.has(TAG) && json.get(TAG) instanceof String tag && !tag.isBlank())) throw missingFieldException(TAG);
List<Long> userList = null;
if (!json.has(USER_LIST)) throw missingFieldException(USER_LIST);
var ul = json.isNull(USER_LIST) ? null : json.get(USER_LIST);

View File

@@ -114,6 +114,28 @@ CREATE TABLE IF NOT EXISTS {0} (
}
}
@Override
public HashMap<Long, Task> find(long userId, List<String> keys, boolean fulltext) {
try {
var tasks = new HashMap<Long,Task>();
var query = select(ALL).from(TABLE_TASKS).leftJoin(ID,TABLE_TASKS_USERS,TASK_ID)
.where(USER_ID,equal(userId));
for (var key : keys) query.where(NAME,like("%"+key+"%"));
LOG.log(WARNING,"Full-text search not implemented for tasks");
var rs = query.exec(db);
while (rs.next()){
var task = Task.of(rs);
tasks.put(task.id(),task);
}
rs.close();
return tasks;
} catch (SQLException e){
LOG.log(WARNING,"Failed to load tasks for user (user_id: {0}",userId,e);
throw new UmbrellaException("Failed to load tasks for project id");
}
}
@Override
public Map<Long, Permission> getMembers(Task task) {
try {

View File

@@ -15,11 +15,13 @@ public interface TaskDb {
void delete(Task task) throws UmbrellaException;
void dropMember(long projectId, long userId);
HashMap<Long, Task> find(long userId, List<String> keys, boolean fulltext);
Map<Long, Permission> getMembers(Task task);
HashMap<Long, Task> listChildrenOf(Long parentTaskId, UmbrellaUser user, boolean showClosed);
HashMap<Long, Task> listProjectTasks(Long projectId, Long parentTaskId, boolean noIndex) throws UmbrellaException;
HashMap<Long, Task> listRootTasks(Long projectId, UmbrellaUser user, boolean showClosed);
HashMap<Long, Task> listTasks(Collection<Long> projectIds) throws UmbrellaException;
List<Task> listUserTasks(long userId, Long limit, long offset, boolean showClosed);
Task load(long taskId) throws UmbrellaException;

View File

@@ -135,6 +135,7 @@ public class TaskModule extends BaseHandler implements TaskService {
case ADD -> postNewTask(user.get(),ex);
case ESTIMATED_TIMES -> estimatedTimes(user.get(),ex);
case LIST -> postTaskList(user.get(),ex);
case SEARCH -> postSearch(user.get(),ex);
default -> super.doPost(path,ex);
};
} catch (UmbrellaException e){
@@ -346,6 +347,15 @@ public class TaskModule extends BaseHandler implements TaskService {
return sendContent(ex,loadMembers(task));
}
private boolean postSearch(UmbrellaUser user, HttpExchange ex) throws IOException {
var json = json(ex);
if (!(json.has(KEY) && json.get(KEY) instanceof String key)) throw missingFieldException(KEY);
var keys = Arrays.asList(key.split(" "));
var fulltext = json.has(FULLTEXT) && json.get(FULLTEXT) instanceof Boolean val && val;
var tasks = taskDb.find(user.id(),keys,fulltext);
return sendContent(ex,mapValues(tasks));
}
private boolean postTaskList(UmbrellaUser user, HttpExchange ex) throws IOException {
var json = json(ex);
LOG.log(WARNING,"Missing permission check in {0}.postTaskList!",getClass().getSimpleName());

View File

@@ -284,3 +284,10 @@ legend{
vertical-align: top;
}
nav > form{
display:inline;
}
li > a > p:nth-child(1){
display: inline;
}