293 lines
11 KiB
PHP
293 lines
11 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => "Report"])
|
|
@include('layouts.shared/head-css', ["mode" => $mode ?? '', "demo" => $demo ?? ''])
|
|
<link href="{{asset('assets/libs/flatpickr/flatpickr.min.css')}}" rel="stylesheet" type="text/css" />
|
|
<link href="{{asset('assets/libs/bootstrap-datepicker/bootstrap-datepicker.min.css')}}" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body class="loading" style="background:#fff">
|
|
<div class="loader text-white">
|
|
<i class="mdi mdi-loading mdi-spin mdi-48px" aria-hidden="true"></i><br />Loading
|
|
</div>
|
|
|
|
<div class="row">
|
|
@foreach($metrics as $metric)
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="dropdown float-end">
|
|
<a href="#" class="dropdown-toggle arrow-none card-drop" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="mdi mdi-dots-vertical"></i>
|
|
</a>
|
|
<div class="dropdown-menu dropdown-menu-end">
|
|
@foreach($metric->available_charts as $chart)
|
|
<!-- item-->
|
|
<a href="/metricreport/report?id={{$metric->id}}&type={{$chart->type}}&chart={{$chart->chart}}&period={{$metric->periods[0]->value}}" class="dropdown-item">{{$chart->name}} Chart</a>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
<h4 class="header-title mb-0">{{$metric->name}}</h4>
|
|
<h6>{{$metric->periods[0]->label}}</h6>
|
|
<div class="widget-chart text-center" dir="ltr">
|
|
<div id="chart-{{$metric->id}}" class="mt-0" data-colors="#f1556c"></div>
|
|
<h5 class="text-muted mt-0">{{$metric->label}}</h5>
|
|
<h2>{{$metric->value}}</h2>
|
|
</div>
|
|
</div>
|
|
</div> <!-- end card -->
|
|
</div> <!-- end col-->
|
|
@endforeach
|
|
</div>
|
|
|
|
<style type="text/css">
|
|
.btn-xs {border-radius: 6px!important;}
|
|
.underline {border-bottom: 2px solid #B9B970;}
|
|
.loader{
|
|
position: absolute;
|
|
height: 100vh;
|
|
width: 100vw;
|
|
z-index: 999;
|
|
background-color: rgba(0,0,0,0.5);
|
|
padding-top: calc(50vh - 24px);
|
|
padding-left: calc(50vw - 24px);
|
|
}
|
|
</style>
|
|
|
|
<!-- end container -->
|
|
@include('layouts.shared/footer-script')
|
|
<!-- third party js -->
|
|
<script src="{{asset('assets/libs/flatpickr/flatpickr.min.js')}}"></script>
|
|
<script src="{{asset('assets/libs/apexcharts/apexcharts.min.js')}}"></script>
|
|
<!-- third party js ends -->
|
|
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
$('.loader').hide()
|
|
$('#period').change(function(){
|
|
let href = new URL(window.location.href);
|
|
href.searchParams.set('period', $(this).val() );
|
|
$('.loader').show()
|
|
window.location.href = href.toString()
|
|
});
|
|
|
|
$('#graph-wrapper a').click(function(event) {
|
|
event.preventDefault();
|
|
$('.loader').show()
|
|
console.log($(this).attr('href'))
|
|
let href = new URL(document.location.origin + $(this).attr('href'));
|
|
href.searchParams.set('period', $('#period').val() );
|
|
window.location.href = href.toString()
|
|
});
|
|
|
|
$('.leaderboard-next').click(function(){
|
|
let href = new URL(window.location.href);
|
|
href.searchParams.set('level', {{$graph->current_level}}-1 );
|
|
window.location.href = href.toString()
|
|
})
|
|
$('.leaderboard-prev').click(function(){
|
|
let href = new URL(window.location.href);
|
|
href.searchParams.set('level', {{$graph->current_level}}+1 );
|
|
window.location.href = href.toString()
|
|
})
|
|
|
|
$('#export').click(function(){
|
|
let href = new URL(window.location.href);
|
|
window.location.href = href.origin + '/form/metricreport' + href.search + '&download=1'
|
|
})
|
|
$('#email-export').click(function(){
|
|
let href = new URL(window.location.href);
|
|
$('.loader').show()
|
|
$.get( href.origin + '/form/metricreport' + href.search + '&download=1&email=1', function( data ) {
|
|
$('.loader').hide()
|
|
$('#graph-wrapper').prepend('<div class="alert alert-success mt-3">Email send Successfully!</div>');
|
|
});
|
|
})
|
|
|
|
let colors = {!!json_encode($colors)!!};
|
|
colors = colors.map(c => '#'+c)
|
|
let options = {}
|
|
let chart = {}
|
|
let values = []
|
|
|
|
@if($graph->type == 'grouped')
|
|
@switch($post['type'])
|
|
@case('graphical')
|
|
values = {!!json_encode($graph->values)!!}
|
|
@if($post['chart'] == 'pie')
|
|
options = {
|
|
series: values.map(a => a.value),
|
|
chart: {
|
|
width: 500,
|
|
type: 'pie',
|
|
},
|
|
labels: values.map(a => a.label),
|
|
responsive: [{
|
|
breakpoint: 480,
|
|
options: {
|
|
chart: {
|
|
width: 380
|
|
},
|
|
legend: {
|
|
position: 'bottom'
|
|
}
|
|
}
|
|
}]
|
|
};
|
|
|
|
@elseif($post['chart'] == 'bar')
|
|
options = {
|
|
series: [{
|
|
name: "{{$graph->label}}",
|
|
data: values.map(a => a.value)
|
|
}],
|
|
chart: {
|
|
height: 350,
|
|
type: '{{$post['chart']}}',
|
|
zoom: {
|
|
enabled: false
|
|
}
|
|
},
|
|
dataLabels: {
|
|
enabled: false
|
|
},
|
|
stroke: {
|
|
curve: 'straight'
|
|
},
|
|
|
|
grid: {
|
|
row: {
|
|
colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
|
|
opacity: 0.5
|
|
},
|
|
},
|
|
xaxis: {
|
|
categories: values.map(a => a.label),
|
|
}
|
|
};
|
|
@endif
|
|
|
|
@break
|
|
|
|
@case('trend')
|
|
values = {!!json_encode($graph->values)!!}
|
|
options = {
|
|
series: values.map(m => {
|
|
return {
|
|
name: m.metric,
|
|
data: m.stats.map(a => a.y)
|
|
}
|
|
}),
|
|
// series: [{
|
|
// name: "{{$graph->label}}",
|
|
// data: values.map(a => a.y)
|
|
// }],
|
|
chart: {
|
|
height: 350,
|
|
type: '{{$post['chart']}}',
|
|
zoom: {
|
|
enabled: false
|
|
}
|
|
},
|
|
dataLabels: {
|
|
enabled: false
|
|
},
|
|
stroke: {
|
|
curve: 'straight'
|
|
},
|
|
|
|
grid: {
|
|
row: {
|
|
colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
|
|
opacity: 0.5
|
|
},
|
|
},
|
|
xaxis: {
|
|
categories: values[0].stats.map(a => a.x),
|
|
}
|
|
};
|
|
console.log(options)
|
|
@break
|
|
|
|
@endswitch
|
|
|
|
@elseif($graph->type == 'simple')
|
|
@switch($post['type'])
|
|
@case('graphical')
|
|
options = {
|
|
series: [{{ $graph->max > 0 ? ceil(($graph->value/$graph->max)*100) : 0 }}],
|
|
chart: {
|
|
height: 250,
|
|
type: 'radialBar',
|
|
},
|
|
plotOptions: {
|
|
radialBar: {
|
|
hollow: {
|
|
size: '68%',
|
|
}
|
|
},
|
|
},
|
|
fill: {
|
|
type: 'gradient',
|
|
gradient: {
|
|
shade: 'dark',
|
|
shadeIntensity: 0.15,
|
|
inverseColors: false,
|
|
opacityFrom: 1,
|
|
opacityTo: 1,
|
|
stops: [0, 50, 65, 91]
|
|
},
|
|
},
|
|
stroke: {
|
|
dashArray: 4
|
|
},
|
|
colors: colors,
|
|
labels: ['{{$graph->label}}'],
|
|
};
|
|
@break
|
|
@case('trend')
|
|
values = {!!json_encode($graph->values)!!}
|
|
options = {
|
|
series: [{
|
|
name: "{{$graph->label}}",
|
|
data: values.map(a => a.y)
|
|
}],
|
|
chart: {
|
|
height: 350,
|
|
type: '{{$post['chart']}}',
|
|
zoom: {
|
|
enabled: false
|
|
}
|
|
},
|
|
dataLabels: {
|
|
enabled: false
|
|
},
|
|
stroke: {
|
|
curve: 'straight'
|
|
},
|
|
|
|
grid: {
|
|
row: {
|
|
colors: ['#f3f3f3', 'transparent'], // takes an array which will be repeated on columns
|
|
opacity: 0.5
|
|
},
|
|
},
|
|
xaxis: {
|
|
categories: values.map(a => a.x),
|
|
}
|
|
};
|
|
@break
|
|
|
|
@endswitch
|
|
|
|
|
|
@endif
|
|
chart = new ApexCharts(document.querySelector("#chart-{{$graph->id}}"), options);
|
|
chart.render();
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|
|
|