Korrekturen
URLs angepasst Statistik Einheit automatisch ändern (MB -> GB)
This commit is contained in:
@@ -1,36 +1,33 @@
|
||||
var dataSlider = [];
|
||||
var dataPeriods = [];
|
||||
|
||||
function statisticBuilder(builder, plugin)
|
||||
{
|
||||
var jsonData = jQuery.ajax({
|
||||
function statisticBuilder(builder, plugin) {
|
||||
jQuery.ajax({
|
||||
url: 'api/v1/statistic.php',
|
||||
method: 'POST',
|
||||
data: { id: builder.id, plugin: plugin, type: 'googleChart' },
|
||||
dataType: 'json',
|
||||
async: true
|
||||
}).done(function(data)
|
||||
{
|
||||
if (data.error != null)
|
||||
{
|
||||
}).done(function (data) {
|
||||
if (data.error != null) {
|
||||
if (data.error.message == 'Empty data.')
|
||||
jQuery('#chart_log_'+builder.id).html('<br /><br /><strong class="red">' + _t('Es sind noch keine Werte verfügbar. Werte werden alle %%s Minuten eingetragen.', builder.cycle) + '</strong>');
|
||||
jQuery('#chart_log_' + builder.id).html('<br /><br /><strong class="red">' + _t('Es sind noch keine Werte verfügbar. Werte werden alle %%s Minuten eingetragen.', builder.cycle) + '</strong>');
|
||||
else
|
||||
jQuery('#chart_log_'+builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehler: %%s', data.error.message) + '</strong>');
|
||||
|
||||
jQuery('#chart_log_' + builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehler: %%s', data.error.message) + '</strong>');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
dataPeriods[builder.id] = data.data.statistic.periods;
|
||||
|
||||
|
||||
var myData = new google.visualization.DataTable(data.data.statistic);
|
||||
|
||||
jQuery('#chart_log_'+builder.id).html('');
|
||||
var myDashboard = new google.visualization.Dashboard(document.getElementById('dashboard_log_'+builder.id));
|
||||
|
||||
|
||||
jQuery('#chart_log_' + builder.id).html('');
|
||||
var myDashboard = new google.visualization.Dashboard(document.getElementById('dashboard_log_' + builder.id));
|
||||
|
||||
dataSlider[builder.id] = new google.visualization.ControlWrapper({
|
||||
'controlType': 'DateRangeFilter',
|
||||
'containerId': 'chart_control_log_'+builder.id,
|
||||
'containerId': 'chart_control_log_' + builder.id,
|
||||
'options': {
|
||||
'filterColumnLabel': _t('Zeit'),
|
||||
'ui': {
|
||||
@@ -40,16 +37,14 @@ function statisticBuilder(builder, plugin)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var t = null;
|
||||
|
||||
|
||||
var myLine = new google.visualization.ChartWrapper({
|
||||
'chartType' : 'AreaChart',
|
||||
'containerId' : 'chart_log_'+builder.id,
|
||||
'chartType': 'AreaChart',
|
||||
'containerId': 'chart_log_' + builder.id,
|
||||
'options': {
|
||||
vAxis: { title: builder.label, viewWindow: { max: data.data.statistic.max, min: data.data.statistic.min }, textPosition: 'in', textStyle: { fontSize: 11, color: '#AAAAAA' }, titleTextStyle: { fontSize: 11, color: '#AAAAAA' }, gridlines: { color: '#fff' } },
|
||||
vAxis: { title: builder.label, viewWindow: { max: data.data.statistic.max, min: data.data.statistic.min }, textPosition: 'in', textStyle: { fontSize: 11, color: '#AAAAAA' }, titleTextStyle: { fontSize: 11, color: '#AAAAAA' }, gridlines: { color: '#fff' } },
|
||||
dateFormat: 'dd.MM.yy HH:mm',
|
||||
hAxis: { format: 'dd.MM. HH:mm', textPosition: 'out', gridlines: { color: '#fff' } , textStyle: { fontSize: 11, color: '#AAAAAA' }},
|
||||
hAxis: { format: 'dd.MM. HH:mm', textPosition: 'out', gridlines: { color: '#fff' }, textStyle: { fontSize: 11, color: '#AAAAAA' } },
|
||||
focusTarget: 'category',
|
||||
crosshair: { orientation: 'vertical', trigger: 'both', color: '#AAAAAA', opacity: 0.4 },
|
||||
chartArea: { width: '100%', height: '80%', top: 0 },
|
||||
@@ -80,37 +75,46 @@ function statisticBuilder(builder, plugin)
|
||||
lineDashStyle: (typeof builder.columns[4] != 'undefined' && typeof builder.columns[4].style != 'undefined' && typeof builder.columns[4].style.lineDashStyle != 'undefined') ? [builder.columns[4].style.lineDashStyle, builder.columns[4].style.lineDashStyle] : null
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var formatter = new google.visualization.NumberFormat({ suffix: ' '+builder.unit });
|
||||
|
||||
|
||||
var formatter = new google.visualization.NumberFormat({ suffix: ' ' + builder.unit });
|
||||
|
||||
for (var i = 1; i < builder.columns.length; i++)
|
||||
formatter.format(myData, i);
|
||||
|
||||
|
||||
myDashboard.bind(dataSlider[builder.id], myLine);
|
||||
myDashboard.draw(myData);
|
||||
}).fail(function(xhr, textStatus)
|
||||
{
|
||||
jQuery('#chart_log_'+builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehlercode: %%s', xhr.status) + '</strong>');
|
||||
|
||||
setRange();
|
||||
}).fail(function (xhr, textStatus) {
|
||||
jQuery('#chart_log_' + builder.id).html('<br /><br /><strong class="red">' + _t('Es ist ein Fehler aufgetreten! Fehlercode: %%s', xhr.status) + '</strong>');
|
||||
});
|
||||
}
|
||||
|
||||
function changeRange(dropdown)
|
||||
{
|
||||
var days = Array('seven', 'six', 'five', 'four', 'three', 'two', 'one');
|
||||
function changeRange(dropdown) {
|
||||
var day = dropdown.value;
|
||||
|
||||
if (days.indexOf(day) > -1)
|
||||
{
|
||||
for (var data in dataSlider)
|
||||
{
|
||||
if (typeof dataSlider[data] != 'undefined')
|
||||
{
|
||||
dataSlider[data].setState({'lowValue': new Date(dataPeriods[data][day])});
|
||||
window.localStorage.setItem("days", day);
|
||||
|
||||
setRange();
|
||||
}
|
||||
|
||||
function setRange() {
|
||||
var days = Array('seven', 'six', 'five', 'four', 'three', 'two', 'one');
|
||||
var day = window.localStorage.getItem("days");
|
||||
|
||||
if (days.indexOf(day) > -1) {
|
||||
for (var data in dataSlider) {
|
||||
if (typeof dataSlider[data] != 'undefined') {
|
||||
dataSlider[data].setState({ 'lowValue': new Date(dataPeriods[data][day]) });
|
||||
dataSlider[data].draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
if (window.localStorage.days)
|
||||
document.getElementById("range").value = window.localStorage.days;
|
||||
}, false);
|
||||
@@ -14,15 +14,15 @@
|
||||
<a href="https://willy-tech.de/kontakt/" target="_blank" data-lang="<?php echo $data['language']; ?>"><?php _e('Feedback'); ?></a><br />
|
||||
<a href="<?php echo $data['helpLink']; ?>" target="_blank"><?php _e('Hilfe'); ?></a><br />
|
||||
<a href="https://play.google.com/store/apps/details?id=de.willytech.picontrol" target="_blank" title="<?php _e('Öffne im Play Store'); ?>"><?php _e('App im Play Store'); ?></a><br />
|
||||
<a href="https://bitbucket.org/GSchulte/pi-control/" target="_blank"><?php _e('Git Repo'); ?></a></td>
|
||||
<td rowspan="2"><a href="https://www.die-schultes.eu/" target="_blank"><?php _e('Mein Blog'); ?></a><br />
|
||||
<a href="https://bugs.schultes.dev/projects/pi-control/repository" target="_blank"><?php _e('Git Repo'); ?></a></td>
|
||||
<td rowspan="2"><a href="https://www.schultes.dev/" target="_blank"><?php _e('Mein Blog'); ?></a><br />
|
||||
<td><?php echo $data['version']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong><?php _e('LIZENZ'); ?></strong><span><?php _e('Raspberry Pi ist ein Markenzeichen<br />der %s.', '<a href="https://www.raspberrypi.org/" target="_blank">Raspberry Pi Foundation</a>'); ?></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="footer-copyright"><?php _e('Mit %s entwickelt von %s.', '<span style="color: #F44336;">❤</span>', '<a href="https://willy-tech.de/" target="_blank">Willy Fritzsche</a>'); ?> 2013-2017 <br>Weiterentwickelt von <a href="https://www.die-schultes.eu">Gregor Schulte</a> 2021</div>
|
||||
<div id="footer-copyright"><?php _e('Mit %s entwickelt von %s.', '<span style="color: #F44336;">❤</span>', '<a href="https://willy-tech.de/" target="_blank">Willy Fritzsche</a>'); ?> 2013-2017 <br>Weiterentwickelt von <a href="https://www.schultes.dev">Gregor Schulte</a> 2021-2022</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">var errorHandler = '<?php echo $data['errorHandler']; ?>';</script>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<span><?php _e('Zeitraum'); ?></span>
|
||||
</div>
|
||||
<div class="inner">
|
||||
<select onchange="changeRange(this)">
|
||||
<select id="range" onchange="changeRange(this)">
|
||||
<option name="" value="seven"><?php _e('Alles (7 Tage)'); ?></option>
|
||||
<option name="" value="six"><?php _e('Letzten 6 Tage'); ?></option>
|
||||
<option name="" value="five"><?php _e('Letzten 5 Tage'); ?></option>
|
||||
@@ -36,42 +36,43 @@
|
||||
<span><?php _e('Statistik'); ?></span>
|
||||
<?php showSettingsIcon('?s=settings&do=statistic'); ?>
|
||||
</div>
|
||||
<?php if ($data['msgInfo'] == 'invisible') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Alle Statistiken sind ausgeblendet!'); ?></div>
|
||||
</div>
|
||||
<?php } elseif ($data['msgInfo'] == 'empty') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Es sind noch keine Statistiken verfügbar. Werte werden alle 5 Minuten eingetragen.'); ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($data['msgInfo'] == 'invisible') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Alle Statistiken sind ausgeblendet!'); ?></div>
|
||||
</div>
|
||||
<?php } elseif ($data['msgInfo'] == 'empty') { ?>
|
||||
<div class="inner-info">
|
||||
<div><?php _e('Es sind noch keine Statistiken verfügbar. Werte werden alle 5 Minuten eingetragen.'); ?></div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear-both"></div>
|
||||
<div class="order-3">
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
<div class="box google-controls" id="dashboard_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<div class="inner-header">
|
||||
<span><?php _e($statistic['array']['title']); ?></span>
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
<div class="box google-controls" id="dashboard_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<div class="inner-header">
|
||||
<span><?php _e($statistic['array']['title']); ?></span>
|
||||
</div>
|
||||
<div class="inner text-center padding-0" id="chart_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<img src="public_html/img/loader.svg" style="margin: 20px;" />
|
||||
</div>
|
||||
<div class="inner text-center" id="chart_control_log_<?php echo $statistic['array']['id']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="inner text-center padding-0" id="chart_log_<?php echo $statistic['array']['id']; ?>">
|
||||
<img src="public_html/img/loader.svg" style="margin: 20px;" />
|
||||
</div>
|
||||
<div class="inner text-center" id="chart_control_log_<?php echo $statistic['array']['id']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
||||
<script type="text/javascript" src="public_html/js/statistic_builder.js"></script>
|
||||
<script type="text/javascript">
|
||||
google.load('visualization', '1', {packages:['controls']});
|
||||
google.load('visualization', '51', {
|
||||
packages: ['controls']
|
||||
});
|
||||
google.setOnLoadCallback(createTable);
|
||||
|
||||
function createTable()
|
||||
{
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
statisticBuilder(<?php echo $statistic['json']; ?>, null);
|
||||
<?php } ?>
|
||||
function createTable() {
|
||||
<?php foreach ($data['statistics'] as $statistic) { ?>
|
||||
statisticBuilder(<?php echo $statistic['json']; ?>, null);
|
||||
<?php } ?>
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
Reference in New Issue
Block a user