-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,63 @@ | ||
<div id="usb-tab"></div> | ||
<h2 data-i18n="usb.clienttab"></h2> | ||
<div id="usb-msg" data-i18n="listing.loading" class="col-lg-12 text-center"></div> | ||
|
||
<script> | ||
$(document).on('appReady', function(){ | ||
$.getJSON(appUrl + '/module/usb/get_data/' + serialNumber, function(data){ | ||
// Set count of USB devices | ||
$('#usb-cnt').text(data.length); | ||
var skipThese = ['id','name','printer_id']; | ||
$.each(data, function(i,d){ | ||
$.getJSON(appUrl + '/module/usb/get_data/' + serialNumber, function(data){ | ||
// Generate rows from data | ||
var rows = '' | ||
for (var prop in d){ | ||
// Skip skipThese | ||
if(skipThese.indexOf(prop) == -1){ | ||
if(prop == 'internal' && d[prop] == 1){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('yes')+'</td></tr>'; | ||
} | ||
else if(prop == 'internal' && d[prop] == 0){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('no')+'</td></tr>'; | ||
} | ||
else if(prop == 'media' && d[prop] == 1){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('yes')+'</td></tr>'; | ||
} | ||
else if(prop == 'media' && d[prop] == 0){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('no')+'</td></tr>'; | ||
// Check if we have data | ||
if( data == "" || ! data || data.length == 0 || data.length == "0"){ | ||
$('#usb-msg').text(i18n.t('usb.nousb')); | ||
} else { | ||
// Hide | ||
$('#usb-msg').text(''); | ||
$('#usb-count-view').removeClass('hide'); | ||
// Set count of USB devices | ||
$('#usb-cnt').text(data.length); | ||
var skipThese = ['id','name','printer_id']; | ||
$.each(data, function(i,d){ | ||
// Generate rows from data | ||
var rows = '' | ||
for (var prop in d){ | ||
// Skip skipThese | ||
if(skipThese.indexOf(prop) == -1){ | ||
if(prop == 'internal' && d[prop] == 1){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('yes')+'</td></tr>'; | ||
} | ||
else if(prop == 'internal' && d[prop] == 0){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('no')+'</td></tr>'; | ||
} | ||
else if(prop == 'media' && d[prop] == 1){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('yes')+'</td></tr>'; | ||
} | ||
else if(prop == 'media' && d[prop] == 0){ | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+i18n.t('no')+'</td></tr>'; | ||
} | ||
else if(prop == 'usb_serial_number' && d[prop] == ''){ | ||
// Do nothing for a blank device serial number | ||
} | ||
else { | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+d[prop]+'</td></tr>'; | ||
} | ||
} | ||
else if(prop == 'usb_serial_number' && d[prop] == ''){ | ||
// Do nothing for a blank device serial number | ||
} | ||
else { | ||
rows = rows + '<tr><th>'+i18n.t('usb.'+prop)+'</th><td>'+d[prop]+'</td></tr>'; | ||
} | ||
} | ||
} | ||
$('#usb-tab') | ||
.append($('<h4>') | ||
.append($('<i>') | ||
.addClass('fa fa-usb')) | ||
.append(' '+d.name)) | ||
.append($('<div style="max-width:370px;">') | ||
.addClass('table-responsive') | ||
.append($('<table>') | ||
.addClass('table table-striped table-condensed') | ||
.append($('<tbody>') | ||
.append(rows)))) | ||
}) | ||
}); | ||
} | ||
$('#usb-tab') | ||
.append($('<h4>') | ||
.append($('<i>') | ||
.addClass('fa fa-usb')) | ||
.append(' '+d.name)) | ||
.append($('<div style="max-width:370px;">') | ||
.addClass('table-responsive') | ||
.append($('<table>') | ||
.addClass('table table-striped table-condensed') | ||
.append($('<tbody>') | ||
.append(rows)))) | ||
}) | ||
} | ||
}); | ||
}); | ||
</script> |