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============================================
40 function _classCallCheck(instance, Constructor) {
41 if (!(instance instanceof Constructor)) {
42 throw new TypeError('Cannot call a class as a function');
47 var HTTP_PROTOCOL_RGX = /https?:\/\//;
49 var CatalogCtrl = function CatalogCtrl(conf, catalogService, confirmBoxService, ExternalRequestAccessService,
50 $log, $window, userProfileService, applicationsService, $scope, $state,
51 $timeout, $interval, $modal, ngDialog) {
55 var externalRequest = true;
56 _classCallCheck(this, CatalogCtrl);
59 this.isLoading = true;
60 $scope.getAppCatalogIsDone = false;
61 $scope.radioValue = 'All';
62 $scope.$watch('radioValue', function(newValue, oldValue) {
63 var appCatalog = $scope.appCatalog;
64 $scope.appCatalog = [];
65 $scope.appCatalog = appCatalog;
70 this.catalogService = catalogService;
71 this.userProfileService = userProfileService;
72 this.applicationsService = applicationsService;
73 var resultAccessValue = null;
81 this.getAccess = function(item) {
83 confirmBoxService.showDynamicInformation(item,
84 'app/views/catalog/information-box.tpl.html','CatalogConfirmationBoxCtrl'
85 ).then(isConfirmed => {});
88 var getExternalAccess = () => {
89 ExternalRequestAccessService.getExternalRequestAccessServiceInfo().then(
91 resultAccessValue = property.accessValue;
94 $log.error('CatalogCtrl: failed getExternalRequestAccessServiceInfo: ' + JSON.stringify(err));
100 $scope.applyPresentationDetailsToAppsCatalog = function(res, value) {
105 // defend against error string result -
106 // a huge list that should never happen.
108 if (_this.apps.length < maxItems)
109 maxItems = _this.apps.length;
110 for (var i = 0; i < maxItems; i++) {
112 if (_this.apps[i].imageUrl)
113 imgLnk = conf.api.appThumbnail.replace(':appId', _this.apps[i].id);
114 //$log.debug('CatalogCtlr::applyPresn: imgLink = ' + imgLnk);
115 $scope.appCatalog[i] = {
118 id : _this.apps[i].id,
119 headerText : _this.apps[i].name,
120 mlAppName: _this.apps[i].mlAppName,
122 restricted : _this.apps[i].restricted,
123 select : _this.apps[i].select,
124 access : _this.apps[i].access,
125 pending: _this.apps[i].pending,
129 //$log.debug('CatalogCtrl: getAppCatalog count : '
130 // + $scope.appCatalog.length);
131 _this.isLoading = false;
132 $scope.getAppCatalogIsDone = true;
135 let getAppsCatalog = () => {
136 catalogService.getAppCatalog()
138 $scope.applyPresentationDetailsToAppsCatalog(appsList);
140 confirmBoxService.showInformation('There was a problem retrieving the Applications. ' +
141 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
142 $log.error('CatalogCtrl:openAddRoleModal: Error: ', err);
146 this.openAddRoleModal = (item) => {
149 if((!item.restricted) && (item.mlproperty)){
153 orgUserId: $scope.orgUserId,
154 firstName: $scope.firstName,
155 lastName: $scope.lastName,
156 headerText: item.headerText,
157 haloAppName : item.mlAppName,
163 templateUrl: 'app/views/catalog/request-access-catalog-dialogs/request-access-catalog.modal.html',
164 controller: 'ExternalRequestAccessCtrl',
165 controllerAs: 'userInfo',
167 }).closePromise.then(needUpdate => {
168 if(needUpdate.value === true){
176 // Run this function when user clicks on checkbox.
177 this.storeSelection = function(item) {
178 // $log.debug('CatalogCtrl:storeSelection: item.id is ' + item.id + ', select is ' + item.select);
179 var pendingFlag = false;
184 pendingFlag = item.pending;
188 select : item.select,
189 pending : pendingFlag // TODO
192 catalogService.updateManualAppSort(appData).then(
194 // $log.debug('CatalogCtrl:storeSelection result is ', result);
195 })['catch'](function(err) {
196 $log.error('CatalogCtrl:storeSelection: exception: ', err);
198 catalogService.updateAppCatalog(appData).then(
200 // $log.debug('CatalogCtrl:storeSelection result is ', result);
201 })['catch'](function(err) {
202 $log.error('CatalogCtrl:storeSelection: exception: ', err);
210 $scope.orgUserId = profile.orgUserId;
211 $scope.firstName = profile.firstName;
212 $scope.lastName = profile.lastName;
213 $scope.appCatalog = [];
215 catalogService.getAppCatalog().then(
217 $scope.applyPresentationDetailsToAppsCatalog(res, resultAccessValue);
218 })['catch'](function(err) {
219 $log.error('CatalogCtrl: failed getAppCatalog: ', JSON.stringify(err));
220 _this.isLoading = false;
221 $scope.getAppCatalogIsDone = true;
225 // applicationsService.getUserApps()
228 this.gridsterOpts = {
232 margins : [ 20, 20 ],
242 if (getParameterByName('noUserError') != null) {
243 if (getParameterByName('noUserError') == "Show") {
244 $("#errorInfo").show();
252 CatalogCtrl.$inject = [ 'conf', 'catalogService', 'confirmBoxService', 'ExternalRequestAccessService', '$log',
253 '$window', 'userProfileService', 'applicationsService', '$scope',
254 '$state', '$timeout', '$interval', '$modal', 'ngDialog' ];
255 angular.module('ecompApp').controller('CatalogCtrl', CatalogCtrl);
258 function getParameterByName(name, url) {
260 url = window.location.href;
261 name = name.replace(/[\[\]]/g, "\\$&");
262 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex
268 return results[2].replace(/\+/g, " ");