2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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('editOptimizationModelController' , function ($scope, $modalInstance, message, $http, UserInfoServiceDS2, Notification){
21 if(message.optimizationModelsDictionaryData==null)
22 $scope.label='Add Optimization Model'
24 $scope.label='Edit Optimization Model'
25 $scope.disableCd=true;
28 /*getting user info from session*/
30 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
31 .then(function (response) {
32 userid = response.userid;
36 $scope.editOptimizationModelName = message.optimizationModelsDictionaryData;
38 $scope.uploadFile = function(files) {
39 var extn = files[0].name.substr(files[0].name.lastIndexOf('.')+1);
40 if(extn == 'zip' || extn == 'xmi'|| extn == 'yml'){
42 var fd = new FormData();
43 fd.append("file", files[0]);
44 $http.post("oof_dictionary/set_ModelData", fd, {
45 withCredentials: false,
46 headers: {'Content-Type': undefined },
47 transformRequest: angular.identity
48 }).success(function(data){
49 if(data.errorMsg != undefined){
50 Notification.error(data.errorMsg);
54 if(data.classListDatas == "EMPTY"){
55 Notification.error("No Optimization Models Available.")
57 $scope.classListDatas=data.classListDatas;
58 $scope.modalDatas = data.modelDatas;
59 $scope.modelType= data.modelType;
60 $scope.dataOrderInfo= data.dataOrderInfo;
61 console.log($scope.classListDatas);
65 Notification.error("Optimization Model Upload file should ends with .zip or .xmi extension");
71 $scope.saveOptimizationModel = function(optimizationModelsDictionaryData) {
73 var uuu = "saveDictionary/oof_dictionary/save_model";
74 var postData={optimizationModelsDictionaryData: optimizationModelsDictionaryData, userid: userid, classMap: $scope.modalDatas,modelType:$scope.modelType, dataOrderInfo:$scope.dataOrderInfo};
79 contentType: 'application/json',
80 data: JSON.stringify(postData),
81 success : function(data){
82 $scope.$apply(function(){
83 $scope.optimizationModelsDictionaryDatas=data.optimizationModelsDictionaryDatas;});
84 if($scope.optimizationModelsDictionaryDatas == "Duplicate"){
85 Notification.error("Optimization Model Dictionary exists with Same Model Name.")
87 console.log($scope.optimizationModelsDictionaryDatas);
88 $modalInstance.close({optimizationModelsDictionaryDatas:$scope.optimizationModelsDictionaryDatas});
91 error : function(data){
92 Notification.error("Error while saving.");
96 Notification.error("Please check Optimization Model Upload file format.");
101 $scope.close = function() {
102 $modalInstance.close();