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, $state,items) {
25 $scope.ngDialogData=items;
26 let widgetId = $scope.ngDialogData.widgetId;
27 $scope.modflag = false;
28 $scope.isLoadingTable = false;
29 $scope.messageInfo = false;
31 widgetsCatalogService.getWidgetCatalogParameters(widgetId).then(res => {
32 if(res.status == 'OK'){
33 $scope.isLoadingTable = true;
34 $scope.widgetParam = res.response;
35 }else if(res.status == 'WARN'){
36 $scope.messageInfo = true;
39 $log.error('WidgetParameterController::init error: ' + err);
42 $scope.setEdit = function(index) {
43 if($scope.modflag === false){
44 $scope.widgetParam[index].showEdit = true;
45 $scope.modflag = true;
49 $scope.resetDefault = function(index) {
50 var widgetParamObject = {};
51 widgetParamObject.user_value = $scope.widgetParam[parseInt(index)].default_value;
52 widgetParamObject.paramId = $scope.widgetParam[parseInt(index)].param_id;
53 widgetParamObject.widgetId = widgetId;
54 widgetsCatalogService.saveWidgetParameter(widgetParamObject)
56 if(res.status == 'OK'){
57 $scope.widgetParam[index].user_value = $scope.widgetParam[index].default_value;
62 $scope.modify = function(index) {
64 var widgetParamObject = {};
65 widgetParamObject.user_value = $scope.widgetParam[parseInt(index)].user_value;
66 widgetParamObject.paramId = $scope.widgetParam[parseInt(index)].param_id;
67 widgetParamObject.widgetId = widgetId;
69 widgetsCatalogService.saveWidgetParameter(widgetParamObject)
71 if(res.status == 'OK'){
72 $scope.modflag = false;
73 $scope.widgetParam[index].showEdit = false;
81 WidgetParameterController.$inject = ['$scope', 'widgetsCatalogService', 'userProfileService', '$state','items'];
82 angular.module('ecompApp').controller('WidgetParameterController', WidgetParameterController);