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 * ================================================================================
22 function _classCallCheck(instance, Constructor) {
23 if (!(instance instanceof Constructor)) {
24 throw new TypeError('Cannot call a class as a function');
29 var HTTP_PROTOCOL_RGX = /https?:\/\//;
31 var CatalogCtrl = function CatalogCtrl(conf, catalogService, confirmBoxService, ExternalRequestAccessService,
32 $log, $window, userProfileService, applicationsService, $scope, $state,
33 $timeout, $interval, $modal, ngDialog) {
37 var externalRequest = true;
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;
54 this.applicationsService = applicationsService;
55 var resultAccessValue = null;
63 var getExternalAccess = () => {
64 ExternalRequestAccessService.getExternalRequestAccessServiceInfo().then(
66 resultAccessValue = property.accessValue;
69 $log.error('CatalogCtrl: failed getExternalRequestAccessServiceInfo: ' + JSON.stringify(err));
75 $scope.applyPresentationDetailsToAppsCatalog = function(res, value) {
80 // defend against error string result -
81 // a huge list that should never happen.
83 if (_this.apps.length < maxItems)
84 maxItems = _this.apps.length;
85 for (var i = 0; i < maxItems; i++) {
87 if (_this.apps[i].imageUrl)
88 imgLnk = conf.api.appThumbnail.replace(':appId', _this.apps[i].id);
89 //$log.debug('CatalogCtlr::applyPresn: imgLink = ' + imgLnk);
90 $scope.appCatalog[i] = {
93 id : _this.apps[i].id,
94 headerText : _this.apps[i].name,
95 mlAppName: _this.apps[i].mlAppName,
97 restricted : _this.apps[i].restricted,
98 select : _this.apps[i].select,
99 access : _this.apps[i].access,
100 pending: _this.apps[i].pending,
104 //$log.debug('CatalogCtrl: getAppCatalog count : '
105 // + $scope.appCatalog.length);
106 _this.isLoading = false;
107 $scope.getAppCatalogIsDone = true;
110 let getAppsCatalog = () => {
111 catalogService.getAppCatalog()
113 $scope.applyPresentationDetailsToAppsCatalog(appsList);
115 confirmBoxService.showInformation('There was a problem retrieving the Applications. ' +
116 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
117 $log.error('CatalogCtrl:openAddRoleModal: Error: ', err);
121 this.openAddRoleModal = (item) => {
124 if((!item.restricted) && (item.mlproperty)){
128 attuid: $scope.attuid,
129 firstName: $scope.firstName,
130 lastName: $scope.lastName,
131 headerText: item.headerText,
132 haloAppName : item.mlAppName,
134 extReqValue : externalRequest
139 templateUrl: 'app/views/catalog/add-catalog-dialogs/new-catalog.modal.html',
140 controller: 'NewCatalogModalCtrl',
141 controllerAs: 'userInfo',
143 }).closePromise.then(needUpdate => {
144 if(needUpdate.value === true){
152 // Run this function when user clicks on checkbox.
153 this.storeSelection = function(item) {
154 // $log.debug('CatalogCtrl:storeSelection: item.id is ' + item.id + ', select is ' + item.select);
155 var pendingFlag = false;
160 pendingFlag = item.pending;
164 select : item.select,
165 pending : pendingFlag // TODO
168 catalogService.updateManualAppSort(appData).then(
170 // $log.debug('CatalogCtrl:storeSelection result is ', result);
171 })['catch'](function(err) {
172 $log.error('CatalogCtrl:storeSelection: exception: ', err);
174 catalogService.updateAppCatalog(appData).then(
176 // $log.debug('CatalogCtrl:storeSelection result is ', result);
177 })['catch'](function(err) {
178 $log.error('CatalogCtrl:storeSelection: exception: ', err);
186 $scope.attuid = profile.orgUserId;
187 $scope.firstName = profile.firstName;
188 $scope.lastName = profile.lastName;
189 $scope.appCatalog = [];
191 catalogService.getAppCatalog().then(
193 $scope.applyPresentationDetailsToAppsCatalog(res, resultAccessValue);
194 })['catch'](function(err) {
195 $log.error('CatalogCtrl: failed getAppCatalog: ', JSON.stringify(err));
196 _this.isLoading = false;
197 $scope.getAppCatalogIsDone = true;
201 // applicationsService.getUserApps()
204 this.gridsterOpts = {
208 margins : [ 20, 20 ],
218 if (getParameterByName('noUserError') != null) {
219 if (getParameterByName('noUserError') == "Show") {
220 $("#errorInfo").show();
228 CatalogCtrl.$inject = [ 'conf', 'catalogService', 'confirmBoxService', 'ExternalRequestAccessService', '$log',
229 '$window', 'userProfileService', 'applicationsService', '$scope',
230 '$state', '$timeout', '$interval', '$modal', 'ngDialog' ];
231 angular.module('ecompApp').controller('CatalogCtrl', CatalogCtrl);
234 function getParameterByName(name, url) {
236 url = window.location.href;
237 name = name.replace(/[\[\]]/g, "\\$&");
238 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex
244 return results[2].replace(/\+/g, " ");