2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 app.controller('exportCtrl', ['$scope', '$rootScope','exportService','dialogs', function($scope,$rootScope,exportService,dialogs){
25 console.log("exportCtrl");
28 $scope.exportfile = function(format) {
29 console.log("//////////exportfile");
31 console.log("exporting data inside exportfile function....");
33 var formatValue=format;
34 $rootScope.exportFormat = format;
35 var testsetValue=$rootScope.testset;
37 var exporturl = "/utm-service/testset_export/exportTestSet";
39 exportService.exportToUrl(testsetValue, formatValue, exporturl)
40 .then(function(results) {
41 console.log("results");
43 var sets=results.data;
44 console.log("Sets value"+sets);
45 var headerValue=results.headers;
46 var fileName=headerValue.filename;
47 console.log("Filename Server value"+fileName);
50 var hiddenElement = document.createElement('a');
52 if (angular.equals($rootScope.exportFormat,"Excel")) {
54 var blob = new Blob([sets], {type: "application/vnd.ms-excel"});
55 var objectUrl = URL.createObjectURL(blob);
56 //alert("EXCEL Format");
57 hiddenElement.href = objectUrl;
58 hiddenElement.download = fileName;
59 } else if (angular.equals($rootScope.exportFormat,"NIST")) {
60 //alert("NIST Format");
61 hiddenElement.href = 'data:attachment/nist,' + encodeURI(sets);
62 hiddenElement.download = fileName;
64 //alert("CSV Format");
65 hiddenElement.href = 'data:attachment/csv,' + encodeURI(sets);
66 hiddenElement.download = fileName;
69 hiddenElement.target = '_blank';
70 hiddenElement.click();
74 //alert("File upload failed and parameters not returned");
78 /* $rootScope.exportUTMTestSet = function() {
79 console.log("exportUTMTestSet");
82 var dlg = dialogs.create('partials/portfolios/export_almqc_data.html','exportALMQCCtrl',{},{size:'xlg',keyboard: true,backdrop: true,windowClass: 'my-class'});
83 dlg.result.then(function(name){
84 console.log("dlg.result");
87 //if(angular.equals($scope.name,''))
88 //$scope.name = 'You did not enter in your name!';
92 /*console.log("exporting data inside exportUTMTestSet function....");
95 var testsetValue=$rootScope.modeltestset;
97 var exporturl = "/utm-service/testset_export/exportMDTTestSet";
99 exportService.exportToUTMTestSet(testsetValue, exporturl)
100 .then(function(results) {
102 var sets=results.data;
103 console.log("Sets value"+sets);
104 var headerValue=results.headers;
105 var fileName="UTMTestSet";
106 //console.log("Filename Server value"+fileName);
107 var hiddenElement = document.createElement('a');
108 var blob = new Blob([sets], {type: "application/vnd.ms-excel"});
109 var objectUrl = URL.createObjectURL(blob);
110 //alert("EXCEL Format");
111 hiddenElement.href = objectUrl;
112 hiddenElement.download = fileName;
113 hiddenElement.target = '_blank';
114 hiddenElement.click();
117 //alert("File upload failed and parameters not returned");