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=========================================================
20 app.controller('importDictionaryController' , function ($scope, $modalInstance, message, $http, PolicyAppService, UserInfoServiceDS2, Notification){
22 /*getting user info from session*/
24 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
25 .then(function (response) {
26 userid = response.userid;
29 $scope.importButton = true;
31 $scope.uploadFile = function(files) {
33 fd.append("file", files[0]);
34 var fileExtension = files[0].name.split(".")[1];
35 if(fileExtension == "csv"){
36 $scope.importButton = false;
39 Notification.error("Upload the Dictionary file extends with .csv format");
43 $scope.submitUpload = function(){
44 $http.post("saveDictionary/dictionary/import_dictionary", fd, {
45 withCredentials: false,
46 headers: {'Content-Type': undefined},
47 transformRequest: angular.identity
48 }).success(function(data){
49 if(data.includes("Success")){
50 Notification.success("Dictionary Uploaded Successfully");
52 Notification.error(data);
54 $scope.importButton = true;
55 }).error(function(data){
56 Notification.error("Dictionary Upload Failed");
60 $scope.close = function() {
61 $modalInstance.close();