connectcore-demo-example: add mechanism to remove available demo sections
While on it, remove multimedia section for the 'ccimx6ulsbc'. Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
parent
9e5eb27132
commit
597e940bf1
|
|
@ -90,7 +90,19 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler):
|
|||
"""
|
||||
Override.
|
||||
"""
|
||||
if re.search("/ajax/get_device_info", self.path) is not None:
|
||||
if re.search("/ajax/get_device_type", self.path) is not None:
|
||||
# Set the response headers.
|
||||
self._set_headers(200)
|
||||
|
||||
log.debug("Get device info")
|
||||
|
||||
info = {
|
||||
"device_type": read_proc_file("/proc/device-tree/digi,machine,name")
|
||||
}
|
||||
|
||||
# Send the JSON value.
|
||||
self.wfile.write(json.dumps(info).encode(encoding="utf_8"))
|
||||
elif re.search("/ajax/get_device_info", self.path) is not None:
|
||||
# Set the response headers.
|
||||
self._set_headers(200)
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Digi Demo - Dashboard
|
|||
<!-- Bootstrap List Group -->
|
||||
|
||||
<ul id="sections" data-pjax class="list-group">
|
||||
<li>
|
||||
<li id="section_dashboard">
|
||||
<a data-pjax href="index.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-tachometer-alt fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -61,7 +61,7 @@ Digi Demo - Dashboard
|
|||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li id="section_multimedia">
|
||||
<a data-pjax href="multimedia.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-film fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -69,7 +69,7 @@ Digi Demo - Dashboard
|
|||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li id="section_management">
|
||||
<a data-pjax href="management.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-cog fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -786,6 +786,9 @@ Digi Demo - Dashboard
|
|||
});
|
||||
}
|
||||
|
||||
// Update available sections.
|
||||
updateAvailableSections();
|
||||
|
||||
// Set the selected section.
|
||||
setSelectedSection();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Digi Demo - Management
|
|||
<!-- Bootstrap List Group -->
|
||||
|
||||
<ul id="sections" data-pjax class="list-group">
|
||||
<li>
|
||||
<li id="section_dashboard">
|
||||
<a data-pjax href="index.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-tachometer-alt fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -61,7 +61,7 @@ Digi Demo - Management
|
|||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li id="section_multimedia">
|
||||
<a data-pjax href="multimedia.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-film fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -69,7 +69,7 @@ Digi Demo - Management
|
|||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li id="section_management">
|
||||
<a data-pjax href="management.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-cog fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -332,6 +332,9 @@ Digi Demo - Management
|
|||
});
|
||||
}
|
||||
|
||||
// Update available sections.
|
||||
updateAvailableSections();
|
||||
|
||||
// Set the selected section.
|
||||
setSelectedSection();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Digi Demo - Multimedia
|
|||
<!-- Bootstrap List Group -->
|
||||
|
||||
<ul id="sections" data-pjax class="list-group">
|
||||
<li>
|
||||
<li id="section_dashboard">
|
||||
<a data-pjax href="index.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-tachometer-alt fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -61,7 +61,7 @@ Digi Demo - Multimedia
|
|||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li id="section_multimedia">
|
||||
<a data-pjax href="multimedia.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-film fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -69,7 +69,7 @@ Digi Demo - Multimedia
|
|||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li id="section_management">
|
||||
<a data-pjax href="management.html" class="list-group-item list-group-item-action d-flex align-items-center">
|
||||
<div class="d-flex w-100 justify-content-start align-items-center">
|
||||
<span class="digi-menu-icon fas fa-cog fa-fw fa-lg mr-3"></span>
|
||||
|
|
@ -273,6 +273,9 @@ Digi Demo - Multimedia
|
|||
});
|
||||
}
|
||||
|
||||
// Update available sections.
|
||||
updateAvailableSections();
|
||||
|
||||
// Set the selected section.
|
||||
setSelectedSection();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ const ID_PANEL_VERTICAL_MARGIN = "panel-vertical-margin";
|
|||
const ID_PATH = "path";
|
||||
const ID_PROGRESS = "progress";
|
||||
const ID_SAMPLE_RATE = "sample_rate";
|
||||
const ID_SECTION_DASHBOARD = "section_dashboard";
|
||||
const ID_SECTION_MANAGEMENT = "section_management";
|
||||
const ID_SECTION_MULTIMEDIA = "section_multimedia";
|
||||
const ID_SERIAL_NUMBER = "serial_number";
|
||||
const ID_SESSION_ID = "session_id";
|
||||
const ID_SIZE = "size";
|
||||
|
|
@ -486,3 +489,34 @@ function isMultimediaShowing() {
|
|||
function getDeviceName() {
|
||||
return new URLSearchParams(window.location.search).get(ID_DEVICE_NAME);
|
||||
}
|
||||
|
||||
// Updates the available web sections.
|
||||
function updateAvailableSections() {
|
||||
// Send request to retrieve device type.
|
||||
$.post(
|
||||
"http://" + getServerAddress() + "/ajax/get_device_type",
|
||||
function(data) {
|
||||
// Process answer.
|
||||
if (data[ID_DEVICE_TYPE] == null || data[ID_DEVICE_TYPE] == "undefined") {
|
||||
// Show error message.
|
||||
toastr.error("Could not get device type");
|
||||
return;
|
||||
}
|
||||
switch (data[ID_DEVICE_TYPE]) {
|
||||
case CCIMX6ULSBC.DEVICE_TYPE:
|
||||
removeSection(ID_SECTION_MULTIMEDIA);
|
||||
break;
|
||||
}
|
||||
}
|
||||
).fail(function(response) {
|
||||
// Process error.
|
||||
processAjaxErrorResponse(response);
|
||||
});
|
||||
}
|
||||
|
||||
// Removes the given section.
|
||||
function removeSection(sectionID) {
|
||||
var sectionElement = document.getElementById(sectionID);
|
||||
if (sectionElement != null && sectionElement != "undefined")
|
||||
sectionElement.parentNode.removeChild(sectionElement);
|
||||
}
|
||||
Loading…
Reference in New Issue