From 5248918a50e42acf7aff7fcb2165cfb35695f723 Mon Sep 17 00:00:00 2001 From: Rello Date: Wed, 6 May 2020 22:14:40 +0200 Subject: [PATCH] 2.3.0 --- CHANGELOG.md | 3 ++- appinfo/info.xml | 2 +- js/app.js | 19 +++++++++++-------- lib/Controller/ThresholdController.php | 15 ++++++++++++++- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98aff01e..970395e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -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 diff --git a/appinfo/info.xml b/appinfo/info.xml index 1e9f57c7..e4451251 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -18,7 +18,7 @@ From data to report. This on premise data warehouse solution provides modular da (*work in progress) ]]> - 2.2.3 + 2.3.0 agpl Marcel Scherello Analytics diff --git a/js/app.js b/js/app.js index 7807b616..8eb66db0 100644 --- a/js/app.js +++ b/js/app.js @@ -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', @@ -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'); } @@ -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(); diff --git a/lib/Controller/ThresholdController.php b/lib/Controller/ThresholdController.php index d612fc97..02666076 100644 --- a/lib/Controller/ThresholdController.php +++ b/lib/Controller/ThresholdController.php @@ -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); } @@ -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'; @@ -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; + } + } } \ No newline at end of file