Refactor of History module #184
@@ -1,9 +1,7 @@
|
|||||||
package com.r11.tools;
|
package com.r11.tools;
|
||||||
|
|
||||||
import com.r11.tools.configuration.RetentionConfigurationProperties;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's generic Spring context starter. Move along...
|
* It's generic Spring context starter. Move along...
|
||||||
|
|||||||
@@ -3,10 +3,15 @@ package com.r11.tools.mappers;
|
|||||||
import com.r11.tools.model.RequestHistory;
|
import com.r11.tools.model.RequestHistory;
|
||||||
import com.r11.tools.model.RequestHistoryDTO;
|
import com.r11.tools.model.RequestHistoryDTO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface RequestHistoryMapper {
|
public interface RequestHistoryMapper {
|
||||||
|
|
||||||
|
@Mapping(target = "id", expression = "java(null)")
|
||||||
|
@Mapping(target = "clientUUID", expression = "java(requestHistoryDTO.getClientUUID().toString())")
|
||||||
RequestHistory requestHistoryDTOToRequestHistory(RequestHistoryDTO requestHistoryDTO);
|
RequestHistory requestHistoryDTOToRequestHistory(RequestHistoryDTO requestHistoryDTO);
|
||||||
|
@Mapping(target = "clientUUID", expression = "java(java.util.UUID.fromString(requestHistory.getClientUUID()))")
|
||||||
RequestHistoryDTO requestHistoryToRequestHistoryDTO(RequestHistory requestHistory);
|
RequestHistoryDTO requestHistoryToRequestHistoryDTO(RequestHistory requestHistory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ function loadHistory(dateFrom, dateTo){
|
|||||||
contentType: "application/json"
|
contentType: "application/json"
|
||||||
}).done(function(data){
|
}).done(function(data){
|
||||||
historyJson = data;
|
historyJson = data;
|
||||||
|
console.log(data);
|
||||||
displayHistory();
|
displayHistory();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -36,6 +37,7 @@ function loadHistory(dateFrom, dateTo){
|
|||||||
function getLast24hHistoryData(){
|
function getLast24hHistoryData(){
|
||||||
$.getJSON(host + '/api/event/' + clientUUID + '/' + lastId, function(data){
|
$.getJSON(host + '/api/event/' + clientUUID + '/' + lastId, function(data){
|
||||||
historyJson = data;
|
historyJson = data;
|
||||||
|
console.log(data);
|
||||||
displayHistory();
|
displayHistory();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -47,12 +49,34 @@ function historyToHtml(){
|
|||||||
let style = i%2==0 ? ' class="even"' : '';
|
let style = i%2==0 ? ' class="even"' : '';
|
||||||
innerHTML += '<tr' + style + '>' +
|
innerHTML += '<tr' + style + '>' +
|
||||||
'<td>' + historyJson[i].dateTimeStamp + '</td>' +
|
'<td>' + historyJson[i].dateTimeStamp + '</td>' +
|
||||||
'<td>' + historyJson[i].interfaceName + '</td>' +
|
'<td>' + historyJson[i].httpMethod + '</td>' +
|
||||||
|
'<td>' + historyJson[i].requestBody + '</td>' +
|
||||||
|
'<td>' +
|
||||||
|
'<th> Header Name </th>' +
|
||||||
|
'<th> Header Value </th>' +
|
||||||
|
historyJson[i].headers.forEach(
|
||||||
|
|
||||||
|
)
|
||||||
|
+ '</td>'
|
||||||
|
'<td>' + parseHeaders(historyJson[i].headers) + '</td>' +
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
return innerHTML;
|
return innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseHeaders(json){
|
||||||
|
console.log(json);
|
||||||
|
parsedJson = "";
|
||||||
|
Object.keys( json ).forEach(
|
||||||
|
(key) => {
|
||||||
|
console.log(key);
|
||||||
|
console.log(json.key)
|
||||||
|
parsedJson += key + " : " + json[key] + "\n";
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return parsedJson;
|
||||||
|
}
|
||||||
|
|
||||||
function displayHistory(){
|
function displayHistory(){
|
||||||
$('#historyTable tbody').html(historyToHtml());
|
$('#historyTable tbody').html(historyToHtml());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,9 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr class="bottom-border">
|
<tr class="bottom-border">
|
||||||
<th>Timestamp</th>
|
<th>Timestamp</th>
|
||||||
<th>Type</th>
|
<th>Method</th>
|
||||||
|
<th>Request Body</th>
|
||||||
|
<th>Request Headers</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user