connectcore-demo-example: remove not needed stuff for local management
https://onedigi.atlassian.net/browse/DEL-7742 Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
|
|
@ -9,7 +9,6 @@ Digi Demo - Dashboard
|
|||
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.7.3/css/bootstrap-slider.min.css" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="./static/css/login.css">
|
||||
<link rel="stylesheet" href="./static/css/general.css">
|
||||
<link rel="stylesheet" href="./static/css/toastr.css">
|
||||
<link rel="stylesheet" href="./static/css/xterm.css">
|
||||
|
|
@ -20,11 +19,7 @@ Digi Demo - Dashboard
|
|||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
|
||||
<script src="https://kit.fontawesome.com/1e66c78073.js" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
|
||||
<script src="https://www.gstatic.com/charts/loader.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.7.3/bootstrap-slider.min.js"></script>
|
||||
<script>
|
||||
google.charts.load("current", {"packages":["line"]});
|
||||
</script>
|
||||
<script type="text/javascript" src="./static/js/common.js"></script>
|
||||
<script type="text/javascript" src="./static/js/devices.js"></script>
|
||||
<script type="text/javascript" src="./static/js/jquery.pjax.js"></script>
|
||||
|
|
@ -43,130 +38,10 @@ Digi Demo - Dashboard
|
|||
|
||||
<div class="nav-right-container">
|
||||
|
||||
<div id="data_usage_panel" class="data-usage-panel" style="display: none;">
|
||||
<div class="data-usage-panel-wrapper">
|
||||
<div id="data_usage_loading" class="data-usage-loading">
|
||||
<div class="data-usage-loading-background"></div>
|
||||
<img class="data-usage-loading-icon" src="./static/images/loading.gif" alt="Loading..." />
|
||||
<div class="data-usage-loading-text">Loading data...</div>
|
||||
</div>
|
||||
<div id="data_usage_content" class="data-usage-content">
|
||||
<div class="data-usage-section">
|
||||
<div class="data-usage-header">
|
||||
<div class="data-usage-title">Total account data usage</div>
|
||||
<div class="fas fa-sync device-card-header-button" onclick="refreshUsageData()"></div>
|
||||
</div>
|
||||
<div id="data_usage_total" class="data-usage-total-value">-</div>
|
||||
<div class="data-usage-graphic-container">
|
||||
<button id="data_usage_graphic_devices" class="fas data-usage-graphic data-usage-graphic-devices" data-toggle="tooltip" data-placement="bottom" title="Total data usage by devices"></button>
|
||||
<button id="data_usage_graphic_web" class="fas data-usage-graphic data-usage-graphic-web" data-toggle="tooltip" data-placement="bottom" title="Total data usage by web APIs"></button>
|
||||
</div>
|
||||
<div class="data-usage-values-container">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-legend data-usage-graphic-devices"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="data-usage-legend-text">Devices data usage</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-legend data-usage-graphic-web"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="data-usage-legend-text">Web APIs data usage</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-usage-section">
|
||||
<div class="data-usage-title">Devices usage</div>
|
||||
<div class="data-usage-values-container">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label-bold">Total devices usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_devices" class="data-usage-value-bold">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label">Current device usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_current_device" class="data-usage-value">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-usage-section">
|
||||
<div class="data-usage-title">Web APIs usage</div>
|
||||
<div class="data-usage-values-container">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label-bold">Total web APIs usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_web" class="data-usage-value-bold">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label">Web services usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_web_services" class="data-usage-value">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label">Monitors usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_monitors" class="data-usage-value">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<img src="./static/images/board.png" class="device-title-img" title="Device">
|
||||
</div>
|
||||
<div id="device-name"></div>
|
||||
<div>
|
||||
<img src="./static/images/status_offline.png" id="device-connection-status" class="device-title-img" title="Offline">
|
||||
</div>
|
||||
<div class="vertical-separator"></div>
|
||||
<div>
|
||||
<button id="devices-list-button" class="btn widget-button" type="button" value="0" onclick="window.open('/','_self');">
|
||||
<img src="./static/images/devices_list_gray.png" id="devices-list-icon" class="devices-list-icon" data-toggle="tooltip" data-placement="bottom" title="Open devices list">
|
||||
</button>
|
||||
<button id="data_usage_button" class="btn widget-button" type="button" value="0" onclick="toggleDataUsagePanel();">
|
||||
<img src="./static/images/data_usage.png" id="data_usage_icon" class="devices-list-icon" data-toggle="tooltip" data-placement="bottom" title="Show data usage">
|
||||
</button>
|
||||
</div>
|
||||
<div class="vertical-separator"></div>
|
||||
|
||||
<div class="dropdown digi-gray" id="profile-container">
|
||||
<button class="btn dropdown-toggle" type="button" id="profileMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<img id="profile-logo" class="banner-icon" src="./static/images/profile_gray.png">
|
||||
</button>
|
||||
<div class="dropdown-menu shadow-sm" aria-labelledby="profileMenuButton">
|
||||
<a class="dropdown-item" href="/access/logout/">Log out</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
|
@ -261,27 +136,6 @@ Digi Demo - Dashboard
|
|||
<div id="device-button-hide-info" class="device-button" onclick="setInfoPanelsVisible(false)">
|
||||
<img id="device-button-hide-info-img" src="./static/images/hide_info.png" width="32px" data-toggle="tooltip" data-placement="bottom" title="Hide all information panels">
|
||||
</div>
|
||||
<div class="samples-info-container">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="device-card-content-text">Time between samples:</span>
|
||||
</td>
|
||||
<td>
|
||||
<span id="sample_rate" class="device-card-content-value">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="device-card-content-text">Samples to buffer:</span>
|
||||
</td>
|
||||
<td>
|
||||
<span id="num_samples_upload" class="device-card-content-value">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="samples-info-overlay" title="Change device sampling settings" data-toggle="tooltip" data-placement="bottom" onclick="changeSampleRate()"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="board_image_container" class="device-board-container">
|
||||
<center><img id="board_image" class="device-board-image" width="" src=""/></center>
|
||||
|
|
@ -295,14 +149,6 @@ Digi Demo - Dashboard
|
|||
</div>
|
||||
<div id="device_info_panel_container" class="device-card-content shadow-sm" style="display: none;">
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width: 130px; vertical-align: top;">
|
||||
<span class="device-card-content-text">Device ID:</span>
|
||||
</td>
|
||||
<td>
|
||||
<span id="device_id" class="device-card-content-value">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top;">
|
||||
<span class="device-card-content-text">Serial number:</span>
|
||||
|
|
@ -921,20 +767,6 @@ Digi Demo - Dashboard
|
|||
</div>
|
||||
|
||||
<script>
|
||||
function getCookie(cName) {
|
||||
if (document.cookie.length > 0) {
|
||||
cStart = document.cookie.indexOf(cName + "=");
|
||||
if (cStart != -1) {
|
||||
cStart = cStart + cName.length + 1;
|
||||
cEnd = document.cookie.indexOf(";", cStart);
|
||||
if (cEnd == -1)
|
||||
cEnd = document.cookie.length;
|
||||
return unescape(document.cookie.substring(cStart, cEnd));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#banner-link").on({
|
||||
"mouseover" : function() {
|
||||
|
|
@ -953,33 +785,6 @@ Digi Demo - Dashboard
|
|||
</script>
|
||||
|
||||
<!-- Local JS files and functions -->
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
$("#profile-container").on({
|
||||
"mouseover" : function() {
|
||||
$("#profile-logo").attr("src", "./static/images/profile_green.png");
|
||||
if (!$("#profile-container").hasClass("digi-green")) {
|
||||
$("#profile-container").addClass("digi-green");
|
||||
}
|
||||
if ($("#profile-container").hasClass("digi-gray")) {
|
||||
$("#profile-container").removeClass("digi-gray");
|
||||
}
|
||||
},
|
||||
"mouseout" : function() {
|
||||
$("#profile-logo").attr("src", "./static/images/profile_gray.png");
|
||||
if (!$("#profile-container").hasClass("digi-gray")) {
|
||||
$("#profile-container").addClass("digi-gray");
|
||||
}
|
||||
if ($("#profile-container").hasClass("digi-green")) {
|
||||
$("#profile-container").removeClass("digi-green");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Local JS files and functions -->
|
||||
<script type="text/javascript" src="./static/js/sidebar.js"></script>
|
||||
<script type="text/javascript" src="./static/js/ccimx8mm-dvk.js"></script>
|
||||
<script type="text/javascript" src="./static/js/ccimx8m-nano.js"></script>
|
||||
|
|
@ -991,15 +796,12 @@ $( document ).ready(function() {
|
|||
<script type="text/javascript" src="./static/js/xterm-addon-fit.js"></script>
|
||||
<script type="text/javascript" src="./static/js/console.js"></script>
|
||||
<script type="text/javascript" src="./static/js/file-system.js"></script>
|
||||
<script type="text/javascript" src="./static/js/data-usage.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Don't show the loading spinner at the beginning. Initial page
|
||||
// load is full, so not relying on AJAX.
|
||||
$("#loading").hide();
|
||||
|
||||
verifyParameters();
|
||||
|
||||
// Set up PJAX.
|
||||
if ($.support.pjax) {
|
||||
$.pjax.defaults.timeout = 20000;
|
||||
|
|
@ -1021,7 +823,6 @@ $( document ).ready(function() {
|
|||
$(document).on("pjax:complete", function() {
|
||||
$("#loading").hide();
|
||||
$("#pjax-container").show();
|
||||
verifyParameters();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1038,28 +839,6 @@ $( document ).ready(function() {
|
|||
|
||||
// Set the name of the selected device.
|
||||
$("#device-name").html("DEY device".toUpperCase());
|
||||
|
||||
// Change the color of the devices icon when hovering.
|
||||
$("#devices-list-button").on({
|
||||
"mouseover" : function() {
|
||||
$("#devices-list-icon").attr("src", "./static/images/devices_list_green.png");
|
||||
},
|
||||
"mouseout" : function() {
|
||||
$("#devices-list-icon").attr("src", "./static/images/devices_list_gray.png");
|
||||
}
|
||||
});
|
||||
// Change the color of the data usage icon when hovering.
|
||||
$("#data_usage_button").on({
|
||||
"mouseover" : function() {
|
||||
$("#data_usage_icon").attr("src", "./static/images/data_usage_green.png");
|
||||
},
|
||||
"mouseout" : function() {
|
||||
$("#data_usage_icon").attr("src", "./static/images/data_usage.png");
|
||||
}
|
||||
});
|
||||
|
||||
// Check the device connection status.
|
||||
checkDeviceConnectionStatus();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ Digi Demo - Management
|
|||
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.7.3/css/bootstrap-slider.min.css" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="./static/css/login.css">
|
||||
<link rel="stylesheet" href="./static/css/general.css">
|
||||
<link rel="stylesheet" href="./static/css/toastr.css">
|
||||
<link rel="stylesheet" href="./static/css/xterm.css">
|
||||
|
|
@ -20,11 +19,7 @@ Digi Demo - Management
|
|||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
|
||||
<script src="https://kit.fontawesome.com/1e66c78073.js" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
|
||||
<script src="https://www.gstatic.com/charts/loader.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.7.3/bootstrap-slider.min.js"></script>
|
||||
<script>
|
||||
google.charts.load("current", {"packages":["line"]});
|
||||
</script>
|
||||
<script type="text/javascript" src="./static/js/common.js"></script>
|
||||
<script type="text/javascript" src="./static/js/devices.js"></script>
|
||||
<script type="text/javascript" src="./static/js/jquery.pjax.js"></script>
|
||||
|
|
@ -43,130 +38,10 @@ Digi Demo - Management
|
|||
|
||||
<div class="nav-right-container">
|
||||
|
||||
<div id="data_usage_panel" class="data-usage-panel" style="display: none;">
|
||||
<div class="data-usage-panel-wrapper">
|
||||
<div id="data_usage_loading" class="data-usage-loading">
|
||||
<div class="data-usage-loading-background"></div>
|
||||
<img class="data-usage-loading-icon" src="./static/images/loading.gif" alt="Loading..." />
|
||||
<div class="data-usage-loading-text">Loading data...</div>
|
||||
</div>
|
||||
<div id="data_usage_content" class="data-usage-content">
|
||||
<div class="data-usage-section">
|
||||
<div class="data-usage-header">
|
||||
<div class="data-usage-title">Total account data usage</div>
|
||||
<div class="fas fa-sync device-card-header-button" onclick="refreshUsageData()"></div>
|
||||
</div>
|
||||
<div id="data_usage_total" class="data-usage-total-value">-</div>
|
||||
<div class="data-usage-graphic-container">
|
||||
<button id="data_usage_graphic_devices" class="fas data-usage-graphic data-usage-graphic-devices" data-toggle="tooltip" data-placement="bottom" title="Total data usage by devices"></button>
|
||||
<button id="data_usage_graphic_web" class="fas data-usage-graphic data-usage-graphic-web" data-toggle="tooltip" data-placement="bottom" title="Total data usage by web APIs"></button>
|
||||
</div>
|
||||
<div class="data-usage-values-container">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-legend data-usage-graphic-devices"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="data-usage-legend-text">Devices data usage</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-legend data-usage-graphic-web"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="data-usage-legend-text">Web APIs data usage</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-usage-section">
|
||||
<div class="data-usage-title">Devices usage</div>
|
||||
<div class="data-usage-values-container">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label-bold">Total devices usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_devices" class="data-usage-value-bold">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label">Current device usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_current_device" class="data-usage-value">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-usage-section">
|
||||
<div class="data-usage-title">Web APIs usage</div>
|
||||
<div class="data-usage-values-container">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label-bold">Total web APIs usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_web" class="data-usage-value-bold">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label">Web services usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_web_services" class="data-usage-value">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="data-usage-value-label">Monitors usage:</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="data_usage_monitors" class="data-usage-value">-</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<img src="./static/images/board.png" class="device-title-img" title="Device">
|
||||
</div>
|
||||
<div id="device-name"></div>
|
||||
<div>
|
||||
<img src="./static/images/status_offline.png" id="device-connection-status" class="device-title-img" title="Offline">
|
||||
</div>
|
||||
<div class="vertical-separator"></div>
|
||||
<div>
|
||||
<button id="devices-list-button" class="btn widget-button" type="button" value="0" onclick="window.open('/','_self');">
|
||||
<img src="./static/images/devices_list_gray.png" id="devices-list-icon" class="devices-list-icon" data-toggle="tooltip" data-placement="bottom" title="Open devices list">
|
||||
</button>
|
||||
<button id="data_usage_button" class="btn widget-button" type="button" value="0" onclick="toggleDataUsagePanel();">
|
||||
<img src="./static/images/data_usage.png" id="data_usage_icon" class="devices-list-icon" data-toggle="tooltip" data-placement="bottom" title="Show data usage">
|
||||
</button>
|
||||
</div>
|
||||
<div class="vertical-separator"></div>
|
||||
|
||||
<div class="dropdown digi-gray" id="profile-container">
|
||||
<button class="btn dropdown-toggle" type="button" id="profileMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<img id="profile-logo" class="banner-icon" src="./static/images/profile_gray.png">
|
||||
</button>
|
||||
<div class="dropdown-menu shadow-sm" aria-labelledby="profileMenuButton">
|
||||
<a class="dropdown-item" href="/access/logout/">Log out</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
|
@ -248,25 +123,6 @@ Digi Demo - Management
|
|||
</div>
|
||||
</div>
|
||||
<div id="loading_wrapper" class="loading-wrapper element-grayed">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">System monitor</h5>
|
||||
<div>Configure the system monitor service parameters.</div>
|
||||
<div class="system-monitor-param-container">
|
||||
<span class="system-monitor-param-label">Time between samples:</span>
|
||||
<input id="sample_rate" class="system-monitor-input" type="text"/>
|
||||
<button class="fas fa-question-circle system-monitor-help" title="Time to wait between samples read (in seconds). Must be a positive number greater than 0." data-toggle="tooltip" data-placement="right"></button>
|
||||
</div>
|
||||
<div id="sample_rate_error" class="system-monitor-error"></div>
|
||||
<div class="system-monitor-param-container">
|
||||
<span class="system-monitor-param-label">Samples to buffer:</span>
|
||||
<input id="num_samples_upload" class="system-monitor-input" type="text"/>
|
||||
<button class="fas fa-question-circle system-monitor-help" title="Number of samples of each parameter to gather before uploading them to Digi Remote Manager. Must be a positive number greater than 0." data-toggle="tooltip" data-placement="right"></button>
|
||||
</div>
|
||||
<div id="samples_buffer_error" class="system-monitor-error"></div>
|
||||
<div id="save_button" class="device-card-button system-monitor-save system-monitor-save-disabled" onclick="saveSystemMonitor()">Save</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Reboot device</h5>
|
||||
|
|
@ -364,13 +220,6 @@ Digi Demo - Management
|
|||
filesLoaded = false;
|
||||
// Initialize page.
|
||||
initializeManagementPage();
|
||||
// Register system monitor input changed.
|
||||
$("#sample_rate").on("input", function(event) {
|
||||
validateSystemMonitor(event.target.value);
|
||||
});
|
||||
$("#num_samples_upload").on("input", function(event) {
|
||||
validateSystemMonitor();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
@ -380,20 +229,6 @@ Digi Demo - Management
|
|||
</div>
|
||||
|
||||
<script>
|
||||
function getCookie(cName) {
|
||||
if (document.cookie.length > 0) {
|
||||
cStart = document.cookie.indexOf(cName + "=");
|
||||
if (cStart != -1) {
|
||||
cStart = cStart + cName.length + 1;
|
||||
cEnd = document.cookie.indexOf(";", cStart);
|
||||
if (cEnd == -1)
|
||||
cEnd = document.cookie.length;
|
||||
return unescape(document.cookie.substring(cStart, cEnd));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#banner-link").on({
|
||||
"mouseover" : function() {
|
||||
|
|
@ -412,33 +247,6 @@ Digi Demo - Management
|
|||
</script>
|
||||
|
||||
<!-- Local JS files and functions -->
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
$("#profile-container").on({
|
||||
"mouseover" : function() {
|
||||
$("#profile-logo").attr("src", "./static/images/profile_green.png");
|
||||
if (!$("#profile-container").hasClass("digi-green")) {
|
||||
$("#profile-container").addClass("digi-green");
|
||||
}
|
||||
if ($("#profile-container").hasClass("digi-gray")) {
|
||||
$("#profile-container").removeClass("digi-gray");
|
||||
}
|
||||
},
|
||||
"mouseout" : function() {
|
||||
$("#profile-logo").attr("src", "./static/images/profile_gray.png");
|
||||
if (!$("#profile-container").hasClass("digi-gray")) {
|
||||
$("#profile-container").addClass("digi-gray");
|
||||
}
|
||||
if ($("#profile-container").hasClass("digi-green")) {
|
||||
$("#profile-container").removeClass("digi-green");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Local JS files and functions -->
|
||||
<script type="text/javascript" src="./static/js/sidebar.js"></script>
|
||||
<script type="text/javascript" src="./static/js/ccimx8mm-dvk.js"></script>
|
||||
<script type="text/javascript" src="./static/js/ccimx8m-nano.js"></script>
|
||||
|
|
@ -450,15 +258,12 @@ $( document ).ready(function() {
|
|||
<script type="text/javascript" src="./static/js/xterm-addon-fit.js"></script>
|
||||
<script type="text/javascript" src="./static/js/console.js"></script>
|
||||
<script type="text/javascript" src="./static/js/file-system.js"></script>
|
||||
<script type="text/javascript" src="./static/js/data-usage.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Don't show the loading spinner at the beginning. Initial page
|
||||
// load is full, so not relying on AJAX.
|
||||
$("#loading").hide();
|
||||
|
||||
verifyParameters();
|
||||
|
||||
// Set up PJAX.
|
||||
if ($.support.pjax) {
|
||||
$.pjax.defaults.timeout = 20000;
|
||||
|
|
@ -480,7 +285,6 @@ $( document ).ready(function() {
|
|||
$(document).on("pjax:complete", function() {
|
||||
$("#loading").hide();
|
||||
$("#pjax-container").show();
|
||||
verifyParameters();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -498,27 +302,6 @@ $( document ).ready(function() {
|
|||
// Set the name of the selected device.
|
||||
$("#device-name").html("DEY device".toUpperCase());
|
||||
|
||||
// Change the color of the devices icon when hovering.
|
||||
$("#devices-list-button").on({
|
||||
"mouseover" : function() {
|
||||
$("#devices-list-icon").attr("src", "./static/images/devices_list_green.png");
|
||||
},
|
||||
"mouseout" : function() {
|
||||
$("#devices-list-icon").attr("src", "./static/images/devices_list_gray.png");
|
||||
}
|
||||
});
|
||||
// Change the color of the data usage icon when hovering.
|
||||
$("#data_usage_button").on({
|
||||
"mouseover" : function() {
|
||||
$("#data_usage_icon").attr("src", "./static/images/data_usage_green.png");
|
||||
},
|
||||
"mouseout" : function() {
|
||||
$("#data_usage_icon").attr("src", "./static/images/data_usage.png");
|
||||
}
|
||||
});
|
||||
|
||||
// Check the device connection status.
|
||||
checkDeviceConnectionStatus();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 589 B |
|
Before Width: | Height: | Size: 618 B |
|
Before Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 596 B |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
|
@ -140,7 +140,7 @@ class CCIMX8MNANO extends ConnectCoreDevice {
|
|||
SUPPORTS_VIDEO_BRIGHTNESS = false;
|
||||
|
||||
// Constructor.
|
||||
constructor(deviceID, deviceData) {
|
||||
super(CCIMX8MNANO.DEVICE_TYPE, CCIMX8MNANO.PLATFORM_NAME, deviceID, deviceData);
|
||||
constructor(deviceData) {
|
||||
super(CCIMX8MNANO.DEVICE_TYPE, CCIMX8MNANO.PLATFORM_NAME, deviceData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class CCIMX8MMINI extends ConnectCoreDevice {
|
|||
BOARD_IMAGE_SCALE = 85;
|
||||
|
||||
CPU_COMPONENT_VISIBLE = true;
|
||||
CPU_COMPONENT_HAS_PANEL = true;
|
||||
CPU_COMPONENT_HAS_PANEL = true;
|
||||
CPU_COMPONENT_HAS_ARROW = true;
|
||||
CPU_COMPONENT_PANEL_ALWAYS_VISIBLE = false;
|
||||
CPU_COMPONENT_PANEL_ORIENTATION = VALUE_TOP;
|
||||
|
|
@ -140,7 +140,7 @@ class CCIMX8MMINI extends ConnectCoreDevice {
|
|||
SUPPORTS_VIDEO_BRIGHTNESS = false;
|
||||
|
||||
// Constructor.
|
||||
constructor(deviceID, deviceData) {
|
||||
super(CCIMX8MMINI.DEVICE_TYPE, CCIMX8MMINI.PLATFORM_NAME, deviceID, deviceData);
|
||||
constructor(deviceData) {
|
||||
super(CCIMX8MMINI.DEVICE_TYPE, CCIMX8MMINI.PLATFORM_NAME, deviceData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class CCIMX8X extends ConnectCoreDevice {
|
|||
SUPPORTS_VIDEO_BRIGHTNESS = false;
|
||||
|
||||
// Constructor.
|
||||
constructor(deviceID, deviceData) {
|
||||
super(CCIMX8X.DEVICE_TYPE, CCIMX8X.PLATFORM_NAME, deviceID, deviceData);
|
||||
constructor(deviceData) {
|
||||
super(CCIMX8X.DEVICE_TYPE, CCIMX8X.PLATFORM_NAME, deviceData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,6 @@ const ID_CPU_TEMPERATURE = "cpu_temperature";
|
|||
const ID_CPU_UPTIME = "cpu_uptime";
|
||||
const ID_CURRENT_DIR = "current_dir";
|
||||
const ID_DATA = "data";
|
||||
const ID_DATA_USAGE_DEVICES = "data_usage_devices";
|
||||
const ID_DATA_USAGE_MONITORS = "data_usage_monitors";
|
||||
const ID_DATA_USAGE_TOTAL = "data_usage_total";
|
||||
const ID_DATA_USAGE_WEB = "data_usage_web";
|
||||
const ID_DATA_USAGE_WEB_SERVICES = "data_usage_web_services";
|
||||
const ID_DEVICE_ID = "device_id";
|
||||
const ID_DEVICE_NAME = "device_name";
|
||||
const ID_DEVICE_TYPE = "device_type";
|
||||
const ID_DEVICES = "devices";
|
||||
|
|
@ -105,7 +99,6 @@ const ID_STREAM = "stream";
|
|||
const ID_TIMESTAMP = "timestamp";
|
||||
const ID_TYPE = "type";
|
||||
const ID_UBOOT_VERSION = "uboot_version";
|
||||
const ID_USAGE = "usage";
|
||||
const ID_VALUE = "value";
|
||||
const ID_VIDEO = "video";
|
||||
const ID_VIDEO_RESOLUTION = "video_resolution";
|
||||
|
|
@ -124,9 +117,7 @@ const VALUE_CANCELED = "canceled";
|
|||
const VALUE_FAILED = "failed";
|
||||
const VALUE_LEFT = "left";
|
||||
const VALUE_OFF = "Off";
|
||||
const VALUE_OFFLINE = "Offline";
|
||||
const VALUE_ON = "On";
|
||||
const VALUE_ONLINE = "Online";
|
||||
const VALUE_RIGHT = "right";
|
||||
const VALUE_SUCCESSFUL = "successful";
|
||||
const VALUE_TOP = "top";
|
||||
|
|
@ -143,9 +134,6 @@ const ERROR_SERVER_ERROR = "Internal server error";
|
|||
const ERROR_TITLE = "Error";
|
||||
const ERROR_UNKNOWN_ERROR = "Unknown error";
|
||||
|
||||
const IMAGE_OFFLINE = "status_offline.png";
|
||||
const IMAGE_ONLINE = "status_online.png";
|
||||
|
||||
const PATH_IMAGES = "../static/images/";
|
||||
|
||||
String.prototype.format = function() {
|
||||
|
|
@ -446,11 +434,6 @@ function isHistoryShowing() {
|
|||
return window.location.pathname.indexOf("history") > -1;
|
||||
}
|
||||
|
||||
// Returns the device ID.
|
||||
function getDeviceID() {
|
||||
return new URLSearchParams(window.location.search).get(ID_DEVICE_ID);
|
||||
}
|
||||
|
||||
// Returns the device name.
|
||||
function getDeviceName() {
|
||||
return new URLSearchParams(window.location.search).get(ID_DEVICE_NAME);
|
||||
|
|
|
|||
|
|
@ -185,9 +185,6 @@ function initCLISession() {
|
|||
showConsoleLoading(true);
|
||||
$.post(
|
||||
"../ajax/cli_init_session",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only if the console is showing.
|
||||
if (!isConsoleShowing())
|
||||
|
|
@ -249,7 +246,6 @@ function sendCLIData(data) {
|
|||
$.post(
|
||||
"../ajax/cli_data",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"session_id": cliSessionID,
|
||||
"data": dataToSend
|
||||
}),
|
||||
|
|
@ -309,7 +305,6 @@ function terminateCLIsession() {
|
|||
$.post(
|
||||
"../ajax/cli_terminate_session",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"session_id": cliSessionID
|
||||
}),
|
||||
function(data) {
|
||||
|
|
@ -346,8 +341,8 @@ function processTerminateCLISessionResponse(response) {
|
|||
// Subscribes to any CLI session change.
|
||||
function subscribeCLISession(sessionID) {
|
||||
// Create the web socket.
|
||||
var socketPrefix = window.location.protocol == "https:" ? "wss" : "ws";
|
||||
cliSocket = new WebSocket(socketPrefix + "://" + window.location.host + "/ws/cli/" + device.getDeviceID() + "/" + sessionID);
|
||||
//var socketPrefix = window.location.protocol == "https:" ? "wss" : "ws";
|
||||
//cliSocket = new WebSocket(socketPrefix + "://" + window.location.host + "/ws/cli/" + device.getDeviceID() + "/" + sessionID);
|
||||
// Define the callback to be notified when data is received in the web socket.
|
||||
cliSocket.onmessage = function(e) {
|
||||
if (isDashboardShowing() && term != null && term != "undefined") {
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ function initDevice() {
|
|||
// Flag initializing.
|
||||
initializingDevice = true;
|
||||
// Check device state.
|
||||
if (deviceInitialized && device.getDeviceID() == getDeviceID()) {
|
||||
if (deviceInitialized) {
|
||||
// Draw the device.
|
||||
drawDevice();
|
||||
// Read device status.
|
||||
|
|
@ -176,11 +176,14 @@ function initDevice() {
|
|||
positionComponents();
|
||||
setInfoPanelsVisible(false);
|
||||
}, 500);
|
||||
initializingDevice = false;
|
||||
} else {
|
||||
// Flag the device as not initialized.
|
||||
deviceInitialized = false;
|
||||
// Read all device info.
|
||||
readDeviceInfo();
|
||||
ledStatus = VALUE_UNKNOWN;
|
||||
setLEDValue(USER_LED, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -196,9 +199,6 @@ function readDeviceInfo() {
|
|||
// Send request to retrieve device information.
|
||||
$.post(
|
||||
"../ajax/get_device_info",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the dashboard page.
|
||||
if (!isDashboardShowing()) {
|
||||
|
|
@ -252,11 +252,8 @@ function readDeviceStatus() {
|
|||
// Show the loading popup.
|
||||
showLoadingPopup(true, MESSAGE_READING_DEVICE_STATUS);
|
||||
// Send request to retrieve device status.
|
||||
$.post(
|
||||
/*$.post(
|
||||
"../ajax/get_device_status",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the dashboard page.
|
||||
if (!isDashboardShowing()) {
|
||||
|
|
@ -274,7 +271,11 @@ function readDeviceStatus() {
|
|||
return;
|
||||
// Process error.
|
||||
processAjaxErrorResponse(response);
|
||||
});
|
||||
});*/
|
||||
// Hide the loading panel of the device.
|
||||
showLoadingPopup(false);
|
||||
// Hide the info panel of the device.
|
||||
showInfoPopup(false);
|
||||
}
|
||||
|
||||
// Processes the response of the device status request.
|
||||
|
|
@ -287,9 +288,6 @@ function processDeviceStatusResponse(response) {
|
|||
}
|
||||
// Update the device status values.
|
||||
updateDataPointsValues(response);
|
||||
// Set LED value to a known status.
|
||||
ledStatus = VALUE_UNKNOWN;
|
||||
setLEDValue(USER_LED, false);
|
||||
// Show the help popup if needed.
|
||||
var helpShown = sessionStorage.getItem(ID_HELP_POPUP_SHOWN);
|
||||
if (helpShown == null || helpShown == "false") {
|
||||
|
|
@ -304,20 +302,20 @@ function createDevice(deviceData) {
|
|||
device = null;
|
||||
switch (deviceData[ID_DEVICE_TYPE]) {
|
||||
case CCIMX8MMINI.DEVICE_TYPE:
|
||||
device = new CCIMX8MMINI(getDeviceID(), deviceData);
|
||||
device = new CCIMX8MMINI(deviceData);
|
||||
break;
|
||||
case CCIMX8MNANO.DEVICE_TYPE:
|
||||
device = new CCIMX8MNANO(getDeviceID(), deviceData);
|
||||
device = new CCIMX8MNANO(deviceData);
|
||||
break;
|
||||
case CCIMX8X.DEVICE_TYPE:
|
||||
device = new CCIMX8X(getDeviceID(), deviceData);
|
||||
device = new CCIMX8X(deviceData);
|
||||
break;
|
||||
}
|
||||
if (device != null) {
|
||||
// Draw the device.
|
||||
drawDevice();
|
||||
// Automatically receive updates.
|
||||
subscribeDataPoints();
|
||||
//subscribeDataPoints();
|
||||
// Set device as initialized.
|
||||
deviceInitialized = true;
|
||||
// Device created successfully.
|
||||
|
|
@ -345,10 +343,6 @@ function drawDevice() {
|
|||
boardImage.style.height = "auto";
|
||||
// Set the device name.
|
||||
updateFieldValue(ID_PLATFORM_NAME, device.getPlatformName());
|
||||
// Set the sample rate.
|
||||
updateFieldValue(ID_SAMPLE_RATE, device.getSampleRate());
|
||||
// Set the number of samples to upload.
|
||||
updateFieldValue(ID_NUM_SAMPLES_UPLOAD, device.getNumSamplesUpload());
|
||||
// Initialize the device component panels.
|
||||
initializeComponents();
|
||||
// Position device components.
|
||||
|
|
@ -557,8 +551,6 @@ function positionComponent(component, boardWidth, boardHeight, headerHeight, das
|
|||
|
||||
// Updates the device information values.
|
||||
function updateInfoValues() {
|
||||
// Set Device ID.
|
||||
updateFieldValue(ID_DEVICE_ID, device.getDeviceID());
|
||||
// Set serial number.
|
||||
updateFieldValue(ID_SERIAL_NUMBER, device.getSerialNumber());
|
||||
// Set DEY version.
|
||||
|
|
@ -837,7 +829,6 @@ function brightnessChanged(newValue) {
|
|||
$.post(
|
||||
"../ajax/set_video_brightness",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"value": newValue
|
||||
}),
|
||||
function(data) {
|
||||
|
|
@ -888,7 +879,6 @@ function volumeChanged(newValue) {
|
|||
$.post(
|
||||
"../ajax/set_audio_volume",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"value": newValue
|
||||
}),
|
||||
function(data) {
|
||||
|
|
@ -953,7 +943,6 @@ function setLEDValue(ledName, ledValue) {
|
|||
$.post(
|
||||
"../ajax/set_led_value",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"led_name": ledName,
|
||||
"value": ledValue
|
||||
}),
|
||||
|
|
@ -1043,3 +1032,4 @@ function subscribeDataPoints() {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,202 +0,0 @@
|
|||
/*
|
||||
* Copyright 2022, Digi International Inc.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// Constants.
|
||||
const ID_DATA_USAGE_BUTTON = "data_usage_button";
|
||||
const ID_DATA_USAGE_CURRENT_DEVICE = "data_usage_current_device";
|
||||
const ID_DATA_USAGE_GRAPHIC_WEB = "data_usage_graphic_web";
|
||||
const ID_DATA_USAGE_GRAPHIC_DEVICES = "data_usage_graphic_devices";
|
||||
const ID_DATA_USAGE_ICON = "data_usage_icon";
|
||||
const ID_DATA_USAGE_LOADING = "data_usage_loading";
|
||||
const ID_DATA_USAGE_PANEL = "data_usage_panel";
|
||||
|
||||
// Returns whether the data usage panel is open or not.
|
||||
function isDataUsageShowing() {
|
||||
// Initialize variables.
|
||||
var dataUsagePanel = document.getElementById(ID_DATA_USAGE_PANEL);
|
||||
// Return visibility.
|
||||
return dataUsagePanel.style.display != "none";
|
||||
}
|
||||
|
||||
// Toggles the data usage panel visibility.
|
||||
function toggleDataUsagePanel() {
|
||||
// Initialize variables.
|
||||
var dataUsageIcon = document.getElementById(ID_DATA_USAGE_ICON);
|
||||
var dataUsageButton = document.getElementById(ID_DATA_USAGE_BUTTON);
|
||||
// Avoid double clicks.
|
||||
dataUsageButton.style.pointerEvents = "none";
|
||||
// Check data usage panel visibility.
|
||||
if (isDataUsageShowing()) {
|
||||
$("#" + ID_DATA_USAGE_PANEL).slideUp("fast", function() {
|
||||
dataUsageIcon.src = "../static/images/data_usage.png";
|
||||
// Enable hover effect.
|
||||
$("#" + ID_DATA_USAGE_BUTTON).on({
|
||||
"mouseover" : function() {
|
||||
dataUsageIcon.src = "../static/images/data_usage_green.png";
|
||||
},
|
||||
"mouseout" : function() {
|
||||
dataUsageIcon.src = "../static/images/data_usage.png";
|
||||
}
|
||||
});
|
||||
// React to mouse events again.
|
||||
dataUsageButton.style.pointerEvents = "auto";
|
||||
// Reset fields.
|
||||
clearDataUsageFields();
|
||||
});
|
||||
} else {
|
||||
$("#" + ID_DATA_USAGE_PANEL).slideDown("fast", function() {
|
||||
dataUsageIcon.src = "../static/images/data_usage_green.png";
|
||||
// Disable hover effect.
|
||||
$("#" + ID_DATA_USAGE_BUTTON).on({
|
||||
"mouseover" : function() {
|
||||
dataUsageIcon.src = "../static/images/data_usage_green.png";
|
||||
},
|
||||
"mouseout" : function() {
|
||||
dataUsageIcon.src = "../static/images/data_usage_green.png";
|
||||
}
|
||||
});
|
||||
// React to mouse events again.
|
||||
dataUsageButton.style.pointerEvents = "auto";
|
||||
// Read data usage.
|
||||
readDataUsage();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Reads the DRM account data usage.
|
||||
function readDataUsage() {
|
||||
// Sanity checks.
|
||||
if (!isDataUsageShowing())
|
||||
return;
|
||||
// Show the data usage loading panel.
|
||||
showDataUsageLoading(true);
|
||||
// Send request to change the LED status.
|
||||
$.post(
|
||||
"../ajax/get_data_usage",
|
||||
function(data) {
|
||||
// Process only if the panel is showing.
|
||||
if (!isDataUsageShowing())
|
||||
return;
|
||||
// Process answer.
|
||||
processReadDataUsageResponse(data);
|
||||
}
|
||||
).fail(function(response) {
|
||||
// Process only if the panel is showing.
|
||||
if (!isDataUsageShowing())
|
||||
return;
|
||||
// Process error.
|
||||
error = processAjaxErrorResponse(response);
|
||||
// Hide the data usage loading panel.
|
||||
showDataUsageLoading(true);
|
||||
});
|
||||
}
|
||||
|
||||
// Processes the read data usage response.
|
||||
function processReadDataUsageResponse(response) {
|
||||
// Hide the data usage loading panel.
|
||||
showDataUsageLoading(false);
|
||||
// Check if there was any error in the request.
|
||||
if (!checkErrorResponse(response, false)) {
|
||||
// Update the data usage values.
|
||||
updateDataUsageValues(response);
|
||||
}
|
||||
}
|
||||
|
||||
// Updates the data usage values.
|
||||
function updateDataUsageValues(response) {
|
||||
// Sanity checks.
|
||||
if (!isDataUsageShowing())
|
||||
return;
|
||||
// Initialize variables.
|
||||
var dataUsageTotal = response[ID_DATA_USAGE_TOTAL];
|
||||
var dataUsageWeb = response[ID_DATA_USAGE_WEB];
|
||||
var dataUsageDevices = response[ID_DATA_USAGE_DEVICES];
|
||||
var dataUsageDevicesPercent = 0;
|
||||
var dataUsageWebPercent = 0;
|
||||
var dataUsageCurrentDevice = 0;
|
||||
var graphicDevicesElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_DEVICES);
|
||||
var graphicWebElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_WEB);
|
||||
// Calculate percent for data devices.
|
||||
if (dataUsageTotal > 0) {
|
||||
dataUsageDevicesPercent = Math.round(dataUsageDevices * 100 / dataUsageTotal);
|
||||
dataUsageWebPercent = Math.round(dataUsageWeb * 100 / dataUsageTotal);
|
||||
}
|
||||
// Calculate values for totals.
|
||||
dataUsageDevices = sizeToHumanRead(dataUsageDevices * 1000 * 1000); // This usage is given in MB.
|
||||
dataUsageWeb = sizeToHumanRead(dataUsageWeb * 1000 * 1000); // This usage is given in MB.
|
||||
// Retrieve the data usage for the current device.
|
||||
for (var device in response[ID_DEVICES]) {
|
||||
if (response[ID_DEVICES][device][ID_DEVICE_ID].toLowerCase() == getDeviceID().toLowerCase()) {
|
||||
dataUsageCurrentDevice = response[ID_DEVICES][device][ID_USAGE];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Set percentage size of graphics.
|
||||
graphicDevicesElement.style.width = dataUsageDevicesPercent + "%";
|
||||
graphicWebElement.style.width = dataUsageWebPercent + "%";
|
||||
// Set graphics tooltips.
|
||||
graphicDevicesElement.setAttribute("data-original-title", "Total data usage by devices: " + dataUsageDevices + " (" + dataUsageDevicesPercent + "%)");
|
||||
graphicWebElement.setAttribute("data-original-title", "Total data usage by web APIs: " + dataUsageWeb + " (" + dataUsageWebPercent + "%)");
|
||||
// Update the data usage values.
|
||||
updateFieldValue(ID_DATA_USAGE_TOTAL, sizeToHumanRead(dataUsageTotal * 1000 * 1000)); // This usage is given in MB.
|
||||
updateFieldValue(ID_DATA_USAGE_DEVICES, dataUsageDevices);
|
||||
updateFieldValue(ID_DATA_USAGE_CURRENT_DEVICE, sizeToHumanRead(dataUsageCurrentDevice * 1000)); // This usage is given in KB.
|
||||
updateFieldValue(ID_DATA_USAGE_WEB, dataUsageWeb);
|
||||
updateFieldValue(ID_DATA_USAGE_WEB_SERVICES, sizeToHumanRead(response[ID_DATA_USAGE_WEB_SERVICES] * 1000)); // This usage is given in KB.
|
||||
updateFieldValue(ID_DATA_USAGE_MONITORS, sizeToHumanRead(response[ID_DATA_USAGE_MONITORS] * 1000)); // This usage is given in KB.
|
||||
}
|
||||
|
||||
// Shows/hides the data usage loading panel.
|
||||
function showDataUsageLoading(visible) {
|
||||
// Sanity checks.
|
||||
if (!isDataUsageShowing())
|
||||
return;
|
||||
// Initialize variables.
|
||||
var dataUsageLoading = document.getElementById(ID_DATA_USAGE_LOADING);
|
||||
// Show the data usage loading panel.
|
||||
if (visible)
|
||||
dataUsageLoading.style.display = "block";
|
||||
else
|
||||
dataUsageLoading.style.display = "none";
|
||||
}
|
||||
|
||||
// Clears all data usage fields.
|
||||
function clearDataUsageFields() {
|
||||
// Initialize variables.
|
||||
var graphicDevicesElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_DEVICES);
|
||||
var graphicWebElement = document.getElementById(ID_DATA_USAGE_GRAPHIC_WEB);
|
||||
// Clear all data usage fields.
|
||||
updateFieldValue(ID_DATA_USAGE_TOTAL, "");
|
||||
updateFieldValue(ID_DATA_USAGE_DEVICES, "");
|
||||
updateFieldValue(ID_DATA_USAGE_CURRENT_DEVICE, "");
|
||||
updateFieldValue(ID_DATA_USAGE_WEB, "");
|
||||
updateFieldValue(ID_DATA_USAGE_WEB_SERVICES, "");
|
||||
updateFieldValue(ID_DATA_USAGE_MONITORS, "");
|
||||
// Reset graphic sizes.
|
||||
graphicDevicesElement.style.width = "0%";
|
||||
graphicWebElement.style.width = "0%";
|
||||
}
|
||||
|
||||
// Refreshes the usage data.
|
||||
function refreshUsageData() {
|
||||
// Sanity checks.
|
||||
if (!isDataUsageShowing())
|
||||
return;
|
||||
// Clear all data usage fields.
|
||||
clearDataUsageFields();
|
||||
// Read data usage.
|
||||
readDataUsage();
|
||||
}
|
||||
|
|
@ -15,33 +15,6 @@
|
|||
*/
|
||||
|
||||
// Constants.
|
||||
const CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED = "add-device-button-disabled";
|
||||
const CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR = "add-device-input-error";
|
||||
const CLASS_DEVICE_SELECTED = "devices-list-entry-selected";
|
||||
|
||||
const ERROR_DEVICE_ID_EMPTY = "A Device ID or MAC Address must be provided.";
|
||||
const ERROR_DEVICE_ID_INVALID = "A device id format is 00000000-00000000-00000000-00000000, while a mac address format is 00:00:00:00:00:00 (optional colon separators)";
|
||||
const ERROR_INVALID_PROVISION_VALUE = "Provided provision value was not valid.";
|
||||
|
||||
const ID_ADD_DEVICE_DIALOG = "add_device_dialog";
|
||||
const ID_ADD_DEVICE_DIALOG_BUTTON = "add_device_button";
|
||||
const ID_ADD_DEVICE_DIALOG_ERROR = "add_device_error";
|
||||
const ID_ADD_DEVICE_DIALOG_INPUT = "add_device_input";
|
||||
const ID_CONTINUE_BUTTON = "continue-button";
|
||||
const ID_DEVICES_LIST = "devices-list";
|
||||
const ID_REFRESH_BUTTON = "refresh-button";
|
||||
|
||||
const MESSAGE_LOADING_DEVICES = "Loading devices..."
|
||||
const MESSAGE_REGISTERING_DEVICE = "Registering device..."
|
||||
|
||||
const PROVISION_TYPE_ID = "id";
|
||||
const PROVISION_TYPE_MAC = "mac";
|
||||
const PROVISION_TYPE_IMEI = "imei";
|
||||
|
||||
const REGEX_DEVICE_ID = "^(?:[a-fA-F0-9]{8}-){3}[a-fA-F0-9]{8}$";
|
||||
const REGEX_DEVICE_MAC = "^(?:[a-fA-F0-9]{2}:?){5}[a-fA-F0-9]{2}$";
|
||||
const REGEX_DEVICE_IMEI = "^[0-9]{15}$";
|
||||
|
||||
const TEMPLATE_COMPONENT_DATA = "" +
|
||||
"{" +
|
||||
" \"" + ID_VISIBLE + "\" : {0}," +
|
||||
|
|
@ -57,290 +30,6 @@ const TEMPLATE_COMPONENT_DATA = "" +
|
|||
" \"" + ID_AREA_WIDTH + "\" : {10}," +
|
||||
" \"" + ID_AREA_HEIGHT + "\" : {11}" +
|
||||
"}"
|
||||
const TEMPLATE_DEVICE_LIST_ENTRY = "" +
|
||||
"<div id='@@ID@@' onclick='selectDevice(\"@@ID@@\")' class='devices-list-entry'>" +
|
||||
" <table>" +
|
||||
" <thead>" +
|
||||
" <tr>" +
|
||||
" <td rowspan='2'><img class='device-list-entry-status' src='/static/images/@@STATUS_IMAGE@@'></td>" +
|
||||
" <td><span class='device-list-entry-name'>@@TYPE@@</span></td>" +
|
||||
" </tr>" +
|
||||
" <tr>" +
|
||||
" <td><span class='device-list-entry-id'>@@ID@@</span></td>" +
|
||||
" <tr>" +
|
||||
" </thead>" +
|
||||
" </table>" +
|
||||
"</div>";
|
||||
|
||||
// Variables.
|
||||
var devices = [];
|
||||
|
||||
// Lists DRM devices.
|
||||
function listDevices() {
|
||||
// Disable the refresh button.
|
||||
document.getElementById(ID_REFRESH_BUTTON).disabled = true;
|
||||
// Disable the continue button.
|
||||
document.getElementById(ID_CONTINUE_BUTTON).disabled = true;
|
||||
// Clear the devices list
|
||||
clearDevices();
|
||||
// Hide info dialog.
|
||||
showInfoPopup(false);
|
||||
// Show loading dialog.
|
||||
showLoadingPopup(true, MESSAGE_LOADING_DEVICES);
|
||||
// Send the request.
|
||||
$.post(
|
||||
"../ajax/get_devices",
|
||||
function(data) {
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process answer.
|
||||
processListDevicesAnswer(data);
|
||||
// Enable the refresh button.
|
||||
document.getElementById(ID_REFRESH_BUTTON).disabled = false;
|
||||
// Update continue button.
|
||||
updateContinueButton();
|
||||
}
|
||||
).fail(function(response) {
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process error.
|
||||
processAjaxErrorResponse(response);
|
||||
// Enable the refresh button.
|
||||
document.getElementById(ID_REFRESH_BUTTON).disabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
// Processes the answer of the list devices request.
|
||||
function processListDevicesAnswer(response) {
|
||||
// Check if there was any error in the request.
|
||||
if (checkErrorResponse(response, false)) {
|
||||
// Do not continue.
|
||||
return;
|
||||
}
|
||||
// Get the devices from the JSON response.
|
||||
let readDevices = response[ID_DEVICES];
|
||||
// Check if the list of devices contains any device.
|
||||
if (readDevices == null || readDevices.length == 0)
|
||||
return;
|
||||
// Process devices.
|
||||
for (let device of readDevices) {
|
||||
// Add a new device entry to the list of devices.
|
||||
devices.push(device);
|
||||
let deviceDivContent = TEMPLATE_DEVICE_LIST_ENTRY;
|
||||
deviceDivContent = deviceDivContent.replace(/@@ID@@/g, device[ID_ID]);
|
||||
deviceDivContent = deviceDivContent.replace(/@@TYPE@@/g, device[ID_TYPE]);
|
||||
if (device[ID_ONLINE] == true)
|
||||
deviceDivContent = deviceDivContent.replace(/@@STATUS_IMAGE@@/g, IMAGE_ONLINE);
|
||||
else
|
||||
deviceDivContent = deviceDivContent.replace(/@@STATUS_IMAGE@@/g, IMAGE_OFFLINE);
|
||||
let deviceDiv = document.createElement("div");
|
||||
deviceDiv.innerHTML = deviceDivContent;
|
||||
$("#" + ID_DEVICES_LIST).append(deviceDiv);
|
||||
}
|
||||
}
|
||||
|
||||
// Clears the list of devices.
|
||||
function clearDevices() {
|
||||
unselectDevices();
|
||||
devices = [];
|
||||
$("#" + ID_DEVICES_LIST).html("");
|
||||
}
|
||||
|
||||
// Selects the given device
|
||||
function selectDevice(deviceID) {
|
||||
// Unselect all devices.
|
||||
unselectDevices();
|
||||
// Set selected style to the selected device div.
|
||||
if (document.getElementById(deviceID) != null)
|
||||
document.getElementById(deviceID).classList.add(CLASS_DEVICE_SELECTED);
|
||||
// Save selected device.
|
||||
for (i = 0; i < devices.length; i++) {
|
||||
device = devices[i];
|
||||
if (device[ID_ID] == deviceID)
|
||||
selectedDevice = device;
|
||||
}
|
||||
// Configure continue button.
|
||||
updateContinueButton();
|
||||
}
|
||||
|
||||
// Unselects all the devices.
|
||||
function unselectDevices() {
|
||||
// Clear selected style from all device divs.
|
||||
for (i = 0; i < devices.length; i++) {
|
||||
device = devices[i];
|
||||
if (document.getElementById(device[ID_ID]) != null)
|
||||
document.getElementById(device[ID_ID]).classList.remove(CLASS_DEVICE_SELECTED);
|
||||
}
|
||||
// Remove selected device.
|
||||
selectedDevice = null;
|
||||
// Configure continue button.
|
||||
updateContinueButton();
|
||||
}
|
||||
|
||||
// Updates the continue button state.
|
||||
function updateContinueButton() {
|
||||
// Initialize variables.
|
||||
var continueButton = document.getElementById(ID_CONTINUE_BUTTON);
|
||||
// Check if there is any selected device.
|
||||
if (selectedDevice != null) {
|
||||
continueButton.disabled = false;
|
||||
continueButton.onclick = function() {openSelectedDevice();};
|
||||
} else {
|
||||
continueButton.disabled = true;
|
||||
continueButton.onclick = function() { };
|
||||
}
|
||||
}
|
||||
|
||||
// Opens the selected device
|
||||
function openSelectedDevice() {
|
||||
// Avoid double click.
|
||||
document.getElementById(ID_CONTINUE_BUTTON).disabled = true;
|
||||
// Show loading dialog.
|
||||
showLoadingPopup(true);
|
||||
// Navigate to device dashboard page.
|
||||
window.open("../dashboard/?device_id=" + selectedDevice[ID_ID] + "&device_name=" + selectedDevice[ID_TYPE], "_self");
|
||||
}
|
||||
|
||||
// Opens the "Add device" dialog.
|
||||
function openAddDeviceDialog() {
|
||||
// Initialize variables.
|
||||
var addDeviceInputElement = document.getElementById(ID_ADD_DEVICE_DIALOG_INPUT);
|
||||
var addDeviceButtonElement = document.getElementById(ID_ADD_DEVICE_DIALOG_BUTTON);
|
||||
var addDeviceErrorElement = document.getElementById(ID_ADD_DEVICE_DIALOG_ERROR);
|
||||
// Reset dialog state.
|
||||
addDeviceInputElement.value = "";
|
||||
addDeviceErrorElement.innerHTML = " ";
|
||||
addDeviceErrorElement.style.visibility = "hidden";
|
||||
if (!addDeviceButtonElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED))
|
||||
addDeviceButtonElement.classList.add(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED);
|
||||
if (addDeviceInputElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR))
|
||||
addDeviceInputElement.classList.remove(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR);
|
||||
// Show panel.
|
||||
showAddDeviceDialog(true);
|
||||
}
|
||||
|
||||
// Closes the "Add device" dialog.
|
||||
function closeAddDeviceDialog() {
|
||||
showAddDeviceDialog(false);
|
||||
}
|
||||
|
||||
// Shows/hides the "Add device" dialog.
|
||||
function showAddDeviceDialog(visible) {
|
||||
// Initialize variables.
|
||||
var addDeviceDialogElement = document.getElementById(ID_ADD_DEVICE_DIALOG);
|
||||
var addDeviceErrorElement = document.getElementById(ID_ADD_DEVICE_DIALOG_ERROR);
|
||||
// Apply visible state.
|
||||
if (visible)
|
||||
addDeviceDialogElement.style.visibility = "visible";
|
||||
else {
|
||||
addDeviceDialogElement.style.visibility = "hidden";
|
||||
addDeviceErrorElement.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
// Validates the device ID.
|
||||
function validateDeviceID(deviceID) {
|
||||
// Initialize variables.
|
||||
var addDeviceInputElement = document.getElementById(ID_ADD_DEVICE_DIALOG_INPUT);
|
||||
var addDeviceButtonElement = document.getElementById(ID_ADD_DEVICE_DIALOG_BUTTON);
|
||||
var addDeviceErrorElement = document.getElementById(ID_ADD_DEVICE_DIALOG_ERROR);
|
||||
var isValid = true;
|
||||
var error = ERROR_DEVICE_ID_INVALID;
|
||||
// Check if the device ID is valid.
|
||||
if (deviceID == null || deviceID == "") {
|
||||
isValid = false;
|
||||
error = ERROR_DEVICE_ID_EMPTY;
|
||||
} else
|
||||
isValid = deviceID.match(REGEX_DEVICE_ID) || deviceID.match(REGEX_DEVICE_MAC) || deviceID.match(REGEX_DEVICE_IMEI);
|
||||
// Update controls.
|
||||
if (isValid) {
|
||||
if (addDeviceButtonElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED))
|
||||
addDeviceButtonElement.classList.remove(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED);
|
||||
if (addDeviceInputElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR))
|
||||
addDeviceInputElement.classList.remove(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR);
|
||||
addDeviceErrorElement.innerHTML = " ";
|
||||
addDeviceErrorElement.style.visibility = "hidden";
|
||||
} else {
|
||||
if (!addDeviceButtonElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED))
|
||||
addDeviceButtonElement.classList.add(CLASS_ADD_DEVICE_DIALOG_BUTTON_DISABLED);
|
||||
if (!addDeviceInputElement.classList.contains(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR))
|
||||
addDeviceInputElement.classList.add(CLASS_ADD_DEVICE_DIALOG_INPUT_ERROR);
|
||||
addDeviceErrorElement.innerHTML = error;
|
||||
addDeviceErrorElement.style.visibility = "visible";
|
||||
}
|
||||
}
|
||||
|
||||
// Handles what happens when the "Register device" button is pressed.
|
||||
function onRegisterDevice() {
|
||||
// Initialize variables.
|
||||
var addDeviceInputElement = document.getElementById(ID_ADD_DEVICE_DIALOG_INPUT);
|
||||
var provisionValue = addDeviceInputElement.value;
|
||||
var provisionType = "";
|
||||
// Determine provision type.
|
||||
if (provisionValue.match(REGEX_DEVICE_ID))
|
||||
provisionType = PROVISION_TYPE_ID;
|
||||
else if (provisionValue.match(REGEX_DEVICE_MAC))
|
||||
provisionType = PROVISION_TYPE_MAC;
|
||||
else if (provisionValue.match(REGEX_DEVICE_IMEI))
|
||||
provisionType = PROVISION_TYPE_IMEI;
|
||||
else {
|
||||
toastr.error(ERROR_INVALID_PROVISION_VALUE);
|
||||
return;
|
||||
}
|
||||
// Register the device.
|
||||
registerDevice(provisionValue, provisionType);
|
||||
}
|
||||
|
||||
// Registers the given device ID.
|
||||
function registerDevice(provisionValue, provisionType) {
|
||||
// Disable the refresh button.
|
||||
document.getElementById(ID_REFRESH_BUTTON).disabled = true;
|
||||
// Disable the continue button.
|
||||
document.getElementById(ID_CONTINUE_BUTTON).disabled = true;
|
||||
// Close the add device dialog.
|
||||
closeAddDeviceDialog();
|
||||
// Hide info dialog.
|
||||
showInfoPopup(false);
|
||||
// Show loading dialog.
|
||||
showLoadingPopup(true, MESSAGE_REGISTERING_DEVICE);
|
||||
// Send the request.
|
||||
$.post(
|
||||
"../ajax/register_device",
|
||||
JSON.stringify({
|
||||
"provision_value": provisionValue,
|
||||
"provision_type": provisionType
|
||||
}),
|
||||
function(data) {
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process answer.
|
||||
processRegisterDeviceAnswer(data);
|
||||
}
|
||||
).fail(function(response) {
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process error.
|
||||
processAjaxErrorResponse(response);
|
||||
// Enable the refresh button.
|
||||
document.getElementById(ID_REFRESH_BUTTON).disabled = false;
|
||||
// Refresh the continue button.
|
||||
updateContinueButton();
|
||||
});
|
||||
}
|
||||
|
||||
// Processes the answer of the register device request.
|
||||
function processRegisterDeviceAnswer(answer) {
|
||||
// Check if there was any error in the request.
|
||||
if (checkErrorResponse(answer, false)) {
|
||||
// Enable the refresh button.
|
||||
document.getElementById(ID_REFRESH_BUTTON).disabled = false;
|
||||
// Refresh the continue button.
|
||||
updateContinueButton();
|
||||
} else {
|
||||
// Update the device list.
|
||||
listDevices();
|
||||
}
|
||||
}
|
||||
|
||||
// Class that represents a ConnectCore device.
|
||||
class ConnectCoreDevice {
|
||||
|
|
@ -482,7 +171,6 @@ class ConnectCoreDevice {
|
|||
// Device information.
|
||||
#deviceType;
|
||||
#platformName;
|
||||
#deviceID;
|
||||
#serialNumber;
|
||||
#ubootVersion;
|
||||
#kernelVersion;
|
||||
|
|
@ -504,10 +192,9 @@ class ConnectCoreDevice {
|
|||
#numSamplesUpload;
|
||||
|
||||
// Class constructor.
|
||||
constructor(deviceType, platformName, deviceID, deviceData) {
|
||||
constructor(deviceType, platformName, deviceData) {
|
||||
this.#deviceType = deviceType;
|
||||
this.#platformName = platformName;
|
||||
this.#deviceID = deviceID;
|
||||
this.#initDevice(deviceData);
|
||||
}
|
||||
|
||||
|
|
@ -549,11 +236,6 @@ class ConnectCoreDevice {
|
|||
return this.#serialNumber;
|
||||
}
|
||||
|
||||
// Returns the device ID.
|
||||
getDeviceID() {
|
||||
return this.#deviceID;
|
||||
}
|
||||
|
||||
// Returns the board image file name.
|
||||
getBoardImage() {
|
||||
return this.BOARD_IMAGE;
|
||||
|
|
@ -802,4 +484,4 @@ class ConnectCoreDevice {
|
|||
supportsVideoBrightness() {
|
||||
return this.SUPPORTS_VIDEO_BRIGHTNESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,7 +246,6 @@ function listDirectory(directory) {
|
|||
$.post(
|
||||
"../ajax/fs_list_directory",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"directory": path
|
||||
}),
|
||||
function(data) {
|
||||
|
|
@ -329,7 +328,6 @@ function downloadFile(fileName) {
|
|||
showFileSystemLoading(true);
|
||||
// Prepare data.
|
||||
var data = JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"path": path
|
||||
});
|
||||
// Send request
|
||||
|
|
@ -440,7 +438,6 @@ function removeFile(fileName, isFile) {
|
|||
$.post(
|
||||
"../ajax/fs_remove_file",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"path": path,
|
||||
"is_file": isFile
|
||||
}),
|
||||
|
|
@ -487,7 +484,6 @@ function uploadFile(file) {
|
|||
showFileSystemLoading(true);
|
||||
// Prepare data.
|
||||
var formData = new FormData();
|
||||
formData.append("device_id", getDeviceID());
|
||||
formData.append("path", path);
|
||||
formData.append("file", file);
|
||||
// Send request.
|
||||
|
|
@ -619,7 +615,6 @@ function createDirectory(directoryName) {
|
|||
$.post(
|
||||
"../ajax/fs_create_dir",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"path": path
|
||||
}),
|
||||
function(data) {
|
||||
|
|
@ -650,4 +645,4 @@ function processCreateDirectoryResponse(response) {
|
|||
// List directory contents again.
|
||||
listDirectory(currentDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ function drawTemperatureChart(refresh=false, showProgress=false) {
|
|||
$.post(
|
||||
"/ajax/history_temperature",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"interval": temperatureInterval
|
||||
}),
|
||||
function(response) {
|
||||
|
|
@ -108,7 +107,6 @@ function drawCPUChart(refresh=false, showProgress=false) {
|
|||
$.post(
|
||||
"/ajax/history_cpu",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"interval": cpuInterval
|
||||
}),
|
||||
function(response) {
|
||||
|
|
@ -142,7 +140,6 @@ function drawMemoryChart(refresh=false, showProgress=false) {
|
|||
$.post(
|
||||
"/ajax/history_memory",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"interval": memoryInterval
|
||||
}),
|
||||
function(response) {
|
||||
|
|
@ -222,7 +219,3 @@ function drawChart(id, data, title, units, color=null) {
|
|||
chart.draw(dataTable, google.charts.Line.convertOptions(options));
|
||||
}
|
||||
|
||||
// Returns the device ID.
|
||||
function getDeviceID() {
|
||||
return new URLSearchParams(window.location.search).get(ID_DEVICE_ID);
|
||||
}
|
||||
|
|
@ -22,9 +22,6 @@ const ID_FIRMWARE_TAB_FILESET = "firmware_tab_fileset";
|
|||
const ID_FIRMWARE_TAB_FILESET_HEADER = "firmware_tab_fileset_header";
|
||||
const ID_FIRMWARE_TAB_UPLOAD = "firmware_tab_upload";
|
||||
const ID_FIRMWARE_TAB_UPLOAD_HEADER = "firmware_tab_upload_header";
|
||||
const ID_NUM_SAMPLES_UPLOAD_ERROR = "samples_buffer_error";
|
||||
const ID_SAMPLE_RATE_ERROR = "sample_rate_error";
|
||||
const ID_SAVE_BUTTON = "save_button";
|
||||
const ID_SELECT_FIRMWARE_BUTTON = "select_firmware_button";
|
||||
const ID_UPDATE_FIRMWARE_BUTTON = "update_firmware_button";
|
||||
const ID_UPDATE_FIRMWARE_FILE = "firmware_file";
|
||||
|
|
@ -46,11 +43,6 @@ const CLASS_PROGRESS_BAR_ERROR = "update-firmware-progress-bar-error";
|
|||
const CLASS_PROGRESS_BAR_INFO = "update-firmware-progress-bar-info";
|
||||
const CLASS_PROGRESS_BAR_SUCCESS = "update-firmware-progress-bar-success";
|
||||
const CLASS_SAVE_BUTTON_DISABLED = "system-monitor-save-disabled";
|
||||
const CLASS_SYSTEM_MONITOR_INPUT_ERROR = "system-monitor-input-error";
|
||||
|
||||
const ERROR_FIELD_EMPTY = "Field cannot be empty";
|
||||
const ERROR_FIELD_NUMBER = "Value must be a positive number";
|
||||
const ERROR_FIELD_POSITIVE = "Value must be greater than 0";
|
||||
|
||||
const TITLE_CONFIRM_CANCEL_UPDATE = "Cancel firmware update";
|
||||
const TITLE_CONFIRM_FIRMWARE_UPDATE = "Confirm firmware update";
|
||||
|
|
@ -69,11 +61,9 @@ const MESSAGE_DEVICE_REBOOTING = "The device is rebooting. Please wait...";
|
|||
const MESSAGE_LOADING_INFORMATION = "Loading device information...";
|
||||
const MESSAGE_LOADING_FILES = "Loading files...";
|
||||
const MESSAGE_NO_FILE_SELECTED = "No file selected";
|
||||
const MESSAGE_SAVING_SYSTEM_MONITOR = "Saving system monitor settings...";
|
||||
const MESSAGE_SENDING_FIRMWARE_UPDATE_REQUEST = "Sending firmware update request...";
|
||||
const MESSAGE_SENDING_REBOOT = "Sending reboot request...";
|
||||
const MESSAGE_SENDING_UPLOAD_REQUEST = "Sending firmware upload request...";
|
||||
const MESSAGE_SYSTEM_MONITOR_SAVED = "System monitor settings saved successfully";
|
||||
const MESSAGE_UPLOAD_COMPLETE = "Firmware file upload complete";
|
||||
const MESSAGE_UPDATING_FIRMWARE = "Updating firmware...";
|
||||
const MESSAGE_UPLOADING_FIRMWARE = "Uploading firmware file...";
|
||||
|
|
@ -135,9 +125,6 @@ function readDeviceInfoManagement() {
|
|||
// Send request to retrieve device information.
|
||||
$.post(
|
||||
"../ajax/get_device_info",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
if (!isManagementShowing())
|
||||
return;
|
||||
|
|
@ -163,8 +150,6 @@ function processDeviceInfoManagementResponse(response) {
|
|||
if (!checkErrorResponse(response, false)) {
|
||||
// Fill device info.
|
||||
fillDeviceInfo(response);
|
||||
// Read system monitor information.
|
||||
readSystemMonitorInfo();
|
||||
} else {
|
||||
readingManagementInfo = false;
|
||||
// Hide the loading panel.
|
||||
|
|
@ -172,57 +157,6 @@ function processDeviceInfoManagementResponse(response) {
|
|||
}
|
||||
}
|
||||
|
||||
// Gets the information of the system monitor.
|
||||
function readSystemMonitorInfo() {
|
||||
// Execute only in the management page.
|
||||
if (!isManagementShowing())
|
||||
return;
|
||||
// Hide the info popup.
|
||||
showInfoPopup(false);
|
||||
// Show the loading popup.
|
||||
showLoadingPopup(true, MESSAGE_LOADING_INFORMATION);
|
||||
// Send request to retrieve device information.
|
||||
$.post(
|
||||
"../ajax/get_sample_rate",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
readingManagementInfo = false;
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
return;
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process device information answer.
|
||||
processSystemMonitorInfoResponse(data);
|
||||
}
|
||||
).fail(function(response) {
|
||||
// Flag reading variable.
|
||||
readingManagementInfo = false;
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
return;
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process error.
|
||||
processAjaxErrorResponse(response);
|
||||
});
|
||||
}
|
||||
|
||||
// Processes the response of the system monitor info request.
|
||||
function processSystemMonitorInfoResponse(response) {
|
||||
// Check if there was any error in the request.
|
||||
if (!checkErrorResponse(response, false)) {
|
||||
// Fill system monitor info.
|
||||
fillSystemMonitorInfo(response);
|
||||
// Flag device info read.
|
||||
managementInfoRead = true;
|
||||
// Check if there is a firmware update running.
|
||||
checkFirmwareUpdateRunning();
|
||||
}
|
||||
}
|
||||
|
||||
// Fills device information.
|
||||
function fillDeviceInfo(deviceData) {
|
||||
// Set DEY version.
|
||||
|
|
@ -233,123 +167,6 @@ function fillDeviceInfo(deviceData) {
|
|||
updateFieldValue(ID_UBOOT_VERSION, deviceData[ID_UBOOT_VERSION]);
|
||||
}
|
||||
|
||||
// Fills system monitor information.
|
||||
function fillSystemMonitorInfo(response) {
|
||||
// Initialize variables.
|
||||
var sampleRateInput = document.getElementById(ID_SAMPLE_RATE);
|
||||
var samplesBufferInput = document.getElementById(ID_NUM_SAMPLES_UPLOAD);
|
||||
// Set the sample rate.
|
||||
if (sampleRateInput != null && sampleRateInput != "undefined")
|
||||
sampleRateInput.value = response[ID_SAMPLE_RATE];
|
||||
// Set the number of samples to upload.
|
||||
if (samplesBufferInput != null && samplesBufferInput != "undefined")
|
||||
samplesBufferInput.value = response[ID_NUM_SAMPLES_UPLOAD];
|
||||
// Validate system monitor.
|
||||
validateSystemMonitor();
|
||||
}
|
||||
|
||||
// Validates the system monitor values.
|
||||
function validateSystemMonitor() {
|
||||
// Initialize vars.
|
||||
var saveButton = document.getElementById(ID_SAVE_BUTTON);
|
||||
var sampleRateValid = validateSystemMonitorField(ID_SAMPLE_RATE, ID_SAMPLE_RATE_ERROR);
|
||||
var samplesBufferValid = validateSystemMonitorField(ID_NUM_SAMPLES_UPLOAD, ID_NUM_SAMPLES_UPLOAD_ERROR);
|
||||
// Check errors.
|
||||
if (!sampleRateValid || !samplesBufferValid) {
|
||||
if (!saveButton.classList.contains(CLASS_SAVE_BUTTON_DISABLED))
|
||||
saveButton.classList.add(CLASS_SAVE_BUTTON_DISABLED);
|
||||
} else {
|
||||
if (saveButton.classList.contains(CLASS_SAVE_BUTTON_DISABLED))
|
||||
saveButton.classList.remove(CLASS_SAVE_BUTTON_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
// Validates the given system monitor field.
|
||||
function validateSystemMonitorField(fieldID, errorID) {
|
||||
// Initialize vars.
|
||||
var field = document.getElementById(fieldID);
|
||||
var fieldError = document.getElementById(errorID);
|
||||
var isValid = true;
|
||||
var error = "";
|
||||
// Sanity checks.
|
||||
if (field == null || fieldError == null)
|
||||
return false;
|
||||
// Check if value is valid.
|
||||
var value = field.value;
|
||||
if (value.length == 0) {
|
||||
isValid = false;
|
||||
error = ERROR_FIELD_EMPTY;
|
||||
} else if (!value.match(REGEX_INTEGER)) {
|
||||
isValid = false;
|
||||
error = ERROR_FIELD_NUMBER;
|
||||
} else if (parseInt(value) <= 0) {
|
||||
isValid = false;
|
||||
error = ERROR_FIELD_POSITIVE;
|
||||
}
|
||||
// Update controls.
|
||||
if (isValid) {
|
||||
if (field.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR))
|
||||
field.classList.remove(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR);
|
||||
fieldError.innerHTML = " ";
|
||||
fieldError.style.display = "none";
|
||||
} else {
|
||||
if (!field.classList.contains(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR))
|
||||
field.classList.add(CLASS_FILE_SYSTEM_DIR_NAME_INPUT_ERROR);
|
||||
fieldError.innerHTML = error;
|
||||
fieldError.style.display = "block";
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
// Saves the system monitor settings.
|
||||
function saveSystemMonitor() {
|
||||
// Initialize vars.
|
||||
var sampleRateInput = document.getElementById(ID_SAMPLE_RATE);
|
||||
var samplesBufferInput = document.getElementById(ID_NUM_SAMPLES_UPLOAD);
|
||||
// Sanity checks.
|
||||
if (sampleRateInput == null || samplesBufferInput == null)
|
||||
return;
|
||||
// Execute only in the management page.
|
||||
if (!isManagementShowing())
|
||||
return;
|
||||
// Hide the info popup.
|
||||
showInfoPopup(false);
|
||||
// Show the loading popup.
|
||||
showLoadingPopup(true, MESSAGE_SAVING_SYSTEM_MONITOR);
|
||||
// Send request to set system monitor settings.
|
||||
$.post(
|
||||
"../ajax/set_sample_rate",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"sample_rate": sampleRateInput.value,
|
||||
"num_samples_upload": samplesBufferInput.value
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
return;
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process device information answer.
|
||||
processSaveSystemMonitorResponse(data);
|
||||
}
|
||||
).fail(function(response) {
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
return;
|
||||
// Hide the loading panel.
|
||||
showLoadingPopup(false);
|
||||
// Process error.
|
||||
processAjaxErrorResponse(response);
|
||||
});
|
||||
}
|
||||
|
||||
// Processes the save system monitor request response.
|
||||
function processSaveSystemMonitorResponse(response) {
|
||||
if (!checkErrorResponse(response, false))
|
||||
toastr.success(MESSAGE_SYSTEM_MONITOR_SAVED);
|
||||
}
|
||||
|
||||
// Asks the user to confirm the reboot action.
|
||||
function askReboot() {
|
||||
showConfirmDialog(TITLE_CONFIRM_REBOOT, MESSAGE_CONFIRM_REBOOT,
|
||||
|
|
@ -372,9 +189,6 @@ function rebootDevice() {
|
|||
// Send request to reboot the device.
|
||||
$.post(
|
||||
"../ajax/reboot_device",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
|
|
@ -487,7 +301,6 @@ function uploadFirmwareFile() {
|
|||
// Prepare data.
|
||||
var formData = new FormData();
|
||||
formData.append("file_set", DEMO_FILE_SET);
|
||||
formData.append("path", getDeviceID());
|
||||
formData.append("file_name", firmwareFile.name);
|
||||
formData.append("file", firmwareFile);
|
||||
// Register websocket to receive upload progress.
|
||||
|
|
@ -553,7 +366,7 @@ function processUploadFirmwareFileResponse(response) {
|
|||
var firmwareFileElement = document.getElementById(ID_UPDATE_FIRMWARE_FILE);
|
||||
var firmwareFile = firmwareFileElement.files[0];
|
||||
// Send the update request.
|
||||
updateFirmware(DEMO_FILE_SET + "/" + getDeviceID() + "/" + firmwareFile.name);
|
||||
//updateFirmware(DEMO_FILE_SET + "/" + getDeviceID() + "/" + firmwareFile.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -586,7 +399,6 @@ function updateFirmware(filePath) {
|
|||
$.post(
|
||||
"../ajax/update_firmware",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID(),
|
||||
"file": filePath
|
||||
}),
|
||||
function(data) {
|
||||
|
|
@ -665,9 +477,6 @@ function checkFirmwareUpdateStatus() {
|
|||
// Send request to check firmware update status.
|
||||
$.post(
|
||||
"../ajax/check_firmware_update_status",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
|
|
@ -724,9 +533,6 @@ function checkFirmwareUpdateRunning() {
|
|||
// Send request to check firmware update running.
|
||||
$.post(
|
||||
"../ajax/check_firmware_update_running",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
|
|
@ -780,9 +586,6 @@ function checkFirmwareUpdateProgress() {
|
|||
// Send request to check firmware update progress.
|
||||
$.post(
|
||||
"../ajax/check_firmware_update_progress",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
|
|
@ -862,9 +665,6 @@ function cancelFirmwareUpdateProcess() {
|
|||
// Send request to cancel firmware update.
|
||||
$.post(
|
||||
"../ajax/cancel_firmware_update",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
// Process only in the management page.
|
||||
if (!isManagementShowing())
|
||||
|
|
|
|||
|
|
@ -14,16 +14,6 @@
|
|||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
// Constants.
|
||||
const ID_DEVICE_CONNECTION_STATUS = "device-connection-status";
|
||||
|
||||
const ERROR_DEVICE_NOT_CONNECTED_TITLE = "Device offline";
|
||||
const ERROR_DEVICE_NOT_CONNECTED_MESSAGE = "The selected device is offline";
|
||||
|
||||
// Variables.
|
||||
var deviceConnectionStatus;
|
||||
var prevDeviceConnectionStatus;
|
||||
|
||||
// Hide submenus
|
||||
$("#body-row .collapse").collapse("hide");
|
||||
|
||||
|
|
@ -105,95 +95,3 @@ function setSelectedSection(element=null) {
|
|||
}
|
||||
}
|
||||
|
||||
// Verifies the given device parameters.
|
||||
function verifyParameters() {
|
||||
let url = new URL(window.location.href);
|
||||
let device_id = url.searchParams.get("device_id");
|
||||
let device_name = url.searchParams.get("device_name");
|
||||
$.post(
|
||||
"../ajax/check_device_connection_status",
|
||||
JSON.stringify({
|
||||
"device_id": device_id,
|
||||
"device_name": device_name
|
||||
}),
|
||||
function(data) {
|
||||
if (data["redirect"])
|
||||
window.location.replace(data["redirect"]);
|
||||
}
|
||||
).fail(function(response) {
|
||||
processAjaxErrorResponse(response);
|
||||
});
|
||||
}
|
||||
|
||||
// Requests an update on the connection status of the device.
|
||||
function checkDeviceConnectionStatus() {
|
||||
$.post(
|
||||
"../ajax/check_device_connection_status",
|
||||
JSON.stringify({
|
||||
"device_id": getDeviceID()
|
||||
}),
|
||||
function(data) {
|
||||
processDeviceConnectionStatusAnswer(data);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Processes the device connection status answer.
|
||||
function processDeviceConnectionStatusAnswer(response) {
|
||||
// Sanity checks.
|
||||
if (response[ID_STATUS] == null || response[ID_STATUS] == "undefined") {
|
||||
// Do not continue.
|
||||
return;
|
||||
}
|
||||
// Save the new connection status.
|
||||
deviceConnectionStatus = response[ID_STATUS];
|
||||
// Get icon and title based on connection status.
|
||||
var statusImage = "";
|
||||
var statusTitle = "";
|
||||
if (deviceConnectionStatus == true) {
|
||||
statusImage = IMAGE_ONLINE;
|
||||
statusTitle = VALUE_ONLINE;
|
||||
} else {
|
||||
statusImage = IMAGE_OFFLINE;
|
||||
statusTitle = VALUE_OFFLINE;
|
||||
}
|
||||
// Update the connection status icon and title.
|
||||
var deviceStatusElement = document.getElementById(ID_DEVICE_CONNECTION_STATUS);
|
||||
if (deviceStatusElement != null) {
|
||||
deviceStatusElement.src = PATH_IMAGES + statusImage;
|
||||
deviceStatusElement.title = statusTitle;
|
||||
}
|
||||
// Check if connection changed to update the displayed section.
|
||||
if (prevDeviceConnectionStatus != deviceConnectionStatus) {
|
||||
if (isDashboardShowing()) {
|
||||
if (deviceConnectionStatus)
|
||||
initDevice();
|
||||
else
|
||||
displayDeviceDisconnectedError();
|
||||
} else if (isManagementShowing()) {
|
||||
if (deviceConnectionStatus)
|
||||
initializeManagementPage();
|
||||
else if (!isDeviceRebooting())
|
||||
displayDeviceDisconnectedError();
|
||||
} else if (isHistoryShowing()) {
|
||||
if (deviceConnectionStatus)
|
||||
initCharts();
|
||||
else
|
||||
displayDeviceDisconnectedError();
|
||||
}
|
||||
}
|
||||
// Store connection status.
|
||||
prevDeviceConnectionStatus = deviceConnectionStatus;
|
||||
// Schedule a new connection status update in 30 seconds.
|
||||
setTimeout(checkDeviceConnectionStatus, 30000);
|
||||
}
|
||||
|
||||
// Displays the device disconnected error.
|
||||
function displayDeviceDisconnectedError() {
|
||||
// Device disconnected, display error.
|
||||
toastr.error(ERROR_DEVICE_NOT_CONNECTED_TITLE);
|
||||
// Hide the loading panel of the device.
|
||||
showLoadingPopup(false);
|
||||
// Show info dialog.
|
||||
showInfoPopup(true, ERROR_DEVICE_NOT_CONNECTED_TITLE, ERROR_DEVICE_NOT_CONNECTED_MESSAGE);
|
||||
}
|
||||