diff --git a/src/main/java/com/release11/klaus/controller/EventController.java b/src/main/java/com/release11/klaus/controller/EventController.java index 4a4e03f..a6faa77 100644 --- a/src/main/java/com/release11/klaus/controller/EventController.java +++ b/src/main/java/com/release11/klaus/controller/EventController.java @@ -8,6 +8,9 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.time.LocalDateTime; +import java.util.UUID; + /** * It's the REST api for {@link com.release11.klaus.model.Event} * @author Gabriel Modzelewski @@ -27,8 +30,24 @@ public class EventController { * @return list of Event's */ @PostMapping - public ResponseEntity getHistory(@RequestBody EventRequestDto event){ + public ResponseEntity filterHistory(@RequestBody EventRequestDto event){ return new ResponseEntity(service.getEventsByDateTimeAndBusinessKeys(event), HttpStatus.OK); } + + @GetMapping(path = "/{uuid}/{messageId}") + public ResponseEntity getLastDay(@PathVariable UUID uuid, + @PathVariable Integer messageId){ + LocalDateTime requestTime = LocalDateTime.now(); + LocalDateTime dayBeforeRequest = requestTime.minusDays(1L); + EventRequestDto eventRequestDto = EventRequestDto.builder() + .clientUUID(uuid) + .mockedResponseId(messageId) + .localDateTimeFrom(dayBeforeRequest) + .localDateTimeTo(requestTime) + .build(); + return new ResponseEntity(service.getEventsByDateTimeAndBusinessKeys(eventRequestDto), HttpStatus.OK); + } + + } diff --git a/src/main/java/com/release11/klaus/model/Event.java b/src/main/java/com/release11/klaus/model/Event.java index b4092d9..2798ae8 100644 --- a/src/main/java/com/release11/klaus/model/Event.java +++ b/src/main/java/com/release11/klaus/model/Event.java @@ -15,7 +15,7 @@ import java.time.LocalDateTime; @ToString @NoArgsConstructor @AllArgsConstructor -public class Event { +public class Event implements Comparable{ @DateTimeFormat(pattern = "yyyy-MM-ddTHH:mm:ss") private LocalDateTime dateTimeStamp; @@ -29,4 +29,9 @@ public class Event { private String level; @Nullable private String message; + + @Override + public int compareTo(Event o) { + return this.getDateTimeStamp().compareTo(o.getDateTimeStamp()) * -1; + } } diff --git a/src/main/java/com/release11/klaus/service/EtrackServiceImpl.java b/src/main/java/com/release11/klaus/service/EtrackServiceImpl.java index 35d052f..44ee5d3 100644 --- a/src/main/java/com/release11/klaus/service/EtrackServiceImpl.java +++ b/src/main/java/com/release11/klaus/service/EtrackServiceImpl.java @@ -8,6 +8,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,7 +38,9 @@ public class EtrackServiceImpl implements EtrackService { if (eventsDto.getMockedResponseId() != null){ businessKeys.put(BusinessKey.MESSAGE_ID, String.valueOf(eventsDto.getMockedResponseId())); } - return eventRepository.findEvents(eventsDto.getLocalDateTimeFrom(), eventsDto.getLocalDateTimeTo(), + List events = eventRepository.findEvents(eventsDto.getLocalDateTimeFrom(), eventsDto.getLocalDateTimeTo(), businessKeys); + Collections.sort(events); + return events; } } diff --git a/src/main/resources/static/css/main.css b/src/main/resources/static/css/main.css new file mode 100644 index 0000000..2f8c9ff --- /dev/null +++ b/src/main/resources/static/css/main.css @@ -0,0 +1,4 @@ +.overflowedTableContent { + max-height: 750px; + overflow: scroll; +} \ No newline at end of file diff --git a/src/main/resources/static/html/mock.html b/src/main/resources/static/html/mock.html index 6c854ac..760397e 100644 --- a/src/main/resources/static/html/mock.html +++ b/src/main/resources/static/html/mock.html @@ -4,6 +4,7 @@ R11 MockedServices + @@ -63,9 +64,7 @@ -
-

> show/hide advanced settings

-
+
@@ -102,7 +101,8 @@
-
+ +
@@ -118,7 +118,7 @@
-
+
diff --git a/src/main/resources/static/js/datatransfer.js b/src/main/resources/static/js/datatransfer.js index 9fa3c6e..ce82f5d 100644 --- a/src/main/resources/static/js/datatransfer.js +++ b/src/main/resources/static/js/datatransfer.js @@ -40,6 +40,8 @@ function getData(){ }); } + + function checkUuid(){ if(clientUUID == null || clientUUID == undefined || clientUUID == ''){ clientUUID = json[0].clientUUID; diff --git a/src/main/resources/static/js/historyloader.js b/src/main/resources/static/js/historyloader.js index f5437e5..f283b76 100644 --- a/src/main/resources/static/js/historyloader.js +++ b/src/main/resources/static/js/historyloader.js @@ -1,5 +1,5 @@ var historyJson = {}; -const maxIterations = 30; +const maxIterations = 200; function filterHistory(){ var dateFrom = new Date($('#historyFrom').val() + 'T' + $('#historyTimeFrom').val()); @@ -52,6 +52,13 @@ function loadHistory(dateFrom, dateTo){ }); } +function getLast24hHistoryData(){ + $.getJSON(host + '/api/event/' + clientUUID + '/' + lastId, function(data){ + historyJson = data; + displayHistory(); + }); +} + function historyToHtml(){ var innerHTML = ''; var iterations = historyJson.length <= maxIterations ? historyJson.length : maxIterations; diff --git a/src/main/resources/static/js/uianimation.js b/src/main/resources/static/js/uianimation.js index 0c7fd25..2d7add0 100644 --- a/src/main/resources/static/js/uianimation.js +++ b/src/main/resources/static/js/uianimation.js @@ -22,8 +22,16 @@ function changeAdvancedVisibility(){ setCookie(); } +const historyFilter = $('#history-filter'); +const historyFilterSwitch = function(){ + historyFilter.toggleClass('active'); +} + $("#optional").click(changeAdvancedVisibility); $('#historyTab').click(showHistory); +$('#btn-history-filter').click(historyFilterSwitch); + + const tabitem = $('.tabitem'); function showHistory(){ @@ -33,8 +41,16 @@ function showHistory(){ $('#history').addClass('active'); $('#historyTab').addClass('active'); $('#historyTab').off('click'); + initializeHistory(); } +function initializeHistory(){ + historyFilter.removeClass('active'); + getLast24hHistoryData(); +} + + + function showHeaders(){ $('#historyTab').click(showHistory); tabitem.removeClass('active'); diff --git a/target/classes/com/release11/klaus/controller/EventController.class b/target/classes/com/release11/klaus/controller/EventController.class index 267b4d6..c81b165 100644 Binary files a/target/classes/com/release11/klaus/controller/EventController.class and b/target/classes/com/release11/klaus/controller/EventController.class differ diff --git a/target/classes/com/release11/klaus/model/Event.class b/target/classes/com/release11/klaus/model/Event.class index 2518b8e..2334bb1 100644 Binary files a/target/classes/com/release11/klaus/model/Event.class and b/target/classes/com/release11/klaus/model/Event.class differ diff --git a/target/classes/com/release11/klaus/service/EtrackServiceImpl.class b/target/classes/com/release11/klaus/service/EtrackServiceImpl.class index 91f4860..0cdf63c 100644 Binary files a/target/classes/com/release11/klaus/service/EtrackServiceImpl.class and b/target/classes/com/release11/klaus/service/EtrackServiceImpl.class differ diff --git a/target/classes/static/css/main.css b/target/classes/static/css/main.css new file mode 100644 index 0000000..2f8c9ff --- /dev/null +++ b/target/classes/static/css/main.css @@ -0,0 +1,4 @@ +.overflowedTableContent { + max-height: 750px; + overflow: scroll; +} \ No newline at end of file diff --git a/target/classes/static/html/mock.html b/target/classes/static/html/mock.html index 6c854ac..760397e 100644 --- a/target/classes/static/html/mock.html +++ b/target/classes/static/html/mock.html @@ -4,6 +4,7 @@ R11 MockedServices + @@ -63,9 +64,7 @@ -
-

> show/hide advanced settings

-
+
@@ -102,7 +101,8 @@
-
+ +
@@ -118,7 +118,7 @@
-
+
diff --git a/target/classes/static/js/datatransfer.js b/target/classes/static/js/datatransfer.js index 9fa3c6e..ce82f5d 100644 --- a/target/classes/static/js/datatransfer.js +++ b/target/classes/static/js/datatransfer.js @@ -40,6 +40,8 @@ function getData(){ }); } + + function checkUuid(){ if(clientUUID == null || clientUUID == undefined || clientUUID == ''){ clientUUID = json[0].clientUUID; diff --git a/target/classes/static/js/historyloader.js b/target/classes/static/js/historyloader.js index f5437e5..f283b76 100644 --- a/target/classes/static/js/historyloader.js +++ b/target/classes/static/js/historyloader.js @@ -1,5 +1,5 @@ var historyJson = {}; -const maxIterations = 30; +const maxIterations = 200; function filterHistory(){ var dateFrom = new Date($('#historyFrom').val() + 'T' + $('#historyTimeFrom').val()); @@ -52,6 +52,13 @@ function loadHistory(dateFrom, dateTo){ }); } +function getLast24hHistoryData(){ + $.getJSON(host + '/api/event/' + clientUUID + '/' + lastId, function(data){ + historyJson = data; + displayHistory(); + }); +} + function historyToHtml(){ var innerHTML = ''; var iterations = historyJson.length <= maxIterations ? historyJson.length : maxIterations; diff --git a/target/classes/static/js/uianimation.js b/target/classes/static/js/uianimation.js index 0c7fd25..2d7add0 100644 --- a/target/classes/static/js/uianimation.js +++ b/target/classes/static/js/uianimation.js @@ -22,8 +22,16 @@ function changeAdvancedVisibility(){ setCookie(); } +const historyFilter = $('#history-filter'); +const historyFilterSwitch = function(){ + historyFilter.toggleClass('active'); +} + $("#optional").click(changeAdvancedVisibility); $('#historyTab').click(showHistory); +$('#btn-history-filter').click(historyFilterSwitch); + + const tabitem = $('.tabitem'); function showHistory(){ @@ -33,8 +41,16 @@ function showHistory(){ $('#history').addClass('active'); $('#historyTab').addClass('active'); $('#historyTab').off('click'); + initializeHistory(); } +function initializeHistory(){ + historyFilter.removeClass('active'); + getLast24hHistoryData(); +} + + + function showHeaders(){ $('#historyTab').click(showHistory); tabitem.removeClass('active');