diff --git a/connectcore-demo-example/index.html b/connectcore-demo-example/index.html index a9cf7b9..d76510c 100644 --- a/connectcore-demo-example/index.html +++ b/connectcore-demo-example/index.html @@ -9,7 +9,6 @@ Digi Demo - Dashboard - @@ -20,11 +19,7 @@ Digi Demo - Dashboard - - @@ -43,130 +38,10 @@ Digi Demo - Dashboard
- | - - | -
- Devices data usage
- |
-
| - - | -
- Web APIs data usage
- |
-
|
- Total devices usage:
- |
-
- -
- |
-
|
- Current device usage:
- |
-
- -
- |
-
|
- Total web APIs usage:
- |
-
- -
- |
-
|
- Web services usage:
- |
-
- -
- |
-
|
- Monitors usage:
- |
-
- -
- |
-
-
| - Time between samples: - | -- - - | -
| - Samples to buffer: - | -- - - | -
| - Device ID: - | -- - - | -||||||||||||||||
|
Serial number:
@@ -921,20 +767,6 @@ Digi Demo - Dashboard
-
-
-
-
@@ -991,15 +796,12 @@ $( document ).ready(function() {
-
diff --git a/connectcore-demo-example/management.html b/connectcore-demo-example/management.html
index ab114c5..55f4a20 100644
--- a/connectcore-demo-example/management.html
+++ b/connectcore-demo-example/management.html
@@ -9,7 +9,6 @@ Digi Demo - Management
-
@@ -20,11 +19,7 @@ Digi Demo - Management
-
-
@@ -43,130 +38,10 @@ Digi Demo - Management
-
-
@@ -248,25 +123,6 @@ Digi Demo - Management
-
-
-
-
-
-
- Loading data...
-
-
-
-
-
-
- Total account data usage
-
- -
-
-
-
-
-
-
-
-
- Devices usage
-
-
-
-
- Web APIs usage
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Log out
-
-
-
-
-
- System monitor-Configure the system monitor service parameters.
-
- Time between samples:
-
-
-
-
-
- Samples to buffer:
-
-
-
-
- Save
- Reboot device@@ -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(); - }); }); @@ -380,20 +229,6 @@ Digi Demo - Management" +
- " ";
-
-// 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;
}
-}
\ No newline at end of file
+}
diff --git a/connectcore-demo-example/static/js/file-system.js b/connectcore-demo-example/static/js/file-system.js
index 10952fa..f6d034a 100644
--- a/connectcore-demo-example/static/js/file-system.js
+++ b/connectcore-demo-example/static/js/file-system.js
@@ -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);
}
-}
\ No newline at end of file
+}
diff --git a/connectcore-demo-example/static/js/history.js b/connectcore-demo-example/static/js/history.js
index 78cfc03..78637d9 100644
--- a/connectcore-demo-example/static/js/history.js
+++ b/connectcore-demo-example/static/js/history.js
@@ -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);
-}
\ No newline at end of file
diff --git a/connectcore-demo-example/static/js/management.js b/connectcore-demo-example/static/js/management.js
index 2be0cd9..4ac3d63 100644
--- a/connectcore-demo-example/static/js/management.js
+++ b/connectcore-demo-example/static/js/management.js
@@ -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())
diff --git a/connectcore-demo-example/static/js/sidebar.js b/connectcore-demo-example/static/js/sidebar.js
index 9bd3be8..dcb7192 100644
--- a/connectcore-demo-example/static/js/sidebar.js
+++ b/connectcore-demo-example/static/js/sidebar.js
@@ -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);
-}
\ No newline at end of file
|