2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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 * ============LICENSE_END=========================================================
23 var app = angular.module('abs');
24 app.controller('exportPolicyController', function ($scope, $window, ExportPolicyService, modalService, $modal, Notification){
25 $( "#dialog" ).hide();
26 $scope.linkEnable = true;
27 $scope.gridOptions = {
28 onRegisterApi: function(gridApi) {
29 $scope.gridPolicyApi = gridApi;
32 enableFiltering: true,
33 showTreeExpandNoChildren: true,
34 paginationPageSizes: [10, 20, 50, 100],
35 paginationPageSize: 20,
36 columnDefs: [{name: 'name'}, {name: 'version'}, {name: 'dateModified'}]
40 ExportPolicyService.getAutoPushPoliciesData().then(function (data1) {
41 $scope.loading = false;
42 $scope.files = data1.data;
43 var data = data1.data;
46 var writeoutNode = function(childArray, currentLevel, dataArray){
47 childArray.forEach( function(childNode){
48 if (childNode.files.length > 0){
49 childNode.$$treeLevel = currentLevel;
50 id=childNode.categoryId;
51 if(childNode.categoryId == childNode.parentCategoryId){
55 if((id!=childNode.parentCategoryId) || (childNode.categoryId == childNode.parentCategoryId)){
56 if(childNode.categoryId == childNode.parentCategoryId){
59 childNode.$$treeLevel = currentLevel;
62 dataArray.push( childNode );
63 writeoutNode( childNode.files, currentLevel + 1, dataArray );
67 $scope.gridOptions.data = [];
68 writeoutNode(data, 0, $scope.gridOptions.data);
70 console.log("failed");
73 $scope.download = function(){
74 var policySelection = $scope.gridPolicyApi.selection.getSelectedRows();
75 console.log(policySelection);
77 "policyDatas": policySelection
79 console.log(finalData);
80 var uuu = "policy_download/exportPolicy.htm";
81 var postData={exportData: finalData};
86 contentType: 'application/json',
87 data: JSON.stringify(postData),
88 success : function(data){
89 $scope.$apply(function(){
90 $scope.data=data.data;
91 var url = '../' + $scope.data;
92 window.location = url;
93 Notification.success("Policies Exported Successfully");
95 console.log($scope.data);
97 error : function(data){
98 Notification.error("Error Occured while Exporting Policy.");
104 $scope.close = function() {
105 $modalInstance.close();