Skip to content

Commit

Permalink
#89 add NC17 support, #86, #85
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstocker committed Nov 1, 2019
1 parent cba359f commit 862f3b6
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 111 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,4 +1,10 @@
# SensorLogger

### 0.1.2nc UNRELEASED
* #85 Fixed error on submitting 0 values
* #89 Updated to support Nextcloud 17
* #86 Fixed fatal on widgetTemplateName

### 0.1.1nc RELEASED
* jqPlot cleanup
* Updated Screenshots
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Expand Up @@ -5,7 +5,7 @@
<description>SensorLogger for ownCloud enables users to log data provided by sensor devices</description>
<licence>AGPL</licence>
<author>Alexander Stocker</author>
<version>0.1.1</version>
<version>0.1.2</version>
<namespace>SensorLogger</namespace>
<category>tools</category>
<ocsid>174814</ocsid>
Expand All @@ -28,7 +28,7 @@
<screenshot>https://www.html5live.at/wp-content/uploads/2019/05/sensorlogger-nc16-widget-sidebar.png</screenshot>
<screenshot>https://www.html5live.at/wp-content/uploads/2019/05/sensorlogger-nc16-device-edit.png</screenshot>
<dependencies>
<nextcloud min-version="14" max-version="16"/>
<nextcloud min-version="15" max-version="19"/>
<database min-version="5.7">mysql</database>
<php min-version="7.0" max-version="7.3"/>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion controller/apisensorloggercontroller.php
Expand Up @@ -127,7 +127,7 @@ public function createLog()
if (!(int)$param['dataTypeId']) {
$this->errors[] = 'dataTypeId needs to be an integer';
}
if (!(int)$param['value'] && !(float)$param['value']) {
if (!is_numeric($param['value'])) {
$this->errors[] = 'value needs to be an integer or float';
}
}
Expand Down
7 changes: 6 additions & 1 deletion lib/Widgets/MaxValues24hWidget.php
Expand Up @@ -10,10 +10,15 @@
use OCA\SensorLogger\Widget;
use OCA\SensorLogger\Widgets\iWidget;

