summaryrefslogtreecommitdiffstats
path: root/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports
diff options
context:
space:
mode:
Diffstat (limited to 'usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports')
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js459
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-import-controller.js20
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js41
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js331
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js186
-rw-r--r--usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js1263
6 files changed, 2300 insertions, 0 deletions
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js
new file mode 100644
index 00000000..8fa14643
--- /dev/null
+++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-chart-controller.js
@@ -0,0 +1,459 @@
+appDS2.controller('reportChartController', function ($scope, $rootScope, $timeout, $window, $http, $routeParams,modalService) {
+ $scope.showLoader = true;
+ $scope.commonOptionOpen = false;
+ $scope.additionalOptionOpen = false;
+ $scope.barChartOptionOpen = false;
+ $scope.timeSeriesChartOptionOpen = false;
+ $scope.selectedChartType = {value:""};
+ $scope.chartTypeOptions = [
+ {value: 'BarChart3D', text: 'Bar Chart'},
+ {value: 'TimeSeriesChart', text: 'Time Series/Area Chart'},
+ {value: 'PieChart', text: 'Pie Chart'},
+ {value: 'AnnotationChart', text: 'Annotation Chart'},
+ {value: 'FlexTimeChart', text: 'Flexible Time Chart'}
+ ];
+
+ $scope.populateChrtWzdFields = function() {
+ $scope.reportRunJson = {};
+ $http.get("raptor.htm?action=chart.json&c_master="+$routeParams.reportId).then(function (response) {
+ $scope.reportRunJson = response.data;
+ //Set chart type
+ $scope.reportRunJson.commonChartOptions.animateAnimatedChart = $scope.reportRunJson.commonChartOptions.animateAnimatedChart+"";
+ $scope.reportRunJson.commonChartOptions.hideLegend = $scope.reportRunJson.commonChartOptions.hideLegend + "";
+ $scope.reportRunJson.showTitle = $scope.reportRunJson.showTitle + "";
+
+ // if barChartOptions is not null
+ if ($scope.reportRunJson.barChartOptions) {
+ $scope.reportRunJson.barChartOptions.displayBarControls = $scope.reportRunJson.barChartOptions.displayBarControls+"";
+ $scope.reportRunJson.barChartOptions.minimizeXAxisTickers = $scope.reportRunJson.barChartOptions.minimizeXAxisTickers+"";
+ $scope.reportRunJson.barChartOptions.stackedChart = $scope.reportRunJson.barChartOptions.stackedChart+"";
+ $scope.reportRunJson.barChartOptions.timeAxis =$scope.reportRunJson.barChartOptions.timeAxis+"";
+ $scope.reportRunJson.barChartOptions.verticalOrientation = $scope.reportRunJson.barChartOptions.verticalOrientation +"";
+ $scope.reportRunJson.barChartOptions.xAxisDateType = $scope.reportRunJson.barChartOptions.xAxisDateType +"";
+ }
+
+ if ($scope.reportRunJson.chartTypeJSON) {
+ var chrtTypeValue = $scope.reportRunJson.chartType;
+ for(var i = 0; i < $scope.chartTypes.length; i++) {
+ if ($scope.chartTypes[i].value==chrtTypeValue) {
+ $scope.reportRunJson.chartTypeJSON.index=$scope.chartTypes[i].index;
+ $scope.reportRunJson.chartTypeJSON.value=$scope.chartTypes[i].value;
+ $scope.reportRunJson.chartTypeJSON.title=$scope.chartTypes[i].title;
+ }
+
+ }
+ }
+
+ //Set Domain Axis
+ if ($scope.reportRunJson.domainAxisJSON) {
+ var domaninAxisValue = $scope.reportRunJson.domainAxisJSON.value;
+ for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
+ if ($scope.reportRunJson.chartColumnJSONList[i].value==domaninAxisValue) {
+ $scope.reportRunJson.domainAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
+ $scope.reportRunJson.domainAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
+ }
+
+ }
+ }
+
+ //Set Category
+ if ($scope.reportRunJson.categoryAxisJSON) {
+ var categoryAxisValue = $scope.reportRunJson.categoryAxisJSON.value;
+ for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
+ if ($scope.reportRunJson.chartColumnJSONList[i].value==categoryAxisValue) {
+ $scope.reportRunJson.categoryAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
+ $scope.reportRunJson.categoryAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
+ }
+ }
+ }
+
+ //Set range axis label
+ if ($scope.reportRunJson.rangeAxisList) {
+ for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) {
+
+ if ($scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON) {
+ var rangeAxisLabelValue = $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.value;
+ for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
+ if ($scope.reportRunJson.chartColumnJSONList[i].value==rangeAxisLabelValue) {
+ $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
+ $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
+ }
+ }
+ }
+ }
+ }
+
+
+ //set range linetype
+ if ($scope.reportRunJson.rangeAxisList) {
+ for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) {
+ if ($scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != ""
+ && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != null) {
+ var lineTypeValue = $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value;
+ for(var i = 0; i < $scope.lineTypes.length; i++) {
+ if ($scope.lineTypes[i].value==lineTypeValue) {
+ $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.index=$scope.lineTypes[i].index;
+ $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.title=$scope.lineTypes[i].title;
+ }
+ }
+ } else {
+ $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON = null;
+ }
+ }
+ }
+ //set range color
+ if ($scope.reportRunJson.rangeAxisList) {
+ for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) {
+ if ($scope.reportRunJson.rangeAxisList[j].rangeColorJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != ""
+ && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != null) {
+ var colorValue = $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value;
+ for(var i = 0; i < $scope.rangeColors.length; i++) {
+ if ($scope.rangeColors[i].value==colorValue) {
+ $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.index=$scope.rangeColors[i].index;
+ $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.title=$scope.rangeColors[i].title;
+ }
+ }
+ }else {
+ $scope.reportRunJson.rangeAxisList[j].rangeColorJSON = null;
+ }
+ }
+ }
+ $scope.showLoader = false;
+ });
+
+ $scope.legend = "true";
+ }
+
+ $scope.saveChartData = function() {
+ $scope.showLoader = true;
+
+ $scope.reportRunJson.commonChartOptions.animateAnimatedChart = ($scope.reportRunJson.commonChartOptions.animateAnimatedChart=="true")
+ $scope.reportRunJson.commonChartOptions.hideLegend = ($scope.reportRunJson.commonChartOptions.hideLegend=="true");
+ $scope.reportRunJson.showTitle = ($scope.reportRunJson.showTitle=="true");
+
+ $scope.reportRunJson.chartTypeJSON = {
+ 'index':0,'title':'','value':''};
+
+
+ if (($scope.reportRunJson.chartType == "BarChart3D")&&($scope.reportRunJson.barChartOptions)) {
+ $scope.reportRunJson.barChartOptions.displayBarControls = ($scope.reportRunJson.barChartOptions.displayBarControls=="true") ;
+ $scope.reportRunJson.barChartOptions.minimizeXAxisTickers = ($scope.reportRunJson.barChartOptions.minimizeXAxisTickers=="true") ;
+ $scope.reportRunJson.barChartOptions.stackedChart = ($scope.reportRunJson.barChartOptions.stackedChart=="true") ;
+ $scope.reportRunJson.barChartOptions.timeAxis= ($scope.reportRunJson.barChartOptions.timeAxi=="true") ;
+ $scope.reportRunJson.barChartOptions.verticalOrientation = ($scope.reportRunJson.barChartOptions.verticalOrientation=="true") ;
+ $scope.reportRunJson.barChartOptions.xAxisDateType = ($scope.reportRunJson.barChartOptions.xAxisDateType=="true") ;
+ }
+
+ for (var i=0;i<$scope.chartTypes.length;i++) {
+ if ($scope.reportRunJson.chartType==$scope.chartTypes[i].value) {
+ $scope.reportRunJson.chartTypeJSON = {
+ 'index':$scope.chartTypes[i].index,
+ 'title':$scope.chartTypes[i].title,
+ 'value':$scope.chartTypes[i].value
+ }
+ }
+ }
+
+ $scope.reportRunJson.domainAxisJSON = {
+ "index":0,"value":$scope.reportRunJson.domainAxis,"title": $scope.reportRunJson.domainAxis
+ };
+ $scope.reportRunJson.categoryAxisJSON = {
+ "index":0,"value":$scope.reportRunJson.categoryAxis,"title": $scope.reportRunJson.categoryAxis
+ };
+
+ // Specifically for DS2 for color
+ for (var i=0; i<$scope.reportRunJson.rangeAxisList.length; i ++) {
+ $scope.reportRunJson.rangeAxisList[i].rangeColorJSON =
+ {"index":0, "value": $scope.reportRunJson.rangeAxisList[i].rangeColor, "title": ""};
+
+ $scope.reportRunJson.rangeAxisList[i].rangeLineTypeJSON =
+ {"index":0, "value": "", "title": ""};
+ for (var j=0;j<$scope.lineTypes.length;j++) {
+ if ($scope.reportRunJson.rangeAxisList[i].rangeLineType ==$scope.lineTypes[j].value) {
+ $scope.reportRunJson.rangeAxisList[i].rangeLineTypeJSON =
+ {"index":$scope.lineTypes[j].index, "value": $scope.lineTypes[j].value, "title": $scope.lineTypes[j].title};
+ }
+ }
+
+ }
+
+ //Converting string variables to numbers
+ $scope.reportRunJson.commonChartOptions.rightMargin = Number($scope.reportRunJson.commonChartOptions.rightMargin);
+ $scope.reportRunJson.commonChartOptions.topMargin = Number($scope.reportRunJson.commonChartOptions.topMargin);
+ $scope.reportRunJson.commonChartOptions.bottomMargin = Number($scope.reportRunJson.commonChartOptions.bottomMargin);
+ $scope.reportRunJson.commonChartOptions.leftMargin = Number($scope.reportRunJson.commonChartOptions.leftMargin);
+
+ if ($scope.reportRunJson.categoryAxisJSON == "") {
+ $scope.reportRunJson.categoryAxisJSON = {};
+ $scope.reportRunJson.categoryAxisJSON.value = -1;
+ }
+ //add the remove list to the json
+ $scope.reportRunJson.rangeAxisRemoveList= $scope.rangeAxisRemoveList;
+ $http.post("save_chart", JSON.stringify($scope.reportRunJson)).success(function(data, status) {
+ $scope.successSubmit=true;
+ $scope.showLoader = false;
+ $scope.reportRunJson.commonChartOptions.animateAnimatedChart = $scope.reportRunJson.commonChartOptions.animateAnimatedChart+"";
+ $scope.reportRunJson.commonChartOptions.hideLegend = $scope.reportRunJson.commonChartOptions.hideLegend + "";
+ $scope.reportRunJson.showTitle = $scope.reportRunJson.showTitle + "";
+ if ($scope.reportRunJson.chartType == "BarChart3D") {
+ $scope.reportRunJson.barChartOptions.displayBarControls = $scope.reportRunJson.barChartOptions.displayBarControls+"";
+ $scope.reportRunJson.barChartOptions.minimizeXAxisTickers = $scope.reportRunJson.barChartOptions.minimizeXAxisTickers+"";
+ $scope.reportRunJson.barChartOptions.stackedChart = $scope.reportRunJson.barChartOptions.stackedChart+"";
+ $scope.reportRunJson.barChartOptions.timeAxis =$scope.reportRunJson.barChartOptions.timeAxis+"";
+ $scope.reportRunJson.barChartOptions.verticalOrientation = $scope.reportRunJson.barChartOptions.verticalOrientation +"";
+ $scope.reportRunJson.barChartOptions.xAxisDateType = $scope.reportRunJson.barChartOptions.xAxisDateType +"";
+ }
+ $scope.populateChrtWzdFields();
+ })
+ }
+
+
+ $scope.addRangeAxisRow = function (rangeaxisitem) {
+ $scope.reportRunJson.rangeAxisList.push({
+ });
+ };
+
+ $scope.rangeAxisRemoveList= [];
+ $scope.removeRangeAxisRow = function (index) {
+ $scope.rangeAxisRemoveList.push($scope.reportRunJson.rangeAxisList[index]);
+ $scope.reportRunJson.rangeAxisList[index].removed="true";
+ };
+
+
+ $scope.init = function () {
+ if ($scope) {
+ $scope.populateChrtWzdFields();
+ $scope.reportRunJson.rangeAxisRemoveList= [];
+ }
+ };
+
+
+
+ $scope.domainItems = [{title:"Domain Axis1", content:"Test1", open: false},{title:"Domain Axis2", content:"Test2", open: false}];
+
+ $scope.chartTypes = [
+ {index: 0, value: 'BarChart3D', title: 'Bar Chart'},
+ {index: 1, value: 'TimeSeriesChart', title: 'Time Series/Area Chart'},
+ {index: 2, value: 'PieChart', title: 'Pie Chart'},
+ {index: 3, value: 'AnnotationChart', title: 'Annotation Chart'},
+ {index: 4, value: 'FlexTimeChart', title: 'Flexible Time Chart'}
+ ];
+
+ $scope.categories = [
+ {index: 0, value: 'scenario_name', title: 'scenario_name'},
+ {index: 1, value: 'total_traffic_in_PB', title: 'Total Traffic in PB'},
+ {index: 2, value: 'Avg Utilization Day', title: 'Avg Utilization Day'}
+ ];
+
+ $scope.rangeColors = [
+ {index: 0, value: "#1f77b4",title: "Dodger Blue"},
+ {index: 1, value: "#ff7f0e",title: "Vivid orange"},
+ {index: 2, value: "#2ca02c",title: "Forest Green"},
+ {index: 3, value: "#8c864b",title: "Greenish Red"},
+ {index: 4, value: "#9467bd",title: "Desaturated violet"},
+ {index: 5, value: "#8c564b",title: "Dark moderate red"},
+ {index: 6, value: "#e377c2",title: "Soft pink"},
+ {index: 7, value: "#7f7f7f",title: "Dark gray"},
+ {index: 8, value: "#bcbd22",title: "Strong yellow"},
+ {index: 9, value: "#17becf",title: "Strong cyan"},
+ {index: 10, value: "#dc143c",title: "Vivid red"},
+ {index: 11, value: "#800080",title: "Dark magenta"},
+ {index: 12, value: "#0000FF",title: "Blue"},
+ {index: 13, value: "#008000",title: "Dark lime green"},
+ {index: 14, value: "#D2691E",title: "Reddish Orange"},
+ {index: 15, value: "#FF0000",title: "Red"},
+ {index: 16, value: "#000000",title: "Black"},
+ {index: 17, value: "#DB7093",title: "Pink"},
+ {index: 18, value: "#FF00FF",title: "Pure Magenta"},
+ {index: 19, value: "#7B68EE",title: "Soft blue"},
+ {index: 20, value: "#1f77b6",title: "Strong blue"},
+ {index: 21, value: "#9edae5",title: "Very soft cyan"},
+ {index: 22, value: "#393b79",title: "Dark Blue"},
+ {index: 23, value: "#5254a3",title: "Dark moderate Blue"},
+ {index: 24, value: "#6b6ecf",title: "Slightly desaturated blue"},
+ {index: 25, value: "#9c9ede",title: "Very soft blue"},
+ {index: 26, value: "#637939",title: "Dark Green"},
+ {index: 27, value: "#8ca252",title: "Dark moderate green"},
+ {index: 28, value: "#b5cf6b",title: "Slightly desaturated green"},
+ {index: 29, value: "#cedb9c",title: "Desaturated Green"},
+
+ /* Old Colors */
+ {index: 30, value: "#00FFFF",title: "Aqua"},
+ {index: 31, value: "#000000",title: "Black"},
+ {index: 32, value: "#0000FF",title: "Blue"},
+ {index: 33, value: "#FF00FF",title: "Fuchsia"},
+ {index: 34, value: "#808080",title: "Gray"},
+ {index: 35, value: "#008000",title: "Green"},
+ {index: 36, value: "#00FF00",title: "Lime"},
+ {index: 37, value: "#800000",title: "Maroon"},
+ {index: 38, value: "#000080",title: "Navy"},
+ {index: 39, value: "#808000",title: "Olive"},
+ {index: 40, value: "#FF9900",title: "Orange"},
+ {index: 41, value: "#800080",title: "Purple"},
+ {index: 42, value: "#FF0000",title: "Red"},
+ {index: 43, value: "#C0C0C0",title: "Silver"},
+ {index: 44, value: "#008080",title: "Teal"},
+ {index: 45, value: "#FFFFFF",title: "White"},
+ {index: 46, value: "#FFFF00",title: "Yellow"}
+ ];
+
+
+ $scope.lineTypes = [
+ {index: 0, value: 'default', title: 'Default'},
+ {index: 1, value: 'dotted_lines', title: 'Dotted Lines'},
+ {index: 2, value: 'dashed_lines', title: 'Dashed Lines'}
+ ];
+
+ $scope.hardCodeReport= {
+ "reportID":"3356",
+ "reportName":"Test: Line Chart",
+ "reportDescr":"",
+ "reportTitle":"",
+ "reportSubTitle":"",
+ "formFieldList":[
+ ],
+ "chartColumnJSONList":[
+ {
+ "index":0,
+ "value":"tr0",
+ "title":"traffic_date",
+ "$$hashKey":"056"
+ },
+ {
+ "index":1,
+ "value":"ut1",
+ "title":"util_perc",
+ "$$hashKey":"057"
+ }
+ ],
+ "formfield_comments":null,
+ "totalRows":0,
+ "chartSqlWhole":"SELECT traffic_date tr0, traffic_date tr0_1,util_perc ut1, 1 FROM portal.demo_util_chart ORDER BY 1",
+ "chartAvailable":true,
+ "chartType":{"index": "", "value": "Bar Chart", "title": ""},
+ "width":"700",
+ "height":"420",
+ "animation":false,
+ "rotateLabels":"90",
+ "staggerLabels":false,
+ "showTitle":"false",
+ "domainAxis":{
+ "index":0,
+ "value":"tr0",
+ "title":"traffic_date",
+ "$$hashKey":"11H"
+ },
+
+ "categoryAxis":{
+ "index":1,
+ "value":"ut1",
+ "title":"util_perc",
+ "$$hashKey":"11I"
+ },
+
+ "hasCategoryAxis":false,
+ "rangeAxisList":[
+ {
+
+ "rangeColor":{
+ "index":"",
+ "value":"#bcbd22",
+ "title":""
+ },
+
+ "rangeLineType":{
+ "index":"",
+ "value":"dotted_lines",
+ "title":""
+ },
+ "rangeAxisLabel":{
+ "index":0,
+ "value":"tr0",
+ "title":"traffic_date",
+ "$$hashKey":"056"
+ },
+ "YAxis":"10",
+ "chartTitle":"test"
+ },
+ {
+ "rangeColor":{
+ "index":"",
+ "value":"#2ca02c",
+ "title":""
+ },
+
+ "rangeLineType":{
+ "index":"",
+ "value":"dashed_lines",
+ "title":""
+
+
+ },
+
+ "rangeAxisLabel":{
+ "index":0,
+ "value":"tr0",
+ "title":"traffic_date",
+ "$$hashKey":"056"
+ },
+ "YAxis":"10",
+ "chartTitle":"test"
+ }
+
+
+ ],
+
+ "primaryAxisLabel":"testlabel",
+ "secondaryAxisLabel":"testseclabel",
+ "minRange":"10",
+ "maxRange":"20",
+ "topMargin":"6",
+ "bottomMargin":"5",
+ "leftMargin":"4",
+ "rightMargin":"3"
+ };
+
+ var colorValue = $scope.hardCodeReport.rangeAxisList[0].rangeColor.value;
+
+ $timeout(function() {
+ $rootScope.isViewRendering = false;
+ });
+
+
+});
+
+appDS2.directive('onlyDigits', function () {
+
+ return {
+ restrict: 'A',
+ require: '?ngModel',
+ link: function (scope, element, attrs, ngModel) {
+ if (!ngModel) return;
+ ngModel.$parsers.unshift(function (inputValue) {
+ var digits = inputValue.split('').filter(function (s) { return (!isNaN(s) && s != ' '); }).join('');
+ ngModel.$viewValue = digits;
+ ngModel.$render();
+ return digits;
+ });
+ }
+ };
+});
+
+appDS2.directive('onlyCharacters', function () {
+ return {
+ restrict: 'A',
+ require: '?ngModel',
+ link: function (scope, element, attrs, ngModel) {
+ if (!ngModel) return;
+ ngModel.$parsers.unshift(function (inputValue) {
+ var digits = inputValue.split('').filter(function (s) { return (isNaN(s) && s != ' '); }).join('');
+ ngModel.$viewValue = digits;
+ ngModel.$render();
+ return digits;
+ });
+ }
+ };
+});
+
+
+
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-import-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-import-controller.js
new file mode 100644
index 00000000..a8f853fd
--- /dev/null
+++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-import-controller.js
@@ -0,0 +1,20 @@
+appDS2.controller('reportImportController', function($scope,$http,$location, $routeParams, $q, $modal,$log,$window, raptorReportFactory, stepFormFactory, DOMHelper) {
+ $scope.importXML = function(){
+
+ var importXMLJSON = {
+ "tabId":"Import",
+ "tabName":"Import",
+ "reportXML":$scope.xmlContent
+ }
+ $scope.errorMessage = ""
+ raptorReportFactory.postImportXml(importXMLJSON).then(function(data){
+ if (data.errormessage) {
+ $scope.errorMessage = data.errormessage;
+ } else {
+ $window.location.href = 'report#/report_wizard/-1';
+ };
+ },function(error){
+ $log.error("raptorReportFactory: postImportXml failed.");
+ });
+ }
+}); \ No newline at end of file
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js
new file mode 100644
index 00000000..1e22cca3
--- /dev/null
+++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-router.js
@@ -0,0 +1,41 @@
+appDS2.config(['$routeProvider',
+ function($routeProvider) {
+ $routeProvider.
+ when('/', {
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html',
+ controller: 'reportSearchController'
+ }).
+ when('/report_search', {
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-search.html',
+ controller: 'reportSearchController'
+ }).
+ when('/report_run/:reportUrlParams*', {
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-run.html',
+ controller: 'reportRunController'
+ }).
+ when('/report_chart_wizard/:reportId', {
+ templateUrl: 'static/fusion/raptor/ebz/report_chart_wizard.html',
+ controller: 'ChartController'
+ }).
+ when('/report_chart/:reportId', {
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/report-chart-wizard.html',
+ controller: 'reportChartController'
+ }).
+ when("/report_wizard", {
+ templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html",
+ controller: "reportStepController"
+ }).
+ when("/report_wizard/:reportId", {
+ templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html",
+ controller: "reportStepController"
+ }).
+ when("/report_wizard/:reportMode/:reportId", {
+ templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/report-step.html",
+ controller: "reportStepController"
+ }).
+ when("/report_import", {
+ templateUrl : "app/fusion/scripts/DS2-view-models/ds2-reports/report-import.html",
+ controller: "reportImportController"
+ })
+ ;
+ }]); \ No newline at end of file
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js
new file mode 100644
index 00000000..6eb0afe6
--- /dev/null
+++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-run-controller.js
@@ -0,0 +1,331 @@
+appDS2.controller("reportRunController", ['$scope','$rootScope','$routeParams','$http','dateFilter', '$window', '$timeout', 'rowSorter',
+ function ($scope,$rootScope,$routeParams,$http,dateFilter,$window,$timeout,rowSorter) {
+ $scope.dateformat = "MM/dd/yyyy";
+ $scope.datetimeformat = "MM/dd/yyyy hh:mm a";
+ $scope.showFormFields = false;
+ $scope.showGrid = false;
+ $scope.showChart = false;
+ $scope.showBackButton = false;
+ $scope.reportData = {};
+ $scope.reportData.allowEdit = false;
+ $scope.formFieldSelectedValues = {};
+ $scope.showFormFieldIds = false;
+ $scope.showFormFieldId = {
+ value: false
+ };
+ $scope.isInProgress = true;
+
+ if($routeParams.reportUrlParams.indexOf("parent___params===")>-1) {
+ $scope.showBackButton = true;
+ $scope.parentReportUrlParams = $routeParams.reportUrlParams.substring($routeParams.reportUrlParams.indexOf("parent___params===")+18);
+ $scope.currentReportUrlParams = $routeParams.reportUrlParams.substring(0,$routeParams.reportUrlParams.indexOf("parent___params==="));
+ } else {
+ $scope.currentReportUrlParams = $routeParams.reportUrlParams;
+ }
+ // console.log($routeParams.reportUrlParams);
+ var parseQueryString = function( queryString ) {
+ var params = {}, queries, temp, i, l;
+ // Split into key/value pairs
+ queries = queryString.split("&");
+ // Convert the array of strings into an object
+ for ( i = 0, l = queries.length; i < l; i++ ) {
+ temp = queries[i].split('=');
+ //console.log(temp[0]);
+ //console.log(temp[0] != "refresh");
+ if(temp[0] && temp[0] != "refresh")
+ params[temp[0]] = temp[1];
+ }
+ return params;
+ };
+
+ var convertQueryString = function(queryString) {
+ var keys = ""; var str = "";
+ keys = Object.keys(queryString);
+ //console.log(keys);
+ for ( i = 0, l = keys.length; i < l; i++ ) {
+ str += keys[i]+"="+queryString[keys[i]] + "&";
+
+ }
+ return str;
+ //queryString =
+ }
+
+
+
+ $scope.backToParentReport = function (){
+ $window.location.href = "report#/report_run/"+$scope.parentReportUrlParams
+ }
+
+ $scope.urlParams = parseQueryString($scope.currentReportUrlParams);
+
+ $scope.reportChartURL = 'report#/report_chart/'+$scope.urlParams.c_master;
+
+ $scope.reportEditURL = 'report#/report_wizard/'+$scope.urlParams.c_master;
+
+
+ $http.get('raptor.htm?action=report.run.container&'+$scope.currentReportUrlParams).then(
+ function(response){
+ // console.log(response);
+ $scope.isInProgress = false;
+ $scope.reportData = response.data;
+ // console.log('reportData report run container response',$scope.reportData);
+ if ($scope.reportData.reportTitle) {
+ $scope.reportData.reportHeading = $scope.reportData.reportTitle;
+ if ($scope.reportData.reportSubTitle) {
+ $scope.reportData.reportSubTitle = $scope.reportData.reportSubTitle;
+ }
+ }
+ else
+ $scope.reportData.reportHeading = $scope.reportData.reportName;
+ if(!$scope.urlParams.hideChart && $scope.reportData.chartAvailable && $scope.reportData.totalRows>1){
+ // console.log('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams));
+ $http.get('raptor.htm?action=chart.run&'+convertQueryString($scope.urlParams)).then(
+ function(response){
+ $scope.showChart = true;
+ document.getElementById('chartiframe').contentWindow.document.write(response.data);
+ document.getElementById('chartiframe').contentWindow.document.close();
+ });
+ }
+
+ if($scope.reportData.displayForm && $scope.reportData.formFieldList && $scope.reportData.formFieldList.length>0 && !$scope.urlParams.hideFormFields){
+ $scope.showFormFields = true;
+ }
+ });
+ $scope.getFormFieldSelectedValuesAsURL = function(){
+ var formFieldsUrl = '';
+ $scope.reportData.formFieldList.forEach(function(formField) {
+ if(formField.fieldType==='LIST_BOX') {
+ if($scope.formFieldSelectedValues && $scope.formFieldSelectedValues[formField.fieldId] && $scope.formFieldSelectedValues[formField.fieldId].value != '') {
+ formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId].value+'&';
+ }
+ } else if(formField.fieldType==='LIST_MULTI_SELECT') {
+ if($scope.formFieldSelectedValues[formField.fieldId].length >0) {
+ for (var i = 0; i < $scope.formFieldSelectedValues[formField.fieldId].length; i++) {
+ if($scope.formFieldSelectedValues[formField.fieldId][i].defaultValue){
+ formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId][i].value+'&';
+ }
+ }
+ }
+ } else if((formField.fieldType === 'text' || formField.fieldType === 'TEXT') && formField.validationType === 'DATE'){
+ formFieldsUrl = formFieldsUrl+formField.fieldId+'='+dateFilter($scope.formFieldSelectedValues[formField.fieldId],$scope.dateformat)+'&';
+ } else if((formField.fieldType === 'text' || formField.fieldType === 'TEXT') && formField.validationType === 'TIMESTAMP_MIN'){
+ formFieldsUrl = formFieldsUrl+formField.fieldId+'='+dateFilter($scope.formFieldSelectedValues[formField.fieldId],$scope.datetimeformat)+'&';
+ } else if((formField.fieldType === 'text' || formField.fieldType === 'TEXT') && $scope.formFieldSelectedValues[formField.fieldId] && $scope.formFieldSelectedValues[formField.fieldId] != ''){
+ formFieldsUrl = formFieldsUrl+formField.fieldId+'='+$scope.formFieldSelectedValues[formField.fieldId]+'&';
+ }
+ });
+ return formFieldsUrl;
+
+ }
+
+ $scope.runReport = function(pagination){
+ var formFieldsUrl = $scope.getFormFieldSelectedValuesAsURL();
+ /*if ($scope.reportData.reportTitle)
+ $scope.reportData.reportHeading = $scope.reportData.reportTitle;
+ else
+ $scope.reportData.reportHeading = $scope.reportData.reportName;*/
+
+ // console.log("pagination");
+ if(!pagination) {
+ //console.log("refreshed ...");
+ $scope.gridOptions.pageNumber = 1;
+ paginationOptions.pageNumber = 1;
+ paginationOptions.pageSize = $scope.reportData.pageSize;
+ //console.log($scope.gridOptions);
+ $scope.gridOptions.paginationCurrentPage = 1;
+ $scope.gridOptions.paginationPageSizes= [$scope.reportData.pageSize];
+ $scope.gridOptions.paginationPageSize= $scope.reportData.pageSize;
+ if($scope.reportData.totalRows<14){
+ $scope.gridHeight = ($scope.reportData.totalRows+7)*30+'px';
+ } else{
+ $scope.gridHeight = '400px';
+ }
+ $scope.gridOptions.totalItems = $scope.reportData.totalRows;
+ $scope.gridOptions.data= $scope.reportData.reportDataRows;
+ $scope.gridOptions.exporterPdfHeader.text= $scope.reportData.reportName;
+
+ }
+ $scope.currentReportUrlParams = 'c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'&display_content=Y&r_page='+(paginationOptions.pageNumber-1);
+ // console.log('raptor.htm?action=report.run.container&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'refresh=Y&display_content=Y&r_page='+(paginationOptions.pageNumber-1));
+ $http.get('raptor.htm?action=report.run.container&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'refresh=Y&display_content=Y&r_page='+(paginationOptions.pageNumber-1)).then(
+ function(response){
+ $scope.reportData = response.data;
+ if ($scope.reportData.reportTitle) {
+ $scope.reportData.reportHeading = $scope.reportData.reportTitle;
+ if ($scope.reportData.reportSubTitle) {
+ $scope.reportData.reportSubTitle = $scope.reportData.reportSubTitle;
+ }
+ }
+ else
+ $scope.reportData.reportHeading = $scope.reportData.reportName;
+
+ if($scope.reportData.errormessage) {
+ //console.log($scope.reportData);
+ var stacktraceFP = $scope.reportData.stacktrace.substring(0, $scope.reportData.stacktrace.indexOf(":")+1);
+ document.getElementById('errorDiv').innerHTML = stacktraceFP + " " + $scope.reportData.errormessage;
+ //console.log(document.getElementById('errorDiv').innerHtml);
+ //console.log(stacktraceFP + " " + $scope.reportData.errormessage);
+ }
+ if(!pagination) {
+ if(!$scope.urlParams.hideChart && $scope.reportData.chartAvailable && $scope.reportData.totalRows>1){
+ // console.log('raptor.htm?action=chart.run&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'display_content=Y&r_page='+(paginationOptions.pageNumber-1));
+ $http.get('raptor.htm?action=chart.run&c_master='+$scope.urlParams.c_master+'&'+formFieldsUrl+'display_content=Y&r_page='+(paginationOptions.pageNumber-1)).then(
+ function(response) {
+ // console.log(response.data);
+ $scope.showChart = true;
+ // console.log('response.data',response.data);
+ document.getElementById('chartiframe').contentWindow.document.write(response.data);
+ document.getElementById('chartiframe').contentWindow.document.close();
+ });
+ } else {
+ $scope.showChart = false;
+ }
+ }
+ if($scope.reportData.displayForm && $scope.reportData.formFieldList && $scope.reportData.formFieldList.length>0 && !$scope.urlParams.hideFormFields && !$scope.reportData.hideFormFieldsAfterRun){
+ $scope.showFormFields = true;
+ } else {
+ $scope.showFormFields = false;
+ }
+ });
+ };
+
+ var paginationOptions = {
+ pageNumber: 1,
+ pageSize: 5,
+ sort: null
+ };
+
+ var correctTotalPaginationTemplate =
+ //same as normal template, but fixed totals: {{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}}
+ "<div role=\"contentinfo\" class=\"ui-grid-pager-panel\" ui-grid-pager ng-show=\"grid.options.enablePaginationControls\"><div role=\"navigation\" class=\"ui-grid-pager-container\"><div role=\"menubar\" class=\"ui-grid-pager-control\"><button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-first\" ui-grid-one-bind-title=\"aria.pageToFirst\" ui-grid-one-bind-aria-label=\"aria.pageToFirst\" ng-click=\"pageFirstPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle\"><div class=\"first-bar\"></div></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-previous\" ui-grid-one-bind-title=\"aria.pageBack\" ui-grid-one-bind-aria-label=\"aria.pageBack\" ng-click=\"pagePreviousPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle prev-triangle\"></div></button> <input type=\"number\" ui-grid-one-bind-title=\"aria.pageSelected\" ui-grid-one-bind-aria-label=\"aria.pageSelected\" class=\"ui-grid-pager-control-input\" ng-model=\"grid.options.paginationCurrentPage\" min=\"1\" max=\"{{ paginationApi.getTotalPages() }}\" required> <span class=\"ui-grid-pager-max-pages-number\" ng-show=\"paginationApi.getTotalPages() > 0\"><abbr ui-grid-one-bind-title=\"paginationOf\">/</abbr> {{ paginationApi.getTotalPages() }}</span> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-next\" ui-grid-one-bind-title=\"aria.pageForward\" ui-grid-one-bind-aria-label=\"aria.pageForward\" ng-click=\"pageNextPageClick()\" ng-disabled=\"cantPageForward()\"><div class=\"last-triangle next-triangle\"></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-last\" ui-grid-one-bind-title=\"aria.pageToLast\" ui-grid-one-bind-aria-label=\"aria.pageToLast\" ng-click=\"pageLastPageClick()\" ng-disabled=\"cantPageToLast()\"><div class=\"last-triangle\"><div class=\"last-bar\"></div></div></button></div><div class=\"ui-grid-pager-row-count-picker\" ng-if=\"grid.options.paginationPageSizes.length > 1\"><select ui-grid-one-bind-aria-labelledby-grid=\"'items-per-page-label'\" ng-model=\"grid.options.paginationPageSize\" ng-options=\"o as o for o in grid.options.paginationPageSizes\"></select><span ui-grid-one-bind-id-grid=\"'items-per-page-label'\" class=\"ui-grid-pager-row-count-label\">&nbsp;{{sizesLabel}}</span></div><span ng-if=\"grid.options.paginationPageSizes.length <= 1\" class=\"ui-grid-pager-row-count-label\">{{grid.options.paginationPageSize}}&nbsp;{{sizesLabel}}</span></div><div class=\"ui-grid-pager-count-container\"><div class=\"ui-grid-pager-count\"><span ng-show=\"grid.options.totalItems > 0\">{{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} <abbr ui-grid-one-bind-title=\"paginationThrough\">-</abbr> {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}</span></div></div></div>";
+
+ $scope.gridOptions = {
+ pageNumber: 1,
+ sort : null,
+ paginationPageSizes: [5],
+ paginationPageSize: 5,
+ paginationTemplate: correctTotalPaginationTemplate,
+ columnDefs: [],
+ data: [],
+ enableGridMenu: true,
+ enableSelectAll: true,
+ gridMenuCustomItems : [
+ { title : 'All Reports',
+ action : function($event) {
+ $window.open('report.htm','_self');
+ }, order : 210 },
+ { title : 'Edit Report',
+ action : function($event) {
+ $window.open($scope.reportEditURL,'_self');
+ }, order : 211 },
+ { title : 'Export All data as Excel 2007',
+ action : function($event) {
+ $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.excel2007.session','_self');
+ }, order : 212 },
+ { title : 'Export All data as Excel',
+ action : function($event) {
+ $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.excel.session','_self');
+ }, order : 213 },
+ { title : 'Export All data as CSV',
+ action : function($event) {
+ $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.csv.session','_self');
+ }, order : 214 },
+ { title : 'Export All data as PDF',
+ action : function($event) {
+ $window.open('raptor.htm?c_master='+$scope.reportData.reportID+'&r_action=report.download.pdf.session','_self');
+ }, order : 215 } ],
+ exporterMenuPdf: false,
+ exporterMenuCsv: false,
+ exporterCsvFilename: 'myFile.csv',
+ exporterPdfDefaultStyle: {fontSize: 9},
+ exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
+ exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
+ exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
+ exporterPdfFooter: function ( currentPage, pageCount ) {
+ return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
+ },
+ exporterPdfCustomFormatter: function ( docDefinition ) {
+ docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
+ docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
+ return docDefinition;
+ },
+ exporterPdfOrientation: 'portrait',
+ exporterPdfPageSize: 'LETTER',
+ exporterPdfMaxGridWidth: 500,
+ exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
+ onRegisterApi: function(gridApi) {
+ $scope.gridApi = gridApi;
+ gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
+ paginationOptions.pageNumber = newPage;
+ paginationOptions.pageSize = pageSize;
+ $scope.runReport(true);
+ });
+ }
+ };
+
+ $scope.uiGridRefresh = function(){
+ var columnDefsArray = [];
+ var columnFreezeEndColumn = $scope.reportData.colIdxTobeFreezed;
+ var doColumnNeedToFreeze = false;
+ if(columnFreezeEndColumn && columnFreezeEndColumn.length>0) {
+ doColumnNeedToFreeze = true;
+ }
+ $scope.reportData.reportDataColumns.forEach(function(entry) {
+ var tempColumnDef = { displayName: entry.columnTitle, field: entry.colId, enableSorting: entry.sortable,
+ sortingAlgorithm: function(a, b) {
+ return rowSorter.sortAlpha(a.displayValue, b.displayValue);
+ },
+ cellTemplate: '<div class="ui-grid-cell-contents" style="text-align:{{COL_FIELD.alignment}};" title="TOOLTIP"> '+
+ ' <div ng-if="!COL_FIELD.drillDownURL || COL_FIELD.drillDownURL==\'\'">{{COL_FIELD.displayValue}}</div>' +
+ ' <a ng-if="COL_FIELD.drillDownURL && COL_FIELD.drillDownURL!=\'\'" ng-href="{{COL_FIELD.drillDownURL}}&parent___params==={{grid.appScope.currentReportUrlParams}}" >{{COL_FIELD.displayValue}}</a>' +
+ '</div>'};
+ if(entry.columnWidth && entry.columnWidth!='null' && entry.columnWidth!='pxpx' && entry.columnWidth!='nullpx' && entry.columnWidth!='nullpxpx'){
+ tempColumnDef['minWidth'] = entry.columnWidth.substring(0, entry.columnWidth.length - 2);
+ } else {
+ tempColumnDef['minWidth'] = '100';
+ }
+ if(doColumnNeedToFreeze) {
+ tempColumnDef['pinnedLeft']= true;
+ if(columnFreezeEndColumn === entry.colId){
+ doColumnNeedToFreeze = false;
+ }
+ }
+ columnDefsArray.push(tempColumnDef);
+ });
+
+ $scope.gridOptions.paginationPageSizes= [$scope.reportData.pageSize];
+ $scope.gridOptions.paginationPageSize= $scope.reportData.pageSize;
+ if($scope.reportData.totalRows<14){
+ $scope.gridHeight = ($scope.reportData.totalRows+5)*30+'px';
+ }else{
+ $scope.gridHeight = '400px';
+ }
+ $scope.gridOptions.totalItems = $scope.reportData.totalRows;
+ $scope.gridOptions.columnDefs= columnDefsArray;
+ $scope.gridOptions.data= $scope.reportData.reportDataRows;
+ $scope.gridOptions.exporterPdfHeader.text= $scope.reportData.reportName;
+ };
+
+ $scope.$watch("reportData",function(newValue,oldValue) {
+ if(!$scope.urlParams.hideGrid){
+ if($scope.reportData){
+ if($scope.reportData.displayData && $scope.reportData.reportDataColumns){
+ $scope.showGrid = true;
+ $scope.uiGridRefresh();
+ }
+ }
+ }
+ });
+
+ $scope.triggerOtherFormFields = function(){
+ // console.log("report_run");
+ var formFieldsUrl = $scope.getFormFieldSelectedValuesAsURL();
+ $http.get('raptor.htm?action=report.formfields.run.container&c_master='+$scope.reportData.reportID+'&'+formFieldsUrl).then(
+ function(response){
+ $scope.reportData = response.data;
+ });
+ };
+ $timeout(function() {
+ $rootScope.isViewRendering = false;
+ });
+}]);
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js
new file mode 100644
index 00000000..e1c5e1e8
--- /dev/null
+++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-search-controller.js
@@ -0,0 +1,186 @@
+appDS2.requires.push('ui.grid');
+appDS2.requires.push('ui.grid.pagination');
+appDS2.requires.push('ui.grid.resizeColumns');
+appDS2.controller("reportSearchController", ['$scope','$rootScope','$http','$timeout','uiGridConstants','$modal','$q','$log','raptorReportFactory',function ($scope,$rootScope,$http,$timeout,uiGridConstants,$modal,$q,$log,raptorReportFactory) {
+
+ $scope.getSearchData = function(){
+ raptorReportFactory.getSearchData().then(function(data){
+ $scope.searchdData = data;
+ },function(error){
+ $log.error("raptorReportFactory: getSearchData failed.");
+ });
+ }
+
+ $scope.getSearchData();
+
+ $scope.runReport = function(){
+ var searchParams = '';
+ if($scope.reportId && $scope.reportId!=''){
+ searchParams = '&rep_id='+$scope.reportId+'&rep_id_options='+$scope.operatorRepId.index;
+ }
+ if($scope.reportName && $scope.reportName!=''){
+ searchParams = searchParams+'&rep_name='+$scope.reportName+'&rep_name_options='+$scope.operatorRepName.index;
+ }
+
+ var pageSearchParameter = ($scope.paginationOptions.pageNumber-1)+searchParams
+ raptorReportFactory.getSearchDataAtPage(pageSearchParameter).then(function(data){
+ $scope.searchdData = data
+ },function(error){
+ $log.error("raptorReportFactory: getSearchDataAtPage failed.");
+ });
+ };
+
+
+ $scope.paginationOptions = {
+ pageNumber: 1,
+ pageSize: 5,
+ sort: null
+ };
+
+ var correctTotalPaginationTemplate =
+ //same as normal template, but fixed totals: {{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}}
+ "<div role=\"contentinfo\" class=\"ui-grid-pager-panel\" ui-grid-pager ng-show=\"grid.options.enablePaginationControls\"><div role=\"navigation\" class=\"ui-grid-pager-container\"><div role=\"menubar\" class=\"ui-grid-pager-control\"><button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-first\" ui-grid-one-bind-title=\"aria.pageToFirst\" ui-grid-one-bind-aria-label=\"aria.pageToFirst\" ng-click=\"pageFirstPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle\"><div class=\"first-bar\"></div></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-previous\" ui-grid-one-bind-title=\"aria.pageBack\" ui-grid-one-bind-aria-label=\"aria.pageBack\" ng-click=\"pagePreviousPageClick()\" ng-disabled=\"cantPageBackward()\"><div class=\"first-triangle prev-triangle\"></div></button> <input type=\"number\" ui-grid-one-bind-title=\"aria.pageSelected\" ui-grid-one-bind-aria-label=\"aria.pageSelected\" class=\"ui-grid-pager-control-input\" ng-model=\"grid.options.paginationCurrentPage\" min=\"1\" max=\"{{ paginationApi.getTotalPages() }}\" required> <span class=\"ui-grid-pager-max-pages-number\" ng-show=\"paginationApi.getTotalPages() > 0\"><abbr ui-grid-one-bind-title=\"paginationOf\">/</abbr> {{ paginationApi.getTotalPages() }}</span> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-next\" ui-grid-one-bind-title=\"aria.pageForward\" ui-grid-one-bind-aria-label=\"aria.pageForward\" ng-click=\"pageNextPageClick()\" ng-disabled=\"cantPageForward()\"><div class=\"last-triangle next-triangle\"></div></button> <button type=\"button\" role=\"menuitem\" class=\"ui-grid-pager-last\" ui-grid-one-bind-title=\"aria.pageToLast\" ui-grid-one-bind-aria-label=\"aria.pageToLast\" ng-click=\"pageLastPageClick()\" ng-disabled=\"cantPageToLast()\"><div class=\"last-triangle\"><div class=\"last-bar\"></div></div></button></div><div class=\"ui-grid-pager-row-count-picker\" ng-if=\"grid.options.paginationPageSizes.length > 1\"><select ui-grid-one-bind-aria-labelledby-grid=\"'items-per-page-label'\" ng-model=\"grid.options.paginationPageSize\" ng-options=\"o as o for o in grid.options.paginationPageSizes\"></select><span ui-grid-one-bind-id-grid=\"'items-per-page-label'\" class=\"ui-grid-pager-row-count-label\">&nbsp;{{sizesLabel}}</span></div><span ng-if=\"grid.options.paginationPageSizes.length <= 1\" class=\"ui-grid-pager-row-count-label\">{{grid.options.paginationPageSize}}&nbsp;{{sizesLabel}}</span></div><div class=\"ui-grid-pager-count-container\"><div class=\"ui-grid-pager-count\"><span ng-show=\"grid.options.totalItems > 0\">{{(((grid.options.paginationCurrentPage-1)*grid.options.paginationPageSize)+1)}} <abbr ui-grid-one-bind-title=\"paginationThrough\">-</abbr> {{(grid.options.paginationCurrentPage*grid.options.paginationPageSize>grid.options.totalItems?grid.options.totalItems:grid.options.paginationCurrentPage*grid.options.paginationPageSize)}} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}</span></div></div></div>";
+
+ $scope.gridOptions = {
+ paginationPageSizes: [5],
+ paginationPageSize: 5,
+ paginationTemplate: correctTotalPaginationTemplate,
+ columnDefs: [],
+ enableColumnResizing: true,
+ data: [],
+ enableGridMenu: true,
+ enableSelectAll: true,
+ exporterMenuPdf: false,
+ exporterMenuCsv: false,
+ exporterCsvFilename: 'myFile.csv',
+ exporterPdfDefaultStyle: {fontSize: 9},
+ exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
+ exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
+ exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
+ exporterPdfFooter: function ( currentPage, pageCount ) {
+ return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
+ },
+ exporterPdfCustomFormatter: function ( docDefinition ) {
+ docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
+ docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
+ return docDefinition;
+ },
+ exporterPdfOrientation: 'portrait',
+ exporterPdfPageSize: 'LETTER',
+ exporterPdfMaxGridWidth: 500,
+ exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
+ onRegisterApi: function(gridApi) {
+ gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
+ $scope.paginationOptions.pageNumber = newPage;
+ $scope.paginationOptions.pageSize = pageSize;
+ $scope.runReport();
+ });
+ }
+ };
+
+
+ var getPage = function() {
+ $scope.gridOptions.columnDefs = [];
+ $scope.searchdData.columns[0].forEach(function(entry) {
+ if(entry.columnTitle=='Run'){
+ $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false,
+ cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="#/report_run/{{COL_FIELD.drillDownLink.substr(39)}}" class="icon-controls-pointer" style="font-size:20px;"></a></div>'
+ });
+ } else if(entry.columnTitle=='Edit'){
+ $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false,
+ cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="{{COL_FIELD.drillDownLink}}" class="icon-misc-pen" style="font-size:20px;"></a></div>'
+ });
+ } else if(entry.columnTitle=='Delete'){
+ $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false,
+ cellTemplate: '<div class="ui-grid-cell-contents"><a ng-click="grid.appScope.removeReport(COL_FIELD.drillDownLink,row)" class="icon-misc-trash" style="font-size:20px;"></a></div>'
+ });
+ } else if(entry.columnTitle=='Copy'){
+ $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId, enableSorting: false,
+ cellTemplate: '<div class="ui-grid-cell-contents"><a ng-href="{{COL_FIELD.drillDownLink}}" class="icon-documents-copy" style="font-size:20px;"></a></div>'
+ });
+ } else if(entry.columnTitle=='Schedule'){
+ } else if(entry.columnTitle=='No'){
+ } else {
+ $scope.gridOptions.columnDefs.push({ displayName: entry.columnTitle, field: entry.columnId,
+ enableSorting: true,
+ cellTemplate: '<div class="ui-grid-cell-contents" style="text-align:{{COL_FIELD.alignment}};" title="TOOLTIP"> <div>{{COL_FIELD.displayValue}}</div> </div>'
+ });
+ }
+ });
+
+ $scope.gridOptions.paginationPageSizes= [$scope.searchdData.metaReport.pageSize];
+ $scope.gridOptions.paginationPageSize= $scope.searchdData.metaReport.pageSize;
+ $scope.gridOptions.totalItems = $scope.searchdData.metaReport.totalSize;
+
+ $scope.gridOptions.data = [];
+ $scope.searchdData.rows[0].forEach(function(entry) {
+ var localData = {};
+ entry.forEach(function(rowData){
+ localData[rowData["columnId"]]= rowData["searchresultField"];
+ });
+ $scope.gridOptions.data.push(localData);
+ });
+ };
+
+ $scope.$watch("searchdData",function(newValue,oldValue) {
+ if($scope.searchdData){
+ getPage();
+ }
+ });
+
+ $scope.operatorsRepId = [
+ {index: 0, value: 'Equal To', text: 'Equal To', alias:'Equal To'},
+ {index: 1, value: 'Less Than', text: 'Less Than', alias:'Less Than'},
+ {index: 2, value: 'Greater Than', text: 'Greater Than', alias:'Greater Than'}];
+ $scope.operatorRepId = {};
+ $scope.operatorRepId.value = $scope.operatorsRepId[0].value;
+ $scope.operatorRepId.index = $scope.operatorsRepId[0].index;
+
+ $scope.operatorsRepName = [
+ {index: 0, value: 'Starts With', text: 'Starts With', alias:'Starts With'},
+ {index:1, value: 'Ends With', text: 'Ends With', alias:'Ends With'},
+ {index: 2, value: 'Contains', text: 'Contains', alias:'Contains'}];
+
+ $scope.operatorRepName = {};
+ $scope.operatorRepName.value = $scope.operatorsRepName[0].value;
+ $scope.operatorRepName.index = $scope.operatorsRepName[0].index;
+
+ $scope.removeReport = function(reportDeleteUrl,row) {
+ var modalInstance = $modal.open({
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-del-confirm.html',
+ sizeClass: 'modal-small',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory', function ($scope, $modalInstance, $http, $log, raptorReportFactory) {
+ $scope.ok = function() {
+ raptorReportFactory.getReportDeleteStatus(reportDeleteUrl).then(function(data){
+ if (!(data.deleted)) {
+ $log.error("raptorReportFactory: report removal failed.")
+ }
+ $modalInstance.close();
+ },function(error){
+ $log.error("report removal error.")
+ });
+ };
+
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ };
+ }]
+ });
+
+ modalInstance.result.then(function () {
+ $scope.$emit('RefreshGridOptions');
+ }, function () {
+ });
+ };
+
+ $scope.$on('RefreshGridOptions', function(event) {
+ $scope.getSearchData();
+ });
+
+ $timeout(function() {
+ $rootScope.isViewRendering = false;
+ });
+
+
+}]);
diff --git a/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js
new file mode 100644
index 00000000..3196b336
--- /dev/null
+++ b/usecaseui-common/src/main/webapp/app/fusion/scripts/DS2-controllers/ds2-reports/report-step-controller.js
@@ -0,0 +1,1263 @@
+appDS2.controller('reportStepController', function($scope,$http,$location, $routeParams, $q, $modal,$log,$window, raptorReportFactory, stepFormFactory) {
+
+ $scope.showLoader = true;
+ // tabs for report wizard steps:
+ $scope.activeTabsId = 'Definition';
+ $scope.addReportUserId = {'id':''};
+ $scope.addReportRoleId = {'id':''};
+ // For all the dropdown box, please declare the active selection variable in the following manner:
+ // $scope.selectedOpt = {};
+ // $scope.selectedOpt.value = "";
+ $scope.getDefinitionById = function(id) {
+ raptorReportFactory.getDefinitionByReportId(id).then(function(data){
+ $scope.loadDefinition(data);
+ $scope.definitionData = data;
+ $scope.showLoader = false;
+ },function(error){
+ $log.error("raptorReportFactory: getSearchData failed.");
+ $scope.showLoader = false;
+ });
+ }
+
+ $scope.addReportSecurityUser = function(userId) {
+ raptorReportFactory.addReportSecurityUser(userId).then(function(data){
+ $scope.loadSecurityPage();
+ },function(error){
+ $log.error("raptorReportFactory: addReportSecurityUser failed.");
+ });
+ }
+
+ $scope.removeReportSecurityUser = function(securityUser) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-user-del-confirm.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','securityUser', function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityUser) {
+ $scope.securityUserName = securityUser.name;
+ $scope.ok = function() {
+ raptorReportFactory.removeReportSecurityUser(securityUser.id).then(function(data){
+ $modalInstance.close();
+ },function(error){
+ $log.error("raptorReportFactory: removeReportSecurityUser failed.");
+ });
+ }
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ };
+ }],
+ resolve:{
+ securityUser: function(){
+ return securityUser;
+ }
+ }
+ });
+ modalInstance.result.then(function () {
+ $scope.loadSecurityPage();
+ }, function () {
+ });
+ };
+
+
+ $scope.addReportSecurityRole = function(roleId) {
+ raptorReportFactory.addReportSecurityRole(roleId).then(function(data){
+ $scope.loadSecurityPage();
+ },function(error){
+ $log.error("raptorReportFactory: addReportSecurityRole failed.");
+ });
+ }
+
+ $scope.removeReportSecurityRole = function(securityRole) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-security-role-del-confirm.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','securityRole', function ($scope, $modalInstance, $http, $log, raptorReportFactory,securityRole) {
+ $scope.securityRoleName = securityRole.name;
+ $scope.ok = function() {
+ raptorReportFactory.removeReportSecurityRole(securityRole.id).then(function(data){
+ $modalInstance.close();
+ },function(error){
+ $log.error("raptorReportFactory: removeReportSecurityRole failed.");
+ });
+ }
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ };
+ }],
+ resolve:{
+ securityRole: function(){
+ return securityRole;
+ }
+ }
+ });
+ modalInstance.result.then(function () {
+ $scope.loadSecurityPage();
+ }, function () {
+ });
+ }
+
+ $scope.saveReportSecurityInfo = function(userId, isPublic) {
+ var securityInfo = {'userId':userId+"",'isPublic':isPublic};
+ raptorReportFactory.updateReportSecurityInfo(securityInfo).then(function(data){
+ $scope.loadSecurityPage();
+ },function(error){
+ $log.error("raptorReportFactory: updateReportSecurityInfo failed.");
+ });
+ };
+
+ $scope.createNewDefinition = function() {
+ raptorReportFactory.createNewDefinition().then(function(data){
+ $scope.loadDefinition(data);
+ $scope.definitionData = data;
+ $scope.showLoader = false;
+ },function(error){
+ $log.error("raptorReportFactory: getSearchData failed.");
+ });
+ }
+
+ var initializeCreateReport = function() {
+ $scope["selectedReportType"] ={};
+ $scope.selectedReportType.value ="linear";
+ $scope.selectedReportType2 ={};
+ $scope.selectedReportType2.value ="";
+ $scope.selectedDataSource ={};
+ $scope.selectedDataSource.value="local";
+ $scope.sqlScript = "SELECT ";
+ $scope.pageSize = {"value":"50"};
+ }
+
+
+ var loadSqlInSession = function(){
+ raptorReportFactory.getSqlInSession().then(function(data){
+ $scope.sqlInSessionJSON = data;
+ $scope.sqlScript = data.query;
+ $scope.showLoader = false;
+ },function(error){
+ $log.error("raptorReportFactory: getSearchData failed.");
+ });
+ };
+
+ initializeCreateReport();
+ if ($routeParams.reportMode) {
+ if ($routeParams.reportMode=="copy") {
+ raptorReportFactory.copyReportById($routeParams.reportId).then(function(data){
+ $scope.$emit('RefreshInsession');
+ },function(error){
+ $log.error("raptorReportFactory: deleteFormFieldById failed.");
+ });
+ } else if ($routeParams.reportMode=="import") {
+ $scope.$emit('RefreshInsession');
+ }
+ } else if ($routeParams.reportId) {
+ $scope.getDefinitionById($routeParams.reportId);
+ $scope.isEdit = true;
+ $scope.reportId = $routeParams.reportId;
+ } else {
+ $scope.isEdit = false;
+ $scope.createNewDefinition();
+ }
+
+
+ $scope.RunCurrentReport = function (){
+ $window.location.href = "#/report_run/c_master="+$scope.reportId+"&refresh=Y";
+ }
+
+ $scope.deleteFormField = function(rowData) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-formfield-del-confirm.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) {
+ $scope.tempFieldId = rowData.id;
+ $scope.ok = function() {
+ raptorReportFactory.deleteFormFieldById(rowData.id).then(function(data){
+ $modalInstance.close();
+ },function(error){
+ $log.error("raptorReportFactory: deleteFormFieldById failed.");
+ });
+ }
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ };
+ }],
+ resolve:{
+ rowData: function(){
+ return rowData;
+ }
+ }
+ });
+ modalInstance.result.then(function () {
+ $scope.$emit('RefreshFormField');
+ }, function () {
+ });
+ }
+
+ $scope.loadDefinition = function(definitionData) {
+ $scope.reportId = definitionData.reportId+"";
+ $scope.reportName = definitionData.reportName;
+ $scope.reportDescr = definitionData.reportDescr;
+ $scope.formHelpText = definitionData.formHelpText;
+ $scope.selectedPageSize = {"value": definitionData.pageSize+''};
+ $scope.selectedMaxRowsInExcelCSVDownload = {"value": definitionData.maxRowsInExcelCSVDownload};
+ $scope.reportTitle = definitionData.reportTitle;
+ $scope.reportSubTitle = definitionData.reportSubTitle;
+ $scope.selectedNumFormCols ={"value": definitionData.numFormCols+''};
+ $scope.selectedFrozenColumns={"value": definitionData.frozenColumns+''};
+ $scope.selectedDataGridAlign = {"value":definitionData.dataGridAlign+''};
+ $scope.emptyMessage = definitionData.emptyMessage+'';
+ $scope.selectedDataContainerHeight = {"value":definitionData.dataContainerHeight+''};
+ $scope.selectedDataContainerWidth = {"value":definitionData.dataContainerWidth+''};
+ var displayAreaValue = "null"
+ for (var i=0; i<3; i++ ) {
+ if (definitionData.displayArea[i].selected) {
+ displayAreaValue = definitionData.displayArea[i].name;
+ }
+ }
+ $scope.selectedDisplayArea = {"value":displayAreaValue+""};
+
+ $scope.hideFormFieldsAfterRunSelected = {"value": definitionData.hideFormFieldsAfterRun}
+
+ $scope.hideFormFieldsSelected = {"value":definitionData.displayOptions[0].selected};
+ $scope.hideChartSelected = {"value":definitionData.displayOptions[1].selected};
+ $scope.hideReportDataSelected = {"value":definitionData.displayOptions[2].selected};
+ $scope.hideExcelSelected = {"value":definitionData.displayOptions[3].selected};
+ $scope.hidePdfSelected = {"value":definitionData.displayOptions[4].selected};
+ $scope.runtimeColSortDisabled = {"value":definitionData.runtimeColSortDisabled};
+ $scope.showLoader = false;
+ }
+
+
+ var setDefinition = function(){
+ $scope.updatedDefJson = {
+ "tabName" : "Definition",
+ "tabId" : "Def",
+ "reportId" : ($scope.isEdit?$scope.reportId+'':"-1"),
+ "reportName" : $scope.reportName,
+ "reportDescr" : $scope.reportDescr,
+ "reportType" : "Linear",
+ "dbInfo" : "local",
+ "formHelpText" : $scope.formHelpText,
+ "pageSize" : Number($scope.selectedPageSize.value),
+ "displayArea" : [ {
+ "id" : "HOME",
+ "name" : "HOME",
+ "selected" : ($scope.selectedDisplayArea.value=="HOME")
+ }, {
+ "id" : "CUSTOMER",
+ "name" : "CUSTOMER",
+ "selected" : ($scope.selectedDisplayArea.value==="CUSTOMER")
+ }, {
+ "id" : "REPORTS",
+ "name" : "REPORTS",
+ "selected" : ($scope.selectedDisplayArea.value==="REPORTS")
+ } ],
+ "hideFormFieldsAfterRun" : $scope.hideFormFieldsAfterRunSelected.value,
+ "maxRowsInExcelCSVDownload" : Number($scope.selectedMaxRowsInExcelCSVDownload.value),
+ "frozenColumns" : Number($scope.selectedFrozenColumns.value),
+ "dataGridAlign" : $scope.selectedDataGridAlign.value,
+ "emptyMessage" : $scope.emptyMessage,
+ "dataContainerHeight" : $scope.selectedDataContainerHeight.value,
+ "dataContainerWidth" : $scope.selectedDataContainerWidth.value,
+ "displayOptions" : [ {
+ "name" : "HideFormFields",
+ "selected" : $scope.hideFormFieldsSelected.value
+ }, {
+ "name" : "HideChart",
+ "selected" : $scope.hideChartSelected.value
+ }, {
+ "name" : "HideReportData",
+ "selected" : $scope.hideReportDataSelected.value
+ }, {
+ "name" : "HideExcel",
+ "selected" : $scope.hideExcelSelected.value
+ }, {
+ "name" : "HidePdf",
+ "selected" : $scope.hidePdfSelected.value
+ } ],
+ "runtimeColSortDisabled" : $scope.runtimeColSortDisabled.value,
+ "numFormCols" : Number($scope.selectedNumFormCols.value),
+ "reportTitle" : $scope.reportTitle,
+ "reportSubTitle" : $scope.reportSubTitle
+ }
+
+ }
+
+ var updateDefinitionData = function() {
+ setDefinition();
+ raptorReportFactory.updateDefinition($scope.updatedDefJson,$scope.isEdit).then(function(data){
+ },function(error){
+ $log.error("raptorReportFactory: updateDefinition by Id failed.");
+ });
+ }
+
+ var saveNewDefinitionData = function() {
+ setDefinition();
+ raptorReportFactory.saveNewDefinition($scope.updatedDefJson).then(function(data){
+ },function(error){
+ $log.error("raptorReportFactory: saveNewDefinition by Id failed.");
+ });
+ }
+
+ $scope.testRunSql = function(){
+ var queryJSON = {query: $scope.sqlScript};
+ queryJSON = JSON.stringify(queryJSON);
+ raptorReportFactory.testRunSQL(queryJSON).then(function(data){
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','queriedData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) {
+ var init = function() {
+ $scope.isError = false;
+ if (queriedData.errormessage) {
+ $scope.isError = true;
+ $scope.errormessage = queriedData.errormessage;
+ $scope.stacktrace = queriedData.stacktrace;
+ } else {
+ $scope.queryData = queriedData;
+ }
+ }
+ init();
+ $scope.close = function() {
+ $modalInstance.dismiss();
+ };
+ }],
+ resolve:{
+ queriedData: function(){
+ return data;
+ }
+ }
+ })
+
+ },function(error){
+ $log.error("raptorReportFactory: test run SQL failed.");
+ });
+ }
+
+
+ $scope.formFieldVerifySQL= function(sqlScript){
+ var queryJSON = {query: sqlScript};
+ queryJSON = JSON.stringify(queryJSON);
+ raptorReportFactory.formFieldVerifySQL(queryJSON).then(function(data){
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-test-run-sql.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','queriedData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, queriedData) {
+ var init = function() {
+ $scope.isError = false;
+ if (queriedData.errormessage) {
+ $scope.isError = true;
+ $scope.errormessage = queriedData.errormessage;
+ $scope.stacktrace = queriedData.stacktrace;
+ } else {
+ $scope.queryData = queriedData;
+ }
+ }
+ init();
+ $scope.close = function() {
+ $modalInstance.dismiss();
+ };
+ }],
+ resolve:{
+ queriedData: function(){
+ return data;
+ }
+ }
+ })
+
+ },function(error){
+ $log.error("raptorReportFactory: test run SQL failed.");
+ });
+ }
+
+
+ /* $scope.selectedDataSource.allowSchedule={};
+ $scope.selectedDataSource.allowSchedule.value=""*/
+
+ var getJsonSrcName = function(stepNum){
+ var JsonSrcPrefix = "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step"
+ return JsonSrcPrefix + stepNum +".json";
+ }
+
+ $scope.gTabs = [
+ {
+ title: 'Definition',
+ id: 'Definition',
+ uniqueId: 'uniqueTab1x',
+ tabPanelId: 'threetab1x'
+ }, {
+ title: 'SQL',
+ id: 'SQL',
+ uniqueId: 'uniqueTab2x',
+ tabPanelId: 'threetab2x',
+ disabled: (!$scope.isEdit)
+ }, {
+ title: 'Columns',
+ id: 'Columns',
+ uniqueId: 'uniqueTab3x',
+ tabPanelId: 'threetab3x',
+ disabled: (!$scope.isEdit)
+ }, {
+ title: 'Form Fields',
+ id: 'Form Fields',
+ uniqueId: 'uniqueTab4x',
+ tabPanelId: 'threetab4x',
+ disabled: (!$scope.isEdit)
+ }, {
+ title: 'Security',
+ id: 'Security',
+ uniqueId: 'uniqueTab5x',
+ tabPanelId: 'threetab5x',
+ disabled: (!$scope.isEdit)
+ }, {
+ title: 'Run',
+ id: 'Run',
+ uniqueId: 'uniqueTab6x',
+ tabPanelId: 'threetab6x',
+ disabled: (!$scope.isEdit)
+ }
+ ];
+
+ $scope.unhideAllOtherTabs = function(){
+ for (var selectedTab = 0; selectedTab < $scope.gTabs.length; selectedTab++) {
+ $scope.gTabs[selectedTab].disabled = false;
+ }
+ }
+
+ $scope.openColumnPopup = function (rowData) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-col-edit.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','colData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, colData) {
+ raptorReportFactory.getColumnEditInfoById(colData.id).then(function(data){
+ $scope.columnEditData = data;
+ $scope.colId = data.colId;
+/* $scope.colName = data.colName;*/
+ $scope.colName = {'value':data.colName+''};
+ $scope.selectedDisplayAlignment = {"value":data.displayAlignment+''};
+ $scope.selectedDisplayHeaderAlignment = {"value":data.displayHeaderAlignment+''};
+ $scope.sortable = {"value":''+data.sortable};
+ $scope.visible = {"value":''+data.visible};
+ $scope.drilldownURL = data.drilldownURL;
+ $scope.drilldownParams = data.drilldownParams;
+ $scope.drilldownType = data.drilldownType;
+ $scope.selectedDrillDownReport = {"value":""};
+
+
+ },function(error){
+ $log.error("raptorReportFactory: getColumnEditInfoById failed.");
+ });
+
+ var init = function() {
+
+ raptorReportFactory.getDrillDownReportList().then(function(data2){
+ $scope.drilldownReports = data2;
+ },function(error){
+ $log.error("raptorReportFactory: getDrillDownReportList failed.");
+ });
+
+/* $scope.colTableRowData = colData;*/
+ $scope.displayAlignmentOptions = [
+ {value:"null", text:""},
+ {value:"Left", text:"Left"},
+ {value:"Center", text:"Center"},
+ {value:"Right", text:"Right"}
+ ];
+ $scope.ynOptions = [
+ {value:"true", text:"Yes"},
+ {value:"false", text:"No"}
+ ];
+ $scope.drillDownOptions = [
+ {value:"drillDownOpt1", text:"drillDownOpt1"},
+ {value:"drillDownOpt2", text:"drillDownOpt2"},
+ {value:"drillDownOpt3", text:"drillDownOpt3"}
+ ];
+ }
+
+ init();
+ $scope.$watch('selectedDrillDownReport.value',function(){
+ if ($scope.selectedDrillDownReport) {
+ $scope.$emit('openDrillDownpage',$scope.selectedDrillDownReport.value);
+ }
+ });
+
+ $scope.save = function() {
+ var drilldownURL = "";//raptorReportFactory.drillDownPopupOptions
+ //raptorReportFactory.drillDownPopupOptions.radioGroup
+ var colInfo = {
+ "tabId" : "ColEdit",
+ "tabName" : "Column Edit",
+ "colId" : $scope.colId,
+ "colName" : $scope.colName.value,
+ "displayAlignment" : ($scope.selectedDisplayAlignment.value=="null")?null:$scope.selectedDisplayAlignment.value,
+ "displayHeaderAlignment" : ($scope.selectedDisplayHeaderAlignment.value=="null")?null:$scope.selectedDisplayHeaderAlignment.value,
+ "sortable" : ($scope.sortable.value=="true"),
+ "visible" : ($scope.visible.value=="true"),
+ "drilldownURL" : raptorReportFactory.drillDownURL,
+ "drilldownParams" : raptorReportFactory.drillDownParams,
+ "drilldownType" : ""
+ }
+ raptorReportFactory.saveColumnEditInfo(colInfo).then(function(data){
+ $modalInstance.close();
+ },function(error){
+ $log.error("raptorReportFactory: getColumnEditInfoById failed.");
+ });
+ };
+
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ };
+ }],
+ resolve:{
+ colData: function(){
+ return rowData;
+ }
+ }
+ });
+
+ modalInstance.result.then(function () {
+ $scope.$emit('RefreshColumnList');
+ }, function () {
+ });
+ };
+
+
+ $scope.throwReportNameMissingError = function () {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-report-name-validation.html',
+ sizeClass: 'modal-small',
+ controller: ['$scope', '$modalInstance', '$http', '$log', function ($scope, $modalInstance, $http, $log) {
+ $scope.close = function() {
+ $modalInstance.dismiss();
+ };
+ }]
+ });
+ modalInstance.result.then(function () {
+ }, function () {
+ });
+ };
+
+
+ $scope.addNewFormField = function () {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory', function ($scope, $modalInstance, $http, $log, raptorReportFactory) {
+ raptorReportFactory.getFormFieldEditInfoById("add").then(function(data){
+ $scope.formFieldEditData = data;
+ $scope.fieldId = $scope.formFieldEditData.fieldId;
+ $scope.fieldName ={"value": $scope.formFieldEditData.fieldName};
+ $scope.selectedVisible = {"value":$scope.formFieldEditData.visible+''};
+ $scope.defaultValue = {"value": $scope.formFieldEditData.defaultValue};
+ $scope.fieldDefaultSQL = {"value": $scope.formFieldEditData.fieldDefaultSQL};
+ $scope.fieldSqlContent = {"value": $scope.formFieldEditData.fieldSQL};
+ $scope.selectedValidationType = {"value":$scope.formFieldEditData.validationType +''};
+ $scope.selectedFieldType = {"value":$scope.formFieldEditData.fieldType +''};
+ $scope.sqlDefaultValueSelected= {value:false};
+ $scope.sqlDefaultValueSelected ={"value":false};
+ if (($scope.fieldDefaultSQL.value)&&($scope.fieldDefaultSQL.value!="")) {
+ $scope.sqlDefaultValueSelected.value =true;
+ }
+ },function(error){
+ $log.error("raptorReportFactory: getColumnEditInfoById failed.");
+ });
+
+
+ $scope.ynOptions = [
+ {value:"true", text:"Yes"},
+ {value:"false", text:"No"}
+ ];
+
+ $scope.verifyFieldValueOptions = [
+ {value:"DATE", text:"Date"},
+ {value:"TIME_STAMP_HOUR", text:"TimeStamp (Hour)"},
+ {value:"TIME_STAMP_HOUR_MIN", text:"TimeStamp (Hour,Min)"},
+ {value:"HIDDEN", text:"Hidden"}
+ ]
+
+ $scope.fieldTypeOptions = [
+ {value:"TEXT", text:"Text Box"},
+ {value:"LIST_BOX", text:"List Box"},
+ {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"},
+ {value:"HIDDEN", text:"Hidden"}
+ ];
+
+ $scope.save = function() {
+ var formFieldJSON = {
+ "tabId" : "FormEdit",
+ "tabName" : "Form Edit",
+ "fieldId" : $scope.fieldId,
+ "fieldName" : $scope.fieldName.value,
+ "fieldType" : $scope.selectedFieldType.value,
+ "visible" : ($scope.selectedVisible.value=="true"),
+ "defaultValue" : ($scope.sqlDefaultValueSelected.value?'':$scope.defaultValue.value),
+ "fieldDefaultSQL" : ($scope.sqlDefaultValueSelected.value?$scope.fieldDefaultSQL.value:""),
+ "fieldSQL" :$scope.fieldSqlContent.value,
+ "validationType" : "NONE",
+ "predefinedValueList" :null
+ }
+ raptorReportFactory.saveFormFieldEditInfo(formFieldJSON).then(function(data){
+ $modalInstance.close();
+ },function(error){
+ $log.error("raptorReportFactory: saveFormFieldEditInfo failed.");
+ });
+ };
+
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ };
+ }]
+ });
+ modalInstance.result.then(function () {
+ $scope.$emit('RefreshFormField');
+ }, function () {
+ });
+ };
+
+ $scope.openFormFieldPopup = function (rowData) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-formfield-edit.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','fieldData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, fieldData) {
+ var init = function() {
+ raptorReportFactory.getFormFieldEditInfoById(fieldData.id).then(function(data){
+ $scope.formFieldEditData = data;
+ $scope.fieldId = $scope.formFieldEditData.fieldId;
+ $scope.fieldName = {"value":$scope.formFieldEditData.fieldName};
+ $scope.selectedVisible = {"value":$scope.formFieldEditData.visible+''};
+ $scope.defaultValue = {"value":$scope.formFieldEditData.defaultValue};
+ $scope.fieldDefaultSQL = {"value": $scope.formFieldEditData.fieldDefaultSQL};
+ $scope.fieldSqlContent = {"value": $scope.formFieldEditData.fieldSQL};
+ $scope.selectedValidationType = {"value":$scope.formFieldEditData.validationType +''};
+ $scope.selectedFieldType = {"value":$scope.formFieldEditData.fieldType +''};
+ $scope.sqlDefaultValueSelected ={"value":false};
+ if (($scope.fieldDefaultSQL.value)&&($scope.fieldDefaultSQL.value!="")) {
+ $scope.sqlDefaultValueSelected.value =true;
+ }
+ },function(error){
+ $log.error("raptorReportFactory: getColumnEditInfoById failed.");
+ });
+
+ $scope.ynOptions = [
+ {value:"true", text:"Yes"},
+ {value:"false", text:"No"}
+ ];
+
+ $scope.verifyFieldValueOptions = [
+ {value:"DATE", text:"Date"},
+ {value:"TIME_STAMP_HOUR", text:"TimeStamp (Hour)"},
+ {value:"TIME_STAMP_HOUR_MIN", text:"TimeStamp (Hour,Min)"},
+ {value:"HIDDEN", text:"Hidden"}
+ ]
+
+ $scope.fieldTypeOptions = [
+ {value:"TEXT", text:"Text Box"},
+ {value:"LIST_BOX", text:"List Box"},
+ {value:"LIST_MULTI_SELECT", text:"Multi-select List Box"},
+ {value:"HIDDEN", text:"Hidden"}
+ ];
+
+ }
+
+ init();
+
+ $scope.save = function() {
+ var formFieldJSON = {
+ "tabId" : "FormEdit",
+ "tabName" : "Form Edit",
+ "fieldId" : $scope.fieldId,
+ "fieldName" : $scope.fieldName.value,
+ "fieldType" : $scope.selectedFieldType.value,
+ "visible" : ($scope.selectedVisible.value=="true"),
+ "defaultValue" : ($scope.sqlDefaultValueSelected.value?'':$scope.defaultValue.value),
+ "fieldDefaultSQL" : ($scope.sqlDefaultValueSelected.value?$scope.fieldDefaultSQL.value:""),
+ "fieldSQL" :$scope.fieldSqlContent.value,
+ "validationType" : "NONE",
+ "predefinedValueList" :null
+ }
+ raptorReportFactory.saveFormFieldEditInfo(formFieldJSON).then(function(data){
+ $modalInstance.close();
+ },function(error){
+ $log.error("raptorReportFactory: saveFormFieldEditInfo failed.");
+ });
+ };
+
+ $scope.cancel = function() {
+ $modalInstance.dismiss();
+ };
+ }],
+ resolve:{
+ fieldData: function(){
+ return rowData;
+ }
+ }
+ });
+
+ modalInstance.result.then(function () {
+ $scope.$emit('RefreshFormField');
+ }, function () {
+ });
+ };
+
+ $scope.openDrillDownReportPopup = function (reportId,parentReportId) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-wizard-drilldown-edit.html',
+ sizeClass: 'modal-large',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','reportId', function ($scope, $modalInstance, $http, $log, raptorReportFactory, reportId) {
+
+ $scope.drillDownOptionList =[];
+ $scope.selectedvalueradioGroup = {"name":""};
+ $scope.selectedChildReportFormField = {"value":""};
+ $scope.selectedChildReportColumn = {"value":""};
+ $scope.fixedValue = {"value":""};
+ $scope.suppressValues = {"value":""};
+
+ raptorReportFactory.getChildReportFormField(reportId).then(function(data){
+ for (var i=0;i<data.length;i++) {
+ $scope.drillDownOptionList.push(
+ {
+ "name": data[i].name,
+ "id": data[i].id,
+ "selectedvalueradioGroup":{"name":""},
+ "selectedChildReportFormField":{"value":""},
+ "selectedChildReportColumn":{"value":""},
+ "fixedValue":{"value":""},
+ "suppressValues":{"value":""}
+ }
+ )
+ }
+ },function(error){
+ $log.error("raptorReportFactory: getChildReportFormField failed.");
+ });
+
+ raptorReportFactory.getChildReportFormField(parentReportId).then(function(data){
+ $scope.childReportFF =data;
+ },function(error){
+ $log.error("raptorReportFactory: getChildReportFormField failed.");
+ });
+
+ raptorReportFactory.getChildReportColumn(parentReportId).then(function(data){
+ $scope.childReportCol =data;
+ },function(error){
+ $log.error("raptorReportFactory: getChildReportFormField failed.");
+ });
+
+ raptorReportFactory.setDrillDownPopupOptions(null);
+
+ $scope.complete = function() {
+ var drillDownPopupOptions= {
+ radioGroup : $scope.selectedvalueradioGroup.name,
+ reportFF: $scope.selectedChildReportFormField.value,
+ reportCol: $scope.selectedChildReportColumn.value,
+ fixedValue: $scope.fixedValue.value,
+ suppressValues: $scope.suppressValues.value
+ }
+ var drillDownParams = "";
+ var ampStr ="";
+ for (var i=0;i<$scope.drillDownOptionList.length; i++) {
+ if (drillDownParams!="") {
+ ampStr = "&amp;";
+ }
+ if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="fixedValue"){
+ drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "="+$scope.drillDownOptionList[i].fixedValue.value;
+ } else if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="reportFF"){
+ drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "=[!"+$scope.drillDownOptionList[i].selectedChildReportFormField.value + "]";
+ } else if ($scope.drillDownOptionList[i].selectedvalueradioGroup.name=="reportCol"){
+ drillDownParams = drillDownParams + ampStr + $scope.drillDownOptionList[i].id + "=["+$scope.drillDownOptionList[i].selectedChildReportColumn.value + "]";
+ }
+ }
+ raptorReportFactory.setDrillDownPopupOptions(reportId,drillDownParams);
+
+ $modalInstance.close();
+ };
+ }],
+ resolve:{
+ reportId: function(){
+ return reportId;
+ }
+ }
+ });
+
+ modalInstance.result.then(function () {
+/* $scope.$emit('RefreshFormField');*/
+ }, function () {
+ });
+};
+
+ $scope.$watch('activeTabsId', function (newVal, oldVal) {
+ if(newVal !== oldVal) {
+ $scope.showLoader = true;
+ var selectedTab;
+ for (selectedTab = 0; selectedTab < $scope.gTabs.length; selectedTab++) {
+ if ($scope.gTabs[selectedTab].id === newVal) {
+ $scope.stepNum = selectedTab;
+/* stepFormFactory.getStepJSONData(getJsonSrcName($scope.stepNum))*/
+ $scope.isColumnStep = false;
+ $scope.isFormFieldStep = false;
+ $scope.isSecurityStep = false;
+ $scope.renderStep(selectedTab+1);
+ if ($scope.stepNum == 1) {
+ $scope.showLoader = false;
+ }
+ else if ($scope.stepNum == 2) {
+ loadSqlInSession();
+ } else if ($scope.stepNum == 3) {
+ $scope.isColumnStep = true;
+ raptorReportFactory.getColumnList().then(function(data){
+ $scope.colTableRowData = data;
+ $scope.showLoader = false;
+ },function(error){
+ $log.error("raptorReportFactory: get column list failed.");
+ $scope.showLoader = false;});
+
+ } else if ($scope.stepNum == 4) {
+ $scope.isFormFieldStep = true;
+ // put within then function:
+ raptorReportFactory.getFormFieldList().then(function(data){
+ $scope.formFieldData = data;
+ $scope.showLoader = false;
+ },function(error){
+ $log.error("raptorReportFactory: get formfields failed.");
+ $scope.showLoader = false;});
+ } else if ($scope.stepNum == 5) {
+ $scope.isSecurityStep = true;
+ $scope.reportOwnerId={'id':''};
+ $scope.isPublicOptionList = [
+ {'value':'true','text':'Yes'},
+ {'value':'false','text':'No'},
+ ];
+ $scope.loadSecurityPage();
+
+ }
+ else if ($scope.stepNum == 6) {
+ raptorReportFactory.getDefinitionInSession().then(function(data){
+ $scope.reportId = data.reportId;
+ $scope.showLoader = false;
+ },function(error){
+ $log.error("raptorReportFactory: getDefinitionInSession failed.");
+ $scope.showLoader = false;});
+ }
+
+ if ($scope.stepNum>1){
+ $scope.unhideAllOtherTabs();
+ }
+ break;
+ }
+ }
+ }
+ });
+
+ $scope.loadSecurityPage = function() {
+ $scope.showLoader = true;
+ raptorReportFactory.resetSecurityLoadingCounter();
+
+ //API call 1:
+ raptorReportFactory.getSecurityReportOwnerList().then(function(data){
+ $scope.reportOwnerList = data;
+ raptorReportFactory.icrementSecurityLoadingCounter();
+ if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;};
+ },function(error){
+ $log.error("raptorReportFactory: getSecurityReportOwnerList failed.");
+ });
+
+ //API call 2: get report role list
+ raptorReportFactory.getReportRoleList().then(function(data){
+ $scope.reportRoleList = data;
+ raptorReportFactory.icrementSecurityLoadingCounter();
+ if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;};
+ },function(error){
+ $log.error("raptorReportFactory: getReportRoleList failed.");
+ });
+
+ //API call 3: get security page basic info
+ raptorReportFactory.getReportSecurityInfo().then(function(data){
+ $scope.reportSecurityInfo = data;
+ $scope.reportOwnerId ={id: $scope.reportSecurityInfo.ownerId};
+ raptorReportFactory.icrementSecurityLoadingCounter();
+ if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;};
+ },function(error){
+ $log.error("raptorReportFactory: getReportSecurityInfo failed.");
+ $scope.showLoader = false;});
+
+ //API call 4: retrieve security users
+ raptorReportFactory.getReportSecurityUsers().then(function(data){
+ $scope.reportSecurityUsers = data;
+ for (var i=0; i<$scope.reportSecurityUsers.length;i++) {
+ $scope.reportSecurityUsers[i]["accessAllowed"] = !$scope.reportSecurityUsers[i]["readOnly"];
+ }
+ raptorReportFactory.icrementSecurityLoadingCounter();
+ if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;};
+ },function(error){
+ $log.error("raptorReportFactory: reportSecurityUsers failed.");
+ });
+
+ //API call 5: retrieve security roles
+ raptorReportFactory.getReportSecurityRoles().then(function(data){
+ $scope.reportSecurityRoles = data;
+ for (var i=0; i<$scope.reportSecurityRoles.length;i++) {
+ $scope.reportSecurityRoles[i]["accessAllowed"] = !$scope.reportSecurityRoles[i]["readOnly"];
+ }
+
+ raptorReportFactory.icrementSecurityLoadingCounter();
+ if(raptorReportFactory.checkSecurityLoadingCounter()){$scope.showLoader = false;};
+ },function(error){
+ $log.error("raptorReportFactory: reportSecurityRoles failed.");
+ });
+ }
+
+
+ $scope.renderStep = function(stepNum){
+ var containerElement = angular.element(document.getElementById("stepView"));
+ containerElement.empty();
+ $scope.stepNum = stepNum;
+ var jsonSrcName = getJsonSrcName(stepNum);
+ stepFormFactory.renderForm(jsonSrcName, containerElement, $scope);
+ }
+
+ $scope.toggleUserEditAccessActive = function(rowData) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html',
+ sizeClass: 'modal-small',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) {
+ $scope.rowData = rowData;
+ $scope.toggleEditAccessStatus = function(rowData) {
+ raptorReportFactory.toggleUserEditAccess(rowData);
+ $modalInstance.close();
+ };
+
+ $scope.cancelEditAccessToggle = function(rowData) {
+ rowData.accessAllowed = ! rowData.accessAllowed;
+ $modalInstance.dismiss('cancel');}
+ }],
+ resolve:{
+ rowData: function(){
+ return rowData;
+ }
+ }
+ });
+ modalInstance.result.then(function () {
+
+ }, function () {
+ });
+ }
+
+ $scope.toggleRoleEditAccessActive = function(rowData) {
+ var modalInstance = $modal.open({
+ scope: $scope,
+ animation: $scope.animationsEnabled,
+ templateUrl: 'app/fusion/scripts/DS2-view-models/ds2-reports/modal/report-user-role-confirm-toggle.html',
+ sizeClass: 'modal-small',
+ controller: ['$scope', '$modalInstance', '$http', '$log','raptorReportFactory','rowData', function ($scope, $modalInstance, $http, $log, raptorReportFactory, rowData) {
+ $scope.rowData = rowData;
+ $scope.toggleEditAccessStatus = function(rowData) {
+ raptorReportFactory.toggleRoleEditAccess(rowData);
+ $modalInstance.close();
+ };
+
+ $scope.cancelEditAccessToggle = function(rowData) {
+ rowData.accessAllowed = ! rowData.accessAllowed;
+ $modalInstance.dismiss('cancel');}
+ }],
+ resolve:{
+ rowData: function(){
+ return rowData;
+ }
+ }
+ });
+ modalInstance.result.then(function () {
+
+ }, function () {
+ });
+ }
+
+
+
+
+
+ // initialize the page at step 1;
+ $scope.renderStep(1);
+
+ // create a message to display in our view
+ $scope.allProjects = [];
+ if(!$routeParams.step && $routeParams.step == "") $routeParams.step = 1;
+ if($routeParams.proj && $routeParams.proj > 0)
+ $scope.projid = $routeParams.proj;
+ if($routeParams.step)
+ $scope.stepNum = $routeParams.step;
+ else
+ $scope.stepNum = 1;
+
+ $scope.jsonSrcName = getJsonSrcName($scope.stepNum);
+
+ $scope.selectAction = function () {
+ var containerElement = angular.element(document.getElementById("stepView"));
+ containerElement.empty();
+ $scope.project_name = this.prj.projectName;
+ $scope.stepNum = 1;
+ var stepNum = $scope.stepNum;
+ var jsonSrcName = getJsonSrcName(stepNum);
+ stepFormFactory.renderForm(jsonSrcName, containerElement, $scope);
+ renderProject(this.prj.id, 1);
+ };
+
+
+ $scope.createAction = function () {
+ var containerElement = angular.element(document.getElementById("stepView"));
+ containerElement.empty();
+ $scope.stepNum = 1;
+ var stepNum = $scope.stepNum;
+ $scope.jsonSrcName = "app/fusion/scripts/DS2-view-models/ds2-reports/wz_steps/json/step"+$scope.stepNum +".json";
+ var jsonSrcName = $scope.jsonSrcName;
+ stepFormFactory.renderForm(jsonSrcName, containerElement, $scope);
+ };
+
+ // select current project
+ renderProject = function (proj_id, stepNum) {
+ var userSelectedPrjId = proj_id;
+ $http({
+ method: 'GET',
+ url: 'get_selected_project_data',
+ params:{'selectedPrjId':userSelectedPrjId, 'step': stepNum}
+ }).then(function successCallback(response) {
+ var selectedproject = response.data;
+ $scope.projid = userSelectedPrjId;
+ //$scope.allProjects = projectLists;
+ //$location.path('/'+userSelectedPrjId+'/'+stepNum);
+ var div = d3.select("#stepView");
+ div.select("[name='proj_id']").text(userSelectedPrjId);
+ div.select("[name='proj_id']").property("value", userSelectedPrjId);
+ d3.select("[name='project_id']").property("value", userSelectedPrjId);
+ var h3Text = div.select("h3").text();
+ div.select("h3").text($scope.project_name+ " - " + h3Text);
+ for (var key in selectedproject) {
+ if (selectedproject.hasOwnProperty(key)) {
+ var val = selectedproject[key];
+ var formElement = d3.selectAll("[name='" + key + "']");
+ if(formElement[0].length > 0)
+ console.log(formElement.attr("type"));
+ if(formElement[0].length > 0 && formElement.attr("type") === "radio") {
+ var formRadio = d3.selectAll("[id='" + key +"_"+val + "']");
+ formRadio.property('checked', true);
+ }
+ if(formElement[0].length > 0 && formElement.property("type") === "textarea") {
+ div.select("textarea[name='" + key +"']").property('value', val);
+ }
+ if(formElement[0].length > 0 && formElement.attr("type") === "text") {
+ var formText = d3.selectAll("[name='" + key + "']");
+ formText.property("value", val);
+ }
+ if(formElement[0].length > 0 && formElement.html().startsWith("<option")) {
+ var formSelect = d3.selectAll("[name='" + key + "']");
+
+ var checkOption = function (e) {
+ if(e.label === val){
+ return formSelect.property("selectedIndex", e.index );
+ }
+ };
+
+ formSelect.selectAll("option").forEach(function(d) {d.forEach(function(optionD) {checkOption(optionD); }) });
+ }
+
+ if(formElement[0].length == 0) {
+ if(key != 'step') {
+ if( Object.prototype.toString.call( val ) === '[object Array]' ) {
+ val.forEach(function(d){
+ for (var keyCheck in d) {
+ if (d.hasOwnProperty(keyCheck)) {
+ var valCheck = d[keyCheck];
+ var formCheck = d3.selectAll("[name='" + key + "_"+keyCheck + "']");
+ if(valCheck === true)
+ formCheck.property('checked', true);
+ }
+ }
+ });
+ }
+ }
+ var formElementOther = d3.selectAll("[name='" + key + "_"+ val + "']");
+ if(formElementOther[0].length > 0 && formElementOther.attr("type") === "checkbox") {
+ var formCheckbox = d3.selectAll("[name='" + key +"_"+val + "']");
+ formRadio.property('checked', true);
+ }
+ }
+ }
+ }
+
+
+
+ });
+ }
+
+ //submit function
+ $scope.submit = function(){
+ let defer = $q.defer();
+
+ var div = d3.select("#stepView");
+ var jsonSrcName = $scope.jsonSrcName;
+ var stepNum = $scope.stepNum;
+ var values = "";
+ $http({
+ method: 'GET',
+ url: jsonSrcName
+ }).then(function successCallback(response) {
+ var json = response.data;
+ var step = json.step;
+ if(step > 0) {
+ var sections = json.content.sections;
+ sections.forEach(function(d, i) {
+ var elements = d.elements;
+ if(elements) {
+ //elements.forEach(function(element, elementIndex) {
+ values += "{";
+ values += "\"step\""+ ":\"" + step + "\",";
+ values += "\"proj_id\""+ ":\"" + d3.select('input[name="project_id"]').property("value") + "\",";
+
+ for (elementIndex = 0; elementIndex < elements.length; elementIndex++) {
+ var element = elements[elementIndex];
+
+ if(elementIndex > 0) values += ",";
+ values += "\""+element.name +"\""+ ":" ;
+ if(element.input === "hidden") {
+ values += "\""+div.select('input[name="'+element.name+'"]').property("value") +"\"";
+ }
+ if(element.input === "radio") {
+ values += "\""+ div.select('input[name="'+element.name+'"]:checked').property("value") +"\"";
+ }
+ if(element.input === "checkbox") {
+ var checkOptions = element.options;
+ values += "[{";
+ checkOptions.forEach(function(d, i) {
+ // if(document.getElementById("'"+element.name+"_"+d.id+"'") != null)
+ values += "\""+d.id+"\""+ ":" + div.select('input[name="'+element.name+"_"+d.id+'"]').property("checked") ;
+ if(i<checkOptions.length-1) {
+ values += ",";
+ }
+ })
+ values += "}]";
+ }
+ if(element.input === "text") {
+ values += "\""+div.select('input[name="'+element.name+'"]').property("value") +"\"";
+ }
+ if(element.input === "textarea") {
+ values += "\""+div.select('textarea[name="'+element.name+'"]').node().value +"\"";
+ }
+ if(element.input === "select") {
+ values += "\""+ div.select('select[name="'+element.name+'"]').property("value") + "\"";
+ }
+
+ };
+ values += "}";
+ }
+ });
+ }
+ var valueJSON = JSON.parse(values);
+ var valueStr = JSON.stringify(valueJSON, null, 4);
+ $http({method:'POST', url:'save_steps', data: jsonSrcName, params:{'result' : valueStr, 'proj_id' : values.proj_id}}).success(function(data, status) {
+ if(data.project_name)
+ $scope.project_name = data.project_name;
+ div.select("[name='proj_id']").property("value", data.proj_id);
+ d3.select("[name='project_id']").property("value", data.proj_id);
+ //$scope.projid = data.proj_id;
+ valueStr=JSON.stringify(data, null, 4);
+ defer.resolve();
+ //stepNum = Number(stepNum || 0)+1;
+ //document.getElementById('itestframe').src = data;
+
+ })
+
+ defer.resolve();
+
+ });
+ // $location.path('/step'+($scope.stepNum+1));
+ return defer.promise;
+
+ };
+
+ //Save function
+ $scope.save = function() {
+ if ($scope.stepNum ==1) {
+ updateDefinitionData();
+ } else if($scope.stepNum ==5) {
+ $scope.saveReportSecurityInfo($scope.reportOwnerId.id,$scope.reportSecurityInfo.isPublic);
+ }
+ };
+
+ //Next function
+ $scope.next = function(){
+ if ($scope.stepNum ==1) {
+ if ($scope.reportName==="") {
+ $scope.throwReportNameMissingError();
+ return;
+ }
+ updateDefinitionData();
+ }
+ $scope.stepNum = $scope.stepNum +1;
+ $scope.activeTabsId = $scope.gTabs[$scope.stepNum-1].id;
+ };
+
+ //Previous function
+ $scope.previous = function(){
+ $scope.stepNum = $scope.stepNum -1;
+ $scope.activeTabsId = $scope.gTabs[$scope.stepNum-1].id;
+
+ };
+
+ $scope.$on('RefreshInsession', function(event) {
+ $scope.isEdit = true;
+ $scope.reportId = -1;
+ $scope.getDefinitionById(-1);
+ });
+
+ $scope.$on('openDrillDownpage', function(event, reportId) {
+ if (reportId!="") {
+ $scope.openDrillDownReportPopup(reportId,$scope.reportId);
+ }
+ });
+
+
+ $scope.$on('RefreshFormField', function(event) {
+ raptorReportFactory.getFormFieldList().then(function(data){
+ $scope.formFieldData = data;
+ },function(error){
+ $log.error("raptorReportFactory: get formfields failed.");
+ });
+ });
+
+ $scope.$on('RefreshColumnList', function(event) {
+ raptorReportFactory.getColumnList().then(function(data){
+ $scope.colTableRowData = data;
+ },function(error){
+ $log.error("raptorReportFactory: get column list failed.");
+ });
+ });
+
+ $scope.getAllProjects = function(){
+ $http({
+ method: 'GET',
+ url: 'get_projects'
+ }).then(function successCallback(response) {
+ var projectLists = response.data;
+ $scope.allProjects = projectLists;
+ });
+ }
+
+ // getAllProjects();
+
+});