Use Laravel url helpers to improve functionality without dns name (#10227)

* Use Laravel url helpers to improve functionality without dns name
Not exhaustive...

* Fix Url generated urls

* Bump js version
This commit is contained in:
Tony Murray
2019-05-20 11:47:34 -05:00
committed by GitHub
parent 604a200891
commit e9ae08d5db
22 changed files with 66 additions and 69 deletions

View File

@@ -208,7 +208,7 @@ class Url
{
$vars = array_merge($vars, $new_vars);
$url = $vars['page'] . '/';
$url = url($vars['page']) . '/';
unset($vars['page']);
foreach ($vars as $var => $value) {

View File

@@ -121,7 +121,7 @@ class DeviceController extends TableController
return [
'extra' => $this->getLabel($device),
'status' => $device->statusName(),
'icon' => '<img src="' . $device->icon . '" title="' . pathinfo($device->icon, PATHINFO_FILENAME) . '">',
'icon' => '<img src="' . asset($device->icon) . '" title="' . pathinfo($device->icon, PATHINFO_FILENAME) . '">',
'hostname' => $this->getHostname($device),
'metrics' => $this->getMetrics($device),
'hardware' => Rewrite::ciscoHardware($device),

View File

@@ -148,7 +148,7 @@ function submitCustomRange(frmdata) {
function updateResolution(refresh)
{
$.post('ajax/set_resolution',
$.post(ajax_url + '/set_resolution',
{
width: $(window).width(),
height:$(window).height()
@@ -422,7 +422,7 @@ function init_map_marker(leaflet, latlng) {
function update_location(id, latlng, callback) {
$.ajax({
method: 'PATCH',
url: "ajax/location/" + id,
url: ajax_url + '/location/' + id,
data: {lat: latlng.lat, lng: latlng.lng}
}).success(function () {
toastr.success('Location updated');
@@ -488,7 +488,7 @@ function init_select2(selector, type, data, selected, placeholder) {
placeholder: placeholder,
allowClear: true,
ajax: {
url: 'ajax/select/' + type,
url: ajax_url + '/select/' + type,
delay: 150,
data: data_function
}

View File

@@ -39,7 +39,7 @@ var eventlog_grid = $("#eventlog").bootgrid({
eventtype: "' . addcslashes($vars['eventtype'], '"') . '",
};
},
url: "ajax/table/eventlog"
url: "' . url('/ajax/table/eventlog') . '"
});
</script>

View File

@@ -125,7 +125,7 @@ $tmp_output .= '
range: "' . (isset($_POST['range']) ? mres($_POST['range']) : '') . '"
};
},
url: "ajax/table/graylog",
url: "' . url('/ajax/table/graylog') . '",
});
init_select2("#stream", "graylog-streams", {}, "' . (isset($_POST['stream']) ? mres($_POST['stream']) : '') . '");

View File

@@ -44,7 +44,7 @@ var syslog_grid = $("#syslog").bootgrid({
from: "' . addcslashes($vars['from'], '"') . '",
};
},
url: "ajax/table/syslog"
url: "' . url('/ajax/table/syslog') . '"
});
</script>

View File

@@ -220,7 +220,7 @@ echo "
event.preventDefault();
$.ajax({
type: 'POST',
url: 'ajax/form',
url: '<?php echo url('/ajax/form'); ?>',
data: { type: "callback-statistics", state: state},
dataType: "json",
success: function(data){
@@ -234,7 +234,7 @@ echo "
event.preventDefault();
$.ajax({
type: 'POST',
url: 'ajax/form',
url: '<?php echo url('/ajax/form'); ?>',
data: { type: "callback-clear"},
dataType: "json",
success: function(data){

View File

@@ -25,7 +25,7 @@ $no_refresh = true;
var grid = $("#customers").bootgrid({
ajax: true,
rowCount: [50, 100, 250, -1],
url: "ajax/table/customers",
url: "<?php echo url('/ajax/table/customers'); ?>",
formatters: {
customer: function (column, row) {
return '<strong>' + row[column.id] + '</strong>';

View File

@@ -60,7 +60,7 @@ if ($device['os'] === 'vrp') {
$('#nac-grid').bootgrid({
ajax: true,
rowCount: [25, 50, 100, -1],
url: "ajax/table/port-nac",
url: "<?php echo url('/ajax/table/port-nac'); ?>",
post: function () {
return {
device_id: <?php echo $device['device_id'] ?>

View File

@@ -26,7 +26,7 @@ var grid = $("#port-fdb").bootgrid({
dns: $("#port-fdb").bootgrid("getColumnSettings")[4].visible
};
},
url: "ajax/table/fdb-tables"
url: "<?php echo url('/ajax/table/fdb-tables'); ?>"
});
</script>

View File

@@ -27,7 +27,7 @@ var grid = $("#ports-fdb").bootgrid({
dns: $("#ports-fdb").bootgrid("getColumnSettings")[5].visible
};
},
url: "ajax/table/fdb-tables"
url: "<?php echo url('/ajax/table/fdb-tables') ?>"
});
</script>

View File

@@ -343,7 +343,7 @@ if ($format == "graph") {
group: '<?php echo mres($vars['group']); ?>',
};
},
url: "ajax/table/device"
url: "<?php echo url('/ajax/table/device') ?>"
});
<?php

View File

@@ -82,7 +82,7 @@ $pagetitle[] = 'Eventlog';
allowClear: true,
placeholder: "All Devices",
ajax: {
url: 'ajax/select/device',
url: '<?php echo url('/ajax/select/device'); ?>',
delay: 200
}
})<?php echo $device_id ? ".val($device_id).trigger('change');" : ''; ?>;
@@ -95,7 +95,7 @@ $pagetitle[] = 'Eventlog';
allowClear: true,
placeholder: "All Types",
ajax: {
url: 'ajax/select/eventlog',
url: '<?php echo url('/ajax/select/eventlog'); ?>',
delay: 200,
data: function(params) {
return {

View File

@@ -611,7 +611,7 @@ if (empty($vars['bare']) || $vars['bare'] == "no") {
if( widget_id > 0 && widget_settings != {} ) {
$.ajax({
type: 'PUT',
url: 'ajax/form/widget-settings/' + widget_id,
url: '<?php echo url('/ajax/form/widget-settings/'); ?>' + widget_id,
data: {settings: widget_settings},
dataType: "json",
success: function (data) {
@@ -642,7 +642,7 @@ if (empty($vars['bare']) || $vars['bare'] == "no") {
}
$.ajax({
type: 'POST',
url: 'ajax/dash/' + data_type,
url: ajax_url + '/dash/' + data_type,
data: {
id: id,
dimensions: {x:$widget_body.width(), y:$widget_body.height()},

View File

@@ -122,7 +122,7 @@ echo '"'.$vars['searchPhrase'].'"+';
dns: $("#fdb-search").bootgrid("getColumnSettings")[6].visible
};
},
url: "ajax/table/fdb-tables"
url: "<?php echo url('/ajax/table/fdb-tables'); ?>"
});
</script>

View File

@@ -147,7 +147,7 @@ $pagetitle[] = 'Syslog';
allowClear: true,
placeholder: "All Devices",
ajax: {
url: 'ajax/select/device',
url: '<?php echo url('/ajax/select/device'); ?>',
delay: 200
}
})<?php echo $device_id ? ".val($device_id).trigger('change');" : ''; ?>;
@@ -160,7 +160,7 @@ $pagetitle[] = 'Syslog';
allowClear: true,
placeholder: "All Programs",
ajax: {
url: 'ajax/select/syslog',
url: '<?php echo url('/ajax/select/syslog'); ?>',
delay: 200,
data: function(params) {
return {
@@ -180,7 +180,7 @@ $pagetitle[] = 'Syslog';
allowClear: true,
placeholder: "All Priorities",
ajax: {
url: 'ajax/select/syslog',
url: '<?php echo url('/ajax/select/syslog'); ?>',
delay: 200,
data: function(params) {
return {

View File

@@ -1,9 +1,5 @@
@extends('layouts.librenmsv1')
@section('javascript')
<script src="js/jquery.qrcode.min.js"></script>
@endsection
@section('content')
<div class="container">
<div class="row">

View File

@@ -8,14 +8,14 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@if(!LibreNMS\Config::get('favicon', false))
<link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
<link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="images/manifest.json">
<link rel="mask-icon" href="images/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="{{ asset('images/apple-touch-icon.png') }}">
<link rel="icon" type="image/png" href="{{ asset('images/favicon-32x32.png') }}" sizes="32x32">
<link rel="icon" type="image/png" href="{{ asset('images/favicon-16x16.png') }}" sizes="16x16">
<link rel="manifest" href="{{ asset('images/manifest.json') }}">
<link rel="mask-icon" href="{{ asset('images/safari-pinned-tab.svg') }}" color="#5bbad5">
<link rel="shortcut icon" href="{{ asset('images/favicon.ico') }}">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="msapplication-config" content="images/browserconfig.xml">
<meta name="msapplication-config" content="{{ asset('images/browserconfig.xml') }}">
<meta name="theme-color" content="#ffffff">
@else
<link rel="shortcut icon" href="{{ LibreNMS\Config::get('favicon') }}" />
@@ -47,31 +47,38 @@
@endforeach
@yield('css')
<script src="js/polyfill.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-hover-dropdown.min.js"></script>
<script src="js/bootstrap-switch.min.js"></script>
<script src="js/hogan-2.0.0.js"></script>
<script src="js/jquery.cycle2.min.js"></script>
<script src="js/moment.min.js"></script>
<script src="js/bootstrap-datetimepicker.min.js"></script>
<script src="js/typeahead.bundle.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/tagmanager.js"></script>
<script src="js/mktree.js"></script>
<script src="js/jquery.bootgrid.min.js"></script>
<script src="js/handlebars.min.js"></script>
<script src="js/pace.min.js"></script>
<script src="js/qrcode.min.js"></script>
<script src="{{ asset('js/polyfill.min.js') }}"></script>
<script src="{{ asset('js/jquery.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
<script src="{{ asset('js/bootstrap-hover-dropdown.min.js') }}"></script>
<script src="{{ asset('js/bootstrap-switch.min.js') }}"></script>
<script src="{{ asset('js/hogan-2.0.0.js') }}"></script>
<script src="{{ asset('js/jquery.cycle2.min.js') }}"></script>
<script src="{{ asset('js/moment.min.js') }}"></script>
<script src="{{ asset('js/bootstrap-datetimepicker.min.js') }}"></script>
<script src="{{ asset('js/typeahead.bundle.min.js') }}"></script>
<script src="{{ asset('js/jquery-ui.min.js') }}"></script>
<script src="{{ asset('js/tagmanager.js') }}"></script>
<script src="{{ asset('js/mktree.js') }}"></script>
<script src="{{ asset('js/jquery.bootgrid.min.js') }}"></script>
<script src="{{ asset('js/handlebars.min.js') }}"></script>
<script src="{{ asset('js/pace.min.js') }}"></script>
<script src="{{ asset('js/qrcode.min.js') }}"></script>
@if(LibreNMS\Config::get('enable_lazy_load', true))
<script src="js/jquery.lazyload.min.js"></script>
<script src="js/lazyload.js"></script>
<script src="{{ asset('js/jquery.lazyload.min.js') }}"></script>
<script src="{{ asset('js/lazyload.js') }}"></script>
@endif
<script src="{{ asset('js/select2.min.js') }}"></script>
<script src="{{ asset('js/librenms.js?ver=20190123') }}"></script>
<script>
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var ajax_url = "{{ url('/ajax') }}";
</script>
<script src="{{ asset('js/librenms.js?ver=20190514') }}"></script>
<script type="text/javascript">
<!-- Begin
function popUp(URL)
{
@@ -80,16 +87,10 @@
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
}
// End -->
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
</script>
<script type="text/javascript" src="js/overlib_mini.js"></script>
<script type="text/javascript" src="js/toastr.min.js"></script>
<script type="text/javascript" src="js/boot.js"></script>
<script type="text/javascript" src="{{ asset('js/overlib_mini.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/toastr.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/boot.js') }}"></script>
@yield('javascript')
</head>
<body>

View File

@@ -88,10 +88,10 @@
locations_grid = $("#locations").bootgrid({
ajax: true,
rowCount: [25, 50, 100, -1],
url: "ajax/table/location",
url: "{{ url('/ajax/table/location') }}",
formatters: {
"location": function (column, row) {
return '<a href=/devices/location=' + row.id + '>' + row.location + '</a>';
return '<a href="{{ url('/devices') }}/location=' + row.id + '">' + row.location + '</a>';
},
"coordinates": function (column, row) {
var text;

View File

@@ -22,6 +22,6 @@
eventtype: "{{ $eventtype }}"
};
},
url: "ajax/table/eventlog"
url: "{{ url('/ajax/table/eventlog') }}"
});
</script>

View File

@@ -34,6 +34,6 @@
range: "{{ $range }}"
};
},
url: "ajax/table/graylog"
url: "{{ url('/ajax/table/graylog') }}"
});
</script>

View File

@@ -23,6 +23,6 @@
device: '{{ $device ?: '' }}'
};
},
url: "ajax/table/syslog"
url: "{{ url('/ajax/table/syslog') }}"
});
</script>