2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ===================================================================
30 function($scope, $rootScope, fileUpload) {
31 console.log("///////////fileUploadCtrl");
32 $rootScope.isAllOption = false;
33 // -----For Required Radio button functionality
34 $scope.requiredonly = function() {
35 console.log("requiredonly");
36 // var tempArray = $rootScope.SUT;
37 // var tempParam = tempArray.parameters;
38 // alert("testParam.length:"+tempParam.length);
39 var parameter = $scope.parArray;
40 var param = $scope.parameters;
42 $('.req').each(function() {
44 var newID = 'requiredval' + i;
45 // jQuery(this).prev("req").attr("requiredval", "newID");
46 // $(this).attr("requiredval","newID");
47 // var newval=$(this).val(newID);
48 var newval = $(this).attr('id', newID);
49 console.log("Angular id: " + newval);
50 if (i < param.length) {
51 document.getElementById(newID).disabled = false;
53 param[i].required = parameter[i];
54 // document.getElementById(newID).disabled=true;
55 document.getElementById(newID).checked = true;
57 param[i].required = parameter[i];
58 // document.getElementById(newID).disabled=false;
59 document.getElementById(newID).checked = false;
65 $scope.allrequired = function() {
66 console.log("allrequired");
67 var param = $scope.parameters;
69 $('.req').each(function() {
71 var newID = 'requiredval' + i;
72 // jQuery(this).prev("req").attr("requiredval", "newID");
73 // $(this).attr("requiredval","newID");
74 // var newval=$(this).val(newID);
75 var newval = $(this).attr('id', newID);
76 console.log("Angular id: " + newval);
77 if (i < param.length) {
78 param[i].required = true;
79 document.getElementById(newID).checked = true;
80 document.getElementById(newID).disabled = true;
85 $scope.uploadSUTFile = function(element) {
86 console.log("uploadSUTFile");
88 .$apply(function($scope) {
90 $rootScope.isAllOption = false;
91 $rootScope.isStatic = true;
92 $scope.requiredval = false;
93 $rootScope.rightTabName = "UTM Build Configuration";
94 $rootScope.testSet = null;
95 if ($rootScope.isStatic == true) {
96 document.getElementById('buidConfigBtn').style.visibility = "hidden";
98 var file = element.files[0];/* $scope.requestFile; */
99 console.log('file is ' + JSON.stringify(file));
100 $rootScope.file_type = "SUT";
101 var uploadUrl = "/utm-service/sut_upload/uploadSUT";
102 fileUpload.uploadFileToUrl(file, uploadUrl).then(function(pars) {
103 console.log("uploadFileToUrl");
104 $rootScope.SUT = pars;
105 console.log("file name :" + pars.name);
106 $scope.fileName = pars.name;
107 $scope.parameters = pars.parameters;
108 $scope.constraints = pars.constraints;
109 $scope.relations = pars.relations;
110 var con = $scope.constraints;
113 // alert("File upload failed and parameters not returned");
115 angular.forEach(angular.element("input[type='file']"),
116 function(inputElem) {
117 console.log("inputElem");
118 angular.element(inputElem).val(null);
122 $scope.buildConfig = function() {
123 console.log("buildConfig");
124 $rootScope.isStatic = true;
125 $rootScope.rightTabName = "UTM Build Configuration";
126 document.getElementById('buidConfigBtn').style.visibility = "hidden";
127 $rootScope.testset = null;
130 * $scope.close = function(){ $modalInstance.close('closed'); };
132 * $scope.importSchema= function(){ var file = $scope.requestFile;
133 * console.log('file is ' + JSON.stringify(file)); var uploadUrl =
134 * "/utm-service/schema_upload/uploadSchema";
135 * fileUpload.uploadFileToUrl(file, uploadUrl) .then(function(pars) {
136 * $rootScope.SUT = pars; console.log("file name :"+pars.name);
137 * $scope.fileName = pars.name; $scope.parameters = pars.parameters; var
138 * param = pars.parameters; }, function(data) { //alert("File upload failed
139 * and parameters not returned"); });
144 function clearFileInput(id) {
145 console.log("clearFileInput");
146 var oldInput = document.getElementById(id);
147 var newInput = document.createElement("input");
148 newInput.type = "file";
149 newInput.id = oldInput.id;
150 newInput.name = oldInput.name;
151 newInput.className = oldInput.className;
152 newInput.style.cssText = oldInput.style.cssText;
153 // TODO: copy any other relevant attributes
154 oldInput.parentNode.replaceChild(newInput, oldInput);