Add BASE_URL constant to page and have AJAX calls use it
This commit is contained in:
parent
2325573c50
commit
cb772a3c62
@ -41,8 +41,12 @@ if(!function_exists('show_datetime')) {
|
||||
* @param \Carbon\Carbon $date
|
||||
* @return string
|
||||
*/
|
||||
function show_datetime(\Carbon\Carbon $date)
|
||||
function show_datetime(\Carbon\Carbon $date=null)
|
||||
{
|
||||
if(empty($date)) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
$timezone = 'UTC';
|
||||
if (Auth::check()) {
|
||||
$timezone = Auth::user()->timezone ?: $timezone;
|
||||
|
@ -2,15 +2,3 @@
|
||||
* admin functions, mostly map/mapping related
|
||||
*/
|
||||
|
||||
function phpvms_vacentral_airport_lookup(icao, callback) {
|
||||
$.ajax({
|
||||
url: '/api/airports/' + icao + '/lookup',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'x-api-key': PHPVMS_USER_API_KEY
|
||||
}
|
||||
}).done(function (data, status) {
|
||||
callback(data.data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,16 @@
|
||||
@section('scripts')
|
||||
<script>
|
||||
function phpvms_vacentral_airport_lookup(icao, callback) {
|
||||
$.ajax({
|
||||
url: BASE_URL + '/api/airports/'+ icao + '/lookup',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'x-api-key': PHPVMS_USER_API_KEY
|
||||
}
|
||||
}).done(function (data, status) {
|
||||
callback(data.data);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
const BASE_URL ='{!! url('/') !!}';
|
||||
@if (Auth::user())
|
||||
const PHPVMS_USER_API_KEY = "{!! Auth::user()->api_key !!}";
|
||||
@else
|
||||
|
@ -3,7 +3,7 @@
|
||||
function changeStatus(values) {
|
||||
var destContainer = '#pirep_' + values.pirep_id + '_container';
|
||||
$.ajax({
|
||||
url: '/admin/pireps/' + values.pirep_id + '/status',
|
||||
url: BASE_URL + '/admin/pireps/' + values.pirep_id + '/status',
|
||||
data: values,
|
||||
type: 'POST',
|
||||
headers: {
|
||||
|
Loading…
Reference in New Issue
Block a user