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
|
@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));
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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');
|
||||||
|
|||||||
Reference in New Issue
Block a user