51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| var historyJson = {};
 | |
| const maxIterations = 30;
 | |
| 
 | |
| function filterHistory(){
 | |
|     var dateFrom = $('#historyFrom').val();
 | |
|     var dateTo = $('#historyTo').val();
 | |
|     loadHistory(dateFrom, dateTo);
 | |
| }
 | |
| 
 | |
| const startSearch = function(){
 | |
|     filterHistory();
 | |
| }
 | |
| $('#btn-searchHistory').click(startSearch);
 | |
| 
 | |
| $('#historyFilterSwitch').click(filterSwitch);
 | |
| 
 | |
| function loadHistory(dateFrom, dateTo){
 | |
|     console.log('Request send for history data')
 | |
|     var eventRequest = {
 | |
|         clientUUID : json[jsonIndex].clientUUID,
 | |
|         localDateTimeFrom : dateFrom,
 | |
|         localDateTimeTo : dateTo,
 | |
|         mockedResponseId : json[jsonIndex].mockedResponseId
 | |
|     };
 | |
|     $.ajax({
 | |
|         url: host + '/api/event',
 | |
|         type: 'POST',
 | |
|         data: JSON.stringify(eventRequest, null, 2),
 | |
|         contentType: "application/json"
 | |
|     }).done(function(data){
 | |
|         historyJson = data;
 | |
|         displayHistory();
 | |
|     });
 | |
| }
 | |
| 
 | |
| function historyToHtml(){
 | |
|     var innerHTML = '';
 | |
|     var iterations = historyJson.length <= maxIterations ? historyJson.length : maxIterations;
 | |
|     for(let i=0; i<iterations; i++){
 | |
|         innerHTML += '<tr>' +
 | |
|             '<td>' + historyJson[i].dateTimeStamp + '</td>' +
 | |
|             '<td>' + historyJson[i].interfaceName + '</td>' +
 | |
|         '</tr>';
 | |
|     }
 | |
|     return innerHTML;
 | |
| }
 | |
| 
 | |
| const displayHistory = function(){
 | |
|     $('#historyTable tbody').html(historyToHtml());
 | |
| }
 |