diff --git a/dashboard_frontend/controllers/widgetsFactoryClasses/WidgetSnap4D3Factory.php b/dashboard_frontend/controllers/widgetsFactoryClasses/WidgetSnap4D3Factory.php new file mode 100755 index 00000000..132e3252 --- /dev/null +++ b/dashboard_frontend/controllers/widgetsFactoryClasses/WidgetSnap4D3Factory.php @@ -0,0 +1,86 @@ +startParams->styleParameters); + $styleParameters->barsColors = []; + $rowParameters = []; + $this->startParams->id_metric = "AggregationSeries"; + $this->startParams->name_w = str_replace("ToBeReplacedByFactory", "AggregationSeries", $this->startParams->name_w); + $myKPIFlag = 0; + + $count = 0; + foreach($this->selectedRows as $selectedRowKey => $selectedRow) + { + switch($selectedRow['high_level_type']) + { + case "KPI": + $myMetricId = $selectedRow['unique_name_id']; + + $link = mysqli_connect($this->host, $this->username, $this->password); + mysqli_select_db($link, $this->schema); + + $q = "SELECT * FROM Dashboard.Descriptions WHERE IdMetric = '$myMetricId'"; + $r = mysqli_query($link, $q); + + if($r) + { + $row = mysqli_fetch_assoc($r); + $myMetricName = $row['description_short']; + } + else + { + $myMetricName = $myMetricId; + } + break; + + case "Sensor": + $myMetricId = $selectedRow['get_instances']; + $myMetricName = $selectedRow['unique_name_id']; + + case "MyKPI": + $myKPIFlag = 1; + if($selectedRow['parameters']) { + $myMetricId = $selectedRow['parameters']; + } else if($selectedRow['get_instances']) { + $myMetricId = $selectedRow['get_instances']; + } + + $myMetricName = $selectedRow['unique_name_id']; + $myMetricType = $selectedRow['low_level_type']; + + default: + //Per ora aggiungiamo solo i KPI, poi si specializzerĂ  + break; + } + + array_push($styleParameters->barsColors, $defaultColors1[$count%7]); + + if ($myKPIFlag != 1) { + $newQueryObj = ["metricId" => $myMetricId, + "metricHighLevelType" => $selectedRow['high_level_type'], + "metricName" => $myMetricName]; + } else { + $newQueryObj = ["metricId" => $myMetricId, + "metricHighLevelType" => $selectedRow['high_level_type'], + "metricName" => $myMetricName, + "metricType" => $myMetricType]; + } + array_push($rowParameters, $newQueryObj); + $count++; + } + + $this->startParams->styleParameters = json_encode($styleParameters); + $this->startParams->rowParameters = json_encode($rowParameters); + //$this->startParams->size_rows = $count; + + return $this->startParams; + } +} \ No newline at end of file diff --git a/dashboard_frontend/js/d3require/d3-require.min.js b/dashboard_frontend/js/d3require/d3-require.min.js new file mode 100755 index 00000000..f825480d --- /dev/null +++ b/dashboard_frontend/js/d3require/d3-require.min.js @@ -0,0 +1,2 @@ +// d3-require v1.2.4 Copyright 2019 Observable, Inc. +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).d3=e.d3||{})}(this,function(e){"use strict";const n=new Map,t=[],r=t.map,o=t.some,s=t.hasOwnProperty,i="https://cdn.jsdelivr.net/npm/",l=/^((?:@[^\/@]+\/)?[^\/@]+)(?:@([^\/]+))?(?:\/(.*))?$/,u=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,c=/\.[^\/]*$/,a=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function p(e){const n=l.exec(e);return n&&{name:n[1],version:n[2],path:n[3]}}function f(e){const t=`${i}${e.name}${e.version?`@${e.version}`:""}/package.json`;let r=n.get(t);return r||n.set(t,r=fetch(t).then(e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!n.has(e.url)&&n.set(e.url,r),e.json()})),r}RequireError.prototype.name=RequireError.name;var d=h(async function(e,n){if(e.startsWith(i)&&(e=e.substring(i.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==n?location:n).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const t=p(e);if(!t)return`${i}${e}`;if(!t.version&&null!=n&&n.startsWith(i)){const e=await f(p(n.substring(i.length)));t.version=e.dependencies&&e.dependencies[t.name]||e.peerDependencies&&e.peerDependencies[t.name]}if(t.path&&!c.test(t.path)&&(t.path+=".js"),t.path&&t.version&&u.test(t.version))return`${i}${t.name}@${t.version}/${t.path}`;const r=await f(t);return`${i}${r.name}@${r.version}/${t.path||function(e){for(const n of a){const t=e[n];if("string"==typeof t)return c.test(t)?t:`${t}.js`}}(r)||"index.js"}`});function h(e){const n=new Map,o=i(null);function s(e){if("string"!=typeof e)return e;let r=n.get(e);return r||n.set(e,r=new Promise((n,r)=>{const o=document.createElement("script");o.onload=()=>{try{n(t.pop()(i(e)))}catch(e){r(new RequireError("invalid module"))}o.remove()},o.onerror=()=>{r(new RequireError("unable to load module")),o.remove()},o.async=!0,o.src=e,window.define=v,document.head.appendChild(o)})),r}function i(n){return t=>Promise.resolve(e(t,n)).then(s)}function l(e){return arguments.length>1?Promise.all(r.call(arguments,o)).then(m):o(e)}return l.alias=function(n){return h((t,r)=>t in n&&(r=null,"string"!=typeof(t=n[t]))?t:e(t,r))},l.resolve=e,l}function m(e){const n={};for(const t of e)for(const e in t)s.call(t,e)&&(null==t[e]?Object.defineProperty(n,e,{get:$(t,e)}):n[e]=t[e]);return n}function $(e,n){return()=>e[n]}function g(e){return"exports"===(e+="")||"module"===e}function v(e,n,s){const i=arguments.length;i<2?(s=e,n=[]):i<3&&(s=n,n="string"==typeof e?[]:e),t.push(o.call(n,g)?e=>{const t={},o={exports:t};return Promise.all(r.call(n,n=>"exports"===(n+="")?t:"module"===n?o:e(n))).then(e=>(s.apply(null,e),o.exports))}:e=>Promise.all(r.call(n,e)).then(e=>"function"==typeof s?s.apply(null,e):s))}v.amd={},e.RequireError=RequireError,e.require=d,e.requireFrom=h,Object.defineProperty(e,"__esModule",{value:!0})}); diff --git a/dashboard_frontend/sql/db_snap4d3_update.sql b/dashboard_frontend/sql/db_snap4d3_update.sql new file mode 100755 index 00000000..3c343959 --- /dev/null +++ b/dashboard_frontend/sql/db_snap4d3_update.sql @@ -0,0 +1,107 @@ +INSERT INTO Dashboard.Widgets +(id, id_type_widget, source_php_widget, min_row, max_row, min_col, max_col, widgetType, unique_metric, numeric_rangeOption, number_metrics_widget, color_widgetOption, dimMap, widgetCategory, isNodeRedSender, domainType, defaultParameters, hasTimer, hasChartColor, hasDataLabels, hasChartLabels, hasTimeRange, hasCartesianPlane, hasChangeMetric, hasAddMode, isCollapsible) +VALUES(null, 'widgetSnap4D3', 'widgetSnap4D3.php', 1, 50, 1, 50, 'Percentuale', '', 1, 1, 1, NULL, 'dataViewer', 'no', NULL, '{ + "actuatorAttribute" : null, + "actuatorEntity" : null, + "actuatorTarget" : null, + "attributeName" : null, + "cancelDate" : null, + "canceller" : null, + "chartColor" : "#ffcc00", + "chartLabelsFontColor" : null, + "chartLabelsFontSize" : null, + "color_w" : "#FFFFFF", + "controlsPosition" : null, + "controlsVisibility" : null, + "dataLabelsFontColor" : null, + "dataLabelsFontSize" : null, + "defaultTab" : null, + "enableFullscreenModal" : "no", + "enableFullscreenTab" : "no", + "entityJson" : null, + "fontColor" : "#000000", + "fontFamily" : "Auto", + "fontSize" : 36, + "frame_color_w" : "rgb(51, 204, 255)", + "frequency_w" : 600, + "headerFontColor" : "#FFFFFF", + "hospitalList" : null, + "infoJson" : null, + "infoMessage_w" : null, + "lastEditDate" : null, + "lastSeries" : null, + "link_w" : "none", + "municipality_w" : null, + "notificatorEnabled" : "no", + "notificatorRegistered" : "no", + "oldParameters" : null, + "parameters" : null, + "scaleX" : null, + "scaleY" : null, + "serviceUri" : null, + "showTitle" : "yes", + "size_columns" : 6, + "size_rows" : 3, + "styleParameters" : null, + "temporal_range_w" : null, + "udm" : "", + "udmPos" : "below", + "viewMode" : null, + "zoomControlsColor" : null, + "zoomFactor" : null +}', 'yes', 'yes', 'no', 'no', 'no', 'no', 'no', 'no', 'no'); + +--- + +INSERT INTO Dashboard.WidgetsIconsMap +(id, mainWidget, targetWidget, snap4CityType, icon, mono_multi, description, available, sm_based, defaultParametersMainWidget, defaultParametersTargetWidget, hasMainWidgetFactory, hasTargetWidgetFactory, comboName, widgetCategory) +VALUES(null, 'widgetSnap4D3', '', 'percentage', 'bar-content-horizontal.png', 'Mono', ' D3 chart viewer', 'true', 'no', '{ + "actuatorAttribute" : null, + "actuatorEntity" : null, + "actuatorTarget" : null, + "attributeName" : null, + "cancelDate" : null, + "canceller" : null, + "chartColor" : "#ffcc00", + "chartLabelsFontColor" : null, + "chartLabelsFontSize" : null, + "color_w" : "#FFFFFF", + "controlsPosition" : null, + "controlsVisibility" : null, + "dataLabelsFontColor" : null, + "dataLabelsFontSize" : null, + "defaultTab" : null, + "enableFullscreenModal" : "no", + "enableFullscreenTab" : "no", + "entityJson" : null, + "fontColor" : "#000000", + "fontFamily" : "Auto", + "fontSize" : 36, + "frame_color_w" : "rgb(51, 204, 255)", + "frequency_w" : 600, + "headerFontColor" : "#FFFFFF", + "hospitalList" : null, + "infoJson" : null, + "infoMessage_w" : null, + "lastEditDate" : null, + "lastSeries" : null, + "link_w" : "none", + "municipality_w" : null, + "notificatorEnabled" : "no", + "notificatorRegistered" : "no", + "oldParameters" : null, + "parameters" : null, + "scaleX" : null, + "scaleY" : null, + "serviceUri" : null, + "showTitle" : "yes", + "size_columns" : 6, + "size_rows" : 3, + "styleParameters" : null, + "temporal_range_w" : null, + "udm" : "", + "udmPos" : "below", + "viewMode" : null, + "zoomControlsColor" : null, + "zoomFactor" : null +}', NULL, 'no', '["no"]', NULL, 'dataViewer'); diff --git a/dashboard_frontend/widgets/widgetSnap4D3.php b/dashboard_frontend/widgets/widgetSnap4D3.php new file mode 100755 index 00000000..a3f6825d --- /dev/null +++ b/dashboard_frontend/widgets/widgetSnap4D3.php @@ -0,0 +1,421 @@ +. */ +include('../config.php'); +header("Cache-Control: private, max-age=$cacheControlMaxAge"); +?> + + + + + + + + +
+
+ + + +
+
+

Loading data, please wait

+
+
+ +
+
+ +
+ +
+
+ No data available +
+
+ +
+
+
+
+
+
\ No newline at end of file