ソースを参照

HUE-7809 [reporting] Adding Counter widget as a graph option

Romain Rigaux 8 年 前
コミット
1c68cf7fd2

+ 1 - 0
desktop/core/src/desktop/static/desktop/js/ko.charts.js

@@ -18,6 +18,7 @@
 
   ko.HUE_CHARTS = {
     TYPES: {
+      COUNTER: "counter",
       LINECHART: "lines",
       BARCHART: "bars",
       TIMELINECHART: "timeline",

+ 4 - 2
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -788,7 +788,8 @@ var Collection = function (vm, collection) {
         facet.widgetType(
             newValue == ko.HUE_CHARTS.TYPES.PIECHART ? 'pie2-widget' :
             (newValue == ko.HUE_CHARTS.TYPES.TIMELINECHART ? 'timeline-widget' :
-            (newValue == ko.HUE_CHARTS.TYPES.GRADIENTMAP ? 'gradient-map-widget' : 'bucket-widget'))
+            (newValue == ko.HUE_CHARTS.TYPES.GRADIENTMAP ? 'gradient-map-widget' :
+            (newValue == ko.HUE_CHARTS.TYPES.COUNTER ? 'hit-widget' : 'bucket-widget')))
         );
       });
 
@@ -1207,7 +1208,8 @@ var Collection = function (vm, collection) {
       hasData = typeof self.template.chartSettings.chartX() != "undefined" && self.template.chartSettings.chartX() != null && self.template.chartSettings.chartYMulti().length > 0;
     }
     else {
-     hasData = typeof self.template.chartSettings.chartX() != "undefined" && self.template.chartSettings.chartX() != null && typeof self.template.chartSettings.chartYSingle() != "undefined" && self.template.chartSettings.chartYSingle() != null ;
+      hasData = typeof self.template.chartSettings.chartX() != "undefined" && self.template.chartSettings.chartX() != null && typeof self.template.chartSettings.chartYSingle() != "undefined" && self.template.chartSettings.chartYSingle() != null
+        || self.template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.COUNTER;
     }
     if (!hasData && self.template.showChart()){
       self.template.showFieldList(true);

+ 18 - 0
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -1313,6 +1313,9 @@ ${ dashboard.layout_skeleton(suffix='search') }
         <div class="dropdown">
           <a class="grid-side-btn" style="padding-right:0" href="javascript:void(0)"
              data-bind="css: {'active': template.showChart() }, click: function(){ template.showChart(true); template.showGrid(false); huePubSub.publish('gridChartForceUpdate'); }">
+            % if HAS_REPORT_ENABLED.get()
+            <i class="fa fa-superscript fa-fw" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.COUNTER"></i>
+            % endif
             <i class="hcha hcha-bar-chart fa-fw" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART"></i>
             <i class="hcha hcha-line-chart fa-fw" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.LINECHART" style="display: none;"></i>
             <i class="hcha hcha-pie-chart fa-fw" data-bind="visible: template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.PIECHART" style="display: none;"></i>
@@ -1326,6 +1329,13 @@ ${ dashboard.layout_skeleton(suffix='search') }
           </a>
 
           <ul class="dropdown-menu">
+            <li>
+              <a href="javascript:void(0)"
+                 data-bind="css: {'active': template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.COUNTER}, click: function(){ template.showChart(true); template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.COUNTER); template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}"
+                 class="active">
+                <i class="fa fa-superscript fa-fw"></i> ${_('Counter')}
+              </a>
+            </li>
             <li>
               <a href="javascript:void(0)"
                  data-bind="css: {'active': template.chartSettings.chartType() == ko.HUE_CHARTS.TYPES.BARCHART}, click: function(){ template.showChart(true); template.chartSettings.chartType(ko.HUE_CHARTS.TYPES.BARCHART); template.showGrid(false); huePubSub.publish('gridChartForceUpdate');}"
@@ -1512,6 +1522,14 @@ ${ dashboard.layout_skeleton(suffix='search') }
         <div data-bind="visible: ! template.hasDataForChart()" style="padding: 10px">${ _('Please select the chart parameters on the left.') }</div>
         <div class="grid-chart-container" data-bind="visible: template.hasDataForChart" style="overflow-x: auto">
 
+        <!-- ko if: widgetType() == 'hit-widget' -->
+          <!-- ko with: $parent -->
+            <!-- ko if: counts().length > 0 -->
+              <span class="big-counter" data-bind="textSqueezer: counts()[0].count"></span>
+            <!-- /ko -->
+          <!-- /ko -->
+        <!-- /ko -->
+
         <!-- ko if: widgetType() == 'bucket-widget' -->
           <!-- ko with: $parent -->