Add Google Analytics tracking ID to settings and to main template #382 (#551)

This commit is contained in:
Nabeel S 2020-02-12 18:28:11 -05:00 committed by GitHub
parent b9993b9c23
commit 77f2138a1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 94 additions and 51 deletions

View File

@ -40,6 +40,13 @@
options: ''
type: boolean
description: 'Send some data (php version, mysql version) to phpVMS. See AnalyticsSvc code for details'
- key: general.google_analytics_id
name: 'Google Analytics Tracking ID'
group: general
value: ''
options: ''
type: text
description: 'Enter your Google Analytics Tracking ID'
- key: units.distance
name: 'Distance Units'
group: units

View File

@ -70,13 +70,13 @@
<li><a href="{!! url('/admin/roles') !!}"><i class="pe-7s-network"></i>roles</a></li>
@endability
@ability('admin', 'settings')
<li><a href="{{ url('/admin/settings') }}"><i class="pe-7s-config"></i>settings</a></li>
@endability
@ability('admin', 'maintenance')
<li><a href="{{ url('/admin/maintenance') }}"><i class="pe-7s-tools"></i>maintenance</a></li>
@endability
@ability('admin', 'settings')
<li><a href="{{ url('/admin/settings') }}"><i class="pe-7s-config"></i>settings</a></li>
@endability
</ul>
</div>
</li>

View File

@ -2,66 +2,80 @@
@foreach($grouped_settings as $group => $settings)
<div class="card border-blue-bottom">
<div class="content table-responsive table-full-width">
<table class="table table-hover" id="flights-table">
<thead>
<th colspan="2">
<h5>{{ $group }}</h5>
</th>
</thead>
<div class="row">
<table class="table table-hover" id="flights-table">
<thead>
<th colspan="2">
<h5>{{ $group }}</h5>
</th>
</thead>
@foreach($settings as $setting)
<tr>
<td width="70%">
<p>{{ $setting->name }}</p>
<p class="description">
@component('admin.components.info')
{{$setting->description}}
@endcomponent
</p></td>
<td align="center">
@if($setting->type === 'date')
{{ Form::input('text', $setting->id, $setting->value, ['class' => 'form-control', 'id' => 'datepicker']) }}
@elseif($setting->type === 'boolean' || $setting->type === 'bool')
{{ Form::hidden($setting->id, 0) }}
{{ Form::checkbox($setting->id, null, $setting->value) }}
@elseif($setting->type === 'int')
{{ Form::number($setting->id, $setting->value, ['class'=>'form-control']) }}
@elseif($setting->type === 'number')
{{ Form::number($setting->id, $setting->value, ['class'=>'form-control', 'step' => '0.01']) }}
@elseif($setting->type === 'select')
@foreach($settings as $setting)
<tr>
<td width="70%">
<p>{{ $setting->name }}</p>
<p class="description">
@component('admin.components.info')
{{$setting->description}}
@endcomponent
</p></td>
<td align="center">
@if($setting->type === 'date')
{{ Form::input('text', $setting->id, $setting->value, ['class' => 'form-control', 'id' => 'datepicker']) }}
@elseif($setting->type === 'boolean' || $setting->type === 'bool')
{{ Form::hidden($setting->id, 0) }}
{{ Form::checkbox($setting->id, null, $setting->value) }}
@elseif($setting->type === 'int')
{{ Form::number($setting->id, $setting->value, ['class'=>'form-control']) }}
@elseif($setting->type === 'number')
{{ Form::number($setting->id, $setting->value, ['class'=>'form-control', 'step' => '0.01']) }}
@elseif($setting->type === 'select')
@if($setting->id === 'general_theme')
{{ Form::select(
$setting->id,
list_to_assoc($themes),
$setting->value,
['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) }}
@else
{{ Form::select(
@if($setting->id === 'general_theme')
{{ Form::select(
$setting->id,
list_to_assoc(explode(',', $setting->options)),
$setting->value,
['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) }}
list_to_assoc($themes),
$setting->value,
['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) }}
@else
{{ Form::select(
$setting->id,
list_to_assoc(explode(',', $setting->options)),
$setting->value,
['class' => 'select2', 'style' => 'width: 100%; text-align: left;']) }}
@endif
@else
{{ Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) }}
@endif
@else
{{ Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) }}
@endif
</td>
</tr>
@endforeach
</table>
</td>
</tr>
@endforeach
</table>
</div>
{{--<div class="row">
<div class="col-sm-12 text-right">
{{ Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) }}
<a href="{{ route('admin.subfleets.index') }}" class="btn btn-default">Cancel</a>
</div>
</div>--}}
</div>
</div>
@endforeach
<div class="card">
<div class="content">
<div class="text-right">
{{ Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) }}
<a href="{{ route('admin.subfleets.index') }}" class="btn btn-default">Cancel</a>
<div class="row">
<div class="col-sm-12 text-right">
{{ Form::button('Save', ['type' => 'submit', 'class' => 'btn btn-success']) }}
<a href="{{ route('admin.subfleets.index') }}" class="btn btn-default">Cancel</a>
</div>
</div>
</div>
</div>
{{ Form::close() }}
<script>
$(document).ready(function () {

View File

@ -108,5 +108,27 @@ with the EU Cookie Law https://privacypolicies.com/blog/eu-cookie-law
$(".select2").select2({width: 'resolve'});
});
</script>
{{--
Google Analytics tracking code. Only active if an ID has been entered
You can modify to any tracking code and re-use that settings field, or
just remove it completely. Only added as a convenience factor
--}}
@php
$gtag = setting('general.google_analytics_id');
@endphp
@if($gtag)
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ $gtag }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ $gtag }}');
</script>
@endif
{{-- End of the Google Analytics code --}}
</body>
</html>