Skip to content

Commit ca1c489

Browse files
committed
feat: aggiornamento info di accesso con icone
1 parent 0a8d4eb commit ca1c489

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

‎gulpfile.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@ function pdfjs() {
421421
return merge(web, build);
422422
}
423423

424+
function uaparser() {
425+
return gulp.src([
426+
config.nodeDirectory + '/ua-parser-js/dist/icons/mono/**/*',
427+
'!' + config.nodeDirectory + '/ua-parser-js/dist/icons/mono/LICENSE.md',
428+
])
429+
.pipe(gulp.dest(config.production + '/img/icons/'));
430+
}
431+
424432
// Elaborazione e minificazione delle informazioni sull'internazionalizzazione
425433
function i18n() {
426434
return gulp.src([
@@ -596,7 +604,7 @@ function clean() {
596604
}
597605

598606
// Operazioni di default per la generazione degli assets
599-
const bower = gulp.series(clean, gulp.parallel(JS, CSS, images, fonts, ckeditor, colorpicker, i18n, pdfjs, hotkeys, chartjs, password_strength, csrf, leaflet, wacom));
607+
const bower = gulp.series(clean, gulp.parallel(JS, CSS, images, fonts, ckeditor, colorpicker, i18n, pdfjs, uaparser, hotkeys, chartjs, password_strength, csrf, leaflet, wacom));
600608

601609
// Debug su CSS e JS
602610
exports.srcJS = srcJS;

‎log.php‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<script>
9999
$(document).ready(function() {
100100
var parser = new UAParser();
101+
var icons_path = globals.rootdir + '/assets/dist/img/icons';
101102

102103
$('tr').each(function(){
103104
user_agent_cell = $(this).find('.user-agent');
@@ -107,7 +108,52 @@
107108
parser.setUA(user_agent);
108109
device = parser.getResult();
109110

110-
user_agent_cell.html('<strong>' + (device.browser.name || '') + '</strong> ' + (device.browser.version || '') + ' | <strong>' + (device.os.name || '') + '</strong> ' + (device.os.version || ''));
111+
var device_info = [];
112+
113+
// Browser
114+
if (device.browser.name) {
115+
device_info['browser'] = {};
116+
device_info['browser']['text'] = '<strong>' + device.browser.name + '</strong> ' + (device.browser.version || '');
117+
device_info['browser']['icon'] = icons_path + '/browser/' + device.browser.name.toLowerCase().replace(' ', '-');
118+
}
119+
120+
// OS
121+
if (device.os.name) {
122+
device_info['os'] = {};
123+
device_info['os']['text'] = '<strong>' + device.os.name + '</strong> ' + (device.os.version || '');
124+
device_info['os']['icon'] = icons_path + '/os/' + device.os.name.toLowerCase();
125+
}
126+
127+
// Device
128+
if (device.device.name) {
129+
device_info['device'] = {};
130+
device_info['device']['text'] = '<strong>' + device.device.vendor + '</strong> ' + (device.device.model || '');
131+
device_info['device']['icon'] = icons_path + '/device/' + device.device.name.toLowerCase();
132+
}
133+
134+
// Preparazione user-agent riscritto
135+
if (device_info.browser || device_info.os) {
136+
user_agent_cell.html('');
137+
}
138+
139+
// Sostituzione user-agent con formato più amichevole
140+
for (var key in device_info) {
141+
var icon = device_info[key]['icon'];
142+
var text = device_info[key]['text'];
143+
144+
if (icon) {
145+
var img = new Image();
146+
img.src = icon + '.svg';
147+
148+
const imgElement = document.createElement('img');
149+
imgElement.src = img.src;
150+
imgElement.width = 14;
151+
imgElement.height = 14;
152+
user_agent_cell.append(imgElement).append(' ');
153+
}
154+
155+
user_agent_cell.append(text + ' | ');
156+
}
111157
}
112158
})
113159
})

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"sweetalert2": "^6.11.4",
5050
"toastr": "^2.1.4",
5151
"tooltipster": "^4.2.5",
52-
"ua-parser-js": "^1.0.37"
52+
"ua-parser-js": "^2.0.0"
5353
},
5454
"devDependencies": {
5555
"@babel/core": "^7.11.1",

0 commit comments

Comments
 (0)