Browse Source

inverted appointment order, implemented loading by date range

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
main
Stephan Richter 4 months ago
parent
commit
71618cc09d
  1. 8
      de.srsoftware.cal.db/src/main/java/de/srsoftware/cal/db/MariaDB.java
  2. 5
      de.srsoftware.cal.web/src/main/java/de/srsoftware/cal/ApiEndpoint.java
  3. 1
      de.srsoftware.cal.web/src/main/resources/script/index.js

8
de.srsoftware.cal.db/src/main/java/de/srsoftware/cal/db/MariaDB.java

@ -203,13 +203,13 @@ public class MariaDB implements Database {
try { try {
var url = URI.create(uri).toURL(); var url = URI.create(uri).toURL();
app.add(new Attachment(url,mime)); app.add(new Attachment(url,mime));
} catch (MalformedURLException e) { } catch (Exception e) {
LOG.log(WARNING,"Faild to create URL object from %s",uri); LOG.log(WARNING,"Failed to create URL object from %s",uri);
} }
} }
rs.close(); rs.close();
} catch (SQLException e) { } catch (Exception e) {
throw new RuntimeException(e); LOG.log(WARNING,"Failed to load attachments.",e);
} }
} }

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

@ -147,7 +147,10 @@ public class ApiEndpoint extends PathHandler {
return HttpError.of(400,"Count (count=%s) is not a number!", o); return HttpError.of(400,"Count (count=%s) is not a number!", o);
} }
return db.list(startDate, null, count, offset).map(res -> filterByTags(res, tags)); Result<LocalDateTime> end = parseDate(param.get(END));
var endDate = (end == null) ? null: end.optional().orElse(null);
return db.list(startDate, endDate, count, offset).map(res -> filterByTags(res, tags));
} }
private Result<List<Appointment>> filterByTags(Result<List<Appointment>> res, List<String> tags) { private Result<List<Appointment>> filterByTags(Result<List<Appointment>> res, List<String> tags) {

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

@ -93,6 +93,7 @@ function fetchLastYear(){
async function handleEvents(response){ async function handleEvents(response){
if (response.ok){ if (response.ok){
var json = await response.json(); var json = await response.json();
json.reverse();
json.forEach(addRow); json.forEach(addRow);
updateTagVisibility(); updateTagVisibility();
if (highlight){ if (highlight){

Loading…
Cancel
Save