count.blade.php 5.32 KB
Newer Older
1 2 3 4 5
@extends('layouts.subPages')

@section('title', $title )

@section('content')
6 7 8 9 10 11 12
	@php ($width = 400)
	@php ($height = 100)
	@php ($padding = 3)
	@php ($paddingArrow = 4)
	@php ($startX = 20)
	@php ($startY = $height-20)
	@php ($maxCount = intval(str_replace(".", "", $rekordCount)))
13 14 15
	@php ($minCount = $minCount)
	@php ($scaleFromTo = $maxCount - $minCount)
	@php ($yPerSearch = ($startY - $padding - $paddingArrow) / floatval($scaleFromTo))
16 17 18 19
	@php ($entryCount = min(sizeof($oldLogs), 30))
	@php ($daysPerEntry = sizeof($oldLogs) / floatval($entryCount))
	<div id="graph">
		<svg width="100%" height="auto" viewbox="0 0 {{$width}} {{$height}}">
20 21 22 23 24 25 26 27 28 29 30 31 32
			<!-- Data -->
			@php($vStep = ($width - $padding - $paddingArrow - $startX) / floatval(sizeof($oldLogs)-1))
			<polyline
				points="
				@foreach($oldLogs as $key => $value)
				{{$width - $padding - $paddingArrow - (($key-1)*$vStep)}},{{$startY - ((intval(str_replace(".", "", $value['insgesamt'])) - $minCount)  * $yPerSearch)}}
				@endforeach
				{{$startX}},{{$startY}}
				{{$width-$padding-$paddingArrow}},{{$startY}}

				"
				fill="rgba(255,127,0,.2)" stroke="rgb(255,127,0)" stroke-width=".5"
			/>
33 34 35 36 37 38 39
			<!-- Y-Achse -->
			<path d="m{{$startX}} {{$startY}} L{{$startX}} {{$padding}} L{{$startX-1}} {{$padding}} L{{$startX}} {{$padding-1}} L{{$startX+1}} {{$padding}} L{{$startX}} {{$padding}}z" fill="#333" stroke="#333" stroke-width=".7" />
			<!-- Skalierung Y-Achse -->
			@for($i = 0; $i < 10; $i++)
			<line x1="{{$startX-1}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$startX+1}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#333" stroke="#333" stroke-width=".7" />
			<line x1="{{$startX}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$width-$padding-$paddingArrow}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#777" stroke="#777" stroke-width=".2" />
			<text x="{{$startX - 15}}" y="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) + 2 }}" style="font-size: .3em;">
40
			{{ round(($maxCount - ($scaleFromTo * ($i/10.0))) / 1000.0)}}k
41 42 43 44 45 46 47 48 49 50 51 52
			</text>
			@endfor
			<!-- X-Achse -->
			<path d="m{{$startX}} {{$startY}} L{{$width-$padding}} {{$startY}} L{{$width-$padding}} {{$startY-1}} L{{$width-($padding-1)}} {{$startY}} L{{$width-$padding}} {{$startY+1}} L{{$width-$padding}} {{$startY}}z" fill="#333" stroke="#333" stroke-width=".5" />
			@for($i = 0; $i < $entryCount; $i++)
			<line x1="{{ $startX + (($width - $padding - $paddingArrow - $startX) * ($i/($entryCount-1)))}}" y1="{{$startY-1}}" x2="{{ $startX + (($width - $padding - $paddingArrow - $startX) * ($i/($entryCount-1)))}}" y2="{{$startY+1}}" fill="#333" stroke="#333" stroke-width=".7" />
			<text x="{{ $startX + (($width - $padding - $paddingArrow - $startX) * ($i/($entryCount-1)))}}" y="{{$startY + 4}}" style="font-size: .3em;" writing-mode="tb">
			{{ Carbon::now()->subDays(floor(($entryCount-$i) * $daysPerEntry))->format('d.m')}}
			</text>
			@endfor
		</svg>
	</div>
Dominik Hebeler's avatar
Dominik Hebeler committed
53 54 55 56 57
	<p>{{ exec("uptime") }}</p>
	@if( isset($rekordDate) && isset($rekordTagSameTime) && isset($rekordCount) )
		<p>Rekord am {{ $rekordDate }} zur gleichen Zeit <span class="text-info">{{ $rekordTagSameTime }}</span> - insgesamt <span class="text-danger">{{ $rekordCount }}</span></p>
	@endif
	<p>Mittelwert der letzten {{ sizeof($oldLogs) }} Tage: {{ $oldLogs[sizeof($oldLogs)]['median'] }}</p>
58
	<table class="table table-striped">
Dominik Hebeler's avatar
Dominik Hebeler committed
59 60 61 62 63 64 65 66
		<caption>
			<form method="POST" style="display: flex; align-items: center;">
				<div class="form-group" style="max-width: 100px; margin-right: 8px;">
					<label for="days">Tage</label>
					<input class="form-control" type="number" id="days" name="days" value="{{$days}}" />
				</div>
				<div class="form-group" style="max-width: 100px; margin-right: 8px;">
					<label for="interface">Sprache</label>
67 68 69 70 71 72
					<select class="form-control" name="interface" id="interface">
						<option value="all" {{ (Request::input('interface', 'all') == "all" ? "selected" : "")}}>Alle</option>
						<option value="de" {{ (Request::input('interface', 'all') == "de" ? "selected" : "")}}>DE</option>
						<option value="en" {{ (Request::input('interface', 'all') == "en" ? "selected" : "")}}>EN</option>
						<option value="es" {{ (Request::input('interface', 'all') == "es" ? "selected" : "")}}>ES</option>
					</select>
Dominik Hebeler's avatar
Dominik Hebeler committed
73 74 75 76 77 78 79 80 81
				</div>
				<div id="refresh" style="margin-top: 11px; margin-right: 8px;">
					<button type="submit" class="btn btn-sm btn-default">Aktualisieren</button>
				</div>
				<div id="export" style="margin-top: 11px;">
					<button type="submit" name="out" value="csv" class="btn btn-sm btn-default">Als CSV exportieren</button>
				</div>
			</form>
		</caption>
82 83 84 85 86 87 88 89
		<tr>
			<th>Datum</th>
			<th>Suchanfragen zur gleichen Zeit</th>
			<th>Suchanfragen insgesamt</th>
			<th>Mittelwert (bis zum jeweiligen Tag zurück)</th>
		</tr>
		@if( isset($today) )
			<tr>
Dominik Hebeler's avatar
Dominik Hebeler committed
90
				<td>{{ Carbon::now()->format('D, d.m.Y') }}</td>
91 92 93 94 95 96 97
				<td>{{ $today }}</td>
				<td>???</td>
				<td>???</td>
			</tr>
		@endif
		@foreach($oldLogs as $key => $value)
			<tr>
Dominik Hebeler's avatar
Dominik Hebeler committed
98
				<td>{{ Carbon::now()->subDays($key)->format('D, d.m.Y') }}</td>
99 100 101 102 103 104
				<td>{{ $value['sameTime'] }}</td>
				<td>{{ $value['insgesamt'] }}</td>
				<td>{{ $value['median'] }}</td>
			</tr>
		@endforeach
	</table>
Dominik Hebeler's avatar
Dominik Hebeler committed
105

106
@endsection