Skip to content

Commit

Permalink
2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Rello committed May 6, 2020
1 parent b2a88b2 commit 5248918
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 2.3.0 - 2020-05-xx
## 2.3.0 - 2020-05-06
### Added
- Enable filters in reports [#41](https://github.com/rello/analytics/issues/41)

Expand All @@ -10,6 +10,7 @@

### Fixed
- Thresholds not working in table [#39](https://github.com/rello/analytics/issues/39)
- Thresholds not accepting commas

## 2.2.3 - 2020-04-27
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ From data to report. This on premise data warehouse solution provides modular da
(*work in progress)
]]></description>
<version>2.2.3</version>
<version>2.3.0</version>
<licence>agpl</licence>
<author>Marcel Scherello</author>
<namespace>Analytics</namespace>
Expand Down
19 changes: 11 additions & 8 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ OCA.Analytics.Backend = {
url = OC.generateUrl('apps/analytics/data/public/') + token;
}

const filterOptions = JSON.parse(document.getElementById('filterOptions').value);
let filterOptions = [];
if (document.getElementById('sharingToken').value === '') {
filterOptions = JSON.parse(document.getElementById('filterOptions').value);
}

$.ajax({
type: 'GET',
Expand All @@ -341,7 +344,7 @@ OCA.Analytics.Backend = {
document.getElementById('reportSubHeader').innerText = data.options.subheader;
document.getElementById('reportSubHeader').style.removeProperty('display');
}
if (parseInt(data.options.type) === OCA.Analytics.TYPE_INTERNAL_DB) {
if (parseInt(data.options.type) === OCA.Analytics.TYPE_INTERNAL_DB && document.getElementById('sharingToken').value === '') {
document.getElementById('filterDimensions').value = JSON.stringify(data.dimensions);
document.getElementById('filterContainer').style.removeProperty('display');
}
Expand Down Expand Up @@ -395,19 +398,19 @@ OCA.Analytics.Backend = {
document.addEventListener('DOMContentLoaded', function () {
OCA.Analytics.initialDocumentTitle = document.title;
document.getElementById('analytics-warning').classList.add('hidden');
document.getElementById('filterOptions').value = JSON.stringify({
'drilldown': {},
'filter': {'dimension1': {}, 'dimension2': {}}
})

if (document.getElementById('sharingToken').value === '') {
document.getElementById('analytics-intro').attributes.removeNamedItem('hidden');
OCA.Analytics.Core.initApplication();
document.getElementById('newDatasetButton').addEventListener('click', OCA.Analytics.Navigation.handleNewDatasetButton);
document.getElementById('addFilterIcon').addEventListener('click', OCA.Analytics.Filter.openFilterDialog);
document.getElementById('drilldownIcon').addEventListener('click', OCA.Analytics.Filter.openDrilldownDialog);
if (document.getElementById('advanced').value === 'false') {
document.getElementById('createDemoReport').addEventListener('click', OCA.Analytics.Navigation.createDemoReport);
document.getElementById('addFilterIcon').addEventListener('click', OCA.Analytics.Filter.openFilterDialog);
document.getElementById('drilldownIcon').addEventListener('click', OCA.Analytics.Filter.openDrilldownDialog);
document.getElementById('filterOptions').value = JSON.stringify({
'drilldown': {},
'filter': {'dimension1': {}, 'dimension2': {}}
})
}
} else {
OCA.Analytics.Backend.getData();
Expand Down
15 changes: 14 additions & 1 deletion lib/Controller/ThresholdController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function read(int $datasetId)
*/
public function create(int $datasetId, $dimension1, $option, $dimension3, int $severity)
{
$dimension3 = $this->floatvalue($dimension3);
return $this->ThresholdMapper->createThreshold($datasetId, $dimension1, $dimension3, $option, $severity);
}

Expand Down Expand Up @@ -101,7 +102,7 @@ public function validate(int $datasetId, $dimension1, $dimension2, $dimension3)

foreach ($thresholds as $threshold) {
//$this->logger->error('ThresholdController 104: ' . $threshold['dimension3'].'==='.$threshold['option'].'==='.$dimension3);
if ($threshold['dimension1'] === $dimension1 OR $threshold['dimension1'] === '*') {
if ($threshold['dimension1'] === $dimension1 or $threshold['dimension1'] === '*') {
if (version_compare($dimension3, $threshold['dimension3'], $threshold['option'])) {
$this->NotificationManager->triggerNotification(NotificationManager::SUBJECT_THRESHOLD, $datasetId, $threshold['id'], ['report' => $datasetMetadata['name'], 'subject' => $dimension1, 'rule' => $threshold['option'], 'value' => $threshold['dimension3']], $datasetMetadata['user_id']);
$result = 'Threshold value met';
Expand All @@ -110,4 +111,16 @@ public function validate(int $datasetId, $dimension1, $dimension2, $dimension3)
}
return $result;
}

private function floatvalue($val)
{
$val = str_replace(",", ".", $val);
$val = preg_replace('/\.(?=.*\.)/', '', $val);
$val = preg_replace('/[^0-9-.]+/', '', $val);
if (is_numeric($val)) {
return number_format(floatval($val), 2, '.', '');
} else {
return false;
}
}
}

0 comments on commit 5248918

Please sign in to comment.