2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
42 constructor($scope,$state,message,$modalInstance,widgetsCatalogService,$log,schedulerService,$filter,confirmBoxService,userProfileService,conf,$interval,$compile,$rootScope) {
43 $scope.parentData = message;
44 /****define fields****/
45 $scope.widgetName= '';
46 $scope.widgetData = [];
49 /**** Functions for widgets *****/
50 $scope.getWidgetData =function(widgetId){
51 $rootScope.showSpinner = true;
52 var script = document.createElement('script');
53 script.src = conf.api.widgetCommon + "/" + widgetId + "/framework.js";
55 var entry = document.getElementsByTagName('script')[0];
56 entry.parentNode.insertBefore(script, entry);
58 $scope.getUserWidgets = function(loginName){
59 this.isCommError = false;
60 widgetsCatalogService.getUserWidgets(loginName).then(res => {
61 if(!(res instanceof Array)){
62 $rootScope.showSpinner = false;
63 this.isCommError = true;
66 for(var i = 0; i < res.length; i++){
67 var widget_id = res[i][0];
68 var widget_name = res[i][1];
69 if(widget_name== $scope.widgetName){
71 attr:'data-'+widget_id,
74 $scope.widgetData.push(data);
75 $scope.getWidgetData(widget_id);
79 $rootScope.showSpinner = false;
80 $log.error('WidgetCatalogCtrl::getUserWidgets caught error', err);
85 $rootScope.closeModal = function(){
86 $modalInstance.dismiss('cancel');
88 $scope.getUserIdAndWidget = function(){
89 $rootScope.showSpinner = true;
90 userProfileService.getUserProfile()
92 $scope.orgUserId = profile.orgUserId;
93 $scope.getUserWidgets($scope.orgUserId);
97 $scope.activateThis = function(ele){
98 $compile(ele.contents())($scope);
102 /*Calling Scheduler UI controller in microservice*/
103 $scope.submit = function(){
104 $scope.$broadcast('submit','');
107 $scope.reject = function(){
108 $scope.$broadcast('reject','');
111 $scope.schedule = function(){
112 $scope.$broadcast('schedule','');
117 var init = function () {
118 $rootScope.showSpinner = false;
119 $scope.widgetName = message.id;
120 $scope.getUserIdAndWidget(); //get logged in user id, then widget data
126 SchedulerCtrl.$inject = ['$scope','$state','message','$modalInstance','widgetsCatalogService','$log', 'schedulerService','$filter','confirmBoxService','userProfileService','conf','$interval','$compile','$rootScope'];
127 angular.module('ecompApp').controller('SchedulerCtrl', SchedulerCtrl);