2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
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 * ================================================================================
23 class WidgetParameterController {
24 constructor($scope, widgetsCatalogService, userProfileService) {
25 let widgetId = $scope.ngDialogData.widgetId;
26 $scope.modflag = false;
27 $scope.isLoadingTable = false;
28 $scope.messageInfo = false;
30 widgetsCatalogService.getWidgetCatalogParameters(widgetId).then(res => {
31 if(res.status == 'OK'){
32 $scope.isLoadingTable = true;
33 $scope.widgetParam = res.response;
34 }else if(res.status == 'WARN'){
35 $scope.messageInfo = true;
38 $log.error('WidgetParameterController::init error: ' + err);
41 $scope.setEdit = function(index) {
42 if($scope.modflag === false){
43 $scope.widgetParam[index].showEdit = true;
44 $scope.modflag = true;
48 $scope.resetDefault = function(index) {
49 var widgetParamObject = {};
50 widgetParamObject.user_value = $scope.widgetParam[parseInt(index)].default_value;
51 widgetParamObject.paramId = $scope.widgetParam[parseInt(index)].param_id;
52 widgetParamObject.widgetId = widgetId;
53 widgetsCatalogService.saveWidgetParameter(widgetParamObject)
55 if(res.status == 'OK'){
56 $scope.widgetParam[index].user_value = $scope.widgetParam[index].default_value;
61 $scope.modify = function(index) {
63 var widgetParamObject = {};
64 widgetParamObject.user_value = $scope.widgetParam[parseInt(index)].user_value;
65 widgetParamObject.paramId = $scope.widgetParam[parseInt(index)].param_id;
66 widgetParamObject.widgetId = widgetId;
68 widgetsCatalogService.saveWidgetParameter(widgetParamObject)
70 if(res.status == 'OK'){
71 $scope.modflag = false;
72 $scope.widgetParam[index].showEdit = false;
79 WidgetParameterController.$inject = ['$scope', 'widgetsCatalogService', 'userProfileService'];
80 angular.module('ecompApp').controller('WidgetParameterController', WidgetParameterController);