From 00cd32f725d458b83efef04a050b0b94f5a03573 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 5 Dec 2018 13:52:07 -0600 Subject: [PATCH] Device management fall back to http if https isn't available. Adds a slight delay on management clicking, may be blocked by popup blocker... --- html/includes/table/devices.inc.php | 2 +- html/js/librenms.js | 21 ++++++++++++++++++++ html/legacy_index.php | 2 +- html/pages/device.inc.php | 2 +- resources/views/layouts/librenmsv1.blade.php | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index 47b2825d5c..e37bc74b57 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -191,7 +191,7 @@ foreach (dbFetchRows($sql, $param) as $device) { $actions .= '
'; } - $actions .= '
+ $actions .= '
'; diff --git a/html/js/librenms.js b/html/js/librenms.js index 57f8c15e79..4b6136216c 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -420,3 +420,24 @@ function update_location(id, latlng, callback) { }); } + +function http_fallback(link) { + var url = link.getAttribute('href'); + console.log(url); + try { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, false); + xhr.timeout = 2000; + xhr.send(null); + + if (xhr.status !== 200) { + url = url.replace(/^https:\/\//, 'http://'); + } + } catch (e) { + // console.log(e); + url = url.replace(/^https:\/\//, 'http://'); + } + + window.open(url, '_blank'); + return false; +} diff --git a/html/legacy_index.php b/html/legacy_index.php index dfff0afceb..34fe2747bc 100644 --- a/html/legacy_index.php +++ b/html/legacy_index.php @@ -137,7 +137,7 @@ foreach ((array)$config['webui']['custom_css'] as $custom_css) { } ?> - +