From 8fb3832a75b73010b7802d276ef9f94c12d6d70d Mon Sep 17 00:00:00 2001 From: mrincon Date: Fri, 13 Nov 2015 13:12:57 +0800 Subject: [PATCH] Fix timezone issue for timeline chart, now it matches the server time. Updated the corresponding getxAxisTickFormat test Fixed version of angular boostrap to use ~0.14.3 due to modal close/dismiss issues Bumped version to 0.2.1 --- .../prDashboardWidgets/timeline/timeline.js | 3 +-- .../prReporting/prUIOption/prUIOptionService.js | 9 ++++----- .../prReporting/prUIOption/prUIOptionService.js | 8 ++++---- bower.json | 2 +- dist/app/app.min.js | 2 +- dist/app/css/demo.css | 16 ++++++++-------- dist/app/css/demo.min.css | 2 +- dist/app/demo.min.js | 2 +- dist/pulsar-reporting-ui-tpls.js | 14 ++++++-------- dist/pulsar-reporting-ui-tpls.min.js | 8 ++++---- dist/pulsar-reporting-ui-tpls.min.js.map | 2 +- dist/pulsar-reporting-ui.js | 14 ++++++-------- dist/pulsar-reporting-ui.min.js | 6 +++--- dist/pulsar-reporting-ui.min.js.map | 2 +- package.json | 2 +- 15 files changed, 43 insertions(+), 49 deletions(-) diff --git a/app/src/prReporting/prDashboardWidgets/timeline/timeline.js b/app/src/prReporting/prDashboardWidgets/timeline/timeline.js index a0604cc..943f312 100644 --- a/app/src/prReporting/prDashboardWidgets/timeline/timeline.js +++ b/app/src/prReporting/prDashboardWidgets/timeline/timeline.js @@ -119,8 +119,7 @@ angular.module('pr.dashboard.widgets.timeline', [ xAxis: { axisLabel: 'Time', tickFormat: function(d) { - console.lo - return prUIOptionService.getxAxisTickFormat(d, $scope.params.granularity, prApi.timezone); + return prUIOptionService.getxAxisTickFormat(d, $scope.params.granularity); } }, showLegend: true diff --git a/app/src/prReporting/prUIOption/prUIOptionService.js b/app/src/prReporting/prUIOption/prUIOptionService.js index dfaa495..24926ef 100644 --- a/app/src/prReporting/prUIOption/prUIOptionService.js +++ b/app/src/prReporting/prUIOption/prUIOptionService.js @@ -174,16 +174,15 @@ angular.module('pr.UIOption') * @description Formats a date according to a granularity, shows a more detailed time if the granularity is higher. * @param {date} date Date to format * @param {string=} granularity (hour or minute) - * @param {string=} timezone Timezone (MST) * @return {object} A date formatted by moment.js */ - getxAxisTickFormat: function(date, granularity, timezone) { + getxAxisTickFormat: function(date, granularity) { if (granularity === 'hour') { - return moment(date).tz(timezone).format('MMM DD, HH:mm'); + return moment(date).format('MMM DD, HH:mm'); } else if (granularity === 'minute') { - return moment(date).tz(timezone).format('MMM DD, HH:mm'); + return moment(date).format('MMM DD, HH:mm'); } else { - return moment(date).tz(timezone).format('MMM DD'); + return moment(date).format('MMM DD'); } }, diff --git a/app/test/prReporting/prUIOption/prUIOptionService.js b/app/test/prReporting/prUIOption/prUIOptionService.js index dbfdb21..97da552 100644 --- a/app/test/prReporting/prUIOption/prUIOptionService.js +++ b/app/test/prReporting/prUIOption/prUIOptionService.js @@ -95,10 +95,10 @@ describe('pr.UIOption.prUIOptionService', function() { }); it('getxAxisTickFormat', function() { - var d = new Date(Date.UTC(115, 7, 10, 17, 05, 0)); - expect(service.getxAxisTickFormat(d, 'hour', 'UTC')).toEqual('Aug 10, 17:05'); - expect(service.getxAxisTickFormat(d, 'minute', 'UTC')).toEqual('Aug 10, 17:05'); - expect(service.getxAxisTickFormat(d, 'day', 'UTC')).toEqual('Aug 10'); + var d = moment('2015-08-10 17:05:00', 'YYYY-MM-DD HH:mm:ss'); + expect(service.getxAxisTickFormat(d, 'hour')).toEqual('Aug 10, 17:05'); + expect(service.getxAxisTickFormat(d, 'minute')).toEqual('Aug 10, 17:05'); + expect(service.getxAxisTickFormat(d, 'day')).toEqual('Aug 10'); }); it('getIndexCellTemplate', function() { diff --git a/bower.json b/bower.json index 9593336..917ce75 100644 --- a/bower.json +++ b/bower.json @@ -27,7 +27,7 @@ "moment": "~2.10.6", "moment-timezone": "0.4.0", "countto": "~1.1.0", - "angular-bootstrap": "0.13.0", + "angular-bootstrap": "~0.14.3", "angular-moment": "0.10.0", "knex": "0.7.6", "jquery-ui": "~1.11.4", diff --git a/dist/app/app.min.js b/dist/app/app.min.js index cbfa366..81c2950 100644 --- a/dist/app/app.min.js +++ b/dist/app/app.min.js @@ -1,5 +1,5 @@ /* - pulsar-reporting-ui | 0.2.0 + pulsar-reporting-ui | 0.2.1 Copyright (C) 2012-2015 eBay Software Foundation Licenses: MIT & Apache 2.0 */ diff --git a/dist/app/css/demo.css b/dist/app/css/demo.css index 821f151..36a843e 100644 --- a/dist/app/css/demo.css +++ b/dist/app/css/demo.css @@ -5,17 +5,17 @@ left: 0; z-index: 10001; height: 2px; - background-color: #ccd1d9; + background-color: #CCD1D9; } #loading-bar .bar { - background: #656d78; + background: #656D78; } /* Fancy blur effect */ #loading-bar .peg { - -moz-box-shadow: #656d78 1px 0 6px 1px; - -ms-box-shadow: #656d78 1px 0 6px 1px; - -webkit-box-shadow: #656d78 1px 0 6px 1px; - box-shadow: #656d78 1px 0 6px 1px; + -moz-box-shadow: #656D78 1px 0 6px 1px; + -ms-box-shadow: #656D78 1px 0 6px 1px; + -webkit-box-shadow: #656D78 1px 0 6px 1px; + box-shadow: #656D78 1px 0 6px 1px; } #loading-bar-spinner { top: auto; @@ -23,6 +23,6 @@ bottom: 15px; } #loading-bar-spinner .spinner-icon { - border-top-color: #656d78; - border-left-color: #656d78; + border-top-color: #656D78; + border-left-color: #656D78; } diff --git a/dist/app/css/demo.min.css b/dist/app/css/demo.min.css index f676dde..f48f7c3 100644 --- a/dist/app/css/demo.min.css +++ b/dist/app/css/demo.min.css @@ -1 +1 @@ -#loading-bar{position:fixed;width:100%;top:0;left:0;z-index:10001;height:2px;background-color:#ccd1d9}#loading-bar .bar{background:#656d78}#loading-bar .peg{-moz-box-shadow:#656d78 1px 0 6px 1px;-ms-box-shadow:#656d78 1px 0 6px 1px;-webkit-box-shadow:#656d78 1px 0 6px 1px;box-shadow:#656d78 1px 0 6px 1px}#loading-bar-spinner{top:auto;left:15px;bottom:15px}#loading-bar-spinner .spinner-icon{border-top-color:#656d78;border-left-color:#656d78} \ No newline at end of file +#loading-bar{position:fixed;width:100%;top:0;left:0;z-index:10001;height:2px;background-color:#CCD1D9}#loading-bar .bar{background:#656D78}#loading-bar .peg{-moz-box-shadow:#656D78 1px 0 6px 1px;-ms-box-shadow:#656D78 1px 0 6px 1px;-webkit-box-shadow:#656D78 1px 0 6px 1px;box-shadow:#656D78 1px 0 6px 1px}#loading-bar-spinner{top:auto;left:15px;bottom:15px}#loading-bar-spinner .spinner-icon{border-top-color:#656D78;border-left-color:#656D78} \ No newline at end of file diff --git a/dist/app/demo.min.js b/dist/app/demo.min.js index 97bb992..de72c8e 100644 --- a/dist/app/demo.min.js +++ b/dist/app/demo.min.js @@ -1,5 +1,5 @@ /* - pulsar-reporting-ui | 0.2.0 + pulsar-reporting-ui | 0.2.1 Copyright (C) 2012-2015 eBay Software Foundation Licenses: MIT & Apache 2.0 */ diff --git a/dist/pulsar-reporting-ui-tpls.js b/dist/pulsar-reporting-ui-tpls.js index f034999..adbfacc 100644 --- a/dist/pulsar-reporting-ui-tpls.js +++ b/dist/pulsar-reporting-ui-tpls.js @@ -1,5 +1,5 @@ /* - pulsar-reporting-ui | 0.2.0 + pulsar-reporting-ui | 0.2.1 Copyright (C) 2012-2015 eBay Software Foundation Licenses: MIT & Apache 2.0 */ @@ -1263,16 +1263,15 @@ angular.module('pr.UIOption') * @description Formats a date according to a granularity, shows a more detailed time if the granularity is higher. * @param {date} date Date to format * @param {string=} granularity (hour or minute) - * @param {string=} timezone Timezone (MST) * @return {object} A date formatted by moment.js */ - getxAxisTickFormat: function(date, granularity, timezone) { + getxAxisTickFormat: function(date, granularity) { if (granularity === 'hour') { - return moment(date).tz(timezone).format('MMM DD, HH:mm'); + return moment(date).format('MMM DD, HH:mm'); } else if (granularity === 'minute') { - return moment(date).tz(timezone).format('MMM DD, HH:mm'); + return moment(date).format('MMM DD, HH:mm'); } else { - return moment(date).tz(timezone).format('MMM DD'); + return moment(date).format('MMM DD'); } }, @@ -3189,8 +3188,7 @@ angular.module('pr.dashboard.widgets.timeline', [ xAxis: { axisLabel: 'Time', tickFormat: function(d) { - console.lo - return prUIOptionService.getxAxisTickFormat(d, $scope.params.granularity, prApi.timezone); + return prUIOptionService.getxAxisTickFormat(d, $scope.params.granularity); } }, showLegend: true diff --git a/dist/pulsar-reporting-ui-tpls.min.js b/dist/pulsar-reporting-ui-tpls.min.js index 9c86fdd..618274d 100644 --- a/dist/pulsar-reporting-ui-tpls.min.js +++ b/dist/pulsar-reporting-ui-tpls.min.js @@ -1,11 +1,11 @@ /* - pulsar-reporting-ui | 0.2.0 + pulsar-reporting-ui | 0.2.1 Copyright (C) 2012-2015 eBay Software Foundation Licenses: MIT & Apache 2.0 */ angular.module("src/demo/realtime/realtime.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtime.html",'

Real-time Analytics Demo Page

')}]),angular.module("src/demo/realtime/realtimeDistribution.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtimeDistribution.html",'

Events Distribution

')}]),angular.module("src/demo/realtime/realtimeFilters.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtimeFilters.html",'
Traffic Source: {{$stateParams.trafficsource}} Device Family: {{$stateParams.devicefamily}} OS Family: {{$stateParams.osfamily}} Country: {{$stateParams.country}} Clear All
')}]),angular.module("src/demo/realtime/realtimeGrid.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtimeGrid.html",'

Traffic Sources

')}]),angular.module("src/demo/realtime/realtimeInfoBox.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtimeInfoBox.html",'
Desktop {{deviceFamily.Desktop || 0 | number:0}}
{{ (deviceFamily.Desktop || 0)*100/deviceFamily.total || 0 | number : 2}}%
Tablet {{deviceFamily.Tablet || 0 | number:0}}
{{ (deviceFamily.Tablet || 0)*100/deviceFamily.total || 0 | number : 2}}%
Mobile {{deviceFamily.Mobile || 0 | number:0}}
{{ (deviceFamily.Mobile || 0)*100/deviceFamily.total || 0 | number : 2}}%
Other {{deviceFamily.Other || 0 | number:0}}
{{ (deviceFamily.Other || 0)*100/deviceFamily.total || 0 | number : 2}}%
')}]),angular.module("src/demo/realtime/realtimeMetric.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtimeMetric.html","")}]),angular.module("src/demo/realtime/realtimeRatio.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtimeRatio.html",'

OS Ratio

')}]),angular.module("src/demo/realtime/realtimeTrend.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/realtime/realtimeTrend.html",'

Trend Today

')}]),angular.module("src/demo/traffic/traffic.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/traffic/traffic.html",'

Traffic Analytics Demo Page

 
')}]),angular.module("src/demo/traffic/trafficDetail.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/traffic/trafficDetail.html",'

Device Family Session

')}]),angular.module("src/demo/traffic/trafficFilters.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/traffic/trafficFilters.html",'

Filters

')}]),angular.module("src/demo/traffic/trafficTrend.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/demo/traffic/trafficTrend.html",'

Trend of Sessions

')}]),angular.module("src/prReporting/prDashboard/prDashboard.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboard/prDashboard.html",'

Your dashboard is empty!

You can start adding new widgets. Select the edit button  , and clicking \'Add a widget\'.
{{column.mockContent}}
')}]),angular.module("src/prReporting/prDashboard/prDashboardWidget.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboard/prDashboardWidget.html",'

{{widget.options.title}}

{{status.httpStatus}} Error

This widget configuration didn\'t work out... Could you try something else?

There was a problem on our side. Is not your fault. Please contact us for assitance.

A problem occured. Please contact us for assitance.

')}]),angular.module("src/prReporting/prDashboard/prDashboardWidgetStructureModal.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboard/prDashboardWidgetStructureModal.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/bar/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/bar/edit.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/bar/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/bar/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/grid/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/grid/edit.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/grid/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/grid/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/groupedBar/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/groupedBar/edit.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/groupedBar/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/groupedBar/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/lineWithFocus/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/lineWithFocus/edit.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/lineWithFocus/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/lineWithFocus/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/metric/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/metric/edit.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/metric/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/metric/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/metric/widget.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/metric/widget.html",'

{{params.metrics[0].alias || params.metrics[0].name}}

--

{{options.description}}


')}]),angular.module("src/prReporting/prDashboardWidgets/pie/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/pie/edit.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/pie/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/pie/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/stack/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/stack/edit.html",' '); }]),angular.module("src/prReporting/prDashboardWidgets/stack/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/stack/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/timeline/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/timeline/edit.html",' ')}]),angular.module("src/prReporting/prDashboardWidgets/timeline/view.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/timeline/view.html","")}]),angular.module("src/prReporting/prDashboardWidgets/util/prMetricPicker.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDashboardWidgets/util/prMetricPicker.html",'
Metric Aggregation Alias
{{metric.name}}
- -
')}]),angular.module("src/prReporting/prDynamicFilter/prDynamicFilter.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prDynamicFilter/prDynamicFilter.html",'
')}]),angular.module("src/prReporting/prGridExtensions/prGridLimitationAlert.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prGridExtensions/prGridLimitationAlert.html",' ')}]),angular.module("src/prReporting/prUIOption/uiGridPager.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prUIOption/uiGridPager.html",'
{{showingLow}} to {{showingHigh}} of {{grid.options.totalItems}} {{totalItemsLabel}}.
Show {{sizesLabel}}.
')}]),angular.module("src/prReporting/prUIOption/uiGridPagerSimple.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/prReporting/prUIOption/uiGridPagerSimple.html",'
{{showingLow}} to {{showingHigh}} of {{grid.options.totalItems}} {{totalItemsLabel}}.
')}]),angular.module("src/ui/admin/admin.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/admin.html",'

Success

{{ tip.message }}

Error

{{ tip.message }}

Admin

')}]),angular.module("src/ui/admin/datasourceManage/add/add.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/datasourceManage/add/add.html",' ')}]),angular.module("src/ui/admin/datasourceManage/cellTemplates/adminDatasourceOperateView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/datasourceManage/cellTemplates/adminDatasourceOperateView.html",'
  
')}]),angular.module("src/ui/admin/datasourceManage/cellTemplates/adminDatasourceTooltipTemplate.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/datasourceManage/cellTemplates/adminDatasourceTooltipTemplate.html",'
{{COL_FIELD}}
')}]),angular.module("src/ui/admin/datasourceManage/datasourceManageView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/datasourceManage/datasourceManageView.html",'

  Datasource Manage

')}]),angular.module("src/ui/admin/datasourceManage/delete/delete.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/datasourceManage/delete/delete.html",' ')}]),angular.module("src/ui/admin/datasourceManage/edit/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/datasourceManage/edit/edit.html",' ')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightDisplayNameView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightDisplayNameView.html",'
{{ COL_FIELD }}
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameSuffixView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameSuffixView.html",'
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameView.html",'
{{ COL_FIELD }}
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightTypeView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightTypeView.html",'
    System     Datasource     Dashboard     Group
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupCreatorView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupCreatorView.html",'
{{ COL_FIELD }}
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupDisplayNameView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupDisplayNameView.html",'
{{COL_FIELD}}
   Loading...
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupNameView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupNameView.html",'
{{COL_FIELD}}
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupOperateView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupOperateView.html",'
  
')}]),angular.module("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupUsersView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupUsersView.html","
{{ user + ( !$last ? ',' : '') }}  
   Loading...
")}]),angular.module("src/ui/admin/groupManage/delete/removeDialogTemplate.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/delete/removeDialogTemplate.html",' ')}]),angular.module("src/ui/admin/groupManage/groupManageView.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/groupManageView.html",'

 Permission Manage

letters, numbers and space only, max length is 64   
')}]),angular.module("src/ui/admin/groupManage/update/edit.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/admin/groupManage/update/edit.html",' ')}]),angular.module("src/ui/creator/creator.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/creator/creator.html",'

Reports creator

   

Select a dashboard or create a new one

If you can\'t select any dashboard, click the add button    to start.
')}]),angular.module("src/ui/creator/creatorDashboard.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/creator/creatorDashboard.html",'
{{name}}: {{value}}
   

\n  {{dashboard | json}}\n
'); -}]),angular.module("src/ui/creator/modals/add.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/creator/modals/add.html",'
')}]),angular.module("src/ui/creator/modals/delete.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/creator/modals/delete.html",' ')}]),angular.module("src/ui/creator/modals/layout.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/creator/modals/layout.html",' ')}]),angular.module("pr.tpls",["src/demo/realtime/realtime.html","src/demo/realtime/realtimeDistribution.html","src/demo/realtime/realtimeFilters.html","src/demo/realtime/realtimeGrid.html","src/demo/realtime/realtimeInfoBox.html","src/demo/realtime/realtimeMetric.html","src/demo/realtime/realtimeRatio.html","src/demo/realtime/realtimeTrend.html","src/demo/traffic/traffic.html","src/demo/traffic/trafficDetail.html","src/demo/traffic/trafficFilters.html","src/demo/traffic/trafficTrend.html","src/prReporting/prDashboard/prDashboard.html","src/prReporting/prDashboard/prDashboardWidget.html","src/prReporting/prDashboard/prDashboardWidgetStructureModal.html","src/prReporting/prDashboardWidgets/bar/edit.html","src/prReporting/prDashboardWidgets/bar/view.html","src/prReporting/prDashboardWidgets/grid/edit.html","src/prReporting/prDashboardWidgets/grid/view.html","src/prReporting/prDashboardWidgets/groupedBar/edit.html","src/prReporting/prDashboardWidgets/groupedBar/view.html","src/prReporting/prDashboardWidgets/lineWithFocus/edit.html","src/prReporting/prDashboardWidgets/lineWithFocus/view.html","src/prReporting/prDashboardWidgets/metric/edit.html","src/prReporting/prDashboardWidgets/metric/view.html","src/prReporting/prDashboardWidgets/metric/widget.html","src/prReporting/prDashboardWidgets/pie/edit.html","src/prReporting/prDashboardWidgets/pie/view.html","src/prReporting/prDashboardWidgets/stack/edit.html","src/prReporting/prDashboardWidgets/stack/view.html","src/prReporting/prDashboardWidgets/timeline/edit.html","src/prReporting/prDashboardWidgets/timeline/view.html","src/prReporting/prDashboardWidgets/util/prMetricPicker.html","src/prReporting/prDynamicFilter/prDynamicFilter.html","src/prReporting/prGridExtensions/prGridLimitationAlert.html","src/prReporting/prUIOption/uiGridPager.html","src/prReporting/prUIOption/uiGridPagerSimple.html","src/ui/admin/admin.html","src/ui/admin/datasourceManage/add/add.html","src/ui/admin/datasourceManage/cellTemplates/adminDatasourceOperateView.html","src/ui/admin/datasourceManage/cellTemplates/adminDatasourceTooltipTemplate.html","src/ui/admin/datasourceManage/datasourceManageView.html","src/ui/admin/datasourceManage/delete/delete.html","src/ui/admin/datasourceManage/edit/edit.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightDisplayNameView.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameSuffixView.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameView.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightTypeView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupCreatorView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupDisplayNameView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupNameView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupOperateView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupUsersView.html","src/ui/admin/groupManage/delete/removeDialogTemplate.html","src/ui/admin/groupManage/groupManageView.html","src/ui/admin/groupManage/update/edit.html","src/ui/creator/creator.html","src/ui/creator/creatorDashboard.html","src/ui/creator/modals/add.html","src/ui/creator/modals/delete.html","src/ui/creator/modals/layout.html"]),function(){"use strict";angular.module("pr.api",[])}(),function(){"use strict";angular.module("pr.api").provider("prApi",function(){var apiUrl="";this.url=function(url){apiUrl=url||apiUrl};var withCredentialsDatasources=!1;this.useWithCredentialsDatasources=function(value){withCredentialsDatasources=!!value};var timezone="MST";this.timezone=function(tz){timezone=tz||timezone},this.$get=function(){return{url:apiUrl,withCredentialsDatasources:withCredentialsDatasources,timezone:timezone}}})}(),function(){"use strict";angular.module("pr.numberfilter",["pr.api"])}(),function(){"use strict";angular.module("pr.numberfilter").filter("duration",function(){function pad(num){for(var s=num+"";s.length<2;)s="0"+s;return s}return function(n){if(angular.isNumber(n)){n=parseFloat(n),n!==n&&(n=0);var duration=moment.duration(Math.abs(n),"milliseconds");return(0>n?"-":"")+pad(Math.floor(duration.asHours()))+":"+pad(duration.minutes())+":"+pad(duration.seconds())}return""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("float",function($log,$filter){return function(n){return $log.warn('"float" filter (in pr.numberfilter module) is deprecated, please use the core "number" filter'),$filter("number")(n,2)}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("percentage",function($filter){return function(n,fractionSize){fractionSize=fractionSize||2;var res=$filter("number")(100*n,fractionSize);return res?res+"%":""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("range",function(){return function(n){for(var res=[],i=0;n>i;i++)res.push(i);return res}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("intervalDate",function(prApi){return function(time,format,originalFormat,timezone){return originalFormat=originalFormat||"X",timezone=timezone||prApi.timezone,format=format||"YYYY-MM-DD HH:mm:ss",moment(time,originalFormat).tz(timezone).format(format)}})}(),function(){"use strict";angular.module("pr.countto",[])}(),function(){"use strict";angular.module("pr.countto").directive("prCountTo",function($compile,$parse,$timeout,$filter){return{restrict:"EA",scope:{value:"=",decimals:"=?",placeholder:"=?"},template:"",link:function(scope,element){scope.placeholder=scope.placeholder||"--",scope.formatter=function(value){return $filter("number")(value,scope.decimals||0)},scope.$watch("value",function(newValue,oldValue){angular.isNumber(newValue)?element.countTo&&angular.isNumber(oldValue)?$timeout(function(){element.countTo("stop").countTo({from:oldValue,to:newValue,speed:1e3,formatter:scope.formatter,refreshInterval:100})},100):element.html(scope.formatter(newValue)):element.html(scope.placeholder)})}}})}(),function(){"use strict";angular.module("pr.gridextensions",["ui.grid","ui.grid.selection","ui.grid.pagination","ui.bootstrap.modal"])}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridHeight",function(gridUtil,$timeout){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var grid=uiGridCtrl.grid,options=grid.options,initialHeight=$attrs.prGridHeight;""===initialHeight&&(initialHeight=1*options.rowHeight,options.showHeader&&(initialHeight+=30),options.enableFiltering&&(initialHeight+=30),options.showFooter&&(initialHeight+=32),""===$attrs.uiGridPagination&&(initialHeight+=32)),$elm.css("height",initialHeight+"px");var calculateHeight=function(){var contentHeight,headerHeight=$elm.find(".ui-grid-header").size()?$elm.find(".ui-grid-header").outerHeight():grid.headerRowHeight;contentHeight=0===options.data.length?1*options.rowHeight:"uiGridPagination"in $attrs&&options.paginationPageSize&&options.data.length>options.paginationPageSize?options.paginationPageSize*options.rowHeight:options.data.length*options.rowHeight;var footerHeight=options.showFooter?options.footerRowHeight:0,columnFooterHeight=options.showColumnFooter?options.columnFooterHeight:0,scrollbarHeight=options.enableHorizontalScrollbar?gridUtil.getScrollbarWidth():0,pager=$elm.find(".ui-grid-pager-panel"),pagerHeight=pager.size()?pager.outerHeight():0,height=headerHeight+contentHeight+footerHeight+columnFooterHeight+scrollbarHeight+pagerHeight;return initialHeight>height&&(height=initialHeight),height++,height};$scope.$watch($attrs.uiGrid+".data",function(){uiGridCtrl.scrollbars=uiGridCtrl.scrollbars||[],$timeout(function(){var newHeight=calculateHeight();$elm.css("height",newHeight+"px"),grid.gridHeight=$scope.gridHeight=gridUtil.elementHeight($elm),grid.refreshCanvas()})},$attrs.prGridHeightDeep?!0:!1)}}})}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridLimitation",function(gridUtil,uiGridConstants,$modal){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var gridApi=uiGridCtrl.grid.api,selectedRows=[],maximum=$attrs.prGridLimitation;gridApi.selection.on.rowSelectionChanged($scope,function(row){selectedRows=gridApi.selection.getSelectedRows(),selectedRows.length>maximum&&($modal.open({templateUrl:"src/prReporting/prGridExtensions/prGridLimitationAlert.html",backdrop:"static",controller:function($scope,$modalInstance,maximum){$scope.maximum=maximum,$scope.cancel=function(){$modalInstance.dismiss("cancel")}},resolve:{maximum:function(){return maximum}}}),gridApi.selection.unSelectRow(row.entity)),selectedRows.length>0&&(gridApi.grid.selection.selectAll=!0)}),gridApi.selection.on.rowSelectionChangedBatch($scope,function(rows){if(gridApi.grid.selection.selectAll)gridApi.grid.selection.selectAll=!1,gridApi.selection.clearSelectedRows();else{var paginationPageSize=gridApi.grid.options.paginationPageSize,pageIndex=gridApi.pagination.getPage()-1,start=paginationPageSize*pageIndex,end=+start+ +maximum;angular.forEach(rows,function(row,index){row.isSelected=index>=start&&end>index})}})}}})}(),function(){"use strict";angular.module("pr.date",["pr.api"])}(),function(){"use strict";angular.module("pr.date").directive("prDatepicker",function(prApi){return{restrict:"E",scope:{startDate:"=",endDate:"=",callbackHandler:"&callback",timezone:"@"},template:'',link:function(scope,element,attrs){function startOfToday(){return moment().tz(timezone).startOf("day")}function endOfToday(){return moment().tz(timezone).endOf("day")}var timezone=scope.timezone||prApi.timezone,format=attrs.format||"YYYY-MM-DD",separator=" - ",callback=scope.callbackHandler?scope.callbackHandler():function(){},ranges={Today:[startOfToday(),endOfToday()],Yesterday:[startOfToday().subtract(1,"days"),endOfToday().subtract(1,"days")],"Last 7 Days":[startOfToday().subtract(1,"weeks"),endOfToday().subtract(1,"days")],"Last 30 Days":[startOfToday().subtract(30,"days"),endOfToday().subtract(1,"days")],"This Month":[startOfToday().startOf("month"),endOfToday()],"Last Month":[startOfToday().subtract(1,"month").startOf("month"),endOfToday().subtract(1,"month").endOf("month")]},maxDate=moment.tz(moment().tz(timezone).format(format),timezone),minDate=maxDate.clone().subtract(6,"month"),options={maxDate:maxDate,minDate:minDate,format:format,showDropdowns:!0,opens:attrs.opens||"right",ranges:ranges};element.daterangepicker(options,function(start,end,label){scope.startDate=moment.tz(start.startOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),scope.endDate=moment.tz(end.endOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),callback(scope.startDate,scope.endDate,start.startOf("day"),end.startOf("day")),scope.$apply()}),scope.$watchGroup(["startDate","endDate"],function(newValues){var startDate=newValues[0]?moment(newValues[0],"X").tz(timezone).format(format):null,endDate=newValues[1]?moment(newValues[1],"X").tz(timezone).format(format):null;if(startDate&&endDate){var val=startDate+separator+endDate;element.find("span").html(val),element.data("daterangepicker").setStartDate(startDate),element.data("daterangepicker").setEndDate(endDate)}})}}})}(),function(){"use strict";angular.module("pr.UIOption",["pr.numberfilter","ui.grid"])}(),function(){"use strict";angular.module("pr.UIOption").factory("prUIOptionService",function($log,$filter,uiGridConstants){var colorSet2=["#4A89DC","#3BAFDA","#37BC9B","#8CC152","#F6BB42","#E9573F","#DA4453","#967ADC","#D770AD"],prUIOptionService={_getBaseGridOptions:function(){return{data:[],enableHorizontalScrollbar:uiGridConstants.scrollbars.NEVER,enableVerticalScrollbar:uiGridConstants.scrollbars.NEVER,rowHeight:30,headerRowHeight:30,columnFooterHeight:33,enableColumnMenus:!1,enableSorting:!1,paginationPageSize:10}},getGridOptions:function(options){var defaults={paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getSimpleGridOptions:function(options){var defaults={paginationPageSizes:[],paginationTemplate:"src/prReporting/prUIOption/uiGridPagerSimple.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getFilterGridOptions:function(options){var defaults={enableFiltering:!0,paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return options&&options.columnDefs&&angular.forEach(options.columnDefs,function(col){col.filter?"undefined"==typeof col.filter.condition&&angular.merge({},!0,col.filter,{condition:uiGridConstants.filter.CONTAINS}):col.filter={condition:uiGridConstants.filter.CONTAINS}}),angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getIndexCellTemplate:function(){return $log.warn("getIndexCellTemplate in pr.UIOption:prUIOptionService is deprecated, please add you own template"),'
{{(grid.options.paginationCurrentPage - 1) * grid.options.paginationPageSize + rowRenderIndex + 1}}
'},getPieChartOptions:function(options){var defaults={type:"pieChart",color:colorSet2,margin:{top:-30,right:-30,bottom:-30,left:-30},height:300,valueFormat:$filter("number"),showLabels:!0,showLegend:!1,transitionDuration:500,labelsOutside:!1,pie:{dispatch:{}}};return{chart:angular.merge({},defaults,options||{})}},getxAxisTickFormat:function(date,granularity,timezone){return"hour"===granularity?moment(date).tz(timezone).format("MMM DD, HH:mm"):"minute"===granularity?moment(date).tz(timezone).format("MMM DD, HH:mm"):moment(date).tz(timezone).format("MMM DD")},getTimeLineChartOptions:function(options){var defaults={type:"lineChart",color:colorSet2,height:135,margin:{top:20,right:40,bottom:40,left:100},forceY:0,interpolate:"cardinal",useInteractiveGuideline:!0,xAxis:{axisLabel:"Time"},xScale:d3.time.scale().nice(d3.time.hour),yAxis:{axisLabelDistance:30}};return{chart:angular.merge({},!0,defaults,options||{})}},getLineWithFocusOptions:function(options){var defaults={type:"lineWithFocusChart",color:colorSet2,margin:{top:20,right:50,bottom:40,left:80},height:380,xAxis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}},x2Axis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getDiscreteBarChartOptions:function(options){var defaults={type:"discreteBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:5,left:100},showValues:!0,transitionDuration:500,discretebar:{dispatch:{}}};return{chart:angular.merge({},!0,defaults,options||{})}},getStackedAreaChartOptions:function(options){var defaults={type:"stackedAreaChart",color:colorSet2,height:380,margin:{top:20,right:40,bottom:50,left:100},x:function(d){return d.x},y:function(d){return d.y},useVoronoi:!1,clipEdge:!0,transitionDuration:500,useInteractiveGuideline:!0,xAxis:{showMaxMin:!1,tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getGroupedBarChartOptions:function(options){var defaults={type:"multiBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:50,left:35},reduceXTicks:!1,stacked:!1,showValues:!0,transitionDuration:500};return{chart:angular.merge({},!0,defaults,options||{})}}};return prUIOptionService})}(),function(){"use strict";angular.module("pr.UIOption").directive("prNvd3ClearTooltip",function(){var _rootScope;return{restrict:"A",controller:function($rootScope){_rootScope=$rootScope},link:function(scope,element){scope.$watch("api",function(api){var chartScope=scope.api.getScope(),off=_rootScope.$on("$stateChangeSuccess",function(){chartScope.chart&&chartScope.chart.tooltip&&d3.select("#"+chartScope.chart.tooltip.id()).remove(),off()});chartScope.$watch("chart",function(chart,oldChart){chart.id!==oldChart.id&&oldChart.tooltip&&d3.select("#"+oldChart.tooltip.id()).remove()})})}}})}(),function(){"use strict";angular.module("pr.dashboard",["ui.sortable","ui.bootstrap.modal","ngResource","pr.api"]).constant("AGGREGATION_TYPES",["count","sum","min","max","unique"]).constant("GRANULARITIES",[{name:"all",displayName:"-- Choose granularity if needed --"},{name:"hour",displayName:"Hourly"},{name:"day",displayName:"Daily"},{name:"week",displayName:"Weekly"}])}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboard",function(prDashboard){return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboard.html",scope:{layout:"=",model:"=?",filters:"=",editMode:"=",mock:"@"},link:function(scope,element,attrs){scope.sortableOptions={handle:".move-icon",connectWith:".column-inner"},scope.isEmpty=function(){var res=!0;return scope.model&&scope.model.config&&scope.model.config.columns&&angular.forEach(scope.model.config.columns,function(column){column.widgets&&column.widgets.length&&(res=!1)}),res},scope.$watch("layout",function(newValue){if(prDashboard.layouts[newValue])if(scope.mock)scope.model={config:angular.copy(prDashboard.layouts[newValue])};else if(scope.model){var newColumns=angular.copy(prDashboard.layouts[newValue].columns);angular.forEach(newColumns,function(newColumn){delete newColumn.mockContent}),angular.forEach(scope.model.config.columns,function(column,index){angular.forEach(column.widgets,function(widget){var i=newColumns[index]?index:newColumns.length-1;newColumns[i].widgets.push(widget)})}),scope.model.config.columns=newColumns}})}}})}(),function(){"use strict";angular.module("pr.dashboard").service("prDashboardResource",function($resource,prApi){return $resource(prApi.url+"/dashboards/:name",{name:"@name"},{get:{method:"GET",withCredentials:!0},save:{method:"POST",withCredentials:!0},update:{url:prApi.url+"/dashboards",params:{name:void 0},method:"PUT",withCredentials:!0,transformResponse:function(data){return void 0}},query:{method:"GET",isArray:!0,withCredentials:!0},remove:{method:"DELETE",withCredentials:!0},"delete":{method:"DELETE",withCredentials:!0}})})}(),function(){"use strict";angular.module("pr.dashboard").provider("prDashboard",function(){var widgets={},layouts={};this.widget=function(name,widget){return widgets[name]=widget,this},this.layout=function(name,layout){return layouts[name]=layout,this},this.$get=function(){var cid=0;return{widgets:widgets,layouts:layouts,id:function(){return++cid}}}})}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboardWidget",function($q,$log,$modal,prDashboard,$templateCache,$sce,$http,$controller,$compile){function getTemplate(widget){var deferred=$q.defer();if(widget.template)deferred.resolve(widget.template);else if(widget.templateUrl){var tpl=$templateCache.get(widget.templateUrl);if(tpl)deferred.resolve(tpl);else{var url=$sce.getTrustedResourceUrl(widget.templateUrl);$http.get(url).success(function(response){$templateCache.put(widget.templateUrl,response),deferred.resolve(response)}).error(function(){deferred.reject("could not load template")})}}return deferred.promise}function compileWidget($scope,$element,currentScope){var content=prDashboard.widgets[$scope.widget.type],templateScope=$scope.$new(),base={$scope:templateScope,widgetParams:$scope.widget.params,widgetOptions:$scope.widget.options},resolvers={};return resolvers.$tpl=getTemplate(content),content.resolve&&angular.forEach(content.resolve,function(promise,key){angular.isString(promise)?resolvers[key]=$injector.get(promise):resolvers[key]=$injector.invoke(promise,promise,base)}),$q.all(resolvers).then(function(locals){angular.extend(locals,base);var template=locals.$tpl,body=$element.find(".widgetContent");if(body.html(template),content.controller){var templateCtrl=$controller(content.controller,locals);body.children().data("$ngControllerController",templateCtrl)}$compile(body.contents())(templateScope)},function(reason){var msg="Could not resolve all promises";reason&&(msg+=": "+reason);var body=$element.find(".widgetContent");body.html(dashboard.messageTemplate.replace(/{}/g,msg)),$log.warn(msg)}),templateScope}return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboardWidget.html",transclude:!0,scope:{widget:"=",filters:"=",editMode:"=?",widgets:"=?"},controller:function($scope,$element){$scope.isCollapsed=!1,$scope.icon=prDashboard.widgets[$scope.widget.type].icon,$scope.title=$scope.widget.title,$scope.widget.params=$scope.widget.params||{},$scope.status={name:"new",errorMessage:null}},link:function(scope,element){compileWidget(scope,element),scope.$on("statusChanged",function(e,newStatus,errorMessage,errorResult){scope.status={name:newStatus,httpStatus:errorResult?errorResult.status:void 0,errorMessage:errorMessage},errorMessage&&$log.error("Widget SQL error: "+errorMessage,errorResult)}),scope.remove=function(){var widgets=scope.widgets;if(widgets){var index=widgets.indexOf(scope.widget);index>=0&&widgets.splice(index,1)}scope.$destroy(),element.remove()},scope.getSummary=function(){var params=scope.widget.params,dims=_.reduce(params.dimensions,function(names,dim){return names.push(dim.name),names},[]);return"Dimensions: "+_.escape(dims.join(", "))},scope.showStructure=function(){var modalInstance;modalInstance=$modal.open({scope:scope,backdrop:"static",templateUrl:"src/prReporting/prDashboard/prDashboardWidgetStructureModal.html",size:"lg"})},scope.edit=function(){var widgetType=prDashboard.widgets[scope.widget.type];if(widgetType){var modalInstance,newParams=angular.copy(scope.widget.params),newOptions=angular.copy(scope.widget.options),editScope=scope.$new();editScope.save=function(){newOptions.disabled=!1,angular.equals(newParams,scope.widget.params)||(scope.widget.params=newParams),angular.equals(newOptions,scope.widget.options)||(scope.widget.options=newOptions),modalInstance.close()},modalInstance=$modal.open({scope:editScope,backdrop:"static",template:widgetType.edit.template,templateUrl:widgetType.edit.templateUrl,controller:widgetType.edit.controller,size:"lg",resolve:{widgetParams:function(){return newParams},widgetOptions:function(){return newOptions}}})}}}}})}(),function(){"use strict";angular.module("pr.dashboard.layouts",["pr.dashboard"])}(),function(){"use strict";angular.module("pr.dashboard.layouts").config(function(prDashboardProvider){prDashboardProvider.layout("12",{displayName:"1 full width column",columns:[{mockContent:"100%",styleClass:"col-sm-12",widgets:[]}]}),prDashboardProvider.layout("6-6",{displayName:"2 columns (50% - 50%)",columns:[{mockContent:"50%",styleClass:"col-sm-6",widgets:[]},{mockContent:"50%",styleClass:"col-sm-6",widgets:[]}]}),prDashboardProvider.layout("3-3-3-3",{displayName:"4 columns (25% each)",columns:[{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]}]}),prDashboardProvider.layout("4-8",{displayName:"2 columns (33% - 66%)",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"66%",styleClass:"col-sm-8",widgets:[]}]}),prDashboardProvider.layout("8-4",{displayName:"2 columns (66% - 33%)",columns:[{mockContent:"66%",styleClass:"col-sm-8",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]}),prDashboardProvider.layout("4-4-4",{displayName:"3 columns",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.grid",["pr.dashboard","ui.select","ngSanitize","ui.grid","ui.grid.selection","ui.grid.pagination","ui.grid.autoResize","pr.gridextensions","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grid",{label:"Table",icon:"fa fa-table",templateUrl:"src/prReporting/prDashboardWidgets/grid/view.html",controller:"prGridWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/grid/edit.html",controller:"prGridWidgetEdit"}})}).directive("prGridWidget",function($compile,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,$element){$scope.options=$scope.options||{},$scope.grid={gridOptions:prUIOptionService.getSimpleGridOptions($scope.options.grid||{})},$scope.addFilter=function(dimensionName,dimensionValue){$scope.filters.where=$scope.filters.where||{},$scope.filters.where[dimensionName]=dimensionValue}},link:function(scope,element,attrs){var staticColumnDefs=scope.grid.gridOptions.columnDefs;scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);if(newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,!scope.options.disabled){scope.$emit("statusChanged","wait");var columnDefs=staticColumnDefs;columnDefs||(columnDefs=[],angular.forEach(newParams.dimensions,function(dimension){columnDefs.push({field:dimension.name,cellTemplate:'
{{COL_FIELD}}
"})}),angular.forEach(newParams.metrics,function(metric){var field=metric.alias||metric.name+" "+metric.type;columnDefs.push({field:field,displayName:field,cellClass:"text-right",cellFilter:metric.filter||"number"})})),prDatasourceSqlService.getDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],!staticColumnDefs&&results.length&&results[0].timestamp&&columnDefs.push({field:"timestamp",cellFilter:"date:'short'"}),scope.grid.gridOptions.columnDefs=columnDefs,scope.grid.gridOptions.data=results,scope.$emit("statusChanged","done")},function(result){scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],scope.$emit("statusChanged","error",result.data.error,result)})}},!0)}}}).controller("prGridWidget",function($scope,widgetParams,widgetOptions){}).controller("prGridWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES)},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.pie",["nvd3","pr.dashboard","pr.datasource.sql","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-pie",{label:"Pie",icon:"fa fa-pie-chart",templateUrl:"src/prReporting/prDashboardWidgets/pie/view.html",controller:"prPieWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/pie/edit.html",controller:"prPieWidgetEdit"}})}).directive("prPieWidget",function($filter,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}},pie:{dispatch:{elementClick:function(e){ -if($scope.filters.where){var dimensionName=$scope.params.dimensions[0].name;$scope.filters.where[dimensionName]=e.data.x,$scope.$apply()}}}}};$scope.pieChart={options:prUIOptionService.getPieChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),0===scope.pieChart.options.chart.width&&(scope.pieChart.options.chart.width=void 0),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results));var data=[];if(results[0]){data=results[0].values;var total=0;angular.forEach(data,function(val,index){total+=val.y}),0===total&&(data=[])}scope.pieChart.data=data,scope.$emit("statusChanged","done")},function(result){scope.pieChart.data=[],scope.pieChart.options.chart.width=0,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prPieWidget",function($scope,widgetParams,widgetOptions){}).controller("prPieWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.bar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-bar",{label:"Bar",icon:"fa fa-bar-chart",templateUrl:"src/prReporting/prDashboardWidgets/bar/view.html",controller:"prBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/bar/edit.html",controller:"prBarWidgetEdit"}})}).directive("prBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}}};$scope.barChart={options:prUIOptionService.getDiscreteBarChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.barChart.data=results,scope.barChart.options.chart.xAxis={axisLabel:results[0].key},scope.$emit("statusChanged","done")},function(result){scope.barChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.timeline",["pr.dashboard","nvd3","pr.datasource.sql","pr.UIOption"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-timeline",{label:"Timeline",icon:"fa fa-clock-o",templateUrl:"src/prReporting/prDashboardWidgets/timeline/view.html",controller:"prTimelineWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/timeline/edit.html",controller:"prTimelineWidgetEdit"}})}).directive("prTimelineWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,prApi){$scope.options=$scope.options||{};var height=$scope.options.height||180;$scope.height=height+20,$scope.defaults={margin:{top:20,right:50,bottom:20,left:80},height:height,xAxis:{axisLabel:"Time",tickFormat:function(d){return console.lo,prUIOptionService.getxAxisTickFormat(d,$scope.params.granularity,prApi.timezone)}},showLegend:!0},$scope.lineChart={options:prUIOptionService.getTimeLineChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.lineChart.data||(scope.lineChart.data=[]),scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getTimeLineChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.options.isArea&&angular.forEach(scope.lineChart.data,function(data){data.area=!0}),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prTimelineWidget",function($scope,widgetParams,widgetOptions){}).controller("prTimelineWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,angular.isUndefined($scope.options.isArea)&&($scope.options.isArea=!1),$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES),$scope.granularities.splice(0,1),"all"==$scope.newParams.granularity&&($scope.newParams.granularity=$scope.granularities[0].name),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.linewithfocus",["nvd3","pr.datasource.sql","pr.dashboard","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-line-with-focus",{label:"Line with Focus",icon:"fa fa-line-chart",templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/view.html",controller:"prLineWithFocusWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/edit.html",controller:"prLineWithFocusWidgetEdit"}})}).directive("prLineWithFocusWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,showLegend:!0},$scope.lineChart={options:prUIOptionService.getLineWithFocusOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),scope.lineChart.data=[],prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getLineWithFocusOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prLineWithFocusWidget",function($scope,widgetParams,widgetOptions){}).controller("prLineWithFocusWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.newParams.granularity="five_minute"},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.stack",["nvd3","pr.dashboard","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-stack",{label:"Stack",icon:"fa fa-area-chart",templateUrl:"src/prReporting/prDashboardWidgets/stack/view.html",controller:"prStackWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/stack/edit.html",controller:"prStackWidgetEdit"}})}).directive("prStackWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,xScale:d3.time.scale(),showLegend:!0},$scope.stackChart={options:prUIOptionService.getStackedAreaChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||200,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getStackDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.stackChart.data=results,scope.stackChart.options=prUIOptionService.getStackedAreaChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prStackWidget",function($scope,widgetParams,widgetOptions){}).controller("prStackWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams;var granularities=angular.copy(GRANULARITIES);granularities.shift(),$scope.newParams.granularity&&"all"!==$scope.newParams.granularity||($scope.newParams.granularity=granularities[0].name),$scope.granularities=granularities,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||200,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.metric",["pr.dashboard","pr.countto","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-metric",{label:"Metric",icon:"fa fa-gears",templateUrl:"src/prReporting/prDashboardWidgets/metric/view.html",controller:"prMetricWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/metric/edit.html",controller:"prMetricWidgetEdit"}})}).directive("prMetricWidget",function(prDatasourceSqlService){return{restrict:"E",templateUrl:"src/prReporting/prDashboardWidgets/metric/widget.html",scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.options=$scope.options||{},$scope.icon=$scope.options.icon||"fa fa-heartbeat"},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=1,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getMetricData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.totalNumber=results,scope.$emit("statusChanged","done")},function(result){scope.totalNumber=null,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prMetricWidget",function($scope,widgetParams,widgetOptions){}).controller("prMetricWidgetEdit",function(widgetParams,widgetOptions,$scope,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initMetrics=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.initMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.groupedBar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grouped-bar",{label:"Grouped Bar",icon:"fa fa-tasks fa-rotate-270",templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/view.html",controller:"prGroupedBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/edit.html",controller:"prGroupedBarWidgetEdit"}})}).directive("prGroupedBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.groupedBarChart={};var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,margin:{top:5,right:5,bottom:5,left:100},showLegend:!0},$scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||40,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getGroupedBarData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.groupedBarChart.data=results,scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),results&&results[0]&&newParams.dimensions[0]&&(scope.groupedBarChart.options.chart.xAxis={axisLabel:newParams.dimensions[0].name}),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prGroupedBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prGroupedBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.multipleMetrics=widgetParams.metrics&&widgetParams.metrics.length>1,$scope.newParams.maxResults=widgetParams.maxResults||40,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("multipleMetrics",function(isMultipleMetrics){isMultipleMetrics&&$scope.newParams.dimensions.splice(1,$scope.newParams.dimensions.length-1)}),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.util",[])}(),function(){"use strict";angular.module("pr.dashboard.widgets.util").directive("prMetricPicker",function(){return{restrict:"E",scope:{metrics:"=",multiple:"=?",metricOptions:"=",aggregationOptions:"="},templateUrl:"src/prReporting/prDashboardWidgets/util/prMetricPicker.html",link:function(scope){function newMetric(metricName){var type=null;return scope.aggregationOptions&&scope.aggregationOptions.length&&(type=scope.aggregationOptions[0]),{name:metricName,type:type,alias:metricName}}scope.metrics=scope.metrics||[],scope.selectMetric=function(metricName){scope.metrics[0]=newMetric(metricName)},scope.addMetric=function(metricName){scope.metrics.push(newMetric(metricName))},scope.removeMetric=function(index){scope.metrics.splice(index,1)},scope.$watchGroup(["multiple","metricOptions","aggregationOptions"],function(newValues){var isMultiple=newValues[0];scope.metrics=scope.metrics||[],isMultiple||(0===scope.metrics.length&&scope.metricOptions&&scope.metricOptions.length>0&&scope.selectMetric(scope.metricOptions[0].name),scope.metrics.length>1&&scope.metrics.splice(1,scope.metrics.length-1))})}}})}(),function(){"use strict";angular.module("pr.datasource",["pr.datasource.sql"])}(),function(){"use strict";angular.module("pr.datasource.sql",["ngResource","pr.api"])}(),function(){"use strict";angular.module("pr.datasource.sql").service("prDatasourceSqlService",function($resource,prSqlBuilder,prApi){var transformDataRequest=function(param){var q={};param.table&&(q.table=param.table),param.orderBy&&(q.orderBy=param.orderBy),param.metrics&&(q.metrics=param.metrics),param.dimensions&&(q.dimensions=param.dimensions),param.maxResults&&(q.maxResults=param.maxResults),param.filters.where&&(q.where=param.filters.where),param.filters.whereRaw&&(q.whereRaw=param.filters.whereRaw);var p={sql:prSqlBuilder.buildQuery(q),intervals:param.filters.intervals,granularity:param.granularity};return angular.toJson(p)};return $resource(prApi.url+"/sql/:dataSourceName",{},{getDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,result=[];return angular.forEach(data,function(value,key){value.result&&"{}"!==angular.toJson(value.result)&&(result[key]=value.result,config.data&&"all"!==config.data.granularity&&(result[key].timestamp=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate()))}),result}},transformRequest:transformDataRequest},getHistogram:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,metrics=config.data.metrics,responses=[];return data&&data.length>0&&angular.forEach(metrics,function(metric){var response=[];angular.forEach(data,function(value){var point={};config.data.dimensions&&config.data.dimensions.length&&!config.data.isTimeline?point.x=value.result[config.data.dimensions[0].name]:point.x=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate(),point.y=value.result[prSqlBuilder.getAlias(metric)],response.push(point)}),responses.push({key:prSqlBuilder.getAlias(metric),values:response})}),responses}},transformRequest:transformDataRequest},getGroupedBarData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,dimensions=config.data.dimensions||[],metrics=config.data.metrics||[],responses=[];if(!data||0===data.length)return responses;if(2===dimensions.length&&1===metrics.length){var dim1Name=dimensions[1].name,dim2Name=dimensions[0].name,dim1Vals=[],dim2Vals=[],metricName=metrics[0].alias;angular.forEach(data,function(d){var value=d.result,dim1Val=value[dim1Name],seriesIndex=dim1Vals.indexOf(dim1Val);-1===seriesIndex&&(seriesIndex=dim1Vals.length,dim1Vals.push(dim1Val),responses.push({key:dim1Val,values:[]})),responses[seriesIndex].values.push({series:seriesIndex,x:value[dim2Name],y:value[metricName]}),-1===dim2Vals.indexOf(value[dim2Name])&&dim2Vals.push(value[dim2Name])}),responses.forEach(function(series,seriesIndex){dim2Vals.forEach(function(dimValue){var have=!1;series.values.forEach(function(e){e.x===dimValue&&(have=!0)}),have||series.values.push({series:seriesIndex,x:dimValue,y:0})})})}else if(1===dimensions.length){var metricNames=[],dimName=dimensions[0].name;angular.forEach(data,function(d){var value=d.result,dimValue=value[dimName];angular.forEach(value,function(val,key){if(key!==dimName){var metricName=key,seriesIndex=metricNames.indexOf(metricName);-1===seriesIndex&&(seriesIndex=responses.length,metricNames.push(metricName),responses.push({key:metricName,values:[]})),responses[seriesIndex].values.push({x:dimValue,y:val})}})})}return responses.forEach(function(series){series.values.sort(function(v1,v2){return v1.x===v2.x?0:v1.x>v2.x?-1:1})}),responses}},transformRequest:transformDataRequest},getStackDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,metricName=prSqlBuilder.getAlias(config.data.metrics[0]),dimensionName=config.data.dimensions[0]?config.data.dimensions[0].name:null,dimensionValues=[],series=[],timestampGroups=_.groupBy(data,"timestamp"),maxTimestampGroupLength=0;for(var d in timestampGroups)maxTimestampGroupLength=maxTimestampGroupLengthseriesIndex;seriesIndex++)if(series[seriesIndex]||(series[seriesIndex]=[]),series[seriesIndex][timestampIndex]={x:date,y:0},timestampGroup[seriesIndex]){var resultValue=timestampGroup[seriesIndex].result;series[seriesIndex][timestampIndex].y=resultValue[metricName],dimensionValues[seriesIndex]=resultValue[dimensionName]}timestampIndex++}var results=[];return angular.forEach(series,function(serie,i){results.push({key:dimensionValues[i]||metricName,values:serie})}),results}},transformRequest:transformDataRequest},getMetricData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var alias=prSqlBuilder.getAlias(response.config.data.metrics[0]);return response.data[0].result[alias]}},transformRequest:transformDataRequest},getDataSources:{method:"GET",url:prApi.url+"/datasources?right=view",isArray:!0,withCredentials:!0},getTables:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"show tables from "+param.dataSourceName};return angular.toJson(p)}},getDimensions:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".dimensions"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(dimension){response.push({name:dimension})}),response}}},getMetrics:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".metrics"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(metric){response.push({name:metric})}),response}}}})})}(),function(){"use strict";angular.module("pr.datasource.sql").factory("prSqlBuilder",function($log){function orWhereFromArray(k,key,array,operator){return array.length>0&&k.where(function(){var i=1;if(operator)for(this.where(key,operator,array[0]);i ')}]),angular.module("src/ui/creator/modals/delete.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/creator/modals/delete.html",' ')}]),angular.module("src/ui/creator/modals/layout.html",[]).run(["$templateCache",function($templateCache){$templateCache.put("src/ui/creator/modals/layout.html",' ')}]),angular.module("pr.tpls",["src/demo/realtime/realtime.html","src/demo/realtime/realtimeDistribution.html","src/demo/realtime/realtimeFilters.html","src/demo/realtime/realtimeGrid.html","src/demo/realtime/realtimeInfoBox.html","src/demo/realtime/realtimeMetric.html","src/demo/realtime/realtimeRatio.html","src/demo/realtime/realtimeTrend.html","src/demo/traffic/traffic.html","src/demo/traffic/trafficDetail.html","src/demo/traffic/trafficFilters.html","src/demo/traffic/trafficTrend.html","src/prReporting/prDashboard/prDashboard.html","src/prReporting/prDashboard/prDashboardWidget.html","src/prReporting/prDashboard/prDashboardWidgetStructureModal.html","src/prReporting/prDashboardWidgets/bar/edit.html","src/prReporting/prDashboardWidgets/bar/view.html","src/prReporting/prDashboardWidgets/grid/edit.html","src/prReporting/prDashboardWidgets/grid/view.html","src/prReporting/prDashboardWidgets/groupedBar/edit.html","src/prReporting/prDashboardWidgets/groupedBar/view.html","src/prReporting/prDashboardWidgets/lineWithFocus/edit.html","src/prReporting/prDashboardWidgets/lineWithFocus/view.html","src/prReporting/prDashboardWidgets/metric/edit.html","src/prReporting/prDashboardWidgets/metric/view.html","src/prReporting/prDashboardWidgets/metric/widget.html","src/prReporting/prDashboardWidgets/pie/edit.html","src/prReporting/prDashboardWidgets/pie/view.html","src/prReporting/prDashboardWidgets/stack/edit.html","src/prReporting/prDashboardWidgets/stack/view.html","src/prReporting/prDashboardWidgets/timeline/edit.html","src/prReporting/prDashboardWidgets/timeline/view.html","src/prReporting/prDashboardWidgets/util/prMetricPicker.html","src/prReporting/prDynamicFilter/prDynamicFilter.html","src/prReporting/prGridExtensions/prGridLimitationAlert.html","src/prReporting/prUIOption/uiGridPager.html","src/prReporting/prUIOption/uiGridPagerSimple.html","src/ui/admin/admin.html","src/ui/admin/datasourceManage/add/add.html","src/ui/admin/datasourceManage/cellTemplates/adminDatasourceOperateView.html","src/ui/admin/datasourceManage/cellTemplates/adminDatasourceTooltipTemplate.html","src/ui/admin/datasourceManage/datasourceManageView.html","src/ui/admin/datasourceManage/delete/delete.html","src/ui/admin/datasourceManage/edit/edit.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightDisplayNameView.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameSuffixView.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightNameView.html","src/ui/admin/groupManage/cellTemplates/groupUpdate/groupUpdateRightTypeView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupCreatorView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupDisplayNameView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupNameView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupOperateView.html","src/ui/admin/groupManage/cellTemplates/groupsView/adminGroupUsersView.html","src/ui/admin/groupManage/delete/removeDialogTemplate.html","src/ui/admin/groupManage/groupManageView.html","src/ui/admin/groupManage/update/edit.html","src/ui/creator/creator.html","src/ui/creator/creatorDashboard.html","src/ui/creator/modals/add.html","src/ui/creator/modals/delete.html","src/ui/creator/modals/layout.html"]),function(){"use strict";angular.module("pr.api",[])}(),function(){"use strict";angular.module("pr.api").provider("prApi",function(){var apiUrl="";this.url=function(url){apiUrl=url||apiUrl};var withCredentialsDatasources=!1;this.useWithCredentialsDatasources=function(value){withCredentialsDatasources=!!value};var timezone="MST";this.timezone=function(tz){timezone=tz||timezone},this.$get=function(){return{url:apiUrl,withCredentialsDatasources:withCredentialsDatasources,timezone:timezone}}})}(),function(){"use strict";angular.module("pr.numberfilter",["pr.api"])}(),function(){"use strict";angular.module("pr.numberfilter").filter("duration",function(){function pad(num){for(var s=num+"";s.length<2;)s="0"+s;return s}return function(n){if(angular.isNumber(n)){n=parseFloat(n),n!==n&&(n=0);var duration=moment.duration(Math.abs(n),"milliseconds");return(0>n?"-":"")+pad(Math.floor(duration.asHours()))+":"+pad(duration.minutes())+":"+pad(duration.seconds())}return""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("float",function($log,$filter){return function(n){return $log.warn('"float" filter (in pr.numberfilter module) is deprecated, please use the core "number" filter'),$filter("number")(n,2)}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("percentage",function($filter){return function(n,fractionSize){fractionSize=fractionSize||2;var res=$filter("number")(100*n,fractionSize);return res?res+"%":""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("range",function(){return function(n){for(var res=[],i=0;n>i;i++)res.push(i);return res}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("intervalDate",function(prApi){return function(time,format,originalFormat,timezone){return originalFormat=originalFormat||"X",timezone=timezone||prApi.timezone,format=format||"YYYY-MM-DD HH:mm:ss",moment(time,originalFormat).tz(timezone).format(format)}})}(),function(){"use strict";angular.module("pr.countto",[])}(),function(){"use strict";angular.module("pr.countto").directive("prCountTo",function($compile,$parse,$timeout,$filter){return{restrict:"EA",scope:{value:"=",decimals:"=?",placeholder:"=?"},template:"",link:function(scope,element){scope.placeholder=scope.placeholder||"--",scope.formatter=function(value){return $filter("number")(value,scope.decimals||0)},scope.$watch("value",function(newValue,oldValue){angular.isNumber(newValue)?element.countTo&&angular.isNumber(oldValue)?$timeout(function(){element.countTo("stop").countTo({from:oldValue,to:newValue,speed:1e3,formatter:scope.formatter,refreshInterval:100})},100):element.html(scope.formatter(newValue)):element.html(scope.placeholder)})}}})}(),function(){"use strict";angular.module("pr.gridextensions",["ui.grid","ui.grid.selection","ui.grid.pagination","ui.bootstrap.modal"])}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridHeight",function(gridUtil,$timeout){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var grid=uiGridCtrl.grid,options=grid.options,initialHeight=$attrs.prGridHeight;""===initialHeight&&(initialHeight=1*options.rowHeight,options.showHeader&&(initialHeight+=30),options.enableFiltering&&(initialHeight+=30),options.showFooter&&(initialHeight+=32),""===$attrs.uiGridPagination&&(initialHeight+=32)),$elm.css("height",initialHeight+"px");var calculateHeight=function(){var contentHeight,headerHeight=$elm.find(".ui-grid-header").size()?$elm.find(".ui-grid-header").outerHeight():grid.headerRowHeight;contentHeight=0===options.data.length?1*options.rowHeight:"uiGridPagination"in $attrs&&options.paginationPageSize&&options.data.length>options.paginationPageSize?options.paginationPageSize*options.rowHeight:options.data.length*options.rowHeight;var footerHeight=options.showFooter?options.footerRowHeight:0,columnFooterHeight=options.showColumnFooter?options.columnFooterHeight:0,scrollbarHeight=options.enableHorizontalScrollbar?gridUtil.getScrollbarWidth():0,pager=$elm.find(".ui-grid-pager-panel"),pagerHeight=pager.size()?pager.outerHeight():0,height=headerHeight+contentHeight+footerHeight+columnFooterHeight+scrollbarHeight+pagerHeight;return initialHeight>height&&(height=initialHeight),height++,height};$scope.$watch($attrs.uiGrid+".data",function(){uiGridCtrl.scrollbars=uiGridCtrl.scrollbars||[],$timeout(function(){var newHeight=calculateHeight();$elm.css("height",newHeight+"px"),grid.gridHeight=$scope.gridHeight=gridUtil.elementHeight($elm),grid.refreshCanvas()})},$attrs.prGridHeightDeep?!0:!1)}}})}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridLimitation",function(gridUtil,uiGridConstants,$modal){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var gridApi=uiGridCtrl.grid.api,selectedRows=[],maximum=$attrs.prGridLimitation;gridApi.selection.on.rowSelectionChanged($scope,function(row){selectedRows=gridApi.selection.getSelectedRows(),selectedRows.length>maximum&&($modal.open({templateUrl:"src/prReporting/prGridExtensions/prGridLimitationAlert.html",backdrop:"static",controller:function($scope,$modalInstance,maximum){$scope.maximum=maximum,$scope.cancel=function(){$modalInstance.dismiss("cancel")}},resolve:{maximum:function(){return maximum}}}),gridApi.selection.unSelectRow(row.entity)),selectedRows.length>0&&(gridApi.grid.selection.selectAll=!0)}),gridApi.selection.on.rowSelectionChangedBatch($scope,function(rows){if(gridApi.grid.selection.selectAll)gridApi.grid.selection.selectAll=!1,gridApi.selection.clearSelectedRows();else{var paginationPageSize=gridApi.grid.options.paginationPageSize,pageIndex=gridApi.pagination.getPage()-1,start=paginationPageSize*pageIndex,end=+start+ +maximum;angular.forEach(rows,function(row,index){row.isSelected=index>=start&&end>index})}})}}})}(),function(){"use strict";angular.module("pr.date",["pr.api"])}(),function(){"use strict";angular.module("pr.date").directive("prDatepicker",function(prApi){return{restrict:"E",scope:{startDate:"=",endDate:"=",callbackHandler:"&callback",timezone:"@"},template:'',link:function(scope,element,attrs){function startOfToday(){return moment().tz(timezone).startOf("day")}function endOfToday(){return moment().tz(timezone).endOf("day")}var timezone=scope.timezone||prApi.timezone,format=attrs.format||"YYYY-MM-DD",separator=" - ",callback=scope.callbackHandler?scope.callbackHandler():function(){},ranges={Today:[startOfToday(),endOfToday()],Yesterday:[startOfToday().subtract(1,"days"),endOfToday().subtract(1,"days")],"Last 7 Days":[startOfToday().subtract(1,"weeks"),endOfToday().subtract(1,"days")],"Last 30 Days":[startOfToday().subtract(30,"days"),endOfToday().subtract(1,"days")],"This Month":[startOfToday().startOf("month"),endOfToday()],"Last Month":[startOfToday().subtract(1,"month").startOf("month"),endOfToday().subtract(1,"month").endOf("month")]},maxDate=moment.tz(moment().tz(timezone).format(format),timezone),minDate=maxDate.clone().subtract(6,"month"),options={maxDate:maxDate,minDate:minDate,format:format,showDropdowns:!0,opens:attrs.opens||"right",ranges:ranges};element.daterangepicker(options,function(start,end,label){scope.startDate=moment.tz(start.startOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),scope.endDate=moment.tz(end.endOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),callback(scope.startDate,scope.endDate,start.startOf("day"),end.startOf("day")),scope.$apply()}),scope.$watchGroup(["startDate","endDate"],function(newValues){var startDate=newValues[0]?moment(newValues[0],"X").tz(timezone).format(format):null,endDate=newValues[1]?moment(newValues[1],"X").tz(timezone).format(format):null;if(startDate&&endDate){var val=startDate+separator+endDate;element.find("span").html(val),element.data("daterangepicker").setStartDate(startDate),element.data("daterangepicker").setEndDate(endDate)}})}}})}(),function(){"use strict";angular.module("pr.UIOption",["pr.numberfilter","ui.grid"])}(),function(){"use strict";angular.module("pr.UIOption").factory("prUIOptionService",function($log,$filter,uiGridConstants){var colorSet2=["#4A89DC","#3BAFDA","#37BC9B","#8CC152","#F6BB42","#E9573F","#DA4453","#967ADC","#D770AD"],prUIOptionService={_getBaseGridOptions:function(){return{data:[],enableHorizontalScrollbar:uiGridConstants.scrollbars.NEVER,enableVerticalScrollbar:uiGridConstants.scrollbars.NEVER,rowHeight:30,headerRowHeight:30,columnFooterHeight:33,enableColumnMenus:!1,enableSorting:!1,paginationPageSize:10}},getGridOptions:function(options){var defaults={paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getSimpleGridOptions:function(options){var defaults={paginationPageSizes:[],paginationTemplate:"src/prReporting/prUIOption/uiGridPagerSimple.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getFilterGridOptions:function(options){var defaults={enableFiltering:!0,paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return options&&options.columnDefs&&angular.forEach(options.columnDefs,function(col){col.filter?"undefined"==typeof col.filter.condition&&angular.merge({},!0,col.filter,{condition:uiGridConstants.filter.CONTAINS}):col.filter={condition:uiGridConstants.filter.CONTAINS}}),angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getIndexCellTemplate:function(){return $log.warn("getIndexCellTemplate in pr.UIOption:prUIOptionService is deprecated, please add you own template"),'
{{(grid.options.paginationCurrentPage - 1) * grid.options.paginationPageSize + rowRenderIndex + 1}}
'},getPieChartOptions:function(options){var defaults={type:"pieChart",color:colorSet2,margin:{top:-30,right:-30,bottom:-30,left:-30},height:300,valueFormat:$filter("number"),showLabels:!0,showLegend:!1,transitionDuration:500,labelsOutside:!1,pie:{dispatch:{}}};return{chart:angular.merge({},defaults,options||{})}},getxAxisTickFormat:function(date,granularity){return"hour"===granularity?moment(date).format("MMM DD, HH:mm"):"minute"===granularity?moment(date).format("MMM DD, HH:mm"):moment(date).format("MMM DD")},getTimeLineChartOptions:function(options){var defaults={type:"lineChart",color:colorSet2,height:135,margin:{top:20,right:40,bottom:40,left:100},forceY:0,interpolate:"cardinal",useInteractiveGuideline:!0,xAxis:{axisLabel:"Time"},xScale:d3.time.scale().nice(d3.time.hour),yAxis:{axisLabelDistance:30}};return{chart:angular.merge({},!0,defaults,options||{})}},getLineWithFocusOptions:function(options){var defaults={type:"lineWithFocusChart",color:colorSet2,margin:{top:20,right:50,bottom:40,left:80},height:380,xAxis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}},x2Axis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getDiscreteBarChartOptions:function(options){var defaults={type:"discreteBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:5,left:100},showValues:!0,transitionDuration:500,discretebar:{dispatch:{}}};return{chart:angular.merge({},!0,defaults,options||{})}},getStackedAreaChartOptions:function(options){var defaults={type:"stackedAreaChart",color:colorSet2,height:380,margin:{top:20,right:40,bottom:50,left:100},x:function(d){return d.x},y:function(d){return d.y},useVoronoi:!1,clipEdge:!0,transitionDuration:500,useInteractiveGuideline:!0,xAxis:{showMaxMin:!1,tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getGroupedBarChartOptions:function(options){var defaults={type:"multiBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:50,left:35},reduceXTicks:!1,stacked:!1,showValues:!0,transitionDuration:500};return{chart:angular.merge({},!0,defaults,options||{})}}};return prUIOptionService})}(),function(){"use strict";angular.module("pr.UIOption").directive("prNvd3ClearTooltip",function(){var _rootScope;return{restrict:"A",controller:function($rootScope){_rootScope=$rootScope},link:function(scope,element){scope.$watch("api",function(api){var chartScope=scope.api.getScope(),off=_rootScope.$on("$stateChangeSuccess",function(){chartScope.chart&&chartScope.chart.tooltip&&d3.select("#"+chartScope.chart.tooltip.id()).remove(),off()});chartScope.$watch("chart",function(chart,oldChart){chart.id!==oldChart.id&&oldChart.tooltip&&d3.select("#"+oldChart.tooltip.id()).remove()})})}}})}(),function(){"use strict";angular.module("pr.dashboard",["ui.sortable","ui.bootstrap.modal","ngResource","pr.api"]).constant("AGGREGATION_TYPES",["count","sum","min","max","unique"]).constant("GRANULARITIES",[{name:"all",displayName:"-- Choose granularity if needed --"},{name:"hour",displayName:"Hourly"},{name:"day",displayName:"Daily"},{name:"week",displayName:"Weekly"}])}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboard",function(prDashboard){return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboard.html",scope:{layout:"=",model:"=?",filters:"=",editMode:"=",mock:"@"},link:function(scope,element,attrs){scope.sortableOptions={handle:".move-icon",connectWith:".column-inner"},scope.isEmpty=function(){var res=!0;return scope.model&&scope.model.config&&scope.model.config.columns&&angular.forEach(scope.model.config.columns,function(column){column.widgets&&column.widgets.length&&(res=!1)}),res},scope.$watch("layout",function(newValue){if(prDashboard.layouts[newValue])if(scope.mock)scope.model={config:angular.copy(prDashboard.layouts[newValue])};else if(scope.model){var newColumns=angular.copy(prDashboard.layouts[newValue].columns);angular.forEach(newColumns,function(newColumn){delete newColumn.mockContent}),angular.forEach(scope.model.config.columns,function(column,index){angular.forEach(column.widgets,function(widget){var i=newColumns[index]?index:newColumns.length-1;newColumns[i].widgets.push(widget)})}),scope.model.config.columns=newColumns}})}}})}(),function(){"use strict";angular.module("pr.dashboard").service("prDashboardResource",function($resource,prApi){return $resource(prApi.url+"/dashboards/:name",{name:"@name"},{get:{method:"GET",withCredentials:!0},save:{method:"POST",withCredentials:!0},update:{url:prApi.url+"/dashboards",params:{name:void 0},method:"PUT",withCredentials:!0,transformResponse:function(data){}},query:{method:"GET",isArray:!0,withCredentials:!0},remove:{method:"DELETE",withCredentials:!0},"delete":{method:"DELETE",withCredentials:!0}})})}(),function(){"use strict";angular.module("pr.dashboard").provider("prDashboard",function(){var widgets={},layouts={};this.widget=function(name,widget){return widgets[name]=widget,this},this.layout=function(name,layout){return layouts[name]=layout,this},this.$get=function(){var cid=0;return{widgets:widgets,layouts:layouts,id:function(){return++cid}}}})}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboardWidget",function($q,$log,$modal,prDashboard,$templateCache,$sce,$http,$controller,$compile){function getTemplate(widget){var deferred=$q.defer();if(widget.template)deferred.resolve(widget.template);else if(widget.templateUrl){var tpl=$templateCache.get(widget.templateUrl);if(tpl)deferred.resolve(tpl);else{var url=$sce.getTrustedResourceUrl(widget.templateUrl);$http.get(url).success(function(response){$templateCache.put(widget.templateUrl,response),deferred.resolve(response)}).error(function(){deferred.reject("could not load template")})}}return deferred.promise}function compileWidget($scope,$element,currentScope){var content=prDashboard.widgets[$scope.widget.type],templateScope=$scope.$new(),base={$scope:templateScope,widgetParams:$scope.widget.params,widgetOptions:$scope.widget.options},resolvers={};return resolvers.$tpl=getTemplate(content),content.resolve&&angular.forEach(content.resolve,function(promise,key){angular.isString(promise)?resolvers[key]=$injector.get(promise):resolvers[key]=$injector.invoke(promise,promise,base)}),$q.all(resolvers).then(function(locals){angular.extend(locals,base);var template=locals.$tpl,body=$element.find(".widgetContent");if(body.html(template),content.controller){var templateCtrl=$controller(content.controller,locals);body.children().data("$ngControllerController",templateCtrl)}$compile(body.contents())(templateScope)},function(reason){var msg="Could not resolve all promises";reason&&(msg+=": "+reason);var body=$element.find(".widgetContent");body.html(dashboard.messageTemplate.replace(/{}/g,msg)),$log.warn(msg)}),templateScope}return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboardWidget.html",transclude:!0,scope:{widget:"=",filters:"=",editMode:"=?",widgets:"=?"},controller:function($scope,$element){$scope.isCollapsed=!1,$scope.icon=prDashboard.widgets[$scope.widget.type].icon,$scope.title=$scope.widget.title,$scope.widget.params=$scope.widget.params||{},$scope.status={name:"new",errorMessage:null}},link:function(scope,element){compileWidget(scope,element),scope.$on("statusChanged",function(e,newStatus,errorMessage,errorResult){scope.status={name:newStatus,httpStatus:errorResult?errorResult.status:void 0,errorMessage:errorMessage},errorMessage&&$log.error("Widget SQL error: "+errorMessage,errorResult)}),scope.remove=function(){var widgets=scope.widgets;if(widgets){var index=widgets.indexOf(scope.widget);index>=0&&widgets.splice(index,1)}scope.$destroy(),element.remove()},scope.getSummary=function(){var params=scope.widget.params,dims=_.reduce(params.dimensions,function(names,dim){return names.push(dim.name),names},[]);return"Dimensions: "+_.escape(dims.join(", "))},scope.showStructure=function(){var modalInstance;modalInstance=$modal.open({scope:scope,backdrop:"static",templateUrl:"src/prReporting/prDashboard/prDashboardWidgetStructureModal.html",size:"lg"})},scope.edit=function(){var widgetType=prDashboard.widgets[scope.widget.type];if(widgetType){var modalInstance,newParams=angular.copy(scope.widget.params),newOptions=angular.copy(scope.widget.options),editScope=scope.$new();editScope.save=function(){newOptions.disabled=!1,angular.equals(newParams,scope.widget.params)||(scope.widget.params=newParams),angular.equals(newOptions,scope.widget.options)||(scope.widget.options=newOptions),modalInstance.close()},modalInstance=$modal.open({scope:editScope,backdrop:"static",template:widgetType.edit.template,templateUrl:widgetType.edit.templateUrl,controller:widgetType.edit.controller,size:"lg",resolve:{widgetParams:function(){return newParams},widgetOptions:function(){return newOptions}}})}}}}})}(),function(){"use strict";angular.module("pr.dashboard.layouts",["pr.dashboard"])}(),function(){"use strict";angular.module("pr.dashboard.layouts").config(function(prDashboardProvider){prDashboardProvider.layout("12",{displayName:"1 full width column",columns:[{mockContent:"100%",styleClass:"col-sm-12",widgets:[]}]}),prDashboardProvider.layout("6-6",{displayName:"2 columns (50% - 50%)",columns:[{mockContent:"50%",styleClass:"col-sm-6",widgets:[]},{mockContent:"50%",styleClass:"col-sm-6",widgets:[]}]}),prDashboardProvider.layout("3-3-3-3",{displayName:"4 columns (25% each)",columns:[{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]}]}),prDashboardProvider.layout("4-8",{displayName:"2 columns (33% - 66%)",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"66%",styleClass:"col-sm-8",widgets:[]}]}),prDashboardProvider.layout("8-4",{displayName:"2 columns (66% - 33%)",columns:[{mockContent:"66%",styleClass:"col-sm-8",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]}),prDashboardProvider.layout("4-4-4",{displayName:"3 columns",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.grid",["pr.dashboard","ui.select","ngSanitize","ui.grid","ui.grid.selection","ui.grid.pagination","ui.grid.autoResize","pr.gridextensions","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grid",{label:"Table",icon:"fa fa-table",templateUrl:"src/prReporting/prDashboardWidgets/grid/view.html",controller:"prGridWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/grid/edit.html",controller:"prGridWidgetEdit"}})}).directive("prGridWidget",function($compile,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,$element){$scope.options=$scope.options||{},$scope.grid={gridOptions:prUIOptionService.getSimpleGridOptions($scope.options.grid||{})},$scope.addFilter=function(dimensionName,dimensionValue){$scope.filters.where=$scope.filters.where||{},$scope.filters.where[dimensionName]=dimensionValue}},link:function(scope,element,attrs){var staticColumnDefs=scope.grid.gridOptions.columnDefs;scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);if(newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,!scope.options.disabled){scope.$emit("statusChanged","wait");var columnDefs=staticColumnDefs;columnDefs||(columnDefs=[],angular.forEach(newParams.dimensions,function(dimension){columnDefs.push({field:dimension.name,cellTemplate:'"})}),angular.forEach(newParams.metrics,function(metric){var field=metric.alias||metric.name+" "+metric.type;columnDefs.push({field:field,displayName:field,cellClass:"text-right",cellFilter:metric.filter||"number"})})),prDatasourceSqlService.getDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],!staticColumnDefs&&results.length&&results[0].timestamp&&columnDefs.push({field:"timestamp",cellFilter:"date:'short'"}),scope.grid.gridOptions.columnDefs=columnDefs,scope.grid.gridOptions.data=results,scope.$emit("statusChanged","done")},function(result){scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],scope.$emit("statusChanged","error",result.data.error,result)})}},!0)}}}).controller("prGridWidget",function($scope,widgetParams,widgetOptions){}).controller("prGridWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES)},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.pie",["nvd3","pr.dashboard","pr.datasource.sql","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-pie",{label:"Pie",icon:"fa fa-pie-chart",templateUrl:"src/prReporting/prDashboardWidgets/pie/view.html",controller:"prPieWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/pie/edit.html",controller:"prPieWidgetEdit"}})}).directive("prPieWidget",function($filter,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}},pie:{dispatch:{elementClick:function(e){if($scope.filters.where){var dimensionName=$scope.params.dimensions[0].name; +$scope.filters.where[dimensionName]=e.data.x,$scope.$apply()}}}}};$scope.pieChart={options:prUIOptionService.getPieChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),0===scope.pieChart.options.chart.width&&(scope.pieChart.options.chart.width=void 0),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results));var data=[];if(results[0]){data=results[0].values;var total=0;angular.forEach(data,function(val,index){total+=val.y}),0===total&&(data=[])}scope.pieChart.data=data,scope.$emit("statusChanged","done")},function(result){scope.pieChart.data=[],scope.pieChart.options.chart.width=0,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prPieWidget",function($scope,widgetParams,widgetOptions){}).controller("prPieWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.bar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-bar",{label:"Bar",icon:"fa fa-bar-chart",templateUrl:"src/prReporting/prDashboardWidgets/bar/view.html",controller:"prBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/bar/edit.html",controller:"prBarWidgetEdit"}})}).directive("prBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}}};$scope.barChart={options:prUIOptionService.getDiscreteBarChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.barChart.data=results,scope.barChart.options.chart.xAxis={axisLabel:results[0].key},scope.$emit("statusChanged","done")},function(result){scope.barChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.timeline",["pr.dashboard","nvd3","pr.datasource.sql","pr.UIOption"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-timeline",{label:"Timeline",icon:"fa fa-clock-o",templateUrl:"src/prReporting/prDashboardWidgets/timeline/view.html",controller:"prTimelineWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/timeline/edit.html",controller:"prTimelineWidgetEdit"}})}).directive("prTimelineWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,prApi){$scope.options=$scope.options||{};var height=$scope.options.height||180;$scope.height=height+20,$scope.defaults={margin:{top:20,right:50,bottom:20,left:80},height:height,xAxis:{axisLabel:"Time",tickFormat:function(d){return prUIOptionService.getxAxisTickFormat(d,$scope.params.granularity)}},showLegend:!0},$scope.lineChart={options:prUIOptionService.getTimeLineChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.lineChart.data||(scope.lineChart.data=[]),scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getTimeLineChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.options.isArea&&angular.forEach(scope.lineChart.data,function(data){data.area=!0}),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prTimelineWidget",function($scope,widgetParams,widgetOptions){}).controller("prTimelineWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,angular.isUndefined($scope.options.isArea)&&($scope.options.isArea=!1),$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES),$scope.granularities.splice(0,1),"all"==$scope.newParams.granularity&&($scope.newParams.granularity=$scope.granularities[0].name),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.linewithfocus",["nvd3","pr.datasource.sql","pr.dashboard","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-line-with-focus",{label:"Line with Focus",icon:"fa fa-line-chart",templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/view.html",controller:"prLineWithFocusWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/edit.html",controller:"prLineWithFocusWidgetEdit"}})}).directive("prLineWithFocusWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,showLegend:!0},$scope.lineChart={options:prUIOptionService.getLineWithFocusOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),scope.lineChart.data=[],prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getLineWithFocusOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prLineWithFocusWidget",function($scope,widgetParams,widgetOptions){}).controller("prLineWithFocusWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.newParams.granularity="five_minute"},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.stack",["nvd3","pr.dashboard","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-stack",{label:"Stack",icon:"fa fa-area-chart",templateUrl:"src/prReporting/prDashboardWidgets/stack/view.html",controller:"prStackWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/stack/edit.html",controller:"prStackWidgetEdit"}})}).directive("prStackWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,xScale:d3.time.scale(),showLegend:!0},$scope.stackChart={options:prUIOptionService.getStackedAreaChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||200,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getStackDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.stackChart.data=results,scope.stackChart.options=prUIOptionService.getStackedAreaChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prStackWidget",function($scope,widgetParams,widgetOptions){}).controller("prStackWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams;var granularities=angular.copy(GRANULARITIES);granularities.shift(),$scope.newParams.granularity&&"all"!==$scope.newParams.granularity||($scope.newParams.granularity=granularities[0].name),$scope.granularities=granularities,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||200,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.metric",["pr.dashboard","pr.countto","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-metric",{label:"Metric",icon:"fa fa-gears",templateUrl:"src/prReporting/prDashboardWidgets/metric/view.html",controller:"prMetricWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/metric/edit.html",controller:"prMetricWidgetEdit"}})}).directive("prMetricWidget",function(prDatasourceSqlService){return{restrict:"E",templateUrl:"src/prReporting/prDashboardWidgets/metric/widget.html",scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.options=$scope.options||{},$scope.icon=$scope.options.icon||"fa fa-heartbeat"},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=1,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getMetricData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.totalNumber=results,scope.$emit("statusChanged","done")},function(result){scope.totalNumber=null,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prMetricWidget",function($scope,widgetParams,widgetOptions){}).controller("prMetricWidgetEdit",function(widgetParams,widgetOptions,$scope,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initMetrics=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.initMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.groupedBar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grouped-bar",{label:"Grouped Bar",icon:"fa fa-tasks fa-rotate-270",templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/view.html",controller:"prGroupedBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/edit.html",controller:"prGroupedBarWidgetEdit"}})}).directive("prGroupedBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.groupedBarChart={};var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,margin:{top:5,right:5,bottom:5,left:100},showLegend:!0},$scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||40,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getGroupedBarData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.groupedBarChart.data=results,scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),results&&results[0]&&newParams.dimensions[0]&&(scope.groupedBarChart.options.chart.xAxis={axisLabel:newParams.dimensions[0].name}),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prGroupedBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prGroupedBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.multipleMetrics=widgetParams.metrics&&widgetParams.metrics.length>1,$scope.newParams.maxResults=widgetParams.maxResults||40,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("multipleMetrics",function(isMultipleMetrics){isMultipleMetrics&&$scope.newParams.dimensions.splice(1,$scope.newParams.dimensions.length-1)}),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.util",[])}(),function(){"use strict";angular.module("pr.dashboard.widgets.util").directive("prMetricPicker",function(){return{restrict:"E",scope:{metrics:"=",multiple:"=?",metricOptions:"=",aggregationOptions:"="},templateUrl:"src/prReporting/prDashboardWidgets/util/prMetricPicker.html",link:function(scope){function newMetric(metricName){var type=null;return scope.aggregationOptions&&scope.aggregationOptions.length&&(type=scope.aggregationOptions[0]),{name:metricName,type:type,alias:metricName}}scope.metrics=scope.metrics||[],scope.selectMetric=function(metricName){scope.metrics[0]=newMetric(metricName)},scope.addMetric=function(metricName){scope.metrics.push(newMetric(metricName))},scope.removeMetric=function(index){scope.metrics.splice(index,1)},scope.$watchGroup(["multiple","metricOptions","aggregationOptions"],function(newValues){var isMultiple=newValues[0];scope.metrics=scope.metrics||[],isMultiple||(0===scope.metrics.length&&scope.metricOptions&&scope.metricOptions.length>0&&scope.selectMetric(scope.metricOptions[0].name),scope.metrics.length>1&&scope.metrics.splice(1,scope.metrics.length-1))})}}})}(),function(){"use strict";angular.module("pr.datasource",["pr.datasource.sql"])}(),function(){"use strict";angular.module("pr.datasource.sql",["ngResource","pr.api"])}(),function(){"use strict";angular.module("pr.datasource.sql").service("prDatasourceSqlService",function($resource,prSqlBuilder,prApi){var transformDataRequest=function(param){var q={};param.table&&(q.table=param.table),param.orderBy&&(q.orderBy=param.orderBy),param.metrics&&(q.metrics=param.metrics),param.dimensions&&(q.dimensions=param.dimensions),param.maxResults&&(q.maxResults=param.maxResults),param.filters.where&&(q.where=param.filters.where),param.filters.whereRaw&&(q.whereRaw=param.filters.whereRaw);var p={sql:prSqlBuilder.buildQuery(q),intervals:param.filters.intervals,granularity:param.granularity};return angular.toJson(p)};return $resource(prApi.url+"/sql/:dataSourceName",{},{getDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,result=[];return angular.forEach(data,function(value,key){value.result&&"{}"!==angular.toJson(value.result)&&(result[key]=value.result,config.data&&"all"!==config.data.granularity&&(result[key].timestamp=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate()))}),result}},transformRequest:transformDataRequest},getHistogram:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,metrics=config.data.metrics,responses=[];return data&&data.length>0&&angular.forEach(metrics,function(metric){var response=[];angular.forEach(data,function(value){var point={};config.data.dimensions&&config.data.dimensions.length&&!config.data.isTimeline?point.x=value.result[config.data.dimensions[0].name]:point.x=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate(),point.y=value.result[prSqlBuilder.getAlias(metric)],response.push(point)}),responses.push({key:prSqlBuilder.getAlias(metric),values:response})}),responses}},transformRequest:transformDataRequest},getGroupedBarData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,dimensions=config.data.dimensions||[],metrics=config.data.metrics||[],responses=[];if(!data||0===data.length)return responses;if(2===dimensions.length&&1===metrics.length){var dim1Name=dimensions[1].name,dim2Name=dimensions[0].name,dim1Vals=[],dim2Vals=[],metricName=metrics[0].alias;angular.forEach(data,function(d){var value=d.result,dim1Val=value[dim1Name],seriesIndex=dim1Vals.indexOf(dim1Val);-1===seriesIndex&&(seriesIndex=dim1Vals.length,dim1Vals.push(dim1Val),responses.push({key:dim1Val,values:[]})),responses[seriesIndex].values.push({series:seriesIndex,x:value[dim2Name],y:value[metricName]}),-1===dim2Vals.indexOf(value[dim2Name])&&dim2Vals.push(value[dim2Name])}),responses.forEach(function(series,seriesIndex){dim2Vals.forEach(function(dimValue){var have=!1;series.values.forEach(function(e){e.x===dimValue&&(have=!0)}),have||series.values.push({series:seriesIndex,x:dimValue,y:0})})})}else if(1===dimensions.length){var metricNames=[],dimName=dimensions[0].name;angular.forEach(data,function(d){var value=d.result,dimValue=value[dimName];angular.forEach(value,function(val,key){if(key!==dimName){var metricName=key,seriesIndex=metricNames.indexOf(metricName);-1===seriesIndex&&(seriesIndex=responses.length,metricNames.push(metricName),responses.push({key:metricName,values:[]})),responses[seriesIndex].values.push({x:dimValue,y:val})}})})}return responses.forEach(function(series){series.values.sort(function(v1,v2){return v1.x===v2.x?0:v1.x>v2.x?-1:1})}),responses}},transformRequest:transformDataRequest},getStackDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,metricName=prSqlBuilder.getAlias(config.data.metrics[0]),dimensionName=config.data.dimensions[0]?config.data.dimensions[0].name:null,dimensionValues=[],series=[],timestampGroups=_.groupBy(data,"timestamp"),maxTimestampGroupLength=0;for(var d in timestampGroups)maxTimestampGroupLength=maxTimestampGroupLengthseriesIndex;seriesIndex++)if(series[seriesIndex]||(series[seriesIndex]=[]),series[seriesIndex][timestampIndex]={x:date,y:0},timestampGroup[seriesIndex]){var resultValue=timestampGroup[seriesIndex].result;series[seriesIndex][timestampIndex].y=resultValue[metricName],dimensionValues[seriesIndex]=resultValue[dimensionName]}timestampIndex++}var results=[];return angular.forEach(series,function(serie,i){results.push({key:dimensionValues[i]||metricName,values:serie})}),results}},transformRequest:transformDataRequest},getMetricData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var alias=prSqlBuilder.getAlias(response.config.data.metrics[0]);return response.data[0].result[alias]}},transformRequest:transformDataRequest},getDataSources:{method:"GET",url:prApi.url+"/datasources?right=view",isArray:!0,withCredentials:!0},getTables:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"show tables from "+param.dataSourceName};return angular.toJson(p)}},getDimensions:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".dimensions"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(dimension){response.push({name:dimension})}),response}}},getMetrics:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".metrics"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(metric){response.push({name:metric})}),response}}}})})}(),function(){"use strict";angular.module("pr.datasource.sql").factory("prSqlBuilder",function($log){function orWhereFromArray(k,key,array,operator){return array.length>0&&k.where(function(){var i=1;if(operator)for(this.where(key,operator,array[0]);in?"-":"")+pad(Math.floor(duration.asHours()))+":"+pad(duration.minutes())+":"+pad(duration.seconds())}return""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("float",function($log,$filter){return function(n){return $log.warn('"float" filter (in pr.numberfilter module) is deprecated, please use the core "number" filter'),$filter("number")(n,2)}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("percentage",function($filter){return function(n,fractionSize){fractionSize=fractionSize||2;var res=$filter("number")(100*n,fractionSize);return res?res+"%":""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("range",function(){return function(n){for(var res=[],i=0;n>i;i++)res.push(i);return res}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("intervalDate",function(prApi){return function(time,format,originalFormat,timezone){return originalFormat=originalFormat||"X",timezone=timezone||prApi.timezone,format=format||"YYYY-MM-DD HH:mm:ss",moment(time,originalFormat).tz(timezone).format(format)}})}(),function(){"use strict";angular.module("pr.countto",[])}(),function(){"use strict";angular.module("pr.countto").directive("prCountTo",function($compile,$parse,$timeout,$filter){return{restrict:"EA",scope:{value:"=",decimals:"=?",placeholder:"=?"},template:"",link:function(scope,element){scope.placeholder=scope.placeholder||"--",scope.formatter=function(value){return $filter("number")(value,scope.decimals||0)},scope.$watch("value",function(newValue,oldValue){angular.isNumber(newValue)?element.countTo&&angular.isNumber(oldValue)?$timeout(function(){element.countTo("stop").countTo({from:oldValue,to:newValue,speed:1e3,formatter:scope.formatter,refreshInterval:100})},100):element.html(scope.formatter(newValue)):element.html(scope.placeholder)})}}})}(),function(){"use strict";angular.module("pr.gridextensions",["ui.grid","ui.grid.selection","ui.grid.pagination","ui.bootstrap.modal"])}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridHeight",function(gridUtil,$timeout){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var grid=uiGridCtrl.grid,options=grid.options,initialHeight=$attrs.prGridHeight;""===initialHeight&&(initialHeight=1*options.rowHeight,options.showHeader&&(initialHeight+=30),options.enableFiltering&&(initialHeight+=30),options.showFooter&&(initialHeight+=32),""===$attrs.uiGridPagination&&(initialHeight+=32)),$elm.css("height",initialHeight+"px");var calculateHeight=function(){var contentHeight,headerHeight=$elm.find(".ui-grid-header").size()?$elm.find(".ui-grid-header").outerHeight():grid.headerRowHeight;contentHeight=0===options.data.length?1*options.rowHeight:"uiGridPagination"in $attrs&&options.paginationPageSize&&options.data.length>options.paginationPageSize?options.paginationPageSize*options.rowHeight:options.data.length*options.rowHeight;var footerHeight=options.showFooter?options.footerRowHeight:0,columnFooterHeight=options.showColumnFooter?options.columnFooterHeight:0,scrollbarHeight=options.enableHorizontalScrollbar?gridUtil.getScrollbarWidth():0,pager=$elm.find(".ui-grid-pager-panel"),pagerHeight=pager.size()?pager.outerHeight():0,height=headerHeight+contentHeight+footerHeight+columnFooterHeight+scrollbarHeight+pagerHeight;return initialHeight>height&&(height=initialHeight),height++,height};$scope.$watch($attrs.uiGrid+".data",function(){uiGridCtrl.scrollbars=uiGridCtrl.scrollbars||[],$timeout(function(){var newHeight=calculateHeight();$elm.css("height",newHeight+"px"),grid.gridHeight=$scope.gridHeight=gridUtil.elementHeight($elm),grid.refreshCanvas()})},$attrs.prGridHeightDeep?!0:!1)}}})}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridLimitation",function(gridUtil,uiGridConstants,$modal){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var gridApi=uiGridCtrl.grid.api,selectedRows=[],maximum=$attrs.prGridLimitation;gridApi.selection.on.rowSelectionChanged($scope,function(row){selectedRows=gridApi.selection.getSelectedRows(),selectedRows.length>maximum&&($modal.open({templateUrl:"src/prReporting/prGridExtensions/prGridLimitationAlert.html",backdrop:"static",controller:function($scope,$modalInstance,maximum){$scope.maximum=maximum,$scope.cancel=function(){$modalInstance.dismiss("cancel")}},resolve:{maximum:function(){return maximum}}}),gridApi.selection.unSelectRow(row.entity)),selectedRows.length>0&&(gridApi.grid.selection.selectAll=!0)}),gridApi.selection.on.rowSelectionChangedBatch($scope,function(rows){if(gridApi.grid.selection.selectAll)gridApi.grid.selection.selectAll=!1,gridApi.selection.clearSelectedRows();else{var paginationPageSize=gridApi.grid.options.paginationPageSize,pageIndex=gridApi.pagination.getPage()-1,start=paginationPageSize*pageIndex,end=+start+ +maximum;angular.forEach(rows,function(row,index){row.isSelected=index>=start&&end>index})}})}}})}(),function(){"use strict";angular.module("pr.date",["pr.api"])}(),function(){"use strict";angular.module("pr.date").directive("prDatepicker",function(prApi){return{restrict:"E",scope:{startDate:"=",endDate:"=",callbackHandler:"&callback",timezone:"@"},template:'',link:function(scope,element,attrs){function startOfToday(){return moment().tz(timezone).startOf("day")}function endOfToday(){return moment().tz(timezone).endOf("day")}var timezone=scope.timezone||prApi.timezone,format=attrs.format||"YYYY-MM-DD",separator=" - ",callback=scope.callbackHandler?scope.callbackHandler():function(){},ranges={Today:[startOfToday(),endOfToday()],Yesterday:[startOfToday().subtract(1,"days"),endOfToday().subtract(1,"days")],"Last 7 Days":[startOfToday().subtract(1,"weeks"),endOfToday().subtract(1,"days")],"Last 30 Days":[startOfToday().subtract(30,"days"),endOfToday().subtract(1,"days")],"This Month":[startOfToday().startOf("month"),endOfToday()],"Last Month":[startOfToday().subtract(1,"month").startOf("month"),endOfToday().subtract(1,"month").endOf("month")]},maxDate=moment.tz(moment().tz(timezone).format(format),timezone),minDate=maxDate.clone().subtract(6,"month"),options={maxDate:maxDate,minDate:minDate,format:format,showDropdowns:!0,opens:attrs.opens||"right",ranges:ranges};element.daterangepicker(options,function(start,end,label){scope.startDate=moment.tz(start.startOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),scope.endDate=moment.tz(end.endOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),callback(scope.startDate,scope.endDate,start.startOf("day"),end.startOf("day")),scope.$apply()}),scope.$watchGroup(["startDate","endDate"],function(newValues){var startDate=newValues[0]?moment(newValues[0],"X").tz(timezone).format(format):null,endDate=newValues[1]?moment(newValues[1],"X").tz(timezone).format(format):null;if(startDate&&endDate){var val=startDate+separator+endDate;element.find("span").html(val),element.data("daterangepicker").setStartDate(startDate),element.data("daterangepicker").setEndDate(endDate)}})}}})}(),function(){"use strict";angular.module("pr.UIOption",["pr.numberfilter","ui.grid"])}(),function(){"use strict";angular.module("pr.UIOption").factory("prUIOptionService",function($log,$filter,uiGridConstants){var colorSet2=["#4A89DC","#3BAFDA","#37BC9B","#8CC152","#F6BB42","#E9573F","#DA4453","#967ADC","#D770AD"],prUIOptionService={_getBaseGridOptions:function(){return{data:[],enableHorizontalScrollbar:uiGridConstants.scrollbars.NEVER,enableVerticalScrollbar:uiGridConstants.scrollbars.NEVER,rowHeight:30,headerRowHeight:30,columnFooterHeight:33,enableColumnMenus:!1,enableSorting:!1,paginationPageSize:10}},getGridOptions:function(options){var defaults={paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getSimpleGridOptions:function(options){var defaults={paginationPageSizes:[],paginationTemplate:"src/prReporting/prUIOption/uiGridPagerSimple.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getFilterGridOptions:function(options){var defaults={enableFiltering:!0,paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return options&&options.columnDefs&&angular.forEach(options.columnDefs,function(col){col.filter?"undefined"==typeof col.filter.condition&&angular.merge({},!0,col.filter,{condition:uiGridConstants.filter.CONTAINS}):col.filter={condition:uiGridConstants.filter.CONTAINS}}),angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getIndexCellTemplate:function(){return $log.warn("getIndexCellTemplate in pr.UIOption:prUIOptionService is deprecated, please add you own template"),'
{{(grid.options.paginationCurrentPage - 1) * grid.options.paginationPageSize + rowRenderIndex + 1}}
'},getPieChartOptions:function(options){var defaults={type:"pieChart",color:colorSet2,margin:{top:-30,right:-30,bottom:-30,left:-30},height:300,valueFormat:$filter("number"),showLabels:!0,showLegend:!1,transitionDuration:500,labelsOutside:!1,pie:{dispatch:{}}};return{chart:angular.merge({},defaults,options||{})}},getxAxisTickFormat:function(date,granularity,timezone){return"hour"===granularity?moment(date).tz(timezone).format("MMM DD, HH:mm"):"minute"===granularity?moment(date).tz(timezone).format("MMM DD, HH:mm"):moment(date).tz(timezone).format("MMM DD")},getTimeLineChartOptions:function(options){var defaults={type:"lineChart",color:colorSet2,height:135,margin:{top:20,right:40,bottom:40,left:100},forceY:0,interpolate:"cardinal",useInteractiveGuideline:!0,xAxis:{axisLabel:"Time"},xScale:d3.time.scale().nice(d3.time.hour),yAxis:{axisLabelDistance:30}};return{chart:angular.merge({},!0,defaults,options||{})}},getLineWithFocusOptions:function(options){var defaults={type:"lineWithFocusChart",color:colorSet2,margin:{top:20,right:50,bottom:40,left:80},height:380,xAxis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}},x2Axis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getDiscreteBarChartOptions:function(options){var defaults={type:"discreteBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:5,left:100},showValues:!0,transitionDuration:500,discretebar:{dispatch:{}}};return{chart:angular.merge({},!0,defaults,options||{})}},getStackedAreaChartOptions:function(options){var defaults={type:"stackedAreaChart",color:colorSet2,height:380,margin:{top:20,right:40,bottom:50,left:100},x:function(d){return d.x},y:function(d){return d.y},useVoronoi:!1,clipEdge:!0,transitionDuration:500,useInteractiveGuideline:!0,xAxis:{showMaxMin:!1,tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getGroupedBarChartOptions:function(options){var defaults={type:"multiBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:50,left:35},reduceXTicks:!1,stacked:!1,showValues:!0,transitionDuration:500};return{chart:angular.merge({},!0,defaults,options||{})}}};return prUIOptionService})}(),function(){"use strict";angular.module("pr.UIOption").directive("prNvd3ClearTooltip",function(){var _rootScope;return{restrict:"A",controller:function($rootScope){_rootScope=$rootScope},link:function(scope,element){scope.$watch("api",function(api){var chartScope=scope.api.getScope(),off=_rootScope.$on("$stateChangeSuccess",function(){chartScope.chart&&chartScope.chart.tooltip&&d3.select("#"+chartScope.chart.tooltip.id()).remove(),off()});chartScope.$watch("chart",function(chart,oldChart){chart.id!==oldChart.id&&oldChart.tooltip&&d3.select("#"+oldChart.tooltip.id()).remove()})})}}})}(),function(){"use strict";angular.module("pr.dashboard",["ui.sortable","ui.bootstrap.modal","ngResource","pr.api"]).constant("AGGREGATION_TYPES",["count","sum","min","max","unique"]).constant("GRANULARITIES",[{name:"all",displayName:"-- Choose granularity if needed --"},{name:"hour",displayName:"Hourly"},{name:"day",displayName:"Daily"},{name:"week",displayName:"Weekly"}])}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboard",function(prDashboard){return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboard.html",scope:{layout:"=",model:"=?",filters:"=",editMode:"=",mock:"@"},link:function(scope,element,attrs){scope.sortableOptions={handle:".move-icon",connectWith:".column-inner"},scope.isEmpty=function(){var res=!0;return scope.model&&scope.model.config&&scope.model.config.columns&&angular.forEach(scope.model.config.columns,function(column){column.widgets&&column.widgets.length&&(res=!1)}),res},scope.$watch("layout",function(newValue){if(prDashboard.layouts[newValue])if(scope.mock)scope.model={config:angular.copy(prDashboard.layouts[newValue])};else if(scope.model){var newColumns=angular.copy(prDashboard.layouts[newValue].columns);angular.forEach(newColumns,function(newColumn){delete newColumn.mockContent}),angular.forEach(scope.model.config.columns,function(column,index){angular.forEach(column.widgets,function(widget){var i=newColumns[index]?index:newColumns.length-1;newColumns[i].widgets.push(widget)})}),scope.model.config.columns=newColumns}})}}})}(),function(){"use strict";angular.module("pr.dashboard").service("prDashboardResource",function($resource,prApi){return $resource(prApi.url+"/dashboards/:name",{name:"@name"},{get:{method:"GET",withCredentials:!0},save:{method:"POST",withCredentials:!0},update:{url:prApi.url+"/dashboards",params:{name:void 0},method:"PUT",withCredentials:!0,transformResponse:function(data){return void 0}},query:{method:"GET",isArray:!0,withCredentials:!0},remove:{method:"DELETE",withCredentials:!0},"delete":{method:"DELETE",withCredentials:!0}})})}(),function(){"use strict";angular.module("pr.dashboard").provider("prDashboard",function(){var widgets={},layouts={};this.widget=function(name,widget){return widgets[name]=widget,this},this.layout=function(name,layout){return layouts[name]=layout,this},this.$get=function(){var cid=0;return{widgets:widgets,layouts:layouts,id:function(){return++cid}}}})}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboardWidget",function($q,$log,$modal,prDashboard,$templateCache,$sce,$http,$controller,$compile){function getTemplate(widget){var deferred=$q.defer();if(widget.template)deferred.resolve(widget.template);else if(widget.templateUrl){var tpl=$templateCache.get(widget.templateUrl);if(tpl)deferred.resolve(tpl);else{var url=$sce.getTrustedResourceUrl(widget.templateUrl);$http.get(url).success(function(response){$templateCache.put(widget.templateUrl,response),deferred.resolve(response)}).error(function(){deferred.reject("could not load template")})}}return deferred.promise}function compileWidget($scope,$element,currentScope){var content=prDashboard.widgets[$scope.widget.type],templateScope=$scope.$new(),base={$scope:templateScope,widgetParams:$scope.widget.params,widgetOptions:$scope.widget.options},resolvers={};return resolvers.$tpl=getTemplate(content),content.resolve&&angular.forEach(content.resolve,function(promise,key){angular.isString(promise)?resolvers[key]=$injector.get(promise):resolvers[key]=$injector.invoke(promise,promise,base)}),$q.all(resolvers).then(function(locals){angular.extend(locals,base);var template=locals.$tpl,body=$element.find(".widgetContent");if(body.html(template),content.controller){var templateCtrl=$controller(content.controller,locals);body.children().data("$ngControllerController",templateCtrl)}$compile(body.contents())(templateScope)},function(reason){var msg="Could not resolve all promises";reason&&(msg+=": "+reason);var body=$element.find(".widgetContent");body.html(dashboard.messageTemplate.replace(/{}/g,msg)),$log.warn(msg)}),templateScope}return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboardWidget.html",transclude:!0,scope:{widget:"=",filters:"=",editMode:"=?",widgets:"=?"},controller:function($scope,$element){$scope.isCollapsed=!1,$scope.icon=prDashboard.widgets[$scope.widget.type].icon,$scope.title=$scope.widget.title,$scope.widget.params=$scope.widget.params||{},$scope.status={name:"new",errorMessage:null}},link:function(scope,element){compileWidget(scope,element),scope.$on("statusChanged",function(e,newStatus,errorMessage,errorResult){scope.status={name:newStatus,httpStatus:errorResult?errorResult.status:void 0,errorMessage:errorMessage},errorMessage&&$log.error("Widget SQL error: "+errorMessage,errorResult)}),scope.remove=function(){var widgets=scope.widgets;if(widgets){var index=widgets.indexOf(scope.widget);index>=0&&widgets.splice(index,1)}scope.$destroy(),element.remove()},scope.getSummary=function(){var params=scope.widget.params,dims=_.reduce(params.dimensions,function(names,dim){return names.push(dim.name),names},[]);return"Dimensions: "+_.escape(dims.join(", "))},scope.showStructure=function(){var modalInstance;modalInstance=$modal.open({scope:scope,backdrop:"static",templateUrl:"src/prReporting/prDashboard/prDashboardWidgetStructureModal.html",size:"lg"})},scope.edit=function(){var widgetType=prDashboard.widgets[scope.widget.type];if(widgetType){var modalInstance,newParams=angular.copy(scope.widget.params),newOptions=angular.copy(scope.widget.options),editScope=scope.$new();editScope.save=function(){newOptions.disabled=!1,angular.equals(newParams,scope.widget.params)||(scope.widget.params=newParams),angular.equals(newOptions,scope.widget.options)||(scope.widget.options=newOptions),modalInstance.close()},modalInstance=$modal.open({scope:editScope,backdrop:"static",template:widgetType.edit.template,templateUrl:widgetType.edit.templateUrl,controller:widgetType.edit.controller,size:"lg",resolve:{widgetParams:function(){return newParams},widgetOptions:function(){return newOptions}}})}}}}})}(),function(){"use strict";angular.module("pr.dashboard.layouts",["pr.dashboard"])}(),function(){"use strict";angular.module("pr.dashboard.layouts").config(function(prDashboardProvider){prDashboardProvider.layout("12",{displayName:"1 full width column",columns:[{mockContent:"100%",styleClass:"col-sm-12",widgets:[]}]}),prDashboardProvider.layout("6-6",{displayName:"2 columns (50% - 50%)",columns:[{mockContent:"50%",styleClass:"col-sm-6",widgets:[]},{mockContent:"50%",styleClass:"col-sm-6",widgets:[]}]}),prDashboardProvider.layout("3-3-3-3",{displayName:"4 columns (25% each)",columns:[{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]}]}),prDashboardProvider.layout("4-8",{displayName:"2 columns (33% - 66%)",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"66%",styleClass:"col-sm-8",widgets:[]}]}),prDashboardProvider.layout("8-4",{displayName:"2 columns (66% - 33%)",columns:[{mockContent:"66%",styleClass:"col-sm-8",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]}),prDashboardProvider.layout("4-4-4",{displayName:"3 columns",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.grid",["pr.dashboard","ui.select","ngSanitize","ui.grid","ui.grid.selection","ui.grid.pagination","ui.grid.autoResize","pr.gridextensions","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grid",{label:"Table",icon:"fa fa-table",templateUrl:"src/prReporting/prDashboardWidgets/grid/view.html",controller:"prGridWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/grid/edit.html",controller:"prGridWidgetEdit"}})}).directive("prGridWidget",function($compile,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,$element){$scope.options=$scope.options||{},$scope.grid={gridOptions:prUIOptionService.getSimpleGridOptions($scope.options.grid||{})},$scope.addFilter=function(dimensionName,dimensionValue){$scope.filters.where=$scope.filters.where||{},$scope.filters.where[dimensionName]=dimensionValue}},link:function(scope,element,attrs){var staticColumnDefs=scope.grid.gridOptions.columnDefs;scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);if(newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,!scope.options.disabled){scope.$emit("statusChanged","wait");var columnDefs=staticColumnDefs;columnDefs||(columnDefs=[],angular.forEach(newParams.dimensions,function(dimension){columnDefs.push({field:dimension.name,cellTemplate:'"})}),angular.forEach(newParams.metrics,function(metric){var field=metric.alias||metric.name+" "+metric.type;columnDefs.push({field:field,displayName:field,cellClass:"text-right",cellFilter:metric.filter||"number"})})),prDatasourceSqlService.getDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],!staticColumnDefs&&results.length&&results[0].timestamp&&columnDefs.push({field:"timestamp",cellFilter:"date:'short'"}),scope.grid.gridOptions.columnDefs=columnDefs,scope.grid.gridOptions.data=results,scope.$emit("statusChanged","done")},function(result){scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],scope.$emit("statusChanged","error",result.data.error,result)})}},!0)}}}).controller("prGridWidget",function($scope,widgetParams,widgetOptions){}).controller("prGridWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES)},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.pie",["nvd3","pr.dashboard","pr.datasource.sql","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-pie",{label:"Pie",icon:"fa fa-pie-chart",templateUrl:"src/prReporting/prDashboardWidgets/pie/view.html",controller:"prPieWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/pie/edit.html",controller:"prPieWidgetEdit"}})}).directive("prPieWidget",function($filter,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}},pie:{dispatch:{elementClick:function(e){if($scope.filters.where){var dimensionName=$scope.params.dimensions[0].name;$scope.filters.where[dimensionName]=e.data.x,$scope.$apply()}}}}};$scope.pieChart={options:prUIOptionService.getPieChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),0===scope.pieChart.options.chart.width&&(scope.pieChart.options.chart.width=void 0),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results));var data=[];if(results[0]){data=results[0].values;var total=0;angular.forEach(data,function(val,index){total+=val.y}),0===total&&(data=[])}scope.pieChart.data=data,scope.$emit("statusChanged","done")},function(result){scope.pieChart.data=[],scope.pieChart.options.chart.width=0,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prPieWidget",function($scope,widgetParams,widgetOptions){}).controller("prPieWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.bar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-bar",{label:"Bar",icon:"fa fa-bar-chart",templateUrl:"src/prReporting/prDashboardWidgets/bar/view.html",controller:"prBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/bar/edit.html",controller:"prBarWidgetEdit"}})}).directive("prBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}}};$scope.barChart={options:prUIOptionService.getDiscreteBarChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.barChart.data=results,scope.barChart.options.chart.xAxis={axisLabel:results[0].key},scope.$emit("statusChanged","done")},function(result){scope.barChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.timeline",["pr.dashboard","nvd3","pr.datasource.sql","pr.UIOption"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-timeline",{label:"Timeline",icon:"fa fa-clock-o",templateUrl:"src/prReporting/prDashboardWidgets/timeline/view.html",controller:"prTimelineWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/timeline/edit.html",controller:"prTimelineWidgetEdit"}})}).directive("prTimelineWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,prApi){$scope.options=$scope.options||{};var height=$scope.options.height||180;$scope.height=height+20,$scope.defaults={margin:{top:20,right:50,bottom:20,left:80},height:height,xAxis:{axisLabel:"Time",tickFormat:function(d){return console.lo,prUIOptionService.getxAxisTickFormat(d,$scope.params.granularity,prApi.timezone); -}},showLegend:!0},$scope.lineChart={options:prUIOptionService.getTimeLineChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.lineChart.data||(scope.lineChart.data=[]),scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getTimeLineChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.options.isArea&&angular.forEach(scope.lineChart.data,function(data){data.area=!0}),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prTimelineWidget",function($scope,widgetParams,widgetOptions){}).controller("prTimelineWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,angular.isUndefined($scope.options.isArea)&&($scope.options.isArea=!1),$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES),$scope.granularities.splice(0,1),"all"==$scope.newParams.granularity&&($scope.newParams.granularity=$scope.granularities[0].name),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.linewithfocus",["nvd3","pr.datasource.sql","pr.dashboard","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-line-with-focus",{label:"Line with Focus",icon:"fa fa-line-chart",templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/view.html",controller:"prLineWithFocusWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/edit.html",controller:"prLineWithFocusWidgetEdit"}})}).directive("prLineWithFocusWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,showLegend:!0},$scope.lineChart={options:prUIOptionService.getLineWithFocusOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),scope.lineChart.data=[],prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getLineWithFocusOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prLineWithFocusWidget",function($scope,widgetParams,widgetOptions){}).controller("prLineWithFocusWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.newParams.granularity="five_minute"},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.stack",["nvd3","pr.dashboard","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-stack",{label:"Stack",icon:"fa fa-area-chart",templateUrl:"src/prReporting/prDashboardWidgets/stack/view.html",controller:"prStackWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/stack/edit.html",controller:"prStackWidgetEdit"}})}).directive("prStackWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,xScale:d3.time.scale(),showLegend:!0},$scope.stackChart={options:prUIOptionService.getStackedAreaChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||200,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getStackDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.stackChart.data=results,scope.stackChart.options=prUIOptionService.getStackedAreaChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prStackWidget",function($scope,widgetParams,widgetOptions){}).controller("prStackWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams;var granularities=angular.copy(GRANULARITIES);granularities.shift(),$scope.newParams.granularity&&"all"!==$scope.newParams.granularity||($scope.newParams.granularity=granularities[0].name),$scope.granularities=granularities,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||200,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.metric",["pr.dashboard","pr.countto","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-metric",{label:"Metric",icon:"fa fa-gears",templateUrl:"src/prReporting/prDashboardWidgets/metric/view.html",controller:"prMetricWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/metric/edit.html",controller:"prMetricWidgetEdit"}})}).directive("prMetricWidget",function(prDatasourceSqlService){return{restrict:"E",templateUrl:"src/prReporting/prDashboardWidgets/metric/widget.html",scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.options=$scope.options||{},$scope.icon=$scope.options.icon||"fa fa-heartbeat"},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=1,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getMetricData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.totalNumber=results,scope.$emit("statusChanged","done")},function(result){scope.totalNumber=null,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prMetricWidget",function($scope,widgetParams,widgetOptions){}).controller("prMetricWidgetEdit",function(widgetParams,widgetOptions,$scope,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initMetrics=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.initMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.groupedBar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grouped-bar",{label:"Grouped Bar",icon:"fa fa-tasks fa-rotate-270",templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/view.html",controller:"prGroupedBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/edit.html",controller:"prGroupedBarWidgetEdit"}})}).directive("prGroupedBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.groupedBarChart={};var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,margin:{top:5,right:5,bottom:5,left:100},showLegend:!0},$scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||40,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getGroupedBarData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.groupedBarChart.data=results,scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),results&&results[0]&&newParams.dimensions[0]&&(scope.groupedBarChart.options.chart.xAxis={axisLabel:newParams.dimensions[0].name}),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prGroupedBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prGroupedBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.multipleMetrics=widgetParams.metrics&&widgetParams.metrics.length>1,$scope.newParams.maxResults=widgetParams.maxResults||40,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("multipleMetrics",function(isMultipleMetrics){isMultipleMetrics&&$scope.newParams.dimensions.splice(1,$scope.newParams.dimensions.length-1)}),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.util",[])}(),function(){"use strict";angular.module("pr.dashboard.widgets.util").directive("prMetricPicker",function(){return{restrict:"E",scope:{metrics:"=",multiple:"=?",metricOptions:"=",aggregationOptions:"="},templateUrl:"src/prReporting/prDashboardWidgets/util/prMetricPicker.html",link:function(scope){function newMetric(metricName){var type=null;return scope.aggregationOptions&&scope.aggregationOptions.length&&(type=scope.aggregationOptions[0]),{name:metricName,type:type,alias:metricName}}scope.metrics=scope.metrics||[],scope.selectMetric=function(metricName){scope.metrics[0]=newMetric(metricName)},scope.addMetric=function(metricName){scope.metrics.push(newMetric(metricName))},scope.removeMetric=function(index){scope.metrics.splice(index,1)},scope.$watchGroup(["multiple","metricOptions","aggregationOptions"],function(newValues){var isMultiple=newValues[0];scope.metrics=scope.metrics||[],isMultiple||(0===scope.metrics.length&&scope.metricOptions&&scope.metricOptions.length>0&&scope.selectMetric(scope.metricOptions[0].name),scope.metrics.length>1&&scope.metrics.splice(1,scope.metrics.length-1))})}}})}(),function(){"use strict";angular.module("pr.datasource",["pr.datasource.sql"])}(),function(){"use strict";angular.module("pr.datasource.sql",["ngResource","pr.api"])}(),function(){"use strict";angular.module("pr.datasource.sql").service("prDatasourceSqlService",function($resource,prSqlBuilder,prApi){var transformDataRequest=function(param){var q={};param.table&&(q.table=param.table),param.orderBy&&(q.orderBy=param.orderBy),param.metrics&&(q.metrics=param.metrics),param.dimensions&&(q.dimensions=param.dimensions),param.maxResults&&(q.maxResults=param.maxResults),param.filters.where&&(q.where=param.filters.where),param.filters.whereRaw&&(q.whereRaw=param.filters.whereRaw);var p={sql:prSqlBuilder.buildQuery(q),intervals:param.filters.intervals,granularity:param.granularity};return angular.toJson(p)};return $resource(prApi.url+"/sql/:dataSourceName",{},{getDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,result=[];return angular.forEach(data,function(value,key){value.result&&"{}"!==angular.toJson(value.result)&&(result[key]=value.result,config.data&&"all"!==config.data.granularity&&(result[key].timestamp=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate()))}),result}},transformRequest:transformDataRequest},getHistogram:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,metrics=config.data.metrics,responses=[];return data&&data.length>0&&angular.forEach(metrics,function(metric){var response=[];angular.forEach(data,function(value){var point={};config.data.dimensions&&config.data.dimensions.length&&!config.data.isTimeline?point.x=value.result[config.data.dimensions[0].name]:point.x=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate(),point.y=value.result[prSqlBuilder.getAlias(metric)],response.push(point)}),responses.push({key:prSqlBuilder.getAlias(metric),values:response})}),responses}},transformRequest:transformDataRequest},getGroupedBarData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,dimensions=config.data.dimensions||[],metrics=config.data.metrics||[],responses=[];if(!data||0===data.length)return responses;if(2===dimensions.length&&1===metrics.length){var dim1Name=dimensions[1].name,dim2Name=dimensions[0].name,dim1Vals=[],dim2Vals=[],metricName=metrics[0].alias;angular.forEach(data,function(d){var value=d.result,dim1Val=value[dim1Name],seriesIndex=dim1Vals.indexOf(dim1Val);-1===seriesIndex&&(seriesIndex=dim1Vals.length,dim1Vals.push(dim1Val),responses.push({key:dim1Val,values:[]})),responses[seriesIndex].values.push({series:seriesIndex,x:value[dim2Name],y:value[metricName]}),-1===dim2Vals.indexOf(value[dim2Name])&&dim2Vals.push(value[dim2Name])}),responses.forEach(function(series,seriesIndex){dim2Vals.forEach(function(dimValue){var have=!1;series.values.forEach(function(e){e.x===dimValue&&(have=!0)}),have||series.values.push({series:seriesIndex,x:dimValue,y:0})})})}else if(1===dimensions.length){var metricNames=[],dimName=dimensions[0].name;angular.forEach(data,function(d){var value=d.result,dimValue=value[dimName];angular.forEach(value,function(val,key){if(key!==dimName){var metricName=key,seriesIndex=metricNames.indexOf(metricName);-1===seriesIndex&&(seriesIndex=responses.length,metricNames.push(metricName),responses.push({key:metricName,values:[]})),responses[seriesIndex].values.push({x:dimValue,y:val})}})})}return responses.forEach(function(series){series.values.sort(function(v1,v2){return v1.x===v2.x?0:v1.x>v2.x?-1:1})}),responses}},transformRequest:transformDataRequest},getStackDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,metricName=prSqlBuilder.getAlias(config.data.metrics[0]),dimensionName=config.data.dimensions[0]?config.data.dimensions[0].name:null,dimensionValues=[],series=[],timestampGroups=_.groupBy(data,"timestamp"),maxTimestampGroupLength=0;for(var d in timestampGroups)maxTimestampGroupLength=maxTimestampGroupLengthseriesIndex;seriesIndex++)if(series[seriesIndex]||(series[seriesIndex]=[]),series[seriesIndex][timestampIndex]={x:date,y:0},timestampGroup[seriesIndex]){var resultValue=timestampGroup[seriesIndex].result;series[seriesIndex][timestampIndex].y=resultValue[metricName],dimensionValues[seriesIndex]=resultValue[dimensionName]}timestampIndex++}var results=[];return angular.forEach(series,function(serie,i){results.push({key:dimensionValues[i]||metricName,values:serie})}),results}},transformRequest:transformDataRequest},getMetricData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var alias=prSqlBuilder.getAlias(response.config.data.metrics[0]);return response.data[0].result[alias]}},transformRequest:transformDataRequest},getDataSources:{method:"GET",url:prApi.url+"/datasources?right=view",isArray:!0,withCredentials:!0},getTables:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"show tables from "+param.dataSourceName};return angular.toJson(p)}},getDimensions:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".dimensions"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(dimension){response.push({name:dimension})}),response}}},getMetrics:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".metrics"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(metric){response.push({name:metric})}),response}}}})})}(),function(){"use strict";angular.module("pr.datasource.sql").factory("prSqlBuilder",function($log){function orWhereFromArray(k,key,array,operator){return array.length>0&&k.where(function(){var i=1;if(operator)for(this.where(key,operator,array[0]);in?"-":"")+pad(Math.floor(duration.asHours()))+":"+pad(duration.minutes())+":"+pad(duration.seconds())}return""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("float",function($log,$filter){return function(n){return $log.warn('"float" filter (in pr.numberfilter module) is deprecated, please use the core "number" filter'),$filter("number")(n,2)}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("percentage",function($filter){return function(n,fractionSize){fractionSize=fractionSize||2;var res=$filter("number")(100*n,fractionSize);return res?res+"%":""}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("range",function(){return function(n){for(var res=[],i=0;n>i;i++)res.push(i);return res}})}(),function(){"use strict";angular.module("pr.numberfilter").filter("intervalDate",function(prApi){return function(time,format,originalFormat,timezone){return originalFormat=originalFormat||"X",timezone=timezone||prApi.timezone,format=format||"YYYY-MM-DD HH:mm:ss",moment(time,originalFormat).tz(timezone).format(format)}})}(),function(){"use strict";angular.module("pr.countto",[])}(),function(){"use strict";angular.module("pr.countto").directive("prCountTo",function($compile,$parse,$timeout,$filter){return{restrict:"EA",scope:{value:"=",decimals:"=?",placeholder:"=?"},template:"",link:function(scope,element){scope.placeholder=scope.placeholder||"--",scope.formatter=function(value){return $filter("number")(value,scope.decimals||0)},scope.$watch("value",function(newValue,oldValue){angular.isNumber(newValue)?element.countTo&&angular.isNumber(oldValue)?$timeout(function(){element.countTo("stop").countTo({from:oldValue,to:newValue,speed:1e3,formatter:scope.formatter,refreshInterval:100})},100):element.html(scope.formatter(newValue)):element.html(scope.placeholder)})}}})}(),function(){"use strict";angular.module("pr.gridextensions",["ui.grid","ui.grid.selection","ui.grid.pagination","ui.bootstrap.modal"])}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridHeight",function(gridUtil,$timeout){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var grid=uiGridCtrl.grid,options=grid.options,initialHeight=$attrs.prGridHeight;""===initialHeight&&(initialHeight=1*options.rowHeight,options.showHeader&&(initialHeight+=30),options.enableFiltering&&(initialHeight+=30),options.showFooter&&(initialHeight+=32),""===$attrs.uiGridPagination&&(initialHeight+=32)),$elm.css("height",initialHeight+"px");var calculateHeight=function(){var contentHeight,headerHeight=$elm.find(".ui-grid-header").size()?$elm.find(".ui-grid-header").outerHeight():grid.headerRowHeight;contentHeight=0===options.data.length?1*options.rowHeight:"uiGridPagination"in $attrs&&options.paginationPageSize&&options.data.length>options.paginationPageSize?options.paginationPageSize*options.rowHeight:options.data.length*options.rowHeight;var footerHeight=options.showFooter?options.footerRowHeight:0,columnFooterHeight=options.showColumnFooter?options.columnFooterHeight:0,scrollbarHeight=options.enableHorizontalScrollbar?gridUtil.getScrollbarWidth():0,pager=$elm.find(".ui-grid-pager-panel"),pagerHeight=pager.size()?pager.outerHeight():0,height=headerHeight+contentHeight+footerHeight+columnFooterHeight+scrollbarHeight+pagerHeight;return initialHeight>height&&(height=initialHeight),height++,height};$scope.$watch($attrs.uiGrid+".data",function(){uiGridCtrl.scrollbars=uiGridCtrl.scrollbars||[],$timeout(function(){var newHeight=calculateHeight();$elm.css("height",newHeight+"px"),grid.gridHeight=$scope.gridHeight=gridUtil.elementHeight($elm),grid.refreshCanvas()})},$attrs.prGridHeightDeep?!0:!1)}}})}(),function(){"use strict";angular.module("pr.gridextensions").directive("prGridLimitation",function(gridUtil,uiGridConstants,$modal){return{restrict:"A",require:"uiGrid",link:function($scope,$elm,$attrs,uiGridCtrl){var gridApi=uiGridCtrl.grid.api,selectedRows=[],maximum=$attrs.prGridLimitation;gridApi.selection.on.rowSelectionChanged($scope,function(row){selectedRows=gridApi.selection.getSelectedRows(),selectedRows.length>maximum&&($modal.open({templateUrl:"src/prReporting/prGridExtensions/prGridLimitationAlert.html",backdrop:"static",controller:function($scope,$modalInstance,maximum){$scope.maximum=maximum,$scope.cancel=function(){$modalInstance.dismiss("cancel")}},resolve:{maximum:function(){return maximum}}}),gridApi.selection.unSelectRow(row.entity)),selectedRows.length>0&&(gridApi.grid.selection.selectAll=!0)}),gridApi.selection.on.rowSelectionChangedBatch($scope,function(rows){if(gridApi.grid.selection.selectAll)gridApi.grid.selection.selectAll=!1,gridApi.selection.clearSelectedRows();else{var paginationPageSize=gridApi.grid.options.paginationPageSize,pageIndex=gridApi.pagination.getPage()-1,start=paginationPageSize*pageIndex,end=+start+ +maximum;angular.forEach(rows,function(row,index){row.isSelected=index>=start&&end>index})}})}}})}(),function(){"use strict";angular.module("pr.date",["pr.api"])}(),function(){"use strict";angular.module("pr.date").directive("prDatepicker",function(prApi){return{restrict:"E",scope:{startDate:"=",endDate:"=",callbackHandler:"&callback",timezone:"@"},template:'',link:function(scope,element,attrs){function startOfToday(){return moment().tz(timezone).startOf("day")}function endOfToday(){return moment().tz(timezone).endOf("day")}var timezone=scope.timezone||prApi.timezone,format=attrs.format||"YYYY-MM-DD",separator=" - ",callback=scope.callbackHandler?scope.callbackHandler():function(){},ranges={Today:[startOfToday(),endOfToday()],Yesterday:[startOfToday().subtract(1,"days"),endOfToday().subtract(1,"days")],"Last 7 Days":[startOfToday().subtract(1,"weeks"),endOfToday().subtract(1,"days")],"Last 30 Days":[startOfToday().subtract(30,"days"),endOfToday().subtract(1,"days")],"This Month":[startOfToday().startOf("month"),endOfToday()],"Last Month":[startOfToday().subtract(1,"month").startOf("month"),endOfToday().subtract(1,"month").endOf("month")]},maxDate=moment.tz(moment().tz(timezone).format(format),timezone),minDate=maxDate.clone().subtract(6,"month"),options={maxDate:maxDate,minDate:minDate,format:format,showDropdowns:!0,opens:attrs.opens||"right",ranges:ranges};element.daterangepicker(options,function(start,end,label){scope.startDate=moment.tz(start.startOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),scope.endDate=moment.tz(end.endOf("day").format("YYYY-MM-DD HH:mm:ss"),timezone).format("X"),callback(scope.startDate,scope.endDate,start.startOf("day"),end.startOf("day")),scope.$apply()}),scope.$watchGroup(["startDate","endDate"],function(newValues){var startDate=newValues[0]?moment(newValues[0],"X").tz(timezone).format(format):null,endDate=newValues[1]?moment(newValues[1],"X").tz(timezone).format(format):null;if(startDate&&endDate){var val=startDate+separator+endDate;element.find("span").html(val),element.data("daterangepicker").setStartDate(startDate),element.data("daterangepicker").setEndDate(endDate)}})}}})}(),function(){"use strict";angular.module("pr.UIOption",["pr.numberfilter","ui.grid"])}(),function(){"use strict";angular.module("pr.UIOption").factory("prUIOptionService",function($log,$filter,uiGridConstants){var colorSet2=["#4A89DC","#3BAFDA","#37BC9B","#8CC152","#F6BB42","#E9573F","#DA4453","#967ADC","#D770AD"],prUIOptionService={_getBaseGridOptions:function(){return{data:[],enableHorizontalScrollbar:uiGridConstants.scrollbars.NEVER,enableVerticalScrollbar:uiGridConstants.scrollbars.NEVER,rowHeight:30,headerRowHeight:30,columnFooterHeight:33,enableColumnMenus:!1,enableSorting:!1,paginationPageSize:10}},getGridOptions:function(options){var defaults={paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getSimpleGridOptions:function(options){var defaults={paginationPageSizes:[],paginationTemplate:"src/prReporting/prUIOption/uiGridPagerSimple.html"};return angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getFilterGridOptions:function(options){var defaults={enableFiltering:!0,paginationPageSizes:[10],paginationTemplate:"src/prReporting/prUIOption/uiGridPager.html"};return options&&options.columnDefs&&angular.forEach(options.columnDefs,function(col){col.filter?"undefined"==typeof col.filter.condition&&angular.merge({},!0,col.filter,{condition:uiGridConstants.filter.CONTAINS}):col.filter={condition:uiGridConstants.filter.CONTAINS}}),angular.merge({},prUIOptionService._getBaseGridOptions(),defaults,options||{})},getIndexCellTemplate:function(){return $log.warn("getIndexCellTemplate in pr.UIOption:prUIOptionService is deprecated, please add you own template"),'
{{(grid.options.paginationCurrentPage - 1) * grid.options.paginationPageSize + rowRenderIndex + 1}}
'},getPieChartOptions:function(options){var defaults={type:"pieChart",color:colorSet2,margin:{top:-30,right:-30,bottom:-30,left:-30},height:300,valueFormat:$filter("number"),showLabels:!0,showLegend:!1,transitionDuration:500,labelsOutside:!1,pie:{dispatch:{}}};return{chart:angular.merge({},defaults,options||{})}},getxAxisTickFormat:function(date,granularity){return"hour"===granularity?moment(date).format("MMM DD, HH:mm"):"minute"===granularity?moment(date).format("MMM DD, HH:mm"):moment(date).format("MMM DD")},getTimeLineChartOptions:function(options){var defaults={type:"lineChart",color:colorSet2,height:135,margin:{top:20,right:40,bottom:40,left:100},forceY:0,interpolate:"cardinal",useInteractiveGuideline:!0,xAxis:{axisLabel:"Time"},xScale:d3.time.scale().nice(d3.time.hour),yAxis:{axisLabelDistance:30}};return{chart:angular.merge({},!0,defaults,options||{})}},getLineWithFocusOptions:function(options){var defaults={type:"lineWithFocusChart",color:colorSet2,margin:{top:20,right:50,bottom:40,left:80},height:380,xAxis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}},x2Axis:{axisLabel:"Time",tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getDiscreteBarChartOptions:function(options){var defaults={type:"discreteBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:5,left:100},showValues:!0,transitionDuration:500,discretebar:{dispatch:{}}};return{chart:angular.merge({},!0,defaults,options||{})}},getStackedAreaChartOptions:function(options){var defaults={type:"stackedAreaChart",color:colorSet2,height:380,margin:{top:20,right:40,bottom:50,left:100},x:function(d){return d.x},y:function(d){return d.y},useVoronoi:!1,clipEdge:!0,transitionDuration:500,useInteractiveGuideline:!0,xAxis:{showMaxMin:!1,tickFormat:function(d){return moment(d).format("MMM DD, HH:mm")}}};return{chart:angular.merge({},!0,defaults,options||{})}},getGroupedBarChartOptions:function(options){var defaults={type:"multiBarChart",color:colorSet2,height:300,margin:{top:5,right:5,bottom:50,left:35},reduceXTicks:!1,stacked:!1,showValues:!0,transitionDuration:500};return{chart:angular.merge({},!0,defaults,options||{})}}};return prUIOptionService})}(),function(){"use strict";angular.module("pr.UIOption").directive("prNvd3ClearTooltip",function(){var _rootScope;return{restrict:"A",controller:function($rootScope){_rootScope=$rootScope},link:function(scope,element){scope.$watch("api",function(api){var chartScope=scope.api.getScope(),off=_rootScope.$on("$stateChangeSuccess",function(){chartScope.chart&&chartScope.chart.tooltip&&d3.select("#"+chartScope.chart.tooltip.id()).remove(),off()});chartScope.$watch("chart",function(chart,oldChart){chart.id!==oldChart.id&&oldChart.tooltip&&d3.select("#"+oldChart.tooltip.id()).remove()})})}}})}(),function(){"use strict";angular.module("pr.dashboard",["ui.sortable","ui.bootstrap.modal","ngResource","pr.api"]).constant("AGGREGATION_TYPES",["count","sum","min","max","unique"]).constant("GRANULARITIES",[{name:"all",displayName:"-- Choose granularity if needed --"},{name:"hour",displayName:"Hourly"},{name:"day",displayName:"Daily"},{name:"week",displayName:"Weekly"}])}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboard",function(prDashboard){return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboard.html",scope:{layout:"=",model:"=?",filters:"=",editMode:"=",mock:"@"},link:function(scope,element,attrs){scope.sortableOptions={handle:".move-icon",connectWith:".column-inner"},scope.isEmpty=function(){var res=!0;return scope.model&&scope.model.config&&scope.model.config.columns&&angular.forEach(scope.model.config.columns,function(column){column.widgets&&column.widgets.length&&(res=!1)}),res},scope.$watch("layout",function(newValue){if(prDashboard.layouts[newValue])if(scope.mock)scope.model={config:angular.copy(prDashboard.layouts[newValue])};else if(scope.model){var newColumns=angular.copy(prDashboard.layouts[newValue].columns);angular.forEach(newColumns,function(newColumn){delete newColumn.mockContent}),angular.forEach(scope.model.config.columns,function(column,index){angular.forEach(column.widgets,function(widget){var i=newColumns[index]?index:newColumns.length-1;newColumns[i].widgets.push(widget)})}),scope.model.config.columns=newColumns}})}}})}(),function(){"use strict";angular.module("pr.dashboard").service("prDashboardResource",function($resource,prApi){return $resource(prApi.url+"/dashboards/:name",{name:"@name"},{get:{method:"GET",withCredentials:!0},save:{method:"POST",withCredentials:!0},update:{url:prApi.url+"/dashboards",params:{name:void 0},method:"PUT",withCredentials:!0,transformResponse:function(data){}},query:{method:"GET",isArray:!0,withCredentials:!0},remove:{method:"DELETE",withCredentials:!0},"delete":{method:"DELETE",withCredentials:!0}})})}(),function(){"use strict";angular.module("pr.dashboard").provider("prDashboard",function(){var widgets={},layouts={};this.widget=function(name,widget){return widgets[name]=widget,this},this.layout=function(name,layout){return layouts[name]=layout,this},this.$get=function(){var cid=0;return{widgets:widgets,layouts:layouts,id:function(){return++cid}}}})}(),function(){"use strict";angular.module("pr.dashboard").directive("prDashboardWidget",function($q,$log,$modal,prDashboard,$templateCache,$sce,$http,$controller,$compile){function getTemplate(widget){var deferred=$q.defer();if(widget.template)deferred.resolve(widget.template);else if(widget.templateUrl){var tpl=$templateCache.get(widget.templateUrl);if(tpl)deferred.resolve(tpl);else{var url=$sce.getTrustedResourceUrl(widget.templateUrl);$http.get(url).success(function(response){$templateCache.put(widget.templateUrl,response),deferred.resolve(response)}).error(function(){deferred.reject("could not load template")})}}return deferred.promise}function compileWidget($scope,$element,currentScope){var content=prDashboard.widgets[$scope.widget.type],templateScope=$scope.$new(),base={$scope:templateScope,widgetParams:$scope.widget.params,widgetOptions:$scope.widget.options},resolvers={};return resolvers.$tpl=getTemplate(content),content.resolve&&angular.forEach(content.resolve,function(promise,key){angular.isString(promise)?resolvers[key]=$injector.get(promise):resolvers[key]=$injector.invoke(promise,promise,base)}),$q.all(resolvers).then(function(locals){angular.extend(locals,base);var template=locals.$tpl,body=$element.find(".widgetContent");if(body.html(template),content.controller){var templateCtrl=$controller(content.controller,locals);body.children().data("$ngControllerController",templateCtrl)}$compile(body.contents())(templateScope)},function(reason){var msg="Could not resolve all promises";reason&&(msg+=": "+reason);var body=$element.find(".widgetContent");body.html(dashboard.messageTemplate.replace(/{}/g,msg)),$log.warn(msg)}),templateScope}return{restrict:"E",templateUrl:"src/prReporting/prDashboard/prDashboardWidget.html",transclude:!0,scope:{widget:"=",filters:"=",editMode:"=?",widgets:"=?"},controller:function($scope,$element){$scope.isCollapsed=!1,$scope.icon=prDashboard.widgets[$scope.widget.type].icon,$scope.title=$scope.widget.title,$scope.widget.params=$scope.widget.params||{},$scope.status={name:"new",errorMessage:null}},link:function(scope,element){compileWidget(scope,element),scope.$on("statusChanged",function(e,newStatus,errorMessage,errorResult){scope.status={name:newStatus,httpStatus:errorResult?errorResult.status:void 0,errorMessage:errorMessage},errorMessage&&$log.error("Widget SQL error: "+errorMessage,errorResult)}),scope.remove=function(){var widgets=scope.widgets;if(widgets){var index=widgets.indexOf(scope.widget);index>=0&&widgets.splice(index,1)}scope.$destroy(),element.remove()},scope.getSummary=function(){var params=scope.widget.params,dims=_.reduce(params.dimensions,function(names,dim){return names.push(dim.name),names},[]);return"Dimensions: "+_.escape(dims.join(", "))},scope.showStructure=function(){var modalInstance;modalInstance=$modal.open({scope:scope,backdrop:"static",templateUrl:"src/prReporting/prDashboard/prDashboardWidgetStructureModal.html",size:"lg"})},scope.edit=function(){var widgetType=prDashboard.widgets[scope.widget.type];if(widgetType){var modalInstance,newParams=angular.copy(scope.widget.params),newOptions=angular.copy(scope.widget.options),editScope=scope.$new();editScope.save=function(){newOptions.disabled=!1,angular.equals(newParams,scope.widget.params)||(scope.widget.params=newParams),angular.equals(newOptions,scope.widget.options)||(scope.widget.options=newOptions),modalInstance.close()},modalInstance=$modal.open({scope:editScope,backdrop:"static",template:widgetType.edit.template,templateUrl:widgetType.edit.templateUrl,controller:widgetType.edit.controller,size:"lg",resolve:{widgetParams:function(){return newParams},widgetOptions:function(){return newOptions}}})}}}}})}(),function(){"use strict";angular.module("pr.dashboard.layouts",["pr.dashboard"])}(),function(){"use strict";angular.module("pr.dashboard.layouts").config(function(prDashboardProvider){prDashboardProvider.layout("12",{displayName:"1 full width column",columns:[{mockContent:"100%",styleClass:"col-sm-12",widgets:[]}]}),prDashboardProvider.layout("6-6",{displayName:"2 columns (50% - 50%)",columns:[{mockContent:"50%",styleClass:"col-sm-6",widgets:[]},{mockContent:"50%",styleClass:"col-sm-6",widgets:[]}]}),prDashboardProvider.layout("3-3-3-3",{displayName:"4 columns (25% each)",columns:[{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]},{mockContent:"25%",styleClass:"col-sm-3",widgets:[]}]}),prDashboardProvider.layout("4-8",{displayName:"2 columns (33% - 66%)",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"66%",styleClass:"col-sm-8",widgets:[]}]}),prDashboardProvider.layout("8-4",{displayName:"2 columns (66% - 33%)",columns:[{mockContent:"66%",styleClass:"col-sm-8",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]}),prDashboardProvider.layout("4-4-4",{displayName:"3 columns",columns:[{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]},{mockContent:"33%",styleClass:"col-sm-4",widgets:[]}]})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.grid",["pr.dashboard","ui.select","ngSanitize","ui.grid","ui.grid.selection","ui.grid.pagination","ui.grid.autoResize","pr.gridextensions","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grid",{label:"Table",icon:"fa fa-table",templateUrl:"src/prReporting/prDashboardWidgets/grid/view.html",controller:"prGridWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/grid/edit.html",controller:"prGridWidgetEdit"}})}).directive("prGridWidget",function($compile,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,$element){$scope.options=$scope.options||{},$scope.grid={gridOptions:prUIOptionService.getSimpleGridOptions($scope.options.grid||{})},$scope.addFilter=function(dimensionName,dimensionValue){$scope.filters.where=$scope.filters.where||{},$scope.filters.where[dimensionName]=dimensionValue}},link:function(scope,element,attrs){var staticColumnDefs=scope.grid.gridOptions.columnDefs;scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);if(newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,!scope.options.disabled){scope.$emit("statusChanged","wait");var columnDefs=staticColumnDefs;columnDefs||(columnDefs=[],angular.forEach(newParams.dimensions,function(dimension){columnDefs.push({field:dimension.name,cellTemplate:'"})}),angular.forEach(newParams.metrics,function(metric){var field=metric.alias||metric.name+" "+metric.type;columnDefs.push({field:field,displayName:field,cellClass:"text-right",cellFilter:metric.filter||"number"})})),prDatasourceSqlService.getDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],!staticColumnDefs&&results.length&&results[0].timestamp&&columnDefs.push({field:"timestamp",cellFilter:"date:'short'"}),scope.grid.gridOptions.columnDefs=columnDefs,scope.grid.gridOptions.data=results,scope.$emit("statusChanged","done")},function(result){scope.grid.gridOptions.data=[],scope.grid.gridOptions.columnDefs=[],scope.$emit("statusChanged","error",result.data.error,result)})}},!0)}}}).controller("prGridWidget",function($scope,widgetParams,widgetOptions){}).controller("prGridWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES)},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.pie",["nvd3","pr.dashboard","pr.datasource.sql","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-pie",{label:"Pie",icon:"fa fa-pie-chart",templateUrl:"src/prReporting/prDashboardWidgets/pie/view.html",controller:"prPieWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/pie/edit.html",controller:"prPieWidgetEdit"}})}).directive("prPieWidget",function($filter,prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}},pie:{dispatch:{elementClick:function(e){if($scope.filters.where){var dimensionName=$scope.params.dimensions[0].name;$scope.filters.where[dimensionName]=e.data.x,$scope.$apply()}}}}};$scope.pieChart={options:prUIOptionService.getPieChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),0===scope.pieChart.options.chart.width&&(scope.pieChart.options.chart.width=void 0),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results));var data=[];if(results[0]){data=results[0].values;var total=0;angular.forEach(data,function(val,index){total+=val.y}),0===total&&(data=[])}scope.pieChart.data=data,scope.$emit("statusChanged","done")},function(result){scope.pieChart.data=[],scope.pieChart.options.chart.width=0,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prPieWidget",function($scope,widgetParams,widgetOptions){}).controller("prPieWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.bar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-bar",{label:"Bar",icon:"fa fa-bar-chart",templateUrl:"src/prReporting/prDashboardWidgets/bar/view.html",controller:"prBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/bar/edit.html",controller:"prBarWidgetEdit"}})}).directive("prBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40;var defaults={height:height,tooltip:{keyFormatter:function(d){if($scope.params.metrics&&$scope.params.metrics[0]){var metric=$scope.params.metrics[0];return(d?d+" ":"")+metric.alias||metric.name}return d}}};$scope.barChart={options:prUIOptionService.getDiscreteBarChartOptions(angular.merge(defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||10,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.barChart.data=results,scope.barChart.options.chart.xAxis={axisLabel:results[0].key},scope.$emit("statusChanged","done")},function(result){scope.barChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||10,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.timeline",["pr.dashboard","nvd3","pr.datasource.sql","pr.UIOption"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-timeline",{label:"Timeline",icon:"fa fa-clock-o",templateUrl:"src/prReporting/prDashboardWidgets/timeline/view.html",controller:"prTimelineWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/timeline/edit.html",controller:"prTimelineWidgetEdit"}})}).directive("prTimelineWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs,prApi){$scope.options=$scope.options||{};var height=$scope.options.height||180;$scope.height=height+20,$scope.defaults={margin:{top:20,right:50,bottom:20,left:80},height:height,xAxis:{axisLabel:"Time",tickFormat:function(d){return prUIOptionService.getxAxisTickFormat(d,$scope.params.granularity)}},showLegend:!0},$scope.lineChart={options:prUIOptionService.getTimeLineChartOptions(angular.merge($scope.defaults,$scope.options.chart||{})) +}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.lineChart.data||(scope.lineChart.data=[]),scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getTimeLineChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.options.isArea&&angular.forEach(scope.lineChart.data,function(data){data.area=!0}),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prTimelineWidget",function($scope,widgetParams,widgetOptions){}).controller("prTimelineWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,angular.isUndefined($scope.options.isArea)&&($scope.options.isArea=!1),$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.granularities=angular.copy(GRANULARITIES),$scope.granularities.splice(0,1),"all"==$scope.newParams.granularity&&($scope.newParams.granularity=$scope.granularities[0].name),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.linewithfocus",["nvd3","pr.datasource.sql","pr.dashboard","pr.UIOption","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-line-with-focus",{label:"Line with Focus",icon:"fa fa-line-chart",templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/view.html",controller:"prLineWithFocusWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/lineWithFocus/edit.html",controller:"prLineWithFocusWidgetEdit"}})}).directive("prLineWithFocusWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,showLegend:!0},$scope.lineChart={options:prUIOptionService.getLineWithFocusOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||100,newParams.isTimeline=!0,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),scope.lineChart.data=[],prDatasourceSqlService.getHistogram({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.lineChart.data=results,scope.lineChart.options=prUIOptionService.getLineWithFocusOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.lineChart.data=[],scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prLineWithFocusWidget",function($scope,widgetParams,widgetOptions){}).controller("prLineWithFocusWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.init=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){}),$scope.newParams.granularity="five_minute"},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||100,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.init(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.init())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.stack",["nvd3","pr.dashboard","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-stack",{label:"Stack",icon:"fa fa-area-chart",templateUrl:"src/prReporting/prDashboardWidgets/stack/view.html",controller:"prStackWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/stack/edit.html",controller:"prStackWidgetEdit"}})}).directive("prStackWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=?",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,xScale:d3.time.scale(),showLegend:!0},$scope.stackChart={options:prUIOptionService.getStackedAreaChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))}},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||200,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getStackDataset({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.stackChart.data=results,scope.stackChart.options=prUIOptionService.getStackedAreaChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prStackWidget",function($scope,widgetParams,widgetOptions){}).controller("prStackWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES,GRANULARITIES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams;var granularities=angular.copy(GRANULARITIES);granularities.shift(),$scope.newParams.granularity&&"all"!==$scope.newParams.granularity||($scope.newParams.granularity=granularities[0].name),$scope.granularities=granularities,$scope.options=widgetOptions,$scope.newParams.maxResults=widgetParams.maxResults||200,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.metric",["pr.dashboard","pr.countto","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-metric",{label:"Metric",icon:"fa fa-gears",templateUrl:"src/prReporting/prDashboardWidgets/metric/view.html",controller:"prMetricWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/metric/edit.html",controller:"prMetricWidgetEdit"}})}).directive("prMetricWidget",function(prDatasourceSqlService){return{restrict:"E",templateUrl:"src/prReporting/prDashboardWidgets/metric/widget.html",scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.options=$scope.options||{},$scope.icon=$scope.options.icon||"fa fa-heartbeat"},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=1,scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getMetricData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.totalNumber=results,scope.$emit("statusChanged","done")},function(result){scope.totalNumber=null,scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prMetricWidget",function($scope,widgetParams,widgetOptions){}).controller("prMetricWidgetEdit",function(widgetParams,widgetOptions,$scope,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initMetrics=function(){prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initMetrics(),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.metrics=[],$scope.initMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.groupedBar",["pr.dashboard","nvd3","pr.UIOption","pr.datasource.sql","pr.dashboard.widgets.util"]).config(function(prDashboardProvider){prDashboardProvider.widget("pr-grouped-bar",{label:"Grouped Bar",icon:"fa fa-tasks fa-rotate-270",templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/view.html",controller:"prGroupedBarWidget",edit:{templateUrl:"src/prReporting/prDashboardWidgets/groupedBar/edit.html",controller:"prGroupedBarWidgetEdit"}})}).directive("prGroupedBarWidget",function(prDatasourceSqlService,prUIOptionService){return{restrict:"E",template:'
',scope:{params:"=",options:"=",filters:"=",transformDataFn:"&transformData"},controller:function($scope,$attrs){$scope.groupedBarChart={};var height=340;$scope.options=$scope.options||{},$scope.options.chart&&$scope.options.chart.height&&(height=$scope.options.chart.height),$scope.height=height+40,$scope.defaults={height:height,margin:{top:5,right:5,bottom:5,left:100},showLegend:!0},$scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge($scope.defaults,$scope.options.chart||{}))},link:function(scope,attrs){scope.$watch(function(){return{filters:scope.filters,params:scope.params,options:scope.options}},function(newVals){var newParams=angular.copy(newVals.params);newParams.filters=angular.copy(newVals.filters),newParams.maxResults=newParams.maxResults||40,scope.options.chart&&void 0!==scope.options.chart.showLegend||(scope.options.chart=scope.options.chart||{},scope.options.chart.showLegend=scope.defaults.showLegend),scope.options.disabled||(scope.$emit("statusChanged","wait"),prDatasourceSqlService.getGroupedBarData({dataSourceName:newParams.dataSourceName},newParams,function(results){var transformData=scope.transformDataFn();transformData&&(results=transformData(results)),scope.groupedBarChart.data=results,scope.groupedBarChart.options=prUIOptionService.getGroupedBarChartOptions(angular.merge(scope.defaults,scope.options.chart||{})),results&&results[0]&&newParams.dimensions[0]&&(scope.groupedBarChart.options.chart.xAxis={axisLabel:newParams.dimensions[0].name}),scope.$emit("statusChanged","done")},function(result){scope.$emit("statusChanged","error",result.data.error,result)}))},!0)}}}).controller("prGroupedBarWidget",function($scope,widgetParams,widgetOptions){}).controller("prGroupedBarWidgetEdit",function($scope,widgetParams,widgetOptions,prDatasourceSqlService,AGGREGATION_TYPES){$scope.initDimensionsAndMetrics=function(){prDatasourceSqlService.getDimensions({},$scope.newParams,function(data){$scope.dimensions=data},function(error){}),prDatasourceSqlService.getMetrics({},$scope.newParams,function(data){$scope.metrics=data},function(error){})},$scope.newParams=widgetParams,$scope.options=widgetOptions,$scope.multipleMetrics=widgetParams.metrics&&widgetParams.metrics.length>1,$scope.newParams.maxResults=widgetParams.maxResults||40,prDatasourceSqlService.getTables({},$scope.newParams,function(data){$scope.tables=data},function(error){}),$scope.aggregationTypes=AGGREGATION_TYPES,$scope.newParams.table&&$scope.initDimensionsAndMetrics(),$scope.$watch("multipleMetrics",function(isMultipleMetrics){isMultipleMetrics&&$scope.newParams.dimensions.splice(1,$scope.newParams.dimensions.length-1)}),$scope.$watch("newParams.table",function(newTable,oldTable){newTable!==oldTable&&($scope.newParams.dimensions=[],$scope.newParams.metrics=[],$scope.initDimensionsAndMetrics())})})}(),function(){"use strict";angular.module("pr.dashboard.widgets.util",[])}(),function(){"use strict";angular.module("pr.dashboard.widgets.util").directive("prMetricPicker",function(){return{restrict:"E",scope:{metrics:"=",multiple:"=?",metricOptions:"=",aggregationOptions:"="},templateUrl:"src/prReporting/prDashboardWidgets/util/prMetricPicker.html",link:function(scope){function newMetric(metricName){var type=null;return scope.aggregationOptions&&scope.aggregationOptions.length&&(type=scope.aggregationOptions[0]),{name:metricName,type:type,alias:metricName}}scope.metrics=scope.metrics||[],scope.selectMetric=function(metricName){scope.metrics[0]=newMetric(metricName)},scope.addMetric=function(metricName){scope.metrics.push(newMetric(metricName))},scope.removeMetric=function(index){scope.metrics.splice(index,1)},scope.$watchGroup(["multiple","metricOptions","aggregationOptions"],function(newValues){var isMultiple=newValues[0];scope.metrics=scope.metrics||[],isMultiple||(0===scope.metrics.length&&scope.metricOptions&&scope.metricOptions.length>0&&scope.selectMetric(scope.metricOptions[0].name),scope.metrics.length>1&&scope.metrics.splice(1,scope.metrics.length-1))})}}})}(),function(){"use strict";angular.module("pr.datasource",["pr.datasource.sql"])}(),function(){"use strict";angular.module("pr.datasource.sql",["ngResource","pr.api"])}(),function(){"use strict";angular.module("pr.datasource.sql").service("prDatasourceSqlService",function($resource,prSqlBuilder,prApi){var transformDataRequest=function(param){var q={};param.table&&(q.table=param.table),param.orderBy&&(q.orderBy=param.orderBy),param.metrics&&(q.metrics=param.metrics),param.dimensions&&(q.dimensions=param.dimensions),param.maxResults&&(q.maxResults=param.maxResults),param.filters.where&&(q.where=param.filters.where),param.filters.whereRaw&&(q.whereRaw=param.filters.whereRaw);var p={sql:prSqlBuilder.buildQuery(q),intervals:param.filters.intervals,granularity:param.granularity};return angular.toJson(p)};return $resource(prApi.url+"/sql/:dataSourceName",{},{getDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,result=[];return angular.forEach(data,function(value,key){value.result&&"{}"!==angular.toJson(value.result)&&(result[key]=value.result,config.data&&"all"!==config.data.granularity&&(result[key].timestamp=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate()))}),result}},transformRequest:transformDataRequest},getHistogram:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,metrics=config.data.metrics,responses=[];return data&&data.length>0&&angular.forEach(metrics,function(metric){var response=[];angular.forEach(data,function(value){var point={};config.data.dimensions&&config.data.dimensions.length&&!config.data.isTimeline?point.x=value.result[config.data.dimensions[0].name]:point.x=moment(value.timestamp,"YYYY-MM-DD HH:mm:ss").toDate(),point.y=value.result[prSqlBuilder.getAlias(metric)],response.push(point)}),responses.push({key:prSqlBuilder.getAlias(metric),values:response})}),responses}},transformRequest:transformDataRequest},getGroupedBarData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(rawResponse){var data=rawResponse.data,config=rawResponse.config,dimensions=config.data.dimensions||[],metrics=config.data.metrics||[],responses=[];if(!data||0===data.length)return responses;if(2===dimensions.length&&1===metrics.length){var dim1Name=dimensions[1].name,dim2Name=dimensions[0].name,dim1Vals=[],dim2Vals=[],metricName=metrics[0].alias;angular.forEach(data,function(d){var value=d.result,dim1Val=value[dim1Name],seriesIndex=dim1Vals.indexOf(dim1Val);-1===seriesIndex&&(seriesIndex=dim1Vals.length,dim1Vals.push(dim1Val),responses.push({key:dim1Val,values:[]})),responses[seriesIndex].values.push({series:seriesIndex,x:value[dim2Name],y:value[metricName]}),-1===dim2Vals.indexOf(value[dim2Name])&&dim2Vals.push(value[dim2Name])}),responses.forEach(function(series,seriesIndex){dim2Vals.forEach(function(dimValue){var have=!1;series.values.forEach(function(e){e.x===dimValue&&(have=!0)}),have||series.values.push({series:seriesIndex,x:dimValue,y:0})})})}else if(1===dimensions.length){var metricNames=[],dimName=dimensions[0].name;angular.forEach(data,function(d){var value=d.result,dimValue=value[dimName];angular.forEach(value,function(val,key){if(key!==dimName){var metricName=key,seriesIndex=metricNames.indexOf(metricName);-1===seriesIndex&&(seriesIndex=responses.length,metricNames.push(metricName),responses.push({key:metricName,values:[]})),responses[seriesIndex].values.push({x:dimValue,y:val})}})})}return responses.forEach(function(series){series.values.sort(function(v1,v2){return v1.x===v2.x?0:v1.x>v2.x?-1:1})}),responses}},transformRequest:transformDataRequest},getStackDataset:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var data=response.data,config=response.config,metricName=prSqlBuilder.getAlias(config.data.metrics[0]),dimensionName=config.data.dimensions[0]?config.data.dimensions[0].name:null,dimensionValues=[],series=[],timestampGroups=_.groupBy(data,"timestamp"),maxTimestampGroupLength=0;for(var d in timestampGroups)maxTimestampGroupLength=maxTimestampGroupLengthseriesIndex;seriesIndex++)if(series[seriesIndex]||(series[seriesIndex]=[]),series[seriesIndex][timestampIndex]={x:date,y:0},timestampGroup[seriesIndex]){var resultValue=timestampGroup[seriesIndex].result;series[seriesIndex][timestampIndex].y=resultValue[metricName],dimensionValues[seriesIndex]=resultValue[dimensionName]}timestampIndex++}var results=[];return angular.forEach(series,function(serie,i){results.push({key:dimensionValues[i]||metricName,values:serie})}),results}},transformRequest:transformDataRequest},getMetricData:{method:"POST",isArray:!0,withCredentials:prApi.withCredentialsDatasources,interceptor:{response:function(response){var alias=prSqlBuilder.getAlias(response.config.data.metrics[0]);return response.data[0].result[alias]}},transformRequest:transformDataRequest},getDataSources:{method:"GET",url:prApi.url+"/datasources?right=view",isArray:!0,withCredentials:!0},getTables:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"show tables from "+param.dataSourceName};return angular.toJson(p)}},getDimensions:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".dimensions"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(dimension){response.push({name:dimension})}),response}}},getMetrics:{method:"POST",url:prApi.url+"/sql",isArray:!0,withCredentials:prApi.withCredentialsDatasources,transformRequest:function(param){var p={sql:"desc "+param.dataSourceName+"."+param.table+".metrics"};return angular.toJson(p)},interceptor:{response:function(results){var response=[];return angular.forEach(results.data,function(metric){response.push({name:metric})}),response}}}})})}(),function(){"use strict";angular.module("pr.datasource.sql").factory("prSqlBuilder",function($log){function orWhereFromArray(k,key,array,operator){return array.length>0&&k.where(function(){var i=1;if(operator)for(this.where(key,operator,array[0]);i