gui improvements
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -91,8 +91,8 @@ public class ApiEndpoint extends PathHandler {
|
||||
|
||||
@Override
|
||||
public boolean doGet(String path, HttpExchange ex) throws IOException {
|
||||
String hostname = "TODO"; // TODO
|
||||
String prodId = "TODO";
|
||||
String hostname = hostname(ex).split("://",2)[1];
|
||||
String prodId = "OpenCloudCal@"+hostname;
|
||||
return switch (path) {
|
||||
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));
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<button onclick="fetchLastYear()">Load previous year</button>
|
||||
</span>
|
||||
<span id="new_event">
|
||||
<button onclick="window.location = '/static/edit'">Create new event</button>
|
||||
<button onclick="openIcal()">ical</button>
|
||||
<button onclick="createNewEvent();">Create new event</button>
|
||||
<button onclick="openIcal();">ical</button>
|
||||
</span>
|
||||
<table id="eventlist">
|
||||
<tr class="head">
|
||||
|
||||
@@ -239,5 +239,13 @@ function loadEvent(){
|
||||
if (aid){
|
||||
element('aid').value = aid;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,19 @@ function addRow(json){
|
||||
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){
|
||||
var td = document.createElement('td');
|
||||
|
||||
Reference in New Issue
Block a user