2 appDS2.controller('nbookController', ['$scope', '$location','$window','$http', function ($scope,$location,$window,$http) {
4 $scope.keyValueList = [{}];
5 //console.log('onload nbookController');
6 $scope.submitParameters = function() {
8 $scope.iframevisibility = false;
9 console.log('Inside nbook invoke save');
13 $scope.additionalqueryParams = {};
15 //Use this if there is only one 1 query param key value pair
16 $scope.additionalqueryParams.paramKey = $scope.qparamKey;
17 $scope.additionalqueryParams.paramVal = $scope.qparamVal;
20 // console.log('$scope.additionalqueryParams',$scope.additionalqueryParams);
21 //console.log('$scope.notebookvalue',$scope.notebookvalue);
24 //$scope.postData['notebookid'] = 'a06a9cf14211012e221bf842c168849d';
25 //$scope.postData['param1'] = 'p1';
26 //$scope.postData['param2'] = 'p2';
28 //console.log('Report Schedule object', $scope.reportScheduleObject);
31 /* if ($window.location.search.substr($window.location.search.indexOf("=")+1)) {
32 $scope.queryParams = $window.location.search;
34 if ($window.location.search.indexOf("&")!=-1) {
35 $scope.notebookparam = $window.location.search.substring($window.location.search.indexOf("?")+1,$window.location.search.indexOf("&"));
36 $scope.additionalqueryParams = JSON.parse('{"' + decodeURI($scope.queryParams.substr($scope.queryParams.indexOf("&")+1).replace(/&/g, "\",\"").replace(/=/g,"\":\"")) + '"}');
37 console.log('Additional parameters present');
40 $scope.notebookparam = $window.location.search.substr($window.location.search.indexOf("?")+1);
41 console.log('Additional parameters absent');
43 console.log('add parameters',$scope.additionalqueryParams);
44 // $scope.notebookid = $scope.notebookparam.substring(0,$scope.notebookparam.indexOf("="));
45 $scope.notebookvalue = $scope.notebookparam.substr($scope.notebookparam.indexOf("=")+1);
46 $scope.postData = $window.location.search.substr($window.location.search.indexOf("=")+1);
47 console.log('Notebook value present ',$scope.notebookvalue);
50 $scope.notebookvalue = '833c0a69ec1433fbb2f8752af733cf0e';
51 console.log('Notebook value absent ',$scope.notebookvalue);
54 // $http.get("notebook.htm#/notebook-frame", {params : {"a" : "b"}})
56 /* $http.get("app/fusion/notebook-integration/scripts/view-models/notebook-frame.html", {params : {"a" : "b"}})
57 .then(function(response) {
58 console.log("Got response from http get ");
59 // window.open ('notebook.htm#/notebook-frame','_self',false);
62 // $location.search(1, $scope.additionalqueryParams);
64 //console.log('$scope.additionalqueryParams',$scope.additionalqueryParams);
65 // $scope.invokeSaveNotebook() = function() {
66 // window.open ('notebook.htm#/notebook-frame/1/2/3','_self',false);
68 //var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue;
69 //var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&'+encodeURIComponent(JSON.stringify($scope.additionalqueryParams));
70 // var testurl = 'notebook.htm#/notebook-frame/' + $scope.notebookvalue + '/' + encodeURIComponent(JSON.stringify($scope.additionalqueryParams));
72 // console.log('$scope.keyValueList',$scope.keyValueList);
74 /*for (var obj in $scope.keyValueList) {
75 for (var prop in obj) {
76 if (obj.hasOwnProperty(prop)) {
77 // or if (Object.prototype.hasOwnProperty.call(obj,prop)) for safety...
78 console.log('property',obj[prop]);
79 //console.log("prop: " + prop.qk + " value: " + obj[prop.qk]);
84 //console.log('$scope.keyValueList.length',$scope.keyValueList.length);
87 for(var i = 0; i < $scope.keyValueList.length; i++) {
88 var obj = $scope.keyValueList[i];
89 //console.log('obj.qK',obj.qK);
90 if (obj.qK != undefined && obj.qV != undefined) {
91 //console.log('Inside qk defined');
93 qryStr = qryStr+'&'+obj.qK+'='+obj.qV;
95 qryStr = obj.qK+'='+obj.qV;
100 //console.log('qryStr',qryStr);
104 //var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&k1='+$scope.additionalqueryParams.paramKey+'&v1='+$scope.additionalqueryParams.paramVal;
106 // var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&'+$scope.additionalqueryParams.paramKey+'='+$scope.additionalqueryParams.paramVal;
108 var queryurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&'+qryStr;
110 // var testurl = 'notebook.htm#/notebook-frame';
112 window.open (queryurl,'_self',false);
115 // var w = window.open ('notebook.htm#/notebook-frame','_self',false);
116 // w.nid = $scope.notebookvalue;
119 // $http.post('rNotebookFE/authCr', $scope.postData).success(function(data, status) {
120 /* $http({method:'POST', url:'rNotebookFE/authCr', data: $scope.notebookvalue, params:{'qparams' : $scope.additionalqueryParams}}).success(function(data, status) {
121 console.log('Data Sent', data);
122 console.log('Status ', status);
126 // iframe.name = "my_iframe";
128 // $scope.ifr = "<div><iframe src='http://www.w3schools.com'/></div>"
130 // var url = "https://rcloud.research.att.com";
131 // document.getElementById('itestfr').src = data;
132 // window.open ('notebook.htm#/notebook-frame/1/2/3','_self',false);
133 // $scope.iframevisibility = true;
134 // document.getElementById('itestfr').src = data;
142 $scope.addKeyValuePairs = function (kv) {
145 if ($scope.keyValueList.length < 9) {
146 $scope.keyValueList.push({
149 // alert($scope.reportRunJson.rangeAxisList.length);
150 // console.log('$scope.keyValueList',$scope.keyValueList);
153 //document.getElementById("addbtn").disabled = true;
154 // $scope.btnactive = false;
155 document.getElementById("addbtn")["disabled"] = true;
156 //document.getElementById("addbtn")["style.background-color"] = "#FFFF00";
158 //$('#addbtn').btn('type') = "disabled";
162 $scope.removeKeyValuePairs = function (index) {
163 $scope.keyValueList.splice(index, 1);
164 if ($scope.keyValueList.length == 8) {
165 document.getElementById("addbtn")["disabled"] = false;
167 //console.log($scope.hardCodeReport.rangeAxisList)