diff options
Diffstat (limited to 'src/main')
4 files changed, 92 insertions, 22 deletions
diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html index 1a49261..ab83053 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribChart.html @@ -6,13 +6,12 @@ <title>Attributes chart</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> - <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script type="text/javascript"> - google.charts.load('current', {'packages':['table']}); - google.charts.load('current', {'packages':['corechart']}); + google.charts.load('current', {'packages':['corechart', 'table', 'controls', 'charteditor']}); google.charts.setOnLoadCallback(refreshChart()); + var chartState = []; + function refreshChart() { setInterval(getData, 5000); } @@ -29,16 +28,71 @@ function drawChart(jsonData) { var data = google.visualization.arrayToDataTable(jsonData); + var columnsTable = new google.visualization.DataTable(); + columnsTable.addColumn('number', 'colIndex'); + columnsTable.addColumn('string', 'colLabel'); + var initState= {selectedValues: []}; + + for (var i = 1; i < data.getNumberOfColumns(); i++) { + columnsTable.addRow([i, data.getColumnLabel(i)]); + initState.selectedValues.push(data.getColumnLabel(i)); + } + + if (chartState === undefined || chartState.length === 0) { + chartState = initState; + } + var options = { - title: 'Attribute values', + width : '70%', hAxis: {title: 'Timestamp', titleTextStyle: {color: '#333'}}, - vAxis: {scaleType: 'log'}, interpolateNulls: true, crosshair: {trigger: 'both', orientation: 'vertical'} }; - var chart = new google.visualization.LineChart(document.getElementById('chart_div')); - chart.draw(data, options); + var chart = new google.visualization.ChartWrapper({ + chartType : 'LineChart', + containerId : 'programmatic_chart_div', + options : options, + dataTable : data + }); + + var columnFilter = new google.visualization.ControlWrapper({ + controlType : 'CategoryFilter', + containerId : 'programmatic_control_div', + dataTable : columnsTable, + options: { + filterColumnLabel: 'colLabel', + ui : { + label : 'Attribute', + allowTyping : false, + allowMultiple : false, + allowNone : false, + selectedValuesLayout : 'below', + cssClass : 'google-visualization-controls-categoryfilter' + } + }, + state : chartState + }); + + function drawChartHandler() { + var state = columnFilter.getState(); + var row; + var columnIndices = [0]; + for (var i = 0; i < state.selectedValues.length; i++) { + row = columnsTable.getFilteredRows([{column: 1, value: state.selectedValues[i]}])[0]; + columnIndices.push(columnsTable.getValue(row, 0)); + } + columnIndices.sort(function (a, b) { + return (a - b); + }); + chartState = state; + chart.setView({columns: columnIndices}); + chart.draw(); + } + + google.visualization.events.addListener(columnFilter, 'statechange', drawChartHandler); + columnFilter.draw(); + drawChartHandler(); } function drawTable(jsonData) { @@ -47,11 +101,11 @@ data.addColumn('string', col); } jsonData.shift(); - data.addRows(jsonData); + data.addRow(jsonData[0]); var table = new google.visualization.Table(document.getElementById('table_div')); - table.draw(data, {width: '100%', height: '100%'}); + table.draw(data, {width: '80%', height: '100%'}); } </script> @@ -60,11 +114,12 @@ <body> <div th:replace="fragments/navbar :: navbar"></div> -<h4 th:text="${currentZone}"></h4> -<div id="zoneAttribForm"> + +<h4 th:text="${currentZone}" class="d-flex justify-content-center mt-2"></h4> +<div id="zoneAttribForm" class="d-flex justify-content-center mt-2"> <form action="#" th:action="@{/values}" th:object="${zoneName}" method="post"> <div class="form-group"> - <label for="ZoneName1">Enter zone name to get attribute values</label> + <label for="ZoneName1">Change zone name</label> <input type="text" class="form-control" id="ZoneName1" rows="3" th:field="*{string}"/> <small id="passwordHelpBlock" class="form-text text-muted" th:text="${availableZones}"> </small> @@ -72,10 +127,17 @@ <button type="submit" class="btn btn-primary">Submit</button> </form> </div> -<div id="table_div"></div> -<div id="chart_div" style="width: 100%; height: 500px;"></div> + +<div id="programmatic_dashboard_div" class="d-flex flex-column justify-content-center mt-5"> + <h4 class="d-flex justify-content-center mt-2">Attribute values</h4> + <div id="programmatic_control_div" class="d-flex justify-content-center mt-3"></div> + <div id="programmatic_chart_div" class="d-flex justify-content-center mt-1"></div> + <div id="table_div" class="d-flex justify-content-center mt-5"></div> +</div> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> +<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> </body> diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html index e348a11..88842be 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/attribForm.html @@ -10,7 +10,9 @@ <body> <div th:replace="fragments/navbar :: navbar"></div> -<div id="queryForm"> + +<h4 class="d-flex justify-content-center mt-2">Add attributes</h4> +<div id="queryForm" class="d-flex justify-content-center mt-2"> <form action="#" th:action="@{/attribs}" th:object="${attributeObject}" method="post"> <div class="form-group"> <label for="ZoneName1">Enter zone name</label> @@ -49,7 +51,6 @@ Time: 3600 <br> Duration: 3600 <br> Contact: { "/contactName" : [ 1, 1, 1, 1 ] } <br> - Query: { "&queryName" : "query" } <br> List: [ 1, 2, 3 ] <br> Set: [ [1, 2], [3, 4], [5, 6] ] <br> </small> diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html index ba0a3a8..e20975f 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/contactsForm.html @@ -10,7 +10,9 @@ <body> <div th:replace="fragments/navbar :: navbar"></div> -<div id="queryForm"> + +<h4 class="d-flex justify-content-center mt-2">Install fallback contacts</h4> +<div id="queryForm" class="d-flex justify-content-center mt-2"> <form action="#" th:action="@{/contacts}" th:object="${contactsObject}" method="post"> <div class="form-group"> <label for="Textarea1">Enter contacts</label> diff --git a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html index f31ef6b..af3a501 100644 --- a/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html +++ b/src/main/resources/pl/edu/mimuw/cloudatlas/client/templates/queryForm.html @@ -10,8 +10,9 @@ <body> <div th:replace="fragments/navbar :: navbar"></div> -<div id="installQueryForm"> - <h2 class="display-7">Install query</h2> + +<h4 class="d-flex justify-content-center mt-2">Install query</h4> +<div id="installQueryForm" class="d-flex justify-content-center mt-2"> <form action="#" th:action="@{/installQuery}" th:object="${queryObject}" method="post"> <div class="form-group"> <label for="InstallQueryName1">Enter query name</label> @@ -20,13 +21,17 @@ <div class="form-group"> <label for="InstallTextarea1">Enter query</label> <textarea class="form-control" id="InstallTextarea1" rows="3" th:field="*{value}"></textarea> + <small id="attributeValueHelpBlock" class="form-text text-muted"> + Enter query in a Json format. Example: + Query: { "&queryName" : "query" } <br> + </small> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> </div> -<div id="uninstallQueryForm"> - <h2 class="display-7">Uninstall query</h2> +<h4 class="d-flex justify-content-center mt-5">Uninstall query</h4> +<div id="uninstallQueryForm" class="d-flex justify-content-center mt-2"> <form action="#" th:action="@{/uninstallQuery}" th:object="${queryObject}" method="post"> <div class="form-group"> <label for="UninstallQueryName1">Enter query name</label> |