Browse Source

working on task index

featue/module_registry
Stephan Richter 3 months ago
parent
commit
983f1bac49
  1. 58
      frontend/src/App.svelte
  2. 51
      frontend/src/routes/task/Index.svelte
  3. 17
      task/src/main/java/de/srsoftware/umbrella/task/SqliteDb.java
  4. 2
      task/src/main/java/de/srsoftware/umbrella/task/TaskDb.java
  5. 7
      task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java

58
frontend/src/App.svelte

@ -25,6 +25,7 @@
import Search from "./routes/search/Search.svelte"; import Search from "./routes/search/Search.svelte";
import SendDoc from "./routes/document/Send.svelte"; import SendDoc from "./routes/document/Send.svelte";
import TagUses from "./routes/tags/TagUses.svelte"; import TagUses from "./routes/tags/TagUses.svelte";
import TaskList from "./routes/task/Index.svelte";
import User from "./routes/user/User.svelte"; import User from "./routes/user/User.svelte";
import ViewDoc from "./routes/document/View.svelte"; import ViewDoc from "./routes/document/View.svelte";
import ViewPrj from "./routes/project/View.svelte"; import ViewPrj from "./routes/project/View.svelte";
@ -50,34 +51,35 @@
<Router> <Router>
{#if user.name } {#if user.name }
<!-- https://github.com/notnotsamuel/svelte-tiny-router --> <!-- https://github.com/notnotsamuel/svelte-tiny-router -->
<Menu /> <Menu />
<Route path="/" component={User} /> <Route path="/" component={User} />
<Route path="/bookmark" component={Bookmarks} /> <Route path="/bookmark" component={Bookmarks} />
<Route path="/bookmark/:id/view" component={Bookmark} /> <Route path="/bookmark/:id/view" component={Bookmark} />
<Route path="/document" component={DocList} /> <Route path="/document" component={DocList} />
<Route path="/document/add" component={AddDoc} /> <Route path="/document/add" component={AddDoc} />
<Route path="/document/:id/send" component={SendDoc} /> <Route path="/document/:id/send" component={SendDoc} />
<Route path="/document/:id/view" component={ViewDoc} /> <Route path="/document/:id/view" component={ViewDoc} />
<Route path="/message/settings" component={Messages} /> <Route path="/message/settings" component={Messages} />
<Route path="/notes" component={Notes} /> <Route path="/notes" component={Notes} />
<Route path="/project" component={ProjectList} /> <Route path="/project" component={ProjectList} />
<Route path="/project/add" component={ProjectAdd} /> <Route path="/project/add" component={ProjectAdd} />
<Route path="/project/:project_id/add_task" component={AddTask} /> <Route path="/project/:project_id/add_task" component={AddTask} />
<Route path="/project/:id/kanban" component={Kanban} /> <Route path="/project/:id/kanban" component={Kanban} />
<Route path="/project/:id/view" component={ViewPrj} /> <Route path="/project/:id/view" component={ViewPrj} />
<Route path="/search" component={Search} /> <Route path="/search" component={Search} />
<Route path="/tags/use/:tag" component={TagUses} /> <Route path="/tags/use/:tag" component={TagUses} />
<Route path="/task/:parent_task_id/add_subtask" component={AddTask} /> <Route path="/task" component={TaskList} />
<Route path="/task/:id/view" component={ViewTask} /> <Route path="/task/:parent_task_id/add_subtask" component={AddTask} />
<Route path="/user" component={User} /> <Route path="/task/:id/view" component={ViewTask} />
<Route path="/user/create" component={EditUser} /> <Route path="/user" component={User} />
<Route path="/user/login" component={User} /> <Route path="/user/create" component={EditUser} />
<Route path="/user/:user_id/edit" component={EditUser} /> <Route path="/user/login" component={User} />
<Route path="/user/oidc/add" component={EditService} /> <Route path="/user/:user_id/edit" component={EditUser} />
<Route path="/user/oidc/edit/:serviceName" component={EditService} /> <Route path="/user/oidc/add" component={EditService} />
<Route> <Route path="/user/oidc/edit/:serviceName" component={EditService} />
Not found! <Route>
</Route> Not found!
</Route>
{:else} {:else}
<Route path="/user/reset/pw" component={ResetPw} /> <Route path="/user/reset/pw" component={ResetPw} />
<Route path="/oidc_callback" component={Callback} /> <Route path="/oidc_callback" component={Callback} />

51
frontend/src/routes/task/Index.svelte

@ -0,0 +1,51 @@
<script>
import { onMount } from 'svelte';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
let error = $state(null);
let tasks = $state(null);
async function load(){
const url = api('task');
const resp = await fetch(url,{credentials:'include'});
let project_ids = {};
if (resp.ok){
tasks = await resp.json();
for (let task of (Object.values(tasks))) project_ids[task.project_id] = true;
} else {
error = await resp.text();
}
project_ids = Object.keys(project_ids);
console.log(project_ids);
}
onMount(load);
</script>
<fieldsett>
<legend>{t('task_list')}</legend>
{#if error}
<soan class="error">{error}</soan>
{/if}
{#if tasks}
<table>
<thead>
<tr>
<th>{t('title')}</th>
<th>{t('project')} / {t('parent_task')}</th>
</tr>
</thead>
<tbody>
{#each Object.entries(tasks) as [tid,task]}
<tr>
<td>{task.name}</td>
<td>{task.project_id} {task.parent_task_id?tasks[task.parent_task_id]?.name:''}</td>
<td>TODO: load projects</td>
</tr>
{/each}
</tbody>
</table>
{/if}
</fieldsett>

17
task/src/main/java/de/srsoftware/umbrella/task/SqliteDb.java

@ -6,6 +6,7 @@ import static de.srsoftware.tools.jdbc.Condition.*;
import static de.srsoftware.tools.jdbc.Query.*; import static de.srsoftware.tools.jdbc.Query.*;
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL; import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
import static de.srsoftware.umbrella.core.model.Status.OPEN; import static de.srsoftware.umbrella.core.model.Status.OPEN;
import static de.srsoftware.umbrella.project.Constants.*; import static de.srsoftware.umbrella.project.Constants.*;
import static de.srsoftware.umbrella.task.Constants.*; import static de.srsoftware.umbrella.task.Constants.*;
@ -210,6 +211,22 @@ CREATE TABLE IF NOT EXISTS {0} (
} }
} }
@Override
public HashMap<Long, Task> listUserTasks(long userId) {
try {
var rs = select(ALL).from(TABLE_TASKS).leftJoin(ID,TABLE_TASKS_USERS,TASK_ID).where(USER_ID,equal(userId)).exec(db);
var map = new HashMap<Long,Task>();
while (rs.next()) {
var task = Task.of(rs);
map.put(task.id(),task);
}
rs.close();
return map;
} catch (SQLException e) {
throw databaseException("Failed to load tasks of user {0}",userId);
}
}
@Override @Override
public Task load(long taskId) throws UmbrellaException { public Task load(long taskId) throws UmbrellaException {
try { try {

2
task/src/main/java/de/srsoftware/umbrella/task/TaskDb.java

@ -18,8 +18,8 @@ public interface TaskDb {
HashMap<Long, Task> listChildrenOf(Long parentTaskId, UmbrellaUser user, boolean showClosed); 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> listProjectTasks(Long projectId, Long parentTaskId, boolean noIndex) throws UmbrellaException;
HashMap<Long, Task> listRootTasks(Long projectId, UmbrellaUser user, boolean showClosed); HashMap<Long, Task> listRootTasks(Long projectId, UmbrellaUser user, boolean showClosed);
HashMap<Long, Task> listTasks(Collection<Long> projectIds) throws UmbrellaException; HashMap<Long, Task> listTasks(Collection<Long> projectIds) throws UmbrellaException;
HashMap<Long, Task> listUserTasks(long userId);
Task load(long taskId) throws UmbrellaException; Task load(long taskId) throws UmbrellaException;

7
task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java

@ -103,7 +103,7 @@ public class TaskModule extends BaseHandler implements TaskService {
var head = path.pop(); var head = path.pop();
return switch (head) { return switch (head) {
case PERMISSIONS -> getPermissionList(ex); case PERMISSIONS -> getPermissionList(ex);
case null -> super.doGet(path,ex); case null -> getUserTasks(user.get(),ex);
default -> { default -> {
var taskId = Long.parseLong(head); var taskId = Long.parseLong(head);
head = path.pop(); head = path.pop();
@ -201,6 +201,11 @@ public class TaskModule extends BaseHandler implements TaskService {
return sendContent(ex,task); return sendContent(ex,task);
} }
private boolean getUserTasks(UmbrellaUser user, HttpExchange ex) throws IOException {
var list = taskDb.listUserTasks(user.id());
return sendContent(ex,mapValues(list));
}
@Override @Override
public HashMap<Long, Task> listCompanyTasks(long companyId) throws UmbrellaException { public HashMap<Long, Task> listCompanyTasks(long companyId) throws UmbrellaException {
var projectList = projects.listCompanyProjects(companyId,false); var projectList = projects.listCompanyProjects(companyId,false);

Loading…
Cancel
Save