Signed-off-by: Jonas Brüstel <jonas@bruestel.net>
This commit is contained in:
parent
58f20c5028
commit
c0a2a4b104
|
@ -163,9 +163,7 @@ public class HomeConnectServlet extends HttpServlet {
|
|||
|
||||
String path = request.getPathInfo();
|
||||
if (path == null || path.isEmpty() || path.equals(ROOT_PATH)) {
|
||||
@Nullable
|
||||
String code = request.getParameter(PARAM_CODE);
|
||||
@Nullable
|
||||
String state = request.getParameter(PARAM_STATE);
|
||||
if (code != null && state != null && !code.trim().isEmpty() && !state.trim().isEmpty()) {
|
||||
getBridgeAuthenticationPage(request, response, code, state);
|
||||
|
@ -173,9 +171,7 @@ public class HomeConnectServlet extends HttpServlet {
|
|||
getBridgesPage(request, response);
|
||||
}
|
||||
} else if (pathMatches(path, APPLIANCES_PATH)) {
|
||||
@Nullable
|
||||
String action = request.getParameter(PARAM_ACTION);
|
||||
@Nullable
|
||||
String thingId = request.getParameter(PARAM_THING_ID);
|
||||
if (action != null && thingId != null && !action.trim().isEmpty() && !thingId.trim().isEmpty()) {
|
||||
processApplianceActions(response, action, thingId);
|
||||
|
@ -183,9 +179,7 @@ public class HomeConnectServlet extends HttpServlet {
|
|||
getAppliancesPage(request, response);
|
||||
}
|
||||
} else if (pathMatches(path, REQUEST_LOG_PATH)) {
|
||||
@Nullable
|
||||
String export = request.getParameter(PARAM_EXPORT);
|
||||
@Nullable
|
||||
String bridgeId = request.getParameter(PARAM_BRIDGE_ID);
|
||||
if (export != null && bridgeId != null && !export.trim().isEmpty() && !bridgeId.trim().isEmpty()) {
|
||||
getRequestLogExport(response, bridgeId);
|
||||
|
@ -193,9 +187,7 @@ public class HomeConnectServlet extends HttpServlet {
|
|||
getRequestLogPage(request, response);
|
||||
}
|
||||
} else if (pathMatches(path, EVENT_LOG_PATH)) {
|
||||
@Nullable
|
||||
String export = request.getParameter(PARAM_EXPORT);
|
||||
@Nullable
|
||||
String bridgeId = request.getParameter(PARAM_BRIDGE_ID);
|
||||
if (export != null && bridgeId != null && !export.trim().isEmpty() && !bridgeId.trim().isEmpty()) {
|
||||
getEventLogExport(response, bridgeId);
|
||||
|
@ -225,11 +217,8 @@ public class HomeConnectServlet extends HttpServlet {
|
|||
}
|
||||
} else if (pathMatches(path, APPLIANCES_PATH)) {
|
||||
String requestPayload = request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
|
||||
@Nullable
|
||||
String action = request.getParameter(PARAM_ACTION);
|
||||
@Nullable
|
||||
String thingId = request.getParameter(PARAM_THING_ID);
|
||||
@Nullable
|
||||
String targetPath = request.getParameter(PARAM_PATH);
|
||||
|
||||
if ((ACTION_PUT_RAW.equals(action) || ACTION_GET_RAW.equals(action)) && thingId != null
|
||||
|
@ -366,7 +355,6 @@ public class HomeConnectServlet extends HttpServlet {
|
|||
String actionResponse = bridgeHandler.get().getApiClient().putRaw(haId, path, body);
|
||||
response.getWriter().write(actionResponse);
|
||||
} else if (ACTION_GET_RAW.equals(action)) {
|
||||
@Nullable
|
||||
String actionResponse = bridgeHandler.get().getApiClient().getRaw(haId, path, true);
|
||||
if (actionResponse == null) {
|
||||
response.getWriter().write("{\"status\": \"No response\"}");
|
||||
|
@ -393,9 +381,7 @@ public class HomeConnectServlet extends HttpServlet {
|
|||
}
|
||||
|
||||
private void postBridgesPage(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
@Nullable
|
||||
String action = request.getParameter(PARAM_ACTION);
|
||||
@Nullable
|
||||
String bridgeId = request.getParameter(PARAM_BRIDGE_ID);
|
||||
Optional<HomeConnectBridgeHandler> bridgeHandlerOptional = bridgeHandlers.stream().filter(
|
||||
homeConnectBridgeHandler -> homeConnectBridgeHandler.getThing().getUID().toString().equals(bridgeId))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* globals Chart:false, feather:false, Plotly:false, requests:false */
|
||||
/* globals Chart:false, feather:false, requests:false */
|
||||
|
||||
(function () {
|
||||
'use strict'
|
||||
|
@ -112,6 +112,7 @@
|
|||
var modal = $(this);
|
||||
var requestBodyElement = modal.find('.modal-request-body');
|
||||
var title = modal.find('.modal-title');
|
||||
var titleBadgeElement = modal.find('.modal-title-badge');
|
||||
var responseBodyElement = modal.find('.modal-response-body');
|
||||
var requestHeaderElement = modal.find('.modal-request-header');
|
||||
var responseHeaderElement = modal.find('.modal-response-header');
|
||||
|
@ -134,6 +135,23 @@
|
|||
responseBodyElement.addClass('text-muted')
|
||||
}
|
||||
|
||||
titleBadgeElement.empty();
|
||||
if (request.homeConnectResponse) {
|
||||
var statusCode = request.homeConnectResponse.code;
|
||||
titleBadgeElement.text(statusCode);
|
||||
titleBadgeElement.removeClass('badge-success');
|
||||
titleBadgeElement.removeClass('badge-danger');
|
||||
titleBadgeElement.removeClass('badge-warning');
|
||||
|
||||
if (statusCode >= 300 && statusCode != 404) {
|
||||
titleBadgeElement.addClass('badge-danger');
|
||||
} else if (statusCode >= 200 && statusCode < 300) {
|
||||
titleBadgeElement.addClass('badge-success');
|
||||
} else {
|
||||
titleBadgeElement.addClass('badge-warning');
|
||||
}
|
||||
}
|
||||
|
||||
responseHeaderElement.empty();
|
||||
if (request.homeConnectResponse && request.homeConnectResponse.header) {
|
||||
var responseHeader = request.homeConnectResponse.header;
|
||||
|
@ -159,60 +177,4 @@
|
|||
$('.reload-page').click(function () {
|
||||
location.reload();
|
||||
});
|
||||
|
||||
$('.request-chart').each(function (index, element) {
|
||||
var bridgeId = $(this).data('bridge-id');
|
||||
var chartElement = element;
|
||||
|
||||
function makeplot (bridgeId, chartElement) {
|
||||
Plotly.d3.csv('requests?bridgeId=' + bridgeId + '&action=request-csv', function (data) {
|
||||
processData(data, chartElement)
|
||||
});
|
||||
}
|
||||
|
||||
function processData (allRows, chartElement) {
|
||||
console.log(allRows);
|
||||
var x = [], y = [], standardDeviation = [];
|
||||
|
||||
for (var i = 0; i < allRows.length; i++) {
|
||||
var row = allRows[i];
|
||||
x.push(row['time']);
|
||||
y.push(row['requests']);
|
||||
}
|
||||
console.log('X', x, 'Y', y, 'SD', standardDeviation);
|
||||
makePlotly(x, y, standardDeviation, chartElement);
|
||||
}
|
||||
|
||||
function makePlotly (x, y, standard_deviation, chartElement){
|
||||
var traces = [{
|
||||
x: x,
|
||||
y: y,
|
||||
type: 'histogram',
|
||||
histfunc: 'sum',
|
||||
xbins: {
|
||||
size: 1000
|
||||
}
|
||||
}];
|
||||
|
||||
Plotly.newPlot(chartElement, traces,
|
||||
{
|
||||
xaxis: {
|
||||
rangemode: 'nonnegative',
|
||||
autorange: true,
|
||||
title: '',
|
||||
type: 'date'
|
||||
},
|
||||
yaxis: {
|
||||
title: 'requests',
|
||||
rangemode: 'nonnegative'
|
||||
}
|
||||
},
|
||||
{
|
||||
displayModeBar: false,
|
||||
responsive: true
|
||||
});
|
||||
}
|
||||
|
||||
makeplot(bridgeId, chartElement);
|
||||
});
|
||||
}())
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<span class="modal-title-badge badge mt-2 mr-1">200</span>
|
||||
<h5 class="modal-title .text-truncate" id="requestDetailModalLabel">Request Details</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
|
|
Loading…
Reference in New Issue