2 * ================================================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ================================================================================
\r
22 function _classCallCheck(instance, Constructor) {
\r
23 if (!(instance instanceof Constructor)) {
\r
24 throw new TypeError('Cannot call a class as a function');
\r
29 var HTTP_PROTOCOL_RGX = /https?:\/\//;
\r
31 var CatalogCtrl = function CatalogCtrl(conf, catalogService, confirmBoxService, ExternalRequestAccessService,
\r
32 $log, $window, userProfileService, applicationsService, $scope, $state,
\r
33 $timeout, $interval, $modal, ngDialog) {
\r
37 _classCallCheck(this, CatalogCtrl);
\r
40 this.isLoading = true;
\r
41 $scope.getAppCatalogIsDone = false;
\r
42 $scope.radioValue = 'All';
\r
43 $scope.$watch('radioValue', function(newValue, oldValue) {
\r
44 var appCatalog = $scope.appCatalog;
\r
45 $scope.appCatalog = [];
\r
46 $scope.appCatalog = appCatalog;
\r
51 this.catalogService = catalogService;
\r
52 this.userProfileService = userProfileService;
\r
53 this.applicationsService = applicationsService;
\r
54 var resultAccessValue = null;
\r
56 $scope.appRoles = [];
\r
59 getExternalAccess();
\r
62 var getExternalAccess = () => {
\r
63 ExternalRequestAccessService.getExternalRequestAccessServiceInfo().then(
\r
64 function(property) {
\r
65 resultAccessValue = property.accessValue;
\r
68 $log.error('CatalogCtrl: failed getExternalRequestAccessServiceInfo: ' + JSON.stringify(err));
\r
74 $scope.applyPresentationDetailsToAppsCatalog = function(res, value) {
\r
79 // defend against error string result -
\r
80 // a huge list that should never happen.
\r
82 if (_this.apps.length < maxItems)
\r
83 maxItems = _this.apps.length;
\r
84 for (var i = 0; i < maxItems; i++) {
\r
86 if (_this.apps[i].imageUrl)
\r
87 imgLnk = conf.api.appThumbnail.replace(':appId', _this.apps[i].id);
\r
88 //$log.debug('CatalogCtlr::applyPresn: imgLink = ' + imgLnk);
\r
89 $scope.appCatalog[i] = {
\r
92 id : _this.apps[i].id,
\r
93 headerText : _this.apps[i].name,
\r
95 restricted : _this.apps[i].restricted,
\r
96 select : _this.apps[i].select,
\r
97 access : _this.apps[i].access,
\r
98 pending: _this.apps[i].pending,
\r
102 //$log.debug('CatalogCtrl: getAppCatalog count : '
\r
103 // + $scope.appCatalog.length);
\r
104 _this.isLoading = false;
\r
105 $scope.getAppCatalogIsDone = true;
\r
108 let getAppsCatalog = () => {
\r
109 catalogService.getAppCatalog()
\r
110 .then(appsList => {
\r
111 $scope.applyPresentationDetailsToAppsCatalog(appsList);
\r
113 confirmBoxService.showInformation('There was a problem retrieving the Applications. ' +
\r
114 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
\r
115 $log.error('CatalogCtrl:openAddRoleModal: Error: ', err);
\r
119 this.openAddRoleModal = (item) => {
\r
122 if((!item.restricted) && (item.mlproperty)){
\r
126 attuid: $scope.attuid,
\r
127 firstName: $scope.firstName,
\r
128 lastName: $scope.lastName,
\r
129 headerText: item.headerText,
\r
135 templateUrl: 'app/views/catalog/add-catalog-dialogs/new-catalog.modal.html',
\r
136 controller: 'NewCatalogModalCtrl',
\r
137 controllerAs: 'userInfo',
\r
139 }).closePromise.then(needUpdate => {
\r
140 if(needUpdate.value === true){
\r
148 // Run this function when user clicks on checkbox.
\r
149 this.storeSelection = function(item) {
\r
150 // $log.debug('CatalogCtrl:storeSelection: item.id is ' + item.id + ', select is ' + item.select);
\r
151 var pendingFlag = false;
\r
154 pendingFlag = false;
\r
156 pendingFlag = item.pending;
\r
160 select : item.select,
\r
161 pending : pendingFlag // TODO
\r
164 catalogService.updateManualAppSort(appData).then(
\r
166 // $log.debug('CatalogCtrl:storeSelection result is ', result);
\r
167 })['catch'](function(err) {
\r
168 $log.error('CatalogCtrl:storeSelection: exception: ', err);
\r
170 catalogService.updateAppCatalog(appData).then(
\r
172 // $log.debug('CatalogCtrl:storeSelection result is ', result);
\r
173 })['catch'](function(err) {
\r
174 $log.error('CatalogCtrl:storeSelection: exception: ', err);
\r
181 function(profile) {
\r
182 $scope.attuid = profile.orgUserId;
\r
183 $scope.firstName = profile.firstName;
\r
184 $scope.lastName = profile.lastName;
\r
185 $scope.appCatalog = [];
\r
187 catalogService.getAppCatalog().then(
\r
189 $scope.applyPresentationDetailsToAppsCatalog(res, resultAccessValue);
\r
190 })['catch'](function(err) {
\r
191 $log.error('CatalogCtrl: failed getAppCatalog: ', JSON.stringify(err));
\r
192 _this.isLoading = false;
\r
193 $scope.getAppCatalogIsDone = true;
\r
197 // applicationsService.getUserApps()
\r
200 this.gridsterOpts = {
\r
204 margins : [ 20, 20 ],
\r
205 outerMargin : true,
\r
211 if (getParameterByName('noUserError') != null) {
\r
212 if (getParameterByName('noUserError') == "Show") {
\r
213 $("#errorInfo").show();
\r
221 CatalogCtrl.$inject = [ 'conf', 'catalogService', 'confirmBoxService', 'ExternalRequestAccessService', '$log',
\r
222 '$window', 'userProfileService', 'applicationsService', '$scope',
\r
223 '$state', '$timeout', '$interval', '$modal', 'ngDialog' ];
\r
224 angular.module('ecompApp').controller('CatalogCtrl', CatalogCtrl);
\r
227 function getParameterByName(name, url) {
\r
229 url = window.location.href;
\r
230 name = name.replace(/[\[\]]/g, "\\$&");
\r
231 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex
\r
237 return results[2].replace(/\+/g, " ");
\r