2 * Copyright (c) 2014 DataTorrent, Inc. ALL Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 .directive('wtTime', function ($interval) {
25 template: '<div>Time<div class="alert alert-success">{{time}}</div></div>',
26 link: function (scope) {
28 scope.time = new Date().toLocaleTimeString();
33 var promise = $interval(update, 500);
35 scope.$on('$destroy', function () {
36 $interval.cancel(promise);
41 .directive('wtScopeWatch', function () {
45 template: '<div>Value<div class="alert alert-info">{{value}}</div></div>',
51 .directive('wtFluid', function () {
55 templateUrl: 'app/fusion/scripts/view-models/reportdashboard-page/src/app/template/fluid.html',
57 controller: function ($scope) {
58 $scope.$on('widgetResized', function (event, size) {
59 $scope.width = size.width || $scope.width;
60 $scope.height = size.height || $scope.height;
65 .directive('raptorReportChart', ['widgetDefinitions','defaultWidgets',function (widgetDefinitions, defaultWidgets) {
69 templateUrl: 'app/fusion/scripts/view-models/reportdashboard-page/src/app/template/raptor-report.html',
71 controller: function ($scope,$http, $rootScope) {
72 // console.log('================= Raptor Report scope =================');
73 // console.log($scope);
74 $scope.showChart = false;
75 $scope.url = "report_embedded#/report_run/c_master="+$scope.widget.report_id+ "&refresh=Y&hideGrid=Y&width="+Math.floor($scope.width*13)+"&height=300";
76 // $scope.url = "report_embedded#/report_run/c_master="+$scope.widget.report_id+ "&refresh=Y&hideGrid="+$scope.hideGrid+"&width=550&height=300";
77 $rootScope.showdataContainer = false;
78 $rootScope.$watch('showdataContainer', function () {
79 console.log('change showdataContainer');
80 console.log($rootScope.showdataContainer);
81 $scope.gridOptions = $rootScope.gridOptions;
82 $scope.gridOptions = $rootScope.gridOptions;
83 $scope.uiGridRefresh = function(){
84 var columnDefsArray = [];
85 var columnFreezeEndColumn = $scope.widget.reportData.colIdxTobeFreezed;
86 var doColumnNeedToFreeze = false;
87 if(columnFreezeEndColumn && columnFreezeEndColumn.length>0) {
88 doColumnNeedToFreeze = true;
90 $scope.widget.reportData.reportDataColumns.forEach(function(entry) {
91 var tempColumnDef = { displayName: entry.columnTitle, field: entry.colId, enableSorting: entry.sortable,
92 sortingAlgorithm: function(a, b) {
93 return rowSorter.sortAlpha(a.displayValue, b.displayValue);
95 cellTemplate: '<div class="ui-grid-cell-contents" style="text-align:{{COL_FIELD.alignment}};" title="TOOLTIP"> '+
96 ' <div ng-if="!COL_FIELD.drillDownURL || COL_FIELD.drillDownURL==\'\'">{{COL_FIELD.displayValue}}</div>' +
97 ' <a ng-if="COL_FIELD.drillDownURL && COL_FIELD.drillDownURL!=\'\'" ng-href="{{COL_FIELD.drillDownURL}}&parent___params==={{grid.appScope.currentReportUrlParams}}" >{{COL_FIELD.displayValue}}</a>' +
99 if(entry.columnWidth && entry.columnWidth!='null' && entry.columnWidth!='pxpx' && entry.columnWidth!='nullpx' && entry.columnWidth!='nullpxpx'){
100 tempColumnDef['minWidth'] = entry.columnWidth.substring(0, entry.columnWidth.length - 2);
102 tempColumnDef['minWidth'] = '100';
104 if(doColumnNeedToFreeze) {
105 tempColumnDef['pinnedLeft']= true;
106 if(columnFreezeEndColumn === entry.colId){
107 doColumnNeedToFreeze = false;
110 columnDefsArray.push(tempColumnDef);
113 $scope.gridOptions.paginationPageSizes= [$scope.widget.reportData.pageSize];
114 $scope.gridOptions.paginationPageSize= $scope.widget.reportData.pageSize;
115 if($scope.widget.reportData.totalRows<14){
116 $scope.widget.gridHeight = (widget.reportData.totalRows+5)*30+'px';
118 $scope.gridHeight = '400px';
120 $scope.gridOptions.totalItems = $scope.widget.reportData.totalRows;
121 $scope.gridOptions.columnDefs= columnDefsArray;
122 $scope.gridOptions.data= $scope.widget.reportData.reportDataRows;
123 $scope.gridOptions.exporterPdfHeader.text= $scope.widget.reportData.reportName;
125 $scope.uiGridRefresh();
128 /*presence.setGlobal({
129 u: $rootScope.currentUser,
133 $scope.$on('widgetResized', function (event, size) {
134 console.log("===$scope===");
136 $scope.width = size.width || $scope.width;
137 $scope.height = size.height || $scope.height;
138 $scope.url = "report_embedded#/report_run/c_master="+$scope.widget.report_id+ "&refresh=Y&hideGrid=Y&width="+Math.floor($scope.width*13)+"&height=300";
143 .directive('raptorReportData', ['widgetDefinitions','defaultWidgets',function (widgetDefinitions, defaultWidgets) {
147 templateUrl: 'app/fusion/scripts/view-models/reportdashboard-page/src/app/template/raptor-report.html',
149 controller: function ($scope,$http, $rootScope) {
150 // console.log('================= Raptor Report scope =================');
151 // console.log($scope);
152 $scope.showChart = false;
153 $scope.url = "report_embedded#/report_run/c_master="+$scope.widget.report_id+ "&refresh=Y&hideChart=Y&width="+Math.floor($scope.width*13)+"&height=300";
154 // $scope.url = "report_embedded#/report_run/c_master="+$scope.widget.report_id+ "&refresh=Y&hideGrid="+$scope.hideGrid+"&width=550&height=300";
155 $rootScope.showdataContainer = false;
156 $rootScope.$watch('showdataContainer', function () {
157 console.log('change showdataContainer');
158 console.log($rootScope.showdataContainer);
159 $scope.gridOptions = $rootScope.gridOptions;
160 $scope.gridOptions = $rootScope.gridOptions;
161 $scope.uiGridRefresh = function(){
162 var columnDefsArray = [];
163 var columnFreezeEndColumn = $scope.widget.reportData.colIdxTobeFreezed;
164 var doColumnNeedToFreeze = false;
165 if(columnFreezeEndColumn && columnFreezeEndColumn.length>0) {
166 doColumnNeedToFreeze = true;
168 $scope.widget.reportData.reportDataColumns.forEach(function(entry) {
169 var tempColumnDef = { displayName: entry.columnTitle, field: entry.colId, enableSorting: entry.sortable,
170 sortingAlgorithm: function(a, b) {
171 return rowSorter.sortAlpha(a.displayValue, b.displayValue);
173 cellTemplate: '<div class="ui-grid-cell-contents" style="text-align:{{COL_FIELD.alignment}};" title="TOOLTIP"> '+
174 ' <div ng-if="!COL_FIELD.drillDownURL || COL_FIELD.drillDownURL==\'\'">{{COL_FIELD.displayValue}}</div>' +
175 ' <a ng-if="COL_FIELD.drillDownURL && COL_FIELD.drillDownURL!=\'\'" ng-href="{{COL_FIELD.drillDownURL}}&parent___params==={{grid.appScope.currentReportUrlParams}}" >{{COL_FIELD.displayValue}}</a>' +
177 if(entry.columnWidth && entry.columnWidth!='null' && entry.columnWidth!='pxpx' && entry.columnWidth!='nullpx' && entry.columnWidth!='nullpxpx'){
178 tempColumnDef['minWidth'] = entry.columnWidth.substring(0, entry.columnWidth.length - 2);
180 tempColumnDef['minWidth'] = '100';
182 if(doColumnNeedToFreeze) {
183 tempColumnDef['pinnedLeft']= true;
184 if(columnFreezeEndColumn === entry.colId){
185 doColumnNeedToFreeze = false;
188 columnDefsArray.push(tempColumnDef);
191 $scope.gridOptions.paginationPageSizes= [$scope.widget.reportData.pageSize];
192 $scope.gridOptions.paginationPageSize= $scope.widget.reportData.pageSize;
193 if($scope.widget.reportData.totalRows<14){
194 $scope.widget.gridHeight = (widget.reportData.totalRows+5)*30+'px';
196 $scope.gridHeight = '400px';
198 $scope.gridOptions.totalItems = $scope.widget.reportData.totalRows;
199 $scope.gridOptions.columnDefs= columnDefsArray;
200 $scope.gridOptions.data= $scope.widget.reportData.reportDataRows;
201 $scope.gridOptions.exporterPdfHeader.text= $scope.widget.reportData.reportName;
203 $scope.uiGridRefresh();
206 /*presence.setGlobal({
207 u: $rootScope.currentUser,
214 .directive('rCloud', function () {
218 templateUrl: 'app/fusion/scripts/view-models/reportdashboard-page/src/app/template/r-cloud.html',
220 controller: function ($scope,$http) {
221 $scope.showChart = false;
222 $scope.hideGrid = 'true';
223 $scope.url = $scope.widget.rcloud_url;
224 $scope.$on('widgetResized', function (event, size) {
225 $scope.width = size.width || $scope.width;
226 $scope.height = size.height || $scope.height;