2 * ================================================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ================================================================================
\r
23 class WidgetParameterController {
\r
24 constructor($scope, widgetsCatalogService, userProfileService) {
\r
25 let widgetId = $scope.ngDialogData.widgetId;
\r
26 $scope.modflag = false;
\r
27 $scope.isLoadingTable = false;
\r
28 $scope.messageInfo = false;
\r
30 widgetsCatalogService.getWidgetCatalogParameters(widgetId).then(res => {
\r
31 if(res.status == 'OK'){
\r
32 $scope.isLoadingTable = true;
\r
33 $scope.widgetParam = res.response;
\r
34 }else if(res.status == 'WARN'){
\r
35 $scope.messageInfo = true;
\r
38 $log.error('WidgetParameterController::init error: ' + err);
\r
41 $scope.setEdit = function(index) {
\r
42 if($scope.modflag === false){
\r
43 $scope.widgetParam[index].showEdit = true;
\r
44 $scope.modflag = true;
\r
48 $scope.resetDefault = function(index) {
\r
49 var widgetParamObject = {};
\r
50 widgetParamObject.user_value = $scope.widgetParam[parseInt(index)].default_value;
\r
51 widgetParamObject.paramId = $scope.widgetParam[parseInt(index)].param_id;
\r
52 widgetParamObject.widgetId = widgetId;
\r
53 widgetsCatalogService.saveWidgetParameter(widgetParamObject)
\r
54 .then(function(res){
\r
55 if(res.status == 'OK'){
\r
56 $scope.widgetParam[index].user_value = $scope.widgetParam[index].default_value;
\r
61 $scope.modify = function(index) {
\r
63 var widgetParamObject = {};
\r
64 widgetParamObject.user_value = $scope.widgetParam[parseInt(index)].user_value;
\r
65 widgetParamObject.paramId = $scope.widgetParam[parseInt(index)].param_id;
\r
66 widgetParamObject.widgetId = widgetId;
\r
68 widgetsCatalogService.saveWidgetParameter(widgetParamObject)
\r
69 .then(function(res){
\r
70 if(res.status == 'OK'){
\r
71 $scope.modflag = false;
\r
72 $scope.widgetParam[index].showEdit = false;
\r
79 WidgetParameterController.$inject = ['$scope', 'widgetsCatalogService', 'userProfileService'];
\r
80 angular.module('ecompApp').controller('WidgetParameterController', WidgetParameterController);
\r