Compare commits
75
Commits
4bdae72aba
...
f5476d7f1c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5476d7f1c | ||
|
|
b1af757976 | ||
|
|
9694b90a88 | ||
|
|
b69429e09e | ||
|
|
3b0693560e | ||
|
|
af1bca6b99 | ||
|
|
ba841978ae | ||
|
|
f2a176ea9b | ||
|
|
097336d66d | ||
|
|
1d7b47aaa0 | ||
|
|
f49b44cd56 | ||
|
|
60777feaa3 | ||
|
|
bcc1182dea | ||
|
|
4a83bb6bee | ||
|
|
0879b53a88 | ||
|
|
6aa858e299 | ||
|
|
31545b8b11 | ||
|
|
feafb44a9f | ||
|
|
d187b6a2fc | ||
|
|
8d7de4b1b6 | ||
|
|
e61e09d834 | ||
|
|
3cff613335 | ||
|
|
0edeef2a9d | ||
|
|
3a7779a665 | ||
|
|
a1164e416a | ||
|
|
2f8276c1be | ||
|
|
8b139b1bed | ||
|
|
3b2371ad64 | ||
|
|
aa48bbcbf5 | ||
|
|
c5e31db99e | ||
|
|
098811547a | ||
|
|
6193b727bd | ||
|
|
1d1520534c | ||
|
|
883b90faa7 | ||
|
|
a8a4ab0985 | ||
|
|
bc9df18307 | ||
|
|
a8e3122152 | ||
|
|
dc1a5f4e94 | ||
|
|
80153ada13 | ||
|
|
9bf9fba9df | ||
|
|
01d56ca451 | ||
|
|
b4af8d1876 | ||
|
|
69c8d0fe9c | ||
|
|
bf1a6684a7 | ||
|
|
5a47ebae2b | ||
|
|
9d62f15b8f | ||
|
|
5524ea7878 | ||
|
|
3d1850b2d2 | ||
|
|
02283d57ba | ||
|
|
1768a48e5e | ||
|
|
1cdf825bcb | ||
|
|
71c86e512d | ||
|
|
9d8013bc33 | ||
|
|
05733d3b7a | ||
|
|
71c071bbdd | ||
|
|
1241fee61d | ||
|
|
d64cb886c9 | ||
|
|
ac8149e6bb | ||
|
|
493b61465b | ||
|
|
df372e9cfd | ||
|
|
ff58f3ae82 | ||
|
|
b71db96b47 | ||
|
|
02434419f4 | ||
|
|
bd096dc61f | ||
|
|
9f286f3121 | ||
|
|
2211f4f39d | ||
|
|
a6b988df3a | ||
|
|
1316d3fb1e | ||
|
|
99fa75a980 | ||
|
|
6fc590d795 | ||
|
|
7afc804586 | ||
|
|
f40692dd3d | ||
|
|
1c91699bf5 | ||
|
|
9f5e1e0853 | ||
|
|
55dfea65b0 |
@@ -13,6 +13,13 @@ jobs:
|
||||
- name: Clone Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY_PATH }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASS }}
|
||||
|
||||
- name: Build docker image
|
||||
run: docker build -t umbrella .
|
||||
|
||||
@@ -28,24 +35,12 @@ jobs:
|
||||
docker tag umbrella ${{ secrets.REGISTRY_PATH }}/umbrella:${{ gitea.ref_name }}
|
||||
docker tag umbrella ${{ secrets.REGISTRY_PATH }}/umbrella:$TAG
|
||||
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY_PATH }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASS }}
|
||||
|
||||
- name: Push to registry
|
||||
run: |
|
||||
TAG=$(cat /tmp/tag)
|
||||
docker push ${{ secrets.REGISTRY_PATH }}/umbrella:${{ gitea.ref_name }}
|
||||
docker push ${{ secrets.REGISTRY_PATH }}/umbrella:$TAG
|
||||
|
||||
- name: Restart umbrella.srsoftware.de
|
||||
if: github.ref == 'refs/heads/dev'
|
||||
run: |
|
||||
curl -X POST -H "Authorization: Bearer ${{ secrets.ELDORADO_MAKE_BEARER }}" -d umbrella_25_start https://make.eldorado.srsoftware.de/launch
|
||||
|
||||
Clean-Registry:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -53,8 +48,10 @@ jobs:
|
||||
run: |
|
||||
TAGS="$(curl -s -u "${{ secrets.REGISTRY_USER }}:${{ secrets.REGISTRY_PASS }}" https://${{ secrets.REGISTRY_PATH }}/v2/umbrella/tags/list | jq -r ".tags[]")"
|
||||
COUNT=$(echo "$TAGS" | wc -l)
|
||||
echo found $COUNT tags: $TAGS
|
||||
if [ $COUNT -gt 10 ]; then
|
||||
REMAIN=$((COUNT - 10))
|
||||
echo $REMAIN tags will be kept!
|
||||
echo "$TAGS" | head -n $REMAIN > /tmp/old_tags
|
||||
else
|
||||
echo less than 10 tags, skipping cleanup
|
||||
|
||||
@@ -63,8 +63,6 @@ public class Application {
|
||||
var port = config.get("umbrella.http.port", 8080);
|
||||
var threads = config.get("umbrella.threads", 16);
|
||||
|
||||
config.get("umbrella.plantuml").map(Object::toString).map(File::new).filter(File::exists).ifPresent(Util::setPlantUmlJar);
|
||||
|
||||
var server = HttpServer.create(new InetSocketAddress(port), 0);
|
||||
try {
|
||||
new Translations(config).bindPath("/api/translations").on(server);
|
||||
@@ -80,7 +78,7 @@ public class Application {
|
||||
new DocumentApi(config).bindPath("/api/document").on(server);
|
||||
new UserLegacy(config).bindPath("/legacy/user").on(server);
|
||||
new NotesLegacy(config).bindPath("/legacy/notes").on(server);
|
||||
new MarkdownApi().bindPath("/api/markdown").on(server);
|
||||
new MarkdownApi(config).bindPath("/api/markdown").on(server);
|
||||
new NoteModule(config).bindPath("/api/notes").on(server);
|
||||
new StockModule(config).bindPath("/api/stock").on(server);
|
||||
new PollModule(config).bindPath("/api/poll").on(server);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core;
|
||||
|
||||
|
||||
import de.srsoftware.umbrella.core.api.*;
|
||||
|
||||
public class ModuleRegistry {
|
||||
|
||||
@@ -7,6 +7,7 @@ import static de.srsoftware.tools.PathHandler.GET;
|
||||
import static de.srsoftware.tools.PathHandler.POST;
|
||||
import static de.srsoftware.tools.Strings.hex;
|
||||
import static de.srsoftware.umbrella.core.Errors.INVALID_URL;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.markdownService;
|
||||
import static de.srsoftware.umbrella.core.constants.Constants.TIME_FORMATTER;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.serverError;
|
||||
@@ -35,14 +36,9 @@ import java.util.regex.Pattern;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Util {
|
||||
public static final System.Logger LOG = System.getLogger("Util");
|
||||
private static final Pattern UML_PATTERN = Pattern.compile("@start(\\w+)(.*?)@end(\\1)",Pattern.DOTALL);
|
||||
private static final Pattern SPREADSHEET_PATTERN = Pattern.compile("@startsheet(.*?)@endsheet",Pattern.DOTALL);
|
||||
private static File plantumlJar = null;
|
||||
private static final JParsedown MARKDOWN = new JParsedown();
|
||||
public static final String SHA1 = "SHA-1";
|
||||
public static final System.Logger LOG = System.getLogger("Util");
|
||||
public static final String SHA1 = "SHA-1";
|
||||
private static final MessageDigest SHA1_DIGEST;
|
||||
private static final Map<Integer,String> umlCache = new HashMap<>();
|
||||
|
||||
private static final String SCRIPT = """
|
||||
<script src="http://127.0.0.1:8080/js/jspreadsheet-ce.js"></script>
|
||||
@@ -111,71 +107,11 @@ jspreadsheet(document.getElementById('spreadsheet'), {
|
||||
public static HashMap<String, Object> mapMarkdown(String source){
|
||||
var map = new HashMap<String,Object>();
|
||||
map.put(SOURCE,source);
|
||||
map.put(RENDERED,markdown(source));
|
||||
map.put(RENDERED,markdownService().markdown(source));
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String markdown(String source){
|
||||
if (source == null) return source;
|
||||
try {
|
||||
var matcher = SPREADSHEET_PATTERN.matcher(source);
|
||||
var count = 0;
|
||||
while (matcher.find()){
|
||||
count++;
|
||||
var sheetData = matcher.group(0).trim();
|
||||
var start = matcher.start(0);
|
||||
var end = matcher.end(0);
|
||||
source = source.substring(0, start)
|
||||
+ "<div class=\"spreadsheet\" id=\"spreadsheet-"+count+"\">"
|
||||
+ sheetData.substring(11,sheetData.length()-10)
|
||||
+ "</div>"
|
||||
+ source.substring(end);
|
||||
matcher = SPREADSHEET_PATTERN.matcher(source);
|
||||
}
|
||||
if (plantumlJar != null && plantumlJar.exists()) {
|
||||
matcher = UML_PATTERN.matcher(source);
|
||||
while (matcher.find()) {
|
||||
var uml = matcher.group(0).trim();
|
||||
var start = matcher.start(0);
|
||||
var end = matcher.end(0);
|
||||
|
||||
var umlHash = uml.hashCode();
|
||||
LOG.log(DEBUG,"Hash of Plantuml code: {0}",umlHash);
|
||||
var svg = umlCache.get(umlHash);
|
||||
if (svg != null){
|
||||
LOG.log(DEBUG,"Serving Plantuml generated SVG from cache…");
|
||||
source = source.substring(0, start) + svg + source.substring(end);
|
||||
matcher = UML_PATTERN.matcher(source);
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG.log(DEBUG,"Cache miss. Generating SVG from plantuml code…");
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", plantumlJar.getAbsolutePath(), "-tsvg", "-pipe");
|
||||
var ignored = processBuilder.redirectErrorStream();
|
||||
var process = processBuilder.start();
|
||||
try (OutputStream os = process.getOutputStream()) {
|
||||
os.write(uml.getBytes(UTF_8));
|
||||
os.flush();
|
||||
}
|
||||
|
||||
try (InputStream is = process.getInputStream()) {
|
||||
byte[] out = is.readAllBytes();
|
||||
LOG.log(DEBUG,"Generated SVG. Pushing to cache…");
|
||||
svg = new String(out, UTF_8);
|
||||
umlCache.put(umlHash,svg);
|
||||
source = source.substring(0, start) + svg + source.substring(end);
|
||||
matcher = UML_PATTERN.matcher(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
return MARKDOWN.text(source);
|
||||
} catch (Throwable e){
|
||||
if (LOG.isLoggable(TRACE)){
|
||||
LOG.log(TRACE,"Failed to render markdown, input was: \n{0}",source,e);
|
||||
} else LOG.log(WARNING,"Failed to render markdown. Enable TRACE log level for details.");
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpURLConnection open(URL url) throws IOException {
|
||||
var conn = (HttpURLConnection) url.openConnection();
|
||||
@@ -249,11 +185,6 @@ jspreadsheet(document.getElementById('spreadsheet'), {
|
||||
return new Hash(hex(bytes),SHA1);
|
||||
}
|
||||
|
||||
public static void setPlantUmlJar(File file){
|
||||
LOG.log(INFO,"Using plantuml @ {0}",file.getAbsolutePath());
|
||||
plantumlJar = file;
|
||||
}
|
||||
|
||||
public static String dateTimeOf(long epochMilis){
|
||||
return LocalDateTime.ofInstant(Instant.ofEpochMilli(epochMilis), ZoneId.systemDefault()).format(TIME_FORMATTER);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
package de.srsoftware.umbrella.core.api;
|
||||
|
||||
public interface MarkdownService {
|
||||
String markdown(String source);
|
||||
}
|
||||
|
||||
@@ -91,10 +91,7 @@ public class Poll implements Mappable {
|
||||
return Map.of(
|
||||
ID,id,
|
||||
NAME,name,
|
||||
DESCRIPTION, Map.of(
|
||||
SOURCE,description,
|
||||
RENDERED,Util.markdown(description)
|
||||
),
|
||||
DESCRIPTION, Util.mapMarkdown(description),
|
||||
STATUS,status
|
||||
);
|
||||
}
|
||||
@@ -292,10 +289,7 @@ public class Poll implements Mappable {
|
||||
ID, id,
|
||||
Field.OWNER, owner.toMap(),
|
||||
NAME,name,
|
||||
Field.DESCRIPTION, Map.of(
|
||||
Field.SOURCE,description,
|
||||
Field.RENDERED,Util.markdown(description)
|
||||
),
|
||||
Field.DESCRIPTION, Util.mapMarkdown(description),
|
||||
Field.OPTIONS, options.stream().collect(Collectors.toMap(Option::id,Option::toMap)),
|
||||
Field.PERMISSION, mapPermissions(),
|
||||
Field.PRIVATE, isPrivate,
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
{#if messages.warning}
|
||||
<span class="warn">{@html messages.warning}</span>
|
||||
{/if}
|
||||
<Route path="/" component={User} />
|
||||
<Route path="/" component={ProjectList} />
|
||||
<Route path="/account/:id" component={Account} />
|
||||
<Route path="/accounting" component={Accounts} />
|
||||
<Route path="/accounting/new" component={NewAccount} />
|
||||
@@ -116,6 +116,7 @@
|
||||
<Route path="/project/:project_id/add_task" component={AddTask} />
|
||||
<Route path="/project/:id/kanban" component={Kanban} />
|
||||
<Route path="/project/:id/view" component={ViewPrj} />
|
||||
<Route path="/project/:id" component={ViewPrj} />
|
||||
<Route path="/search" component={Search} />
|
||||
<Route path="/stock" component={Stock} />
|
||||
<Route path="/stock/location/:location_id" component={Stock} />
|
||||
|
||||
@@ -49,12 +49,16 @@
|
||||
console.warn(`${candidate.display} selected, but onSelect not overridden!`)
|
||||
}
|
||||
|
||||
function disableDropdown(){
|
||||
candidates = [];
|
||||
selected = null;
|
||||
}
|
||||
|
||||
async function ondblclick(evt){
|
||||
const select = evt.target;
|
||||
const idx = select.value;
|
||||
candidate = candidates[idx];
|
||||
candidates = [];
|
||||
selected = null;
|
||||
disableDropdown();
|
||||
onSelect(candidate);
|
||||
}
|
||||
|
||||
@@ -63,6 +67,10 @@
|
||||
selected = null;
|
||||
}
|
||||
|
||||
function onblur(ev){
|
||||
setTimeout(disableDropdown,400);
|
||||
}
|
||||
|
||||
async function onkeyup(ev){
|
||||
if (ignore.includes(ev.key)) return;
|
||||
if (ev.key == 'ArrowDown'){
|
||||
@@ -83,22 +91,19 @@
|
||||
ev.preventDefault();
|
||||
if (selected != null && selected < candidates.length) {
|
||||
candidate = candidates[selected];
|
||||
candidates = [];
|
||||
selected = null;
|
||||
disableDropdown();
|
||||
onSelect(candidate);
|
||||
return false;
|
||||
}
|
||||
if (ev.key == 'Enter') {
|
||||
candidates = [];
|
||||
selected = null;
|
||||
disableDropdown();
|
||||
if (onCommit(candidate)) candidate = { display : '' };
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (ev.key == 'Escape'){
|
||||
ev.preventDefault();
|
||||
candidates = [];
|
||||
selected = null;
|
||||
disableDropdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -110,10 +115,8 @@
|
||||
|
||||
function select(index){
|
||||
candidate = candidates[index];
|
||||
selected = null;
|
||||
candidates = [];
|
||||
disableDropdown();
|
||||
onSelect(candidate);
|
||||
|
||||
}
|
||||
|
||||
function scrollTo(index){
|
||||
@@ -145,11 +148,11 @@
|
||||
</style>
|
||||
|
||||
<span class="autocomplete">
|
||||
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} />
|
||||
<input type="text" bind:value={candidate.display} {onkeyup} autofocus={autofocus} {id} {onblur} />
|
||||
{#if candidates && candidates.length > 0}
|
||||
<ul bind:this={list_elem} class="suggestions">
|
||||
<ul bind:this={list_elem} class="suggestions" tabindex="-1">
|
||||
{#each candidates as candidate,i}
|
||||
<li class="option {selected==i?'highlight':''}" onclick={e => select(i)} ondblclick={e => select(i)}>{candidate.display}</li>
|
||||
<li class="option {selected==i?'highlight':''}" tabindex="-1" onclick={e => select(i)} ondblclick={e => select(i)}>{candidate.display}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
@@ -18,15 +18,16 @@
|
||||
|
||||
function calcSums(){
|
||||
let sums = {};
|
||||
sums[0] = 0;
|
||||
sums[ 0] = 0;
|
||||
sums[-1] = 0;
|
||||
for (let user of Object.values(users)) sums[user.id] = 0;
|
||||
for (let transaction of filtered) {
|
||||
for (let user of Object.values(users)){
|
||||
if (user.id == transaction.destination.id) sums[user.id] += transaction.amount;
|
||||
if (user.id == transaction.source.id) sums[user.id] -= transaction.amount;
|
||||
}
|
||||
if (!transaction.destination.id) sums[0] += transaction.amount;
|
||||
if (!transaction.source.id) sums[0] -= transaction.amount;
|
||||
if (!transaction.destination.id) sums[ 0] += transaction.amount;
|
||||
if (!transaction.source.id) sums[-1] += transaction.amount;
|
||||
}
|
||||
return sums;
|
||||
}
|
||||
@@ -102,7 +103,10 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.amount{ text-align: right }
|
||||
:global {
|
||||
.amount{ text-align: right }
|
||||
.nowrap{ whitespace: nowrap }
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
@@ -154,10 +158,16 @@
|
||||
</th>
|
||||
{/each}
|
||||
<td class="amount">
|
||||
<br/>
|
||||
{sums[0].toFixed(2)} {account.currency}
|
||||
{sums[-1].toFixed(2)} {account.currency} <br/>
|
||||
-{sums[0].toFixed(2)} {account.currency}<br/>
|
||||
{(sums[-1]-sums[0]).toFixed(2)} {account.currency}
|
||||
</td>
|
||||
<td colspan="3"></td>
|
||||
<td class="nowrap">
|
||||
{t('external gains')}<br/>
|
||||
{t('external expenses')}<br/>
|
||||
{t('sum external')}
|
||||
</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -44,9 +44,9 @@
|
||||
</span>
|
||||
|
||||
<ul>
|
||||
{#each accounts as account (account.id)}
|
||||
{#each accounts.toSorted((a,b) => a.name.localeCompare(b.name)) as account (account.id)}
|
||||
<li>
|
||||
<a {onclick} href="/account/{account.id}">{account.name} ({account.id})</a>
|
||||
<a {onclick} href="/account/{account.id}">{account.name}</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { api, post } from '../../urls.svelte.js';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
@@ -21,13 +21,9 @@
|
||||
});
|
||||
|
||||
async function onsubmit(ev){
|
||||
ev.preventDefault();
|
||||
if (ev) ev.preventDefault();
|
||||
const url = api('project');
|
||||
var resp = await fetch(url,{
|
||||
credentials : 'include',
|
||||
method : 'POST',
|
||||
body : JSON.stringify(project)
|
||||
});
|
||||
var resp = await post(url,project);
|
||||
if (resp.ok){
|
||||
var newProject = await resp.json();
|
||||
router.navigate(`/project/${newProject.id}/view`);
|
||||
@@ -50,72 +46,70 @@
|
||||
label{ display: block }
|
||||
</style>
|
||||
|
||||
<form {onsubmit}>
|
||||
<fieldset>
|
||||
<legend>
|
||||
{t('create_new_project')}
|
||||
</legend>
|
||||
<fieldset>
|
||||
<legend>
|
||||
{t('create_new_project')}
|
||||
</legend>
|
||||
<fieldset>
|
||||
<legend>{t('basic_data')}</legend>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
{t('company_optional')}
|
||||
</th>
|
||||
<td>
|
||||
<CompanySelector caption={t('no_company')} {onselect} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('Name')}
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" bind:value={project.name}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('description')}
|
||||
</th>
|
||||
<td>
|
||||
<MarkdownEditor bind:value={project.description} simple={true} />
|
||||
</td>
|
||||
</tr>
|
||||
{#if showSettings}
|
||||
<tr>
|
||||
<th>
|
||||
{t('settings')}
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" bind:checked={project.settings.show_closed} />
|
||||
{t('display_closed_tasks')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{:else}
|
||||
<tr>
|
||||
<th>
|
||||
{t('settings')}
|
||||
</th>
|
||||
<td>
|
||||
<button onclick={toggleSettings} >{t('extended_settings')}</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<th>
|
||||
{t('tags')}
|
||||
</th>
|
||||
<td>
|
||||
<Tags module="project" bind:tags={project.tags} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
<button type="submit" disabled={!ready}>{t('create')}</button>
|
||||
<legend>{t('basic_data')}</legend>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
{t('company_optional')}
|
||||
</th>
|
||||
<td>
|
||||
<CompanySelector caption={t('no_company')} {onselect} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('Name')}
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" bind:value={project.name}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('description')}
|
||||
</th>
|
||||
<td>
|
||||
<MarkdownEditor bind:value={project.description} simple={true} />
|
||||
</td>
|
||||
</tr>
|
||||
{#if showSettings}
|
||||
<tr>
|
||||
<th>
|
||||
{t('settings')}
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" bind:checked={project.settings.show_closed} />
|
||||
{t('display_closed_tasks')}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{:else}
|
||||
<tr>
|
||||
<th>
|
||||
{t('settings')}
|
||||
</th>
|
||||
<td>
|
||||
<button onclick={toggleSettings} >{t('extended_settings')}</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<th>
|
||||
{t('tags')}
|
||||
</th>
|
||||
<td>
|
||||
<Tags module={null} bind:tags={project.tags} onEmptyCommit={onsubmit} />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
</form>
|
||||
<button onclick={onsubmit} disabled={!ready}>{t('create')}</button>
|
||||
</fieldset>
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
task.members[assignee] = project.members[assignee];
|
||||
task.members[assignee].permission = { name : "ASSIGNEE", code : 3 }
|
||||
}
|
||||
if (task.taks.length < 1) task.tags = project.tags;
|
||||
yikes();
|
||||
} else {
|
||||
error(resp);
|
||||
@@ -154,7 +155,7 @@
|
||||
</div>
|
||||
<div>{t('tags')}</div>
|
||||
<div>
|
||||
<Tags module="task" bind:tags={task.tags} />
|
||||
<Tags module={null} bind:tags={task.tags} onEmptyCommit={saveTask} />
|
||||
</div>
|
||||
|
||||
{#if extendedSettings}
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
<legend>{t('state_open')}</legend>
|
||||
{#if sorted}
|
||||
{#each sorted as task}
|
||||
{#if task.status == 20 && match(task)}
|
||||
{#if task.status < 60 && task.status >= 20 && match(task)}
|
||||
<div href={`/task/${task.id}/view`} title={task.description.source} task_id={task.id} {onclick} {oncontextmenu} {ontouchstart} {ontouchend} onmousedown={ontouchstart} onmouseup={ontouchend} >
|
||||
{task.name}
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { api, drop, patch, post } from '../../urls.svelte.js';
|
||||
import { api, drop, get, patch, post } from '../../urls.svelte.js';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { timetrack } from '../../user.svelte.js';
|
||||
@@ -41,10 +41,18 @@
|
||||
});
|
||||
|
||||
async function addTime(task_id){
|
||||
const url = api(`time/track_task/${task_id}`);
|
||||
const resp = await post(url,now()); // create new time or return time with assigned tasks
|
||||
let url = api(`time/track_task/${task_id}`);
|
||||
let resp = await post(url,now()); // create new time or return time with assigned tasks
|
||||
if (resp.ok) {
|
||||
const track = await resp.json();
|
||||
if (timetrack.running){
|
||||
url = api(`time/${timetrack.running.id}`);
|
||||
resp = await get(url);
|
||||
if (resp.ok){
|
||||
let previous = await resp.json();
|
||||
times[previous.id] = previous;
|
||||
}
|
||||
}
|
||||
timetrack.running = track;
|
||||
} else {
|
||||
error(resp);
|
||||
|
||||
@@ -3,9 +3,7 @@ package de.srsoftware.umbrella.legacy;
|
||||
|
||||
|
||||
import static de.srsoftware.tools.Optionals.nullable;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.noteService;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
|
||||
import static de.srsoftware.umbrella.core.Util.markdown;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.TOKEN;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.URI;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidField;
|
||||
@@ -72,7 +70,7 @@ public class NotesLegacy extends BaseHandler {
|
||||
new Tag("fieldset")
|
||||
.add(new Tag("legend").content(authorName))
|
||||
.add(new Tag("legend").content(note.timestamp().format(DateTimeFormatter.ISO_DATE_TIME)))
|
||||
.add(new Tag("div").content(markdown(note.text())))
|
||||
.add(new Tag("div").content(markdownService().markdown(note.text())))
|
||||
.addTo(html);
|
||||
}
|
||||
return sendContent(ex,html.toString(2));
|
||||
|
||||
@@ -3,21 +3,53 @@ package de.srsoftware.umbrella.markdown;
|
||||
|
||||
import static de.srsoftware.tools.MimeType.MIME_HTML;
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.BASE_URL;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingField;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.xrbpowered.jparsedown.JParsedown;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.tools.Path;
|
||||
import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.Util;
|
||||
import de.srsoftware.umbrella.core.api.MarkdownService;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MarkdownApi extends BaseHandler implements MarkdownService {
|
||||
|
||||
private static final System.Logger LOG = System.getLogger(MarkdownApi.class.getSimpleName());
|
||||
private static final Pattern PATTERN_ANCHOR = Pattern.compile("(?is)<a\\b[^>]*>.*?</a>");
|
||||
private static final Pattern PATTERN_HREF = Pattern.compile("(?i)\\bhref\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))");
|
||||
private static final Pattern PATTERN_SPREADSHEET = Pattern.compile("@startsheet(.*?)@endsheet",Pattern.DOTALL);
|
||||
private static final Pattern PATTERN_TARGET = Pattern.compile("(?i)\\btarget\\s*=");
|
||||
private static final Pattern PATTERN_URL = Pattern.compile("@start(\\w+)(.*?)@end(\\1)",Pattern.DOTALL);
|
||||
private static final Map<Integer,String> umlCache = new HashMap<>();
|
||||
private static final JParsedown MARKDOWN = new JParsedown();
|
||||
|
||||
public MarkdownApi() {
|
||||
|
||||
private final String baseUrl;
|
||||
private final File plantumlJar;
|
||||
|
||||
public MarkdownApi(Configuration config) {
|
||||
super();
|
||||
Optional<String> baseUrl = config.get(BASE_URL);
|
||||
if (baseUrl.isEmpty()) throw missingField(BASE_URL);
|
||||
this.baseUrl = baseUrl.get();
|
||||
plantumlJar = config.get("umbrella.plantuml").map(Object::toString).map(File::new).filter(File::exists).orElse(null);
|
||||
if (plantumlJar != null) LOG.log(INFO,"Using plant uml @ {}",plantumlJar);
|
||||
ModuleRegistry.add(this);
|
||||
}
|
||||
|
||||
@@ -28,11 +60,98 @@ public class MarkdownApi extends BaseHandler implements MarkdownService {
|
||||
var user = userService().refreshSession(ex);
|
||||
|
||||
if (user.isEmpty()) throw UmbrellaException.forbidden("You must be logged in to use the markdown renderer!");
|
||||
var rendered = Util.markdown(body(ex));
|
||||
var rendered = markdown(body(ex));
|
||||
|
||||
ex.getResponseHeaders().add(CONTENT_TYPE,MIME_HTML);
|
||||
return sendContent(ex,rendered);
|
||||
} catch (UmbrellaException e){
|
||||
return send(ex,e);
|
||||
}
|
||||
}
|
||||
|
||||
public String markdown(String source){
|
||||
if (source == null || source.isBlank()) return source;
|
||||
try {
|
||||
var matcher = PATTERN_SPREADSHEET.matcher(source);
|
||||
var count = 0;
|
||||
while (matcher.find()){
|
||||
LOG.log(DEBUG,"Processing spreadsheet code…");
|
||||
count++;
|
||||
var sheetData = matcher.group(0).trim();
|
||||
var start = matcher.start(0);
|
||||
var end = matcher.end(0);
|
||||
source = source.substring(0, start)
|
||||
+ "<div class=\"spreadsheet\" id=\"spreadsheet-"+count+"\">"
|
||||
+ sheetData.substring(11,sheetData.length()-10)
|
||||
+ "</div>"
|
||||
+ source.substring(end);
|
||||
LOG.log(DEBUG,"Updated markdown with spreadsheet div.");
|
||||
matcher.reset(source);
|
||||
}
|
||||
if (plantumlJar != null && plantumlJar.exists()) {
|
||||
matcher = PATTERN_URL.matcher(source);
|
||||
while (matcher.find()) {
|
||||
var uml = matcher.group(0).trim();
|
||||
var start = matcher.start(0);
|
||||
var end = matcher.end(0);
|
||||
|
||||
var umlHash = uml.hashCode();
|
||||
LOG.log(DEBUG,"Hash of Plantuml code: {0}",umlHash);
|
||||
var svg = umlCache.get(umlHash);
|
||||
if (svg != null){
|
||||
LOG.log(DEBUG,"Serving Plantuml generated SVG from cache…");
|
||||
source = source.substring(0, start) + svg + source.substring(end);
|
||||
matcher.reset(source);
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG.log(DEBUG,"Cache miss. Generating SVG from plantuml code…");
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", plantumlJar.getAbsolutePath(), "-tsvg", "-pipe");
|
||||
var ignored = processBuilder.redirectErrorStream();
|
||||
var process = processBuilder.start();
|
||||
try (OutputStream os = process.getOutputStream()) {
|
||||
os.write(uml.getBytes(UTF_8));
|
||||
os.flush();
|
||||
}
|
||||
|
||||
try (InputStream is = process.getInputStream()) {
|
||||
byte[] out = is.readAllBytes();
|
||||
LOG.log(DEBUG,"Generated SVG. Pushing to cache…");
|
||||
svg = new String(out, UTF_8);
|
||||
umlCache.put(umlHash,svg);
|
||||
source = source.substring(0, start) + svg + source.substring(end);
|
||||
matcher.reset(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
var rendered = MARKDOWN.text(source);
|
||||
if (baseUrl == null) return rendered;
|
||||
var anchors = PATTERN_ANCHOR.matcher(rendered);
|
||||
while (anchors.find()){
|
||||
String anchor = anchors.group();
|
||||
LOG.log(TRACE,"Processing anchor: {}",anchor);
|
||||
var urls = PATTERN_HREF.matcher(anchor);
|
||||
if (!urls.find()) continue; // no url → nothing to do
|
||||
|
||||
var href = urls.group(1) != null ? urls.group(1) : (urls.group(2) != null ? urls.group(2) : urls.group(3));
|
||||
LOG.log(TRACE," encountered href = {}",href);
|
||||
if (!href.startsWith("http")) continue; // relative url? good!
|
||||
LOG.log(TRACE," {} is not a relative url!",href);
|
||||
var target = PATTERN_TARGET.matcher(anchor);
|
||||
if (target.find()) continue; // target already set → leave untouched
|
||||
LOG.log(TRACE," anchor has no target!");
|
||||
if (href.startsWith(baseUrl)) continue; // local url → don`t touch
|
||||
LOG.log(TRACE," {} is not an internal url, adding anchor…",href);
|
||||
var replacement = "<a target=\"_blank\""+anchor.substring(2);
|
||||
rendered = rendered.replace(anchor, replacement);
|
||||
anchors.reset(rendered);
|
||||
}
|
||||
return rendered;
|
||||
} catch (Throwable e){
|
||||
if (LOG.isLoggable(TRACE)){
|
||||
LOG.log(TRACE,"Failed to render markdown, input was: \n{0}",source,e);
|
||||
} else LOG.log(WARNING,"Failed to render markdown. Enable TRACE log level for details.");
|
||||
return source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static de.srsoftware.umbrella.messagebus.MessageBus.messageBus;
|
||||
import static de.srsoftware.umbrella.messagebus.events.Event.EventType.CREATE;
|
||||
import static de.srsoftware.umbrella.project.Constants.PERMISSIONS;
|
||||
import static de.srsoftware.umbrella.task.Constants.*;
|
||||
import static java.lang.System.Logger.Level.ERROR;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
import static java.net.URLDecoder.decode;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -198,6 +199,7 @@ public class TaskModule extends BaseHandler implements TaskService {
|
||||
var projectTasks = taskDb.listProjectTasks(project.id(),null, false);
|
||||
var mapped = projectTasks.values().stream().collect(Collectors.toMap(Task::id,Task::toMap));
|
||||
var roots = new HashMap<Long,Map<String,Object>>();
|
||||
LOG.log(ERROR,"getParentCandidates not fully functional");
|
||||
for (var map : mapped.values()){
|
||||
if (!(map.get(ID) instanceof Long id)) continue;
|
||||
if (id == taskId) continue;
|
||||
|
||||
@@ -79,8 +79,15 @@ public class TimeModule extends BaseHandler implements TimeService {
|
||||
if (user.isEmpty()) return unauthorized(ex);
|
||||
var head = path.pop();
|
||||
return switch (head) {
|
||||
case STARTED -> getStartedTime(user.get(),ex);
|
||||
case null, default -> super.doGet(path,ex);
|
||||
case STARTED -> getStartedTime(user.get(),ex);
|
||||
case null -> super.doGet(path,ex);
|
||||
default -> {
|
||||
try {
|
||||
yield sendContent(ex,timeDb.load(Long.parseLong(head)));
|
||||
} catch (NumberFormatException ignored) {
|
||||
yield super.doGet(path,ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (UmbrellaException e){
|
||||
return send(ex,e);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"abort": "abbrechen",
|
||||
"account": "Konto",
|
||||
"accounting": "Konten",
|
||||
"account name": "Konto-Name",
|
||||
"accounts": "Konten",
|
||||
"actions": "Aktionen",
|
||||
"add_login_service": "Login-Service anlegen",
|
||||
@@ -75,6 +76,7 @@
|
||||
"CREATE_USERS": "Nutzer anlegen",
|
||||
"create_pdf": "PDF erzeugen",
|
||||
"created_with": "erzeugt mit {tool} von {producer}",
|
||||
"currency": "Währung",
|
||||
"customer": "Kunde",
|
||||
"customer_address": "Adresse",
|
||||
"customer_email": "Emailadresse des Kunden",
|
||||
@@ -124,6 +126,8 @@
|
||||
"evaluate": "auswerten",
|
||||
"expand_on_click": "Anklicken zum Anzeigen",
|
||||
"extended_settings": "erweiterte Einstellungen",
|
||||
"external expenses": "externe Ausgaben",
|
||||
"external gains": "externe Einnahmen",
|
||||
|
||||
"failed": "fehlgeschlagen",
|
||||
"failed_login_attempts" : "Account nach {attempts} fehlgeschlagenen Logins gesperrt bis {release_time}",
|
||||
@@ -162,6 +166,7 @@
|
||||
"files": "Dateien",
|
||||
"filter": "Filter",
|
||||
"filter by tags": "Nach Tags filtern",
|
||||
"first_transaction": "erste Transaktion",
|
||||
"footer": "Fuß-Text",
|
||||
"foreign_id": "externe Kennung",
|
||||
"forgot_pass" : "Password vergessen?",
|
||||
@@ -374,6 +379,7 @@
|
||||
"subtask": "Unteraufgabe",
|
||||
"subtasks": "Unteraufgaben",
|
||||
"succeeding_document": "Nachfolge-Dokument",
|
||||
"sum external": "Summe externe Umsätze",
|
||||
"sum_of_records": "Summe der ausgewählten Einträge",
|
||||
"sums": "Summen",
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"abort": "abort",
|
||||
"account": "account",
|
||||
"accounting": "accounting",
|
||||
"account name": "Account name",
|
||||
"accounts": "accounts",
|
||||
"actions": "actions",
|
||||
"add_login_service": "add login service",
|
||||
@@ -75,6 +76,7 @@
|
||||
"CREATE_USERS": "create users",
|
||||
"create_pdf": "create PDF",
|
||||
"created_with": "created with {tool} by {producer}",
|
||||
"currency": "Currency",
|
||||
"customer": "customer",
|
||||
"customer_address": "address",
|
||||
"customer_email": "customer email address",
|
||||
@@ -124,6 +126,8 @@
|
||||
"evaluate": "evaluate",
|
||||
"expand_on_click": "click to expand",
|
||||
"extended_settings": "extended settings",
|
||||
"external expenses": "external expenses",
|
||||
"external gains": "external gains",
|
||||
|
||||
"failed": "failed",
|
||||
"failed_login_attempts" : "account locked until {release_time} after {attempts} failed login attempts",
|
||||
@@ -162,6 +166,7 @@
|
||||
"files": "files",
|
||||
"filter": "filter",
|
||||
"filter by tags": "filter by tags",
|
||||
"first_transaction": "first transaction",
|
||||
"footer": "footer",
|
||||
"foreign_id": "external ID",
|
||||
"forgot_pass" : "forgot password?",
|
||||
@@ -374,6 +379,7 @@
|
||||
"subtask": "subtask",
|
||||
"subtasks": "subtasks",
|
||||
"succeeding_document": "succeeding document",
|
||||
"sum external";"sum of external positions",
|
||||
"sum_of_records": "sum of records",
|
||||
"sums": "sums",
|
||||
|
||||
@@ -459,11 +465,11 @@
|
||||
"wiki_pages": "wiki pages",
|
||||
|
||||
"year": "year",
|
||||
"You have been added to the new project '{project}', created by {user}:\n\n{body}": "You have been added to the new project '{project}', created by {user}:\n\n{body}",
|
||||
"You can view/edit this transaction at {base_url}/account/{id}": "Du kannst diese transaktion unter {base_url}/account/{id} ansehen",
|
||||
"You can view/edit this transaction at {base_url}/account/{id}": "You can view/edit this transaction at {base_url}/account/{id}",
|
||||
"You can view/edit this project at {base_url}/project/{id}/view": "You can view/edit this project at {base_url}/project/{id}/view",
|
||||
"You can view/edit this task at {base_url}/task/{id}/view": "You can view/edit this task at {base_url}/task/{id}/view",
|
||||
"You can view/edit this wiki page at {base_url}/wiki/{id}/view": "You can view/edit this wiki page at {base_url}/wiki/{id}/view",
|
||||
"You have been added to the new project '{project}', created by {user}:\n\n{body}": "You have been added to the new project '{project}', created by {user}:\n\n{body}",
|
||||
"You may change your notification settings at {base_url}/message/settings": "You may change your notification settings at {base_url}/message/settings .",
|
||||
"Your token to create a new password" : "Your token to create a new password",
|
||||
"your_profile": "your profile"
|
||||
|
||||
@@ -74,6 +74,7 @@ tr:hover .taglist .tag button {
|
||||
color: black;
|
||||
}
|
||||
|
||||
code,
|
||||
.code{
|
||||
color: chocolate;
|
||||
}
|
||||
@@ -336,4 +337,4 @@ tr:hover .taglist .tag button {
|
||||
background: black;
|
||||
color: orange;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@ body {
|
||||
background-position: 98% 70px;
|
||||
background-attachment: fixed;
|
||||
}
|
||||
|
||||
.code,
|
||||
code {
|
||||
font-size: 16px;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
@@ -769,4 +770,4 @@ fieldset.vcard{
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user