implemented account list

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-04-02 13:57:08 +02:00
parent 44fb120891
commit a5d5d5872d
5 changed files with 29 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ import static de.srsoftware.tools.Optionals.nullIfEmpty;
import static de.srsoftware.umbrella.accounting.Constants.CONFIG_DATABASE;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.constants.Path.JSON;
import static de.srsoftware.umbrella.core.constants.Path.SEARCH;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidField;
@@ -81,7 +82,7 @@ public class AccountingModule extends BaseHandler implements AccountingService {
}
private boolean getAccounts(UmbrellaUser user, HttpExchange ex) throws IOException {
return sendContent(ex,accountDb.listAccounts(user.id()));
return sendContent(ex,accountDb.listAccounts(user.id()).stream().map(Account::toMap));
}

View File

@@ -5,6 +5,7 @@
import { loadTranslation } from './translations.svelte';
import { checkUser, user } from './user.svelte';
import Account from "./routes/accounting/account.svelte";
import Accounts from "./routes/accounting/index.svelte";
import AddDoc from "./routes/document/Add.svelte";
import AddTask from "./routes/task/Add.svelte";
@@ -90,6 +91,7 @@
<span class="warn">{@html messages.warning}</span>
{/if}
<Route path="/" component={User} />
<Route path="/account/:id" component={Account} />
<Route path="/accounting" component={Accounts} />
<Route path="/accounting/new" component={NewAccount} />
<Route path="/bookmark" component={Bookmarks} />

View File

@@ -0,0 +1,5 @@
<script>
let { id } = $props();
</script>
<h1>Account {id}</h1>

View File

@@ -22,11 +22,29 @@
router.navigate('/accounting/new');
}
function onclick(e){
e.preventDefault();
let href = e.target.getAttribute('href');
if (href) router.navigate(href);
return false;
}
onMount(load);
</script>
<fieldset>
<legend>{t('accounts')}</legend>
<button onclick={newAccount}>{t('create_new_object',{'object':t('account')})}</button>
<span></span>
<span>
<button onclick={newAccount}>{t('create_new_object',{'object':t('account')})}</button>
</span>
<ul>
{#each accounts as account (account.id)}
<li>
<a {onclick} href="account/{account.id}">{account.name} ({account.id})</a>
</li>
{/each}
</ul>
</fieldset>

View File

@@ -412,8 +412,7 @@ public class UserModule extends BaseHandler implements UserService {
private boolean getUserList(HttpExchange ex, UmbrellaUser user) throws IOException, UmbrellaException {
if (!(user instanceof DbUser dbUser && dbUser.permissions().contains(LIST_USERS))) throw forbidden("You are not allowed to list users!");
var list = users.list(0, null,null).values().stream().map(UmbrellaUser::toMap).toList();
return sendContent(ex,list);
return sendContent(ex,users.list(0, null,null).values().stream().map(UmbrellaUser::toMap));
}
private boolean impersonate(HttpExchange ex, Long targetId) throws IOException, UmbrellaException {