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 function _classCallCheck(instance, Constructor) {
24 if (!(instance instanceof Constructor)) {
25 throw new TypeError('Cannot call a class as a function');
30 var HTTP_PROTOCOL_RGX = /https?:\/\//;
32 var CatalogCtrl = function CatalogCtrl(catalogService, confirmBoxService,
33 $log, $window, userProfileService, $scope, $timeout, $interval,
38 _classCallCheck(this, CatalogCtrl);
41 this.isLoading = true;
42 $scope.getAppCatalogIsDone = false;
43 $scope.radioValue = 'All';
44 $scope.$watch('radioValue', function(newValue, oldValue) {
45 var appCatalog = $scope.appCatalog;
46 $scope.appCatalog = [];
47 $scope.appCatalog = appCatalog;
52 this.catalogService = catalogService;
53 this.userProfileService = userProfileService;
56 this.getAccess = function(item) {
58 confirmBoxService.showDynamicInformation(item,
59 'app/views/catalog/information-box.tpl.html','CatalogConfirmationBoxCtrl'
60 ).then(isConfirmed => {});
63 // Run this function when user clicks on checkbox.
64 this.storeSelection = function(item) {
65 // $log.debug('CatalogCtrl:storeSelection: item.id is ' + item.id + ', select is ' + item.select);
66 var pendingFlag = false;
71 pendingFlag = item.pending;
79 pending : pendingFlag // TODO
81 catalogService.updateAppCatalog(appData).then(
83 // $log.debug('CatalogCtrl:storeSelection result is ', result);
84 })['catch'](function(err) {
85 $log.error('CatalogCtrl:storeSelection: exception: ', err);
93 $scope.attuid = profile.attuid;
94 $scope.appCatalog = [];
96 // applicationsService.getUserApps()
104 for (var i = 0; i < _this.apps.length; i++) {
105 $scope.appCatalog[i] = {
108 id : _this.apps[i].id,
109 headerText : _this.apps[i].name,
110 imageLink : _this.apps[i].thumbnail
111 || _this.apps[i].imageUrl,
112 url : _this.apps[i].url,
113 restricted : _this.apps[i].restricted,
114 select : (_this.apps[i].select || (_this.apps[i].access && _this.apps[i].pending)),
115 access : _this.apps[i].access,
116 pending: _this.apps[i].pending
119 //$log.debug('CatalogCtrl: getAppCatalog count : '
120 // + $scope.appCatalog.length);
121 _this.isLoading = false;
122 $scope.getAppCatalogIsDone = true;
123 })['catch'](function(err) {
124 $log.error('CatalogCtrl: failed to get app list: ', err);
125 _this.isLoading = false;
126 $scope.getAppCatalogIsDone = true;
130 this.gridsterOpts = {
134 margins : [ 20, 20 ],
141 if (getParameterByName('noUserError') != null) {
142 if (getParameterByName('noUserError') == "Show") {
143 $("#errorInfo").show();
149 CatalogCtrl.$inject = [ 'catalogService', 'confirmBoxService', '$log',
150 '$window', 'userProfileService', '$scope', '$timeout', '$interval',
151 '$modal', 'ngDialog' ];
152 angular.module('ecompApp').controller('CatalogCtrl', CatalogCtrl);
155 function getParameterByName(name, url) {
157 url = window.location.href;
158 name = name.replace(/[\[\]]/g, "\\$&");
159 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex
165 return results[2].replace(/\+/g, " ");