Device management fall back to http if https isn't available.

Adds a slight delay on management clicking, may be blocked by popup blocker...
This commit is contained in:
Tony Murray
2018-12-05 13:52:07 -06:00
parent 7788f93a57
commit 00cd32f725
5 changed files with 25 additions and 4 deletions

View File

@@ -191,7 +191,7 @@ foreach (dbFetchRows($sql, $param) as $device) {
$actions .= '<div class="col-xs-1"><a href="ssh://' . $device['hostname'] . '"><i class="fa fa-lock fa-lg icon-theme" title="SSH to ' . $device['hostname'] . '"></i></a></div>
';
}
$actions .= '<div class="col-xs-1"><a href="https://' . $device['hostname'] . '" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" title="Launch browser https://' . $device['hostname'] . '"></i></a></div>
$actions .= '<div class="col-xs-1"><a href="https://' . $device['hostname'] . '" onclick="http_fallback(this); return false;" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" title="Launch browser https://' . $device['hostname'] . '"></i></a></div>
</div>
</div>
';

View File

@@ -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;
}

View File

@@ -137,7 +137,7 @@ foreach ((array)$config['webui']['custom_css'] as $custom_css) {
}
?>
<script src="js/select2.min.js"></script>
<script src="js/librenms.js?ver=20181130"></script>
<script src="js/librenms.js?ver=20181205"></script>
<script type="text/javascript">
<!-- Begin

View File

@@ -454,7 +454,7 @@ if (device_permitted($vars['device']) || $permitted_by_port) {
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><i class="fa fa-cog fa-lg icon-theme" aria-hidden="true"></i>
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="https://'.$device['hostname'].'" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" aria-hidden="true"></i> Web</a></li>';
<li><a href="https://'.$device['hostname'].'" onclick="http_fallback(this); return false;" target="_blank" rel="noopener"><i class="fa fa-globe fa-lg icon-theme" aria-hidden="true"></i> Web</a></li>';
if (isset($config['gateone']['server'])) {
if ($config['gateone']['use_librenms_user'] == true) {
echo '<li><a href="' . $config['gateone']['server'] . '?ssh=ssh://' . LegacyAuth::user()->username . '@' . $device['hostname'] . '&location=' . $device['hostname'] .'" target="_blank" rel="noopener"><i class="fa fa-lock fa-lg icon-theme" aria-hidden="true"></i> SSH</a></li>';

View File

@@ -69,7 +69,7 @@
<script src="js/lazyload.js"></script>
@endif
<script src="{{ asset('js/select2.min.js') }}"></script>
<script src="{{ asset('js/librenms.js?ver=20181130') }}"></script>
<script src="{{ asset('js/librenms.js?ver=20181205') }}"></script>
<script type="text/javascript">
<!-- Begin