/**
* Class MaxValues24hWidget
* @package OCA\SensorLogger\Widgets
* @deprecated will be removed and replace by something smarter and less expensive
*/
class MaxValues24hWidget extends Widget implements iWidget
{
protected $identifier = 'max_values_24h';
protected $displayName = '24h max Values';
protected $displayName = '24h max Values @deprecated';
protected $templateName = 'maxValues24h';
private $userId;
private $connection;
Expand Down
211 changes: 108 additions & 103 deletions templates/widget_dashboard.php
@@ -1,130 +1,135 @@
<?php $widgets = $_['widgets']; ?>
<?php if($widgets) { ?>
<?php foreach ($widgets as $widget) { ?>
<div id="column-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>" class="column">
<div id="dashboard-widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>"
<?php if ($widgets) { ?>
<?php foreach ($widgets as $widget) { ?>
<div id="column-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>" class="column">
<div id="dashboard-widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>"
class="widget dashboard-widget dragbox"
data-id="<?php p($widget->getDeviceId()); ?>"
data-widget-type="<?php p($widget->getType()); ?>">
<h2 class="widget-header ui-widget-header">
<h2 class="widget-header ui-widget-header">
<?php p($widget->getName()); ?> -
<small><?php p($l->t('Widget '.$widget->getDisplayName())); ?></small>
<?php if($widget->getType() === 'chart') { ?>
<a href="#" id="zoom_reset" title="<?php p($l->t('Reset Chart')); ?>" class="reset opIcons">
<span class="icon icon-reset-white"></span>
</a>
<?php } ?>
<a href="#" class="widget-delete opIcons" title="<?php p($l->t('Delete Widget')); ?>">
<small><?php p($l->t('Widget ' . $widget->getDisplayName())); ?></small>
<?php if ($widget->getType() === 'chart') { ?>
<a href="#" id="zoom_reset" title="<?php p($l->t('Reset Chart')); ?>" class="reset opIcons">
<span class="icon icon-reset-white"></span>
</a>
<?php } ?>
<a href="#" class="widget-delete opIcons" title="<?php p($l->t('Delete Widget')); ?>">
<span class="icon icon-delete-white"
data-id="widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>">
data-id="widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>">
</span>
</a>
</h2>
</a>
</h2>

<div class="section <?php p($widget->getType()); ?>">
<div class="section <?php p($widget->getType()); ?>">

<?php if($widget->getType() === 'last') { ?>
<?php if($widget->getLog()) { ?>
<?php if(is_array($widget->getLog()->getData()) && !empty($widget->getLog()->getData())) { ?>
<?php foreach ($widget->getLog()->getData() as $dataLog) { ?>
<h3><?php p($dataLog->getValue()); ?> <?php p($dataLog->getShort()); ?></h3>
<small><?php p($dataLog->getDescription()); ?></small>
<?php } ?>
<?php } else { ?>
<h3><?php p($widget->getLog()->getTemperature()); ?>°C</h3>
<h3><?php p($widget->getLog()->getHumidity()); ?>% r.F.</h3>
<?php } ?>
<h3><?php p($widget->getLog()->getCreatedAt()); ?> UTC</h3>
<?php } else { ?>
<div class="center">
<div class="icon-info"></div>
<span class="center">No data</span>
<p>Read
<a href="https://github.com/alexstocker/sensorlogger/wiki"
title="SensorLogger Wiki" target="_blank">SensorLogger Wiki</a>
</p>
</div>
<?php } ?>
<?php } else if ($widget->getType() === 'list') { ?>
<?php if($widget->getLog()) { ?>
<table style="width: 100%;">
<?php foreach ($widget->getLog() as $dataLog) { ?>
<tr ><td colspan="3" class="right"><small><?php p($dataLog->getCreatedAt()); ?></small></td></tr>
<?php if ($widget->getType() === 'last') { ?>
<?php if ($widget->getLog()) { ?>
<?php if (is_array($widget->getLog()->getData()) && !empty($widget->getLog()->getData())) { ?>
<?php foreach ($widget->getLog()->getData() as $dataLog) { ?>
<h3><?php p($dataLog->getValue()); ?><?php p($dataLog->getShort()); ?></h3>
<small><?php p($dataLog->getDescription()); ?></small>
<?php } ?>
<?php } else { ?>
<h3><?php p($widget->getLog()->getTemperature()); ?>°C</h3>
<h3><?php p($widget->getLog()->getHumidity()); ?>% r.F.</h3>
<?php } ?>
<h3><?php p($widget->getLog()->getCreatedAt()); ?> UTC</h3>
<?php } else { ?>
<div class="center">
<div class="icon-info"></div>
<span class="center">No data</span>
<p>Read
<a href="https://github.com/alexstocker/sensorlogger/wiki"
title="SensorLogger Wiki" target="_blank">SensorLogger Wiki</a>
</p>
</div>
<?php } ?>
<?php } else if ($widget->getType() === 'list') { ?>
<?php if ($widget->getLog()) { ?>
<table style="width: 100%;">
<?php foreach ($widget->getLog() as $dataLog) { ?>
<tr>
<td colspan="3" class="right">
<small><?php p($dataLog->getCreatedAt()); ?></small></td>
</tr>

<?php if (empty($dataLog->getData())) { ?>
<?php if (empty($dataLog->getData())) { ?>

<tr>
<td>Temperature</td>
<td class="right"><?php p($dataLog->getTemperature()); ?></td>
<td class="center">°C</td>
</tr>
<tr>
<td>Humidity</td>
<td class="right"><?php p($dataLog->getHumidity()); ?></td>
<td class="center">% r.F.</td>
</tr>
<tr>
<td>Temperature</td>
<td class="right"><?php p($dataLog->getTemperature()); ?></td>
<td class="center">°C</td>
</tr>
<tr>
<td>Humidity</td>
<td class="right"><?php p($dataLog->getHumidity()); ?></td>
<td class="center">% r.F.</td>
</tr>

<?php } else { ?>
<?php } else { ?>

<?php foreach ($dataLog->getData() as $log) { ?>
<tr>
<td><?php p($log->getType()); ?></td>
<td class="right"><?php p($log->getValue()); ?></td>
<td class="center"> <?php p($log->getShort()); ?></td>
</tr>
<?php } ?>
<?php foreach ($dataLog->getData() as $log) { ?>
<tr>
<td><?php p($log->getType()); ?></td>
<td class="right"><?php p($log->getValue()); ?></td>
<td class="center"> <?php p($log->getShort()); ?></td>
</tr>
<?php } ?>

<?php } ?>
<?php } ?>

<tr><td colspan="3" >--</td></tr>
<?php } ?>
</table>
<?php } else { ?>
<div class="center">
<div class="icon-info"></div>
<span class="center">No data</span>
<p>Read
<a href="https://github.com/alexstocker/sensorlogger/wiki"
title="SensorLogger Wiki" target="_blank">SensorLogger Wiki</a>
</p>
</div>
<?php } ?>
<?php ?>
<?php } else if($widget->getType() === 'chart') { ?>
<tr>
<td colspan="3">--</td>
</tr>
<?php } ?>
</table>
<?php } else { ?>
<div class="center">
<div class="icon-info"></div>
<span class="center">No data</span>
<p>Read
<a href="https://github.com/alexstocker/sensorlogger/wiki"
title="SensorLogger Wiki" target="_blank">SensorLogger Wiki</a>
</p>
</div>
<?php } ?>
<?php ?>
<?php } else if ($widget->getType() === 'chart') { ?>

<?php //var_dump($widget); ?>
<div class="widget widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>">
<?php //var_dump($widget)//$device = $_['device'] ?>
<div id="widget-plotArea-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>" class="chartcontainer" data-id="<?php p($widget->getDeviceId()); ?>"></div>
</div>
<div>
<?php //var_dump($widget); ?>
<div class="widget widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>">
<?php //var_dump($widget)//$device = $_['device'] ?>
<div id="widget-plotArea-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>"
class="chartcontainer" data-id="<?php p($widget->getDeviceId()); ?>"></div>
</div>
<div>

</div>
<?php } else if($widget->getType() === 'realTimeChart') { ?>
</div>
<?php } else if ($widget->getType() === 'realTimeChart') { ?>

<?php //var_dump($widget); ?>
<div class="widget widget-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>">
<?php //var_dump($widget)//$device = $_['device'] ?>
<div id="widget-realTimePlotArea-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>" class="chartcontainer" data-id="<?php p($widget->getDeviceId()); ?>"></div>
<div id="widget-realTimePlotArea-<?php p($widget->getType()); ?>-<?php p($widget->getDeviceId()); ?>"
class="chartcontainer" data-id="<?php p($widget->getDeviceId()); ?>"></div>
</div>
<div>

</div>
<?php } else { ?>
<?php print_unescaped($this->inc('widgets/'.$widget->widgetTemplateName(), array('widget' => $widget))); ?>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
<?php } else { ?>
<div class="widget dashboard-widget">
<div class="widget-header"></div>
<div id="emptycontent" class="">
<div class="icon-info"></div>
<h2>No dashboard widget configured</h2>
<p>Read <a href="https://github.com/alexstocker/sensorlogger/wiki/Users#widgets"
title="SensorLogger Wiki Dashboard Widgets" target="_blank">SensorLogger Wiki Dashboard Widgets</a></p>
</div>
</div>
<div class="widget dashboard-widget">
<div class="widget-header"></div>
<div id="emptycontent" class="">
<div class="icon-info"></div>
<h2>No dashboard widget configured</h2>
<p>Read <a href="https://github.com/alexstocker/sensorlogger/wiki/Users#widgets"
title="SensorLogger Wiki Dashboard Widgets" target="_blank">SensorLogger Wiki Dashboard
Widgets</a></p>
</div>
</div>
<?php } ?>
3 changes: 0 additions & 3 deletions templates/widgets/maxValues24h.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/curl/post_extend.php
@@ -1,7 +1,7 @@
<?php
$url = 'http://nextcloud-dev.loc/index.php/apps/sensorlogger/api/v1/createlog/';

$humidity = mt_rand (1.00*10, 99.99*10) / 10;
$humidity = 0;
$temperature = mt_rand (-9.00*10, 49.99*10) / 10;
$co2 = mt_rand (1*10, 1000*10) / 10;

Expand Down

0 comments on commit 862f3b6

Please sign in to comment.