gui improvements

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-12-31 16:10:17 +01:00
parent 990cdbaba6
commit 50e7f2e71d
4 changed files with 27 additions and 6 deletions

View File

@@ -91,8 +91,8 @@ public class ApiEndpoint extends PathHandler {
@Override @Override
public boolean doGet(String path, HttpExchange ex) throws IOException { public boolean doGet(String path, HttpExchange ex) throws IOException {
String hostname = "TODO"; // TODO String hostname = hostname(ex).split("://",2)[1];
String prodId = "TODO"; String prodId = "OpenCloudCal@"+hostname;
return switch (path) { return switch (path) {
case "/event" -> sendContent(ex,getEvent(ex).map(ApiEndpoint::toJson).map(ApiEndpoint::httpError)); case "/event" -> sendContent(ex,getEvent(ex).map(ApiEndpoint::toJson).map(ApiEndpoint::httpError));
case "/event/ical"-> sendContent(ex,getEvent(ex).map(event -> toIcal(event,hostname)).map(ical -> Util.wrapIcal(ical,prodId)).map(ApiEndpoint::httpError)); case "/event/ical"-> sendContent(ex,getEvent(ex).map(event -> toIcal(event,hostname)).map(ical -> Util.wrapIcal(ical,prodId)).map(ApiEndpoint::httpError));

View File

@@ -15,8 +15,8 @@
<button onclick="fetchLastYear()">Load previous year</button> <button onclick="fetchLastYear()">Load previous year</button>
</span> </span>
<span id="new_event"> <span id="new_event">
<button onclick="window.location = '/static/edit'">Create new event</button> <button onclick="createNewEvent();">Create new event</button>
<button onclick="openIcal()">ical</button> <button onclick="openIcal();">ical</button>
</span> </span>
<table id="eventlist"> <table id="eventlist">
<tr class="head"> <tr class="head">

View File

@@ -239,5 +239,13 @@ function loadEvent(){
if (aid){ if (aid){
element('aid').value = aid; element('aid').value = aid;
} else aid = params.get('copy'); } else aid = params.get('copy');
if (aid) fetch('/api/event?id='+aid).then(distributeEventData); if (aid) {
} fetch('/api/event?id='+aid).then(distributeEventData);
} else {
const urlParams = new URLSearchParams(window.location.search);
var tags = urlParams.get('tags');}
if (tags){
tags = tags.split(',');
for (var tag of tags) addTag(tag);
}
}

View File

@@ -30,6 +30,19 @@ function addRow(json){
row.appendChild(createTags(json.tags)); row.appendChild(createTags(json.tags));
} }
function createNewEvent(){
var s = '';
var url = location.href;
console.log(url);
var pos = url.indexOf("?");
if (pos>0) {
s = url.substring(pos);
url = url.substring(0,pos);
console.log({url:url,search:s});
}
location.href = url+'static/edit'+s;
}
function createTags(tagList){ function createTags(tagList){
var td = document.createElement('td'); var td = document.createElement('td');