Browse Source

gui improvements

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
main
Stephan Richter 4 months ago
parent
commit
50e7f2e71d
  1. 4
      de.srsoftware.cal.web/src/main/java/de/srsoftware/cal/ApiEndpoint.java
  2. 4
      de.srsoftware.cal.web/src/main/resources/index.html
  3. 12
      de.srsoftware.cal.web/src/main/resources/script/edit.js
  4. 13
      de.srsoftware.cal.web/src/main/resources/script/index.js

4
de.srsoftware.cal.web/src/main/java/de/srsoftware/cal/ApiEndpoint.java

@ -91,8 +91,8 @@ public class ApiEndpoint extends PathHandler { @@ -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));

4
de.srsoftware.cal.web/src/main/resources/index.html

@ -15,8 +15,8 @@ @@ -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">

12
de.srsoftware.cal.web/src/main/resources/script/edit.js

@ -239,5 +239,13 @@ function loadEvent(){ @@ -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);
}
}

13
de.srsoftware.cal.web/src/main/resources/script/index.js

@ -30,6 +30,19 @@ function addRow(json){ @@ -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');

Loading…
Cancel
Save