add description of device in actions
This commit is contained in:
parent
c10a5f24b4
commit
f011e29ce9
|
@ -10,9 +10,7 @@ $(document).ready(function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
function deviceSelect() {
|
function deviceSelect() {
|
||||||
var devices = $(".deviceSelect").filter(':checked');
|
var devices_count = $(".deviceSelect").filter(':checked').length;
|
||||||
var devices_count = devices.length;
|
|
||||||
var devices_id = $.map(devices, function(x) { return $(x).attr('data')}).join(",");
|
|
||||||
if (devices_count == 0) {
|
if (devices_count == 0) {
|
||||||
$("#addingLotModal .text-danger").show();
|
$("#addingLotModal .text-danger").show();
|
||||||
$("#addingLotModal .btn-primary").hide();
|
$("#addingLotModal .btn-primary").hide();
|
||||||
|
@ -43,9 +41,6 @@ function deviceSelect() {
|
||||||
|
|
||||||
$("#addingTagModal .text-danger").hide();
|
$("#addingTagModal .text-danger").hide();
|
||||||
}
|
}
|
||||||
$.map($(".devicesList"), function(x) {
|
|
||||||
$(x).val(devices_id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeTag() {
|
function removeTag() {
|
||||||
|
@ -61,15 +56,46 @@ function removeTag() {
|
||||||
function newAction(action) {
|
function newAction(action) {
|
||||||
$("#actionModal #type").val(action);
|
$("#actionModal #type").val(action);
|
||||||
$("#actionModal #title-action").html(action);
|
$("#actionModal #title-action").html(action);
|
||||||
var devices_count = $(".deviceSelect").filter(':checked').length;
|
get_device_list();
|
||||||
$("#actionModal .devices-count").html(devices_count);
|
|
||||||
$("#activeActionModal").click();
|
$("#activeActionModal").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
function newAllocate(action) {
|
function newAllocate(action) {
|
||||||
$("#allocateModal #type").val(action);
|
$("#allocateModal #type").val(action);
|
||||||
$("#allocateModal #title-action").html(action);
|
$("#allocateModal #title-action").html(action);
|
||||||
var devices_count = $(".deviceSelect").filter(':checked').length;
|
get_device_list();
|
||||||
$("#allocateModal .devices-count").html(devices_count);
|
|
||||||
$("#activeAllocateModal").click();
|
$("#activeAllocateModal").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_device_list() {
|
||||||
|
var devices = $(".deviceSelect").filter(':checked');
|
||||||
|
|
||||||
|
/* Insert the correct count of devices in actions form */
|
||||||
|
var devices_count = devices.length;
|
||||||
|
$("#allocateModal .devices-count").html(devices_count);
|
||||||
|
$("#actionModal .devices-count").html(devices_count);
|
||||||
|
|
||||||
|
/* Insert the correct value in the input devicesList */
|
||||||
|
var devices_id = $.map(devices, function(x) { return $(x).attr('data')}).join(",");
|
||||||
|
$.map($(".devicesList"), function(x) {
|
||||||
|
$(x).val(devices_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Create a list of devices for human representation */
|
||||||
|
var computer = {
|
||||||
|
"Desktop": "<i class='bi bi-building'></i>",
|
||||||
|
"Laptop": "<i class='bi bi-laptop'></i>",
|
||||||
|
};
|
||||||
|
list_devices = devices.map(function (x) {
|
||||||
|
var typ = $(devices[x]).data("device-type");
|
||||||
|
var manuf = $(devices[x]).data("device-manufacturer");
|
||||||
|
var dhid = $(devices[x]).data("device-dhid");
|
||||||
|
if (computer[typ]) {
|
||||||
|
typ = computer[typ];
|
||||||
|
};
|
||||||
|
return typ + " " + manuf + " " + dhid;
|
||||||
|
});
|
||||||
|
|
||||||
|
description = $.map(list_devices, function(x) { return x }).join(", ");
|
||||||
|
$(".enumeration-devices").html(description);
|
||||||
|
}
|
||||||
|
|
|
@ -234,7 +234,11 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for dev in devices %}
|
{% for dev in devices %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="checkbox" class="deviceSelect" data="{{ dev.id }}"/></td>
|
<td>
|
||||||
|
<input type="checkbox" class="deviceSelect" data="{{ dev.id }}"
|
||||||
|
data-device-type="{{ dev.type }}" data-device-manufacturer="{{ dev.manufacturer }}"
|
||||||
|
data-device-dhid="{{ dev.devicehub_id }}" />
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('inventory.devices.device_details', id=dev.devicehub_id)}}">
|
<a href="{{ url_for('inventory.devices.device_details', id=dev.devicehub_id)}}">
|
||||||
{{ dev.type }} {{ dev.manufacturer }} {{ dev.model }}
|
{{ dev.type }} {{ dev.manufacturer }} {{ dev.model }}
|
||||||
|
|
Reference in New Issue