2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
21 app.config(function($routeProvider) {
24 //.when('/notebook-frame/:id/:key/:value',{
25 //.when('/notebook-frame/:nid/:qprms',{
26 /*.when('/notebook-frame',{
27 templateUrl: 'app/fusion/notebook-integration/scripts/view-models/notebook-frame.html',
28 controller: 'notebookFrameController'
32 // templateUrl: 'app/fusion/notebook-integration/scripts/view-models/notebook-frame.html',
33 templateUrl: 'app/fusion/notebook-integration/scripts/view-models/notebookInputs.html',
34 controller: 'nbookController'
36 }).controller('nbookController', ['$scope', '$location','$window','$http', function ($scope,$location,$window,$http) {
38 $scope.keyValueList = [{}];
39 console.log('onload nbookController');
40 $scope.submitParameters = function() {
42 $scope.iframevisibility = false;
43 console.log('Inside nbook invoke save');
47 $scope.additionalqueryParams = {};
49 //Use this if there is only one 1 query param key value pair
50 $scope.additionalqueryParams.paramKey = $scope.qparamKey;
51 $scope.additionalqueryParams.paramVal = $scope.qparamVal;
54 // console.log('$scope.additionalqueryParams',$scope.additionalqueryParams);
55 console.log('$scope.notebookvalue',$scope.notebookvalue);
58 //$scope.postData['notebookid'] = 'a06a9cf14211012e221bf842c168849d';
59 //$scope.postData['param1'] = 'p1';
60 //$scope.postData['param2'] = 'p2';
62 //console.log('Report Schedule object', $scope.reportScheduleObject);
65 /* if ($window.location.search.substr($window.location.search.indexOf("=")+1)) {
66 $scope.queryParams = $window.location.search;
68 if ($window.location.search.indexOf("&")!=-1) {
69 $scope.notebookparam = $window.location.search.substring($window.location.search.indexOf("?")+1,$window.location.search.indexOf("&"));
70 $scope.additionalqueryParams = JSON.parse('{"' + decodeURI($scope.queryParams.substr($scope.queryParams.indexOf("&")+1).replace(/&/g, "\",\"").replace(/=/g,"\":\"")) + '"}');
71 console.log('Additional parameters present');
74 $scope.notebookparam = $window.location.search.substr($window.location.search.indexOf("?")+1);
75 console.log('Additional parameters absent');
77 console.log('add parameters',$scope.additionalqueryParams);
78 // $scope.notebookid = $scope.notebookparam.substring(0,$scope.notebookparam.indexOf("="));
79 $scope.notebookvalue = $scope.notebookparam.substr($scope.notebookparam.indexOf("=")+1);
80 $scope.postData = $window.location.search.substr($window.location.search.indexOf("=")+1);
81 console.log('Notebook value present ',$scope.notebookvalue);
84 $scope.notebookvalue = '833c0a69ec1433fbb2f8752af733cf0e';
85 console.log('Notebook value absent ',$scope.notebookvalue);
88 // $http.get("notebook.htm#/notebook-frame", {params : {"a" : "b"}})
90 /* $http.get("app/fusion/notebook-integration/scripts/view-models/notebook-frame.html", {params : {"a" : "b"}})
91 .then(function(response) {
92 console.log("Got response from http get ");
93 // window.open ('notebook.htm#/notebook-frame','_self',false);
96 // $location.search(1, $scope.additionalqueryParams);
98 console.log('$scope.additionalqueryParams',$scope.additionalqueryParams);
99 // $scope.invokeSaveNotebook() = function() {
100 // window.open ('notebook.htm#/notebook-frame/1/2/3','_self',false);
102 //var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue;
103 //var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&'+encodeURIComponent(JSON.stringify($scope.additionalqueryParams));
104 // var testurl = 'notebook.htm#/notebook-frame/' + $scope.notebookvalue + '/' + encodeURIComponent(JSON.stringify($scope.additionalqueryParams));
106 console.log('$scope.keyValueList',$scope.keyValueList);
108 /*for (var obj in $scope.keyValueList) {
109 for (var prop in obj) {
110 if (obj.hasOwnProperty(prop)) {
111 // or if (Object.prototype.hasOwnProperty.call(obj,prop)) for safety...
112 console.log('property',obj[prop]);
113 //console.log("prop: " + prop.qk + " value: " + obj[prop.qk]);
118 console.log('$scope.keyValueList.length',$scope.keyValueList.length);
121 for(var i = 0; i < $scope.keyValueList.length; i++) {
122 var obj = $scope.keyValueList[i];
123 //console.log('obj.qK',obj.qK);
124 if (obj.qK != undefined && obj.qV != undefined) {
125 //console.log('Inside qk defined');
127 qryStr = qryStr+'&'+obj.qK+'='+obj.qV;
129 qryStr = obj.qK+'='+obj.qV;
134 console.log('qryStr',qryStr);
138 //var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&k1='+$scope.additionalqueryParams.paramKey+'&v1='+$scope.additionalqueryParams.paramVal;
140 // var testurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&'+$scope.additionalqueryParams.paramKey+'='+$scope.additionalqueryParams.paramVal;
142 var queryurl = 'nbooktest.htm?nid='+$scope.notebookvalue+'&'+qryStr;
144 // var testurl = 'notebook.htm#/notebook-frame';
146 window.open (queryurl,'_self',false);
151 $scope.addKeyValuePairs = function (kv) {
154 if ($scope.keyValueList.length < 9) {
155 $scope.keyValueList.push({
158 // alert($scope.reportRunJson.rangeAxisList.length);
159 // console.log('$scope.keyValueList',$scope.keyValueList);
162 //document.getElementById("addbtn").disabled = true;
163 // $scope.btnactive = false;
164 document.getElementById("addbtn")["disabled"] = true;
165 //document.getElementById("addbtn")["style.background-color"] = "#FFFF00";
167 //$('#addbtn').btn('type') = "disabled";
171 $scope.removeKeyValuePairs = function (index) {
172 $scope.keyValueList.splice(index, 1);
173 if ($scope.keyValueList.length == 8) {
174 document.getElementById("addbtn")["disabled"] = false;
176 //console.log($scope.hardCodeReport.rangeAxisList)