diff --git a/angularjs-portal-home/src/main/webapp/js/login-config.js b/angularjs-portal-home/src/main/webapp/js/login-config.js
index 67424fe52..da7fe38cb 100644
--- a/angularjs-portal-home/src/main/webapp/js/login-config.js
+++ b/angularjs-portal-home/src/main/webapp/js/login-config.js
@@ -2,6 +2,7 @@
define([], function() {
return {
'loginURL': null, // null for localhost so we don't break things
- // "loginURL" : "/portal/Login?silent=true&profile=bucky" //overlay will have something like this
+ // overlay will have something like this:
+ // 'loginURL': "/portal/Login?silent=true&profile=bucky"
};
});
diff --git a/angularjs-portal-home/src/main/webapp/js/master-override.js b/angularjs-portal-home/src/main/webapp/js/master-override.js
index a8c51970e..c63ea688b 100644
--- a/angularjs-portal-home/src/main/webapp/js/master-override.js
+++ b/angularjs-portal-home/src/main/webapp/js/master-override.js
@@ -57,22 +57,26 @@ define(['angular'], function(angular) {
{
'id': 'webPortletRender',
'title': '/web portlet rendering',
- 'description': 'Renders portlets via /web\'s exclusive page, but not as launched from expanded widgets.',
+ 'description': 'Renders portlets via /web\'s exclusive page, ' +
+ 'but not as launched from expanded widgets.',
},
{
'id': 'showKeywordsInMarketplace',
'title': 'Show Keywords in app directory',
- 'description': 'Enable/Disable keywords showing up in app directory entry details',
+ 'description': 'Enable/Disable keywords showing up in app ' +
+ 'directory entry details',
},
{
'id': 'exampleWidgets',
'title': 'Example Widgets',
- 'description': 'Show the My Courses, Email, and Calendar example widgets',
+ 'description': 'Show the My Courses, Email, and Calendar ' +
+ 'example widgets',
},
{
'id': 'showFilterOption',
'title': 'Show Filter Option on Home',
- 'description': 'Enables a filter on home to filter ones content down to what want',
+ 'description': 'Enables a filter on home to filter ones ' +
+ 'content down to what want',
},
],
});
diff --git a/angularjs-portal-home/src/main/webapp/js/override.js b/angularjs-portal-home/src/main/webapp/js/override.js
index fc7658b57..c4f5d35d6 100644
--- a/angularjs-portal-home/src/main/webapp/js/override.js
+++ b/angularjs-portal-home/src/main/webapp/js/override.js
@@ -57,27 +57,35 @@ define(['angular'], function(angular) {
{
'id': 'webPortletRender',
'title': '/web portlet rendering',
- 'description': 'Renders portlets via /web\'s exclusive page, but not as launched from expanded widgets.',
+ 'description': 'Renders portlets via /web\'s exclusive page, ' +
+ 'but not as launched from expanded widgets.',
},
{
'id': 'showKeywordsInMarketplace',
'title': 'Show Keywords in app directory',
- 'description': 'Enable/Disable keywords showing up in app directory details',
+ 'description': 'Enable/Disable keywords showing up in app ' +
+ 'directory details',
},
{
'id': 'linkRatingsApi',
'title': 'Link ratings API',
- 'description': 'Links the ratings JSON API from the ratings count in the details page for each app. Actual access to this JSON API depends upon MANAGE permissions; this setting just includes the hyperlink in the UI for convenience.',
+ 'description': 'Links the ratings JSON API from the ratings ' +
+ 'count in the details page for each app. Actual access to ' +
+ 'this JSON API depends upon MANAGE permissions; this ' +
+ 'setting just includes the hyperlink in the UI for ' +
+ 'convenience.',
},
{
'id': 'exampleWidgets',
'title': 'Example Widgets',
- 'description': 'Show the My Courses, Email, and Calendar example widgets',
+ 'description': 'Show the My Courses, Email, and Calendar ' +
+ 'example widgets',
},
{
'id': 'showFilterOption',
'title': 'Show Filter Option on Home',
- 'description': 'Enables a filter on home to filter ones content down to what want',
+ 'description': 'Enables a filter on home to filter ones ' +
+ 'content down to what want',
},
],
});
diff --git a/angularjs-portal-home/src/main/webapp/js/web-config.js b/angularjs-portal-home/src/main/webapp/js/web-config.js
index 8ea37d0f3..f4626650f 100644
--- a/angularjs-portal-home/src/main/webapp/js/web-config.js
+++ b/angularjs-portal-home/src/main/webapp/js/web-config.js
@@ -1,3 +1,4 @@
+/* eslint max-len: "off" */
define(['angular'], function(angular) {
var config = angular.module('web-config', []);
config.value('SEARCH_CONFIG', [
diff --git a/angularjs-portal-home/src/main/webapp/main.js b/angularjs-portal-home/src/main/webapp/main.js
index 98225c046..a5835389c 100644
--- a/angularjs-portal-home/src/main/webapp/main.js
+++ b/angularjs-portal-home/src/main/webapp/main.js
@@ -1,68 +1,83 @@
'use strict';
require(['./config', './js/login-config'], function(config, loginConfig) {
- require.config(config);
+ require.config(config);
- require(['angular', 'jquery', 'my-app'], function(angular, $) {
- // Idea taken from
- // https://blog.mariusschulz.com/2014/10/22/asynchronously-bootstrapping-angularjs-applications-with-server-side-data
- doLogin().then(bootstrapApplication)
- .catch(function() {
- $('#loading-splash').html('An error has occured during loading, please try refreshing the page. If the issue persists please contact the helpdesk.');
- console.error('Issue logging in.');
- });
+ require(['angular', 'jquery', 'my-app'], function(angular, $) {
+ // Idea taken from
+ // https://blog.mariusschulz.com/2014/10/22/asynchronously-bootstrapping-angularjs-applications-with-server-side-data
+ doLogin().then(bootstrapApplication)
+ .catch(function() {
+ angular.element('#loading-splash').html(
+ 'An error has occured during loading, ' +
+ 'please try refreshing the page. If the issue persists please ' +
+ 'contact the helpdesk.');
+ });
- // Bootstrap the application like normal now
- function bootstrapApplication() {
- angular.bootstrap(document, ['my-app']);
- }
+ /**
+ * Bootstrap the application like normal now
+ */
+ function bootstrapApplication() {
+ angular.bootstrap(document, ['my-app']);
+ }
- // Checks if the last login is still valid (4 hour timeout)
- function lastLoginValid($sessionStorage) {
- var timeLapseBetweenLogins = 14400000;
- if($sessionStorage.portal && $sessionStorage.portal.lastAccessed) {
- var now = (new Date()).getTime();
- if(now - $sessionStorage.portal.lastAccessed <= timeLapseBetweenLogins) {// 4 hours
- return true;
- }
+ /**
+ * Checks if the last login is still valid (4 hour timeout)
+ * @param {Object} $sessionStorage
+ * @return {boolean} is the last login valid
+ */
+ function lastLoginValid($sessionStorage) {
+ var timeLapseBetweenLogins = 14400000; // 4 hours
+ if ($sessionStorage.portal && $sessionStorage.portal.lastAccessed) {
+ var now = (new Date()).getTime();
+ if (now - $sessionStorage.portal.lastAccessed <=
+ timeLapseBetweenLogins) {
+ return true;
}
- return false;
}
+ return false;
+ }
- // Do the login
- function doLogin() {
- // init stuff
- var initInjector = angular.injector(['ng', 'ngStorage']);
- var $sessionStorage = initInjector.get('$sessionStorage');
- var $rootScope = initInjector.get('$rootScope');
+ /**
+ * Do the login
+ * @return {Promise} the Promised login
+ */
+ function doLogin() {
+ // init stuff
+ var initInjector = angular.injector(['ng', 'ngStorage']);
+ var $sessionStorage = initInjector.get('$sessionStorage');
+ var $rootScope = initInjector.get('$rootScope');
- // login stuff
- if(loginConfig.loginURL && !lastLoginValid($sessionStorage)) {
- // assume not valid, go get a username and bootstrap the user
- var $http = initInjector.get('$http');
- return $http.get(loginConfig.loginURL).then(function(response) {
- if('success' === response.data.status
- || response.data.username === 'guest') {
- // store some meta data for caching reason
- if(!$sessionStorage.portal) {
- $sessionStorage.portal = {};
- }
- $sessionStorage.portal.lastAccessed = (new Date).getTime();
- $sessionStorage.portal.username = response.data.username;
- if (response.data.username === 'guest') {
- $rootScope.GuestMode = true;
- }
- // for some really weird reason the $sessionStorage here isn't being
- // persisted to real session storage, so we have to do it manually.
- $sessionStorage.$apply();
+ // login stuff
+ if(loginConfig.loginURL && !lastLoginValid($sessionStorage)) {
+ // assume not valid, go get a username and bootstrap the user
+ var $http = initInjector.get('$http');
+ return $http
+ .get(loginConfig.loginURL)
+ .then(function(response) {
+ if ('success' === response.data.status
+ || response.data.username === 'guest') {
+ // store some meta data for caching reason
+ if(!$sessionStorage.portal) {
+ $sessionStorage.portal = {};
}
- });
- } else {
- // the cache is still valid with a valid session, carry on
- var $q = initInjector.get('$q');
- return $q.resolve(loginConfig.loginURL
- ? 'Login cache still valid from previous login'
- : 'Silent login not configured.');
- }
+ $sessionStorage.portal.lastAccessed = (new Date).getTime();
+ $sessionStorage.portal.username = response.data.username;
+ if (response.data.username === 'guest') {
+ $rootScope.GuestMode = true;
+ }
+ // for some really weird reason the $sessionStorage here isn't being
+ // persisted to real session storage, so we have to do it manually.
+ $sessionStorage.$apply();
+ }
+ return response; // Returning response for promise chaining
+ });
+ } else {
+ // the cache is still valid with a valid session, carry on
+ var $q = initInjector.get('$q');
+ return $q.resolve(loginConfig.loginURL
+ ? 'Login cache still valid from previous login'
+ : 'Silent login not configured.');
}
- });
+ }
+ });
});
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/controllers.js b/angularjs-portal-home/src/main/webapp/my-app/layout/controllers.js
index ea71e7c51..55190cc4d 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/controllers.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/controllers.js
@@ -6,30 +6,39 @@ define(['angular', 'jquery'], function(angular, $) {
/**
* Controller for default view (my-app/layout/partials/default-view.html)
*/
- app.controller('DefaultViewController', ['$scope', '$location', '$mdMedia', '$localStorage', '$sessionStorage', 'APP_FLAGS',
- function($scope, $location, $mdMedia, $localStorage, $sessionStorage, APP_FLAGS) {
+ app.controller('DefaultViewController',
+ ['$scope', '$location', '$mdMedia', '$localStorage', 'APP_FLAGS',
+ function($scope, $location, $mdMedia, $localStorage, APP_FLAGS) {
$scope.loading = [];
if (!APP_FLAGS[$localStorage.layoutMode]) {
// Layout mode set weird, reset to default
- $localStorage.layoutMode = ($mdMedia('xs') && APP_FLAGS.compact) ? 'compact' : APP_FLAGS.defaultView;
+ $localStorage.layoutMode = ($mdMedia('xs') && APP_FLAGS.compact) ?
+ 'compact' : APP_FLAGS.defaultView;
}
$location.path('/' + $localStorage.layoutMode);
}]);
/**
- * Controller for the compact mode widget layout (layout/list/partials/home-list-view.html and layout/partials/default-card.html)
+ * Controller for the compact mode widget layout
+ * (layout/list/partials/home-list-view.html and
+ * layout/partials/default-card.html)
*/
- app.controller('LayoutController', ['$location', '$localStorage', '$sessionStorage', '$scope', '$rootScope', 'layoutService', 'miscService',
- function($location, $localStorage, $sessionStorage, $scope, $rootScope, layoutService, miscService) {
+ app.controller('LayoutController',
+ ['$localStorage', '$log', '$sessionStorage',
+ '$scope', '$rootScope', 'layoutService',
+ function($localStorage, $log, $sessionStorage,
+ $scope, $rootScope, layoutService) {
/**
- * Set the href based on whether it's a static, exclusive, or basic widget (based on attributes from entity file)
+ * Set the href based on whether it's a static, exclusive,
+ * or basic widget (based on attributes from entity file)
* @param portlet
- * @returns {*}
+ * @returns {String}
*/
this.renderURL = function(portlet) {
if (portlet.staticContent != null && portlet.altMaxUrl == false) {
return 'static/' + portlet.fname;
- } else if (portlet.altMaxUrl == false && (portlet.renderOnWeb || $localStorage.webPortletRender)) {
+ } else if (portlet.altMaxUrl == false &&
+ (portlet.renderOnWeb || $localStorage.webPortletRender)) {
return 'exclusive/' + portlet.fname;
} else {
return portlet.url;
@@ -51,7 +60,8 @@ define(['angular', 'jquery'], function(angular, $) {
// remove
$scope.layout.splice(index, 1);
if ($sessionStorage.marketplace != null) {
- var marketplaceEntries = $.grep($sessionStorage.marketplace, function(e) {
+ var marketplaceEntries = $.grep($sessionStorage.marketplace,
+ function(e) {
return e.fname === result[0].fname;
});
if (marketplaceEntries.length > 0) {
@@ -61,13 +71,16 @@ define(['angular', 'jquery'], function(angular, $) {
});
}).error(
function(request, text, error) {
- alert('Issue deleting ' + title + ' from your list of favorites, try again later.');
+ alert('Issue deleting ' + title +
+ ' from your list of favorites, try again later.');
});
};
/**
* Configure ui-sortable options
- * @type {{delay: number, cursorAt: {top: number, left: number}, stop: $scope.sortableOptions.stop}}
+ * @type {{delay: number,
+ * cursorAt: {top: number, left: number},
+ * stop: $scope.sortableOptions.stop}}
*/
$scope.sortableOptions = {
delay: 250,
@@ -75,11 +88,17 @@ define(['angular', 'jquery'], function(angular, $) {
stop: function(e, ui) {
if (ui.item.sortable.dropindex != ui.item.sortable.index) {
var node = $scope.layout[ui.item.sortable.dropindex];
- console.log('Change happened, logging move of ' + node.fname + ' from ' + ui.item.sortable.index + ' to ' + ui.item.sortable.dropindex);
+ $log.info('Change happened, logging move of ' + node.fname +
+ ' from ' + ui.item.sortable.index +
+ ' to ' + ui.item.sortable.dropindex);
// index, length, movingNodeId, previousNodeId, nextNodeId
- var prevNodeId = ui.item.sortable.dropindex != 0 ? $scope.layout[ui.item.sortable.dropindex - 1].nodeId : '';
- var nextNodeId = ui.item.sortable.dropindex != $scope.layout.length - 1 ? $scope.layout[ui.item.sortable.dropindex + 1].nodeId : '';
- layoutService.moveStuff(ui.item.sortable.dropindex, $scope.layout.length, node.nodeId, prevNodeId, nextNodeId);
+ var prevNodeId = ui.item.sortable.dropindex != 0 ?
+ $scope.layout[ui.item.sortable.dropindex - 1].nodeId : '';
+ var nextNodeId = ui.item.sortable.dropindex !=
+ $scope.layout.length - 1 ?
+ $scope.layout[ui.item.sortable.dropindex + 1].nodeId : '';
+ layoutService.moveStuff(ui.item.sortable.dropindex,
+ $scope.layout.length, node.nodeId, prevNodeId, nextNodeId);
}
},
};
@@ -88,7 +107,8 @@ define(['angular', 'jquery'], function(angular, $) {
* Initialize LayoutController
*/
this.init = function() {
- if (typeof $rootScope.layout === 'undefined' || $rootScope.layout == null) {
+ if (typeof $rootScope.layout === 'undefined' ||
+ $rootScope.layout == null) {
$rootScope.layout = [];
$scope.layoutEmpty = false;
@@ -98,6 +118,9 @@ define(['angular', 'jquery'], function(angular, $) {
if (data.layout && data.layout.length == 0) {
$scope.layoutEmpty = true;
}
+ return data;
+ }).catch(function() {
+ $log.warn('Could not getLayout');
});
}
};
@@ -106,18 +129,25 @@ define(['angular', 'jquery'], function(angular, $) {
}]);
/**
- * Basic widget logic leveraged by WidgetController, expanded mode widget layout (/widget/partials/home-widget-view.html and /widget/partials/widget-card.html),
+ * Basic widget logic leveraged by WidgetController,
+ * expanded mode widget layout
+ * (/widget/partials/home-widget-view.html and
+ * /widget/partials/widget-card.html),
* and 'widget' component (/widget/directives.js)
*/
- app.controller('BaseWidgetFunctionsController', ['$scope', '$location', '$sessionStorage', '$localStorage', 'layoutService', 'childController',
- function($scope, $location, $sessionStorage, $localStorage, layoutService, childController) {
+ app.controller('BaseWidgetFunctionsController',
+ ['$scope', '$sessionStorage', '$localStorage',
+ 'layoutService', 'childController',
+ function($scope, $sessionStorage, $localStorage,
+ layoutService, childController) {
/**
* Determine the type of widget to display
* @param portlet
* @returns {*}
*/
childController.portletType = function portletType(portlet) {
- // If portlet has a defined widgetType, check if it's one we have a defined template for
+ // If portlet has a defined widgetType,
+ // check if it's one we have a defined template for
if (portlet.widgetType) {
if ('option-link' === portlet.widgetType) {
return 'OPTION_LINK';
@@ -126,8 +156,12 @@ define(['angular', 'jquery'], function(angular, $) {
} else if ('rss' === portlet.widgetType) {
return 'RSS';
} else if ('list-of-links' === portlet.widgetType) {
- if (portlet.widgetConfig.links.length === 1 && portlet.altMaxUrl && portlet.widgetConfig.links[0].href === portlet.url) {
- // If list of links has only one link and if it is the same as the portlet URL, display the default widget view
+ if (portlet.widgetConfig.links.length === 1 &&
+ portlet.altMaxUrl &&
+ portlet.widgetConfig.links[0].href === portlet.url) {
+ // If list of links has only one link and
+ // if it is the same as the portlet URL,
+ // display the default widget view
return 'BASIC';
} else {
return 'LOL';
@@ -135,7 +169,9 @@ define(['angular', 'jquery'], function(angular, $) {
} else if ('search-with-links' === portlet.widgetType) {
return 'SWL';
} else if ('generic' === portlet.widgetType) {
- // DEPRECATED: Include 'generic' for the sake of backwards compatibility, but return what it really is: CUSTOM
+ // DEPRECATED: Include 'generic' for the
+ // sake of backwards compatibility,
+ // but return what it really is: CUSTOM
return 'CUSTOM';
} else if ('custom' === portlet.widgetType) {
return 'CUSTOM';
@@ -143,7 +179,9 @@ define(['angular', 'jquery'], function(angular, $) {
return 'WIDGET';
}
} else {
- // Return "BASIC" widget type for anything else lacking an explicit widget type definition (default experience)
+ // Return "BASIC" widget type for anything
+ // else lacking an explicit widget
+ // type definition (default experience)
return 'BASIC';
}
};
@@ -157,7 +195,8 @@ define(['angular', 'jquery'], function(angular, $) {
// Check if it's a static or exclusive portlet
if (portlet.staticContent != null && portlet.altMaxUrl == false) {
return 'static/' + portlet.fname;
- } else if (portlet.altMaxUrl == false && (portlet.renderOnWeb || $localStorage.webPortletRender)) {
+ } else if (portlet.altMaxUrl == false && (portlet.renderOnWeb ||
+ $localStorage.webPortletRender)) {
return 'exclusive/' + portlet.fname;
} else {
return portlet.url;
@@ -169,7 +208,8 @@ define(['angular', 'jquery'], function(angular, $) {
* @param nodeId
* @param title
*/
- childController.removePortlet = function removePortletFunction(nodeId, title) {
+ childController.removePortlet =
+ function removePortletFunction(nodeId, title) {
layoutService.removeFromHome(nodeId, title).success(function() {
$scope.$apply(function(request, text) {
var result = $.grep($scope.layout, function(e) {
@@ -179,7 +219,8 @@ define(['angular', 'jquery'], function(angular, $) {
// remove
$scope.layout.splice(index, 1);
if ($sessionStorage.marketplace != null) {
- var marketplaceEntries = $.grep($sessionStorage.marketplace, function(e) {
+ var marketplaceEntries = $.grep($sessionStorage.marketplace,
+ function(e) {
return e.fname === result[0].fname;
});
if (marketplaceEntries.length > 0) {
@@ -188,7 +229,8 @@ define(['angular', 'jquery'], function(angular, $) {
}
});
}).error(function(request, text, error) {
- alert('Issue deleting ' + title + ' from your list of favorites, try again later.');
+ alert('Issue deleting ' + title +
+ ' from your list of favorites, try again later.');
});
};
},
@@ -196,16 +238,22 @@ define(['angular', 'jquery'], function(angular, $) {
/**
* Widget initialization and sorting for expanded mode widget layout
- * (/widget/partials/home-widget-view.html and /widget/partials/widget-card.html)
+ * (/widget/partials/home-widget-view.html and
+ * /widget/partials/widget-card.html)
*/
- app.controller('WidgetController', ['$controller', '$location', '$localStorage', '$sessionStorage', '$scope', '$rootScope', 'layoutService', 'miscService',
- function($controller, $location, $localStorage, $sessionStorage, $scope, $rootScope, layoutService, miscService) {
+ app.controller('WidgetController',
+ ['$controller', '$log', '$scope', '$rootScope', 'layoutService',
+ function($controller, $log, $scope, $rootScope, layoutService) {
// Inherit from BaseWidgetFunctionsController
- var base = $controller('BaseWidgetFunctionsController', {$scope: $scope, childController: this});
+ $controller('BaseWidgetFunctionsController',
+ {$scope: $scope, childController: this});
- // Initialize expanded mode widget layout
+ /**
+ * Initialize expanded mode widget layout
+ */
function init() {
- if (typeof $rootScope.layout === 'undefined' || $rootScope.layout == null) {
+ if (typeof $rootScope.layout === 'undefined' ||
+ $rootScope.layout == null) {
$rootScope.layout = [];
$scope.layoutEmpty = false;
// Get user's home layout
@@ -214,13 +262,20 @@ define(['angular', 'jquery'], function(angular, $) {
if (data.layout && data.layout.length == 0) {
$scope.layoutEmpty = true;
}
+ return data;
+ }).catch(function() {
+ $log.warn('Could not getLayout');
});
}
}
/**
* Configure ui-sortable options
- * @type {{delay: number, cursorAt: {top: number, left: number}, stop: $scope.sortableOptions.stop}}
+ * @type {{
+ * delay: number,
+ * cursorAt: {top: number, left: number},
+ * stop: $scope.sortableOptions.stop
+ * }}
*/
$scope.sortableOptions = {
delay: 250,
@@ -228,13 +283,17 @@ define(['angular', 'jquery'], function(angular, $) {
stop: function(e, ui) {
if (ui.item.sortable.dropindex != ui.item.sortable.index) {
var node = $scope.layout[ui.item.sortable.dropindex];
- if (console) {
- console.log('Change happened, logging move of ' + node.fname + ' from ' + ui.item.sortable.index + ' to ' + ui.item.sortable.dropindex);
- }
+ $log.log('Change happened, logging move of ' + node.fname +
+ ' from ' + ui.item.sortable.index +
+ ' to ' + ui.item.sortable.dropindex);
// index, length, movingNodeId, previousNodeId, nextNodeId
- var prevNodeId = ui.item.sortable.dropindex != 0 ? $scope.layout[ui.item.sortable.dropindex - 1].nodeId : '';
- var nextNodeId = ui.item.sortable.dropindex != $scope.layout.length - 1 ? $scope.layout[ui.item.sortable.dropindex + 1].nodeId : '';
- layoutService.moveStuff(ui.item.sortable.dropindex, $scope.layout.length, node.nodeId, prevNodeId, nextNodeId);
+ var prevNodeId = ui.item.sortable.dropindex != 0 ?
+ $scope.layout[ui.item.sortable.dropindex - 1].nodeId : '';
+ var nextNodeId = ui.item.sortable.dropindex !=
+ $scope.layout.length - 1 ?
+ $scope.layout[ui.item.sortable.dropindex + 1].nodeId : '';
+ layoutService.moveStuff(ui.item.sortable.dropindex,
+ $scope.layout.length, node.nodeId, prevNodeId, nextNodeId);
}
},
};
@@ -242,10 +301,12 @@ define(['angular', 'jquery'], function(angular, $) {
}]);
/**
- * Controller for toggling between expanded and compact mode via the app-header's toggle
+ * Controller for toggling between expanded
+ * and compact mode via the app-header's toggle
*/
- app.controller('ToggleController', ['$localStorage', '$scope', '$location', 'miscService', 'APP_FLAGS',
- function($localStorage, $scope, $location, miscService, APP_FLAGS) {
+ app.controller('ToggleController',
+ ['$localStorage', '$scope', '$location', '$log', 'miscService', 'APP_FLAGS',
+ function($localStorage, $scope, $location, $log, miscService, APP_FLAGS) {
/**
* Switch between compact and expanded mode
* @param mode
@@ -283,7 +344,7 @@ define(['angular', 'jquery'], function(angular, $) {
if (APP_FLAGS[$localStorage.layoutMode]) {
$location.path('/' + $localStorage.layoutMode);
} else {
- console.log('Something is weird, resetting to default layout view');
+ $log.log('Something is weird, resetting to default layout view');
$scope.switchMode(APP_FLAGS.defaultView);
}
}
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/directives.js b/angularjs-portal-home/src/main/webapp/my-app/layout/directives.js
index d9f716410..b2f2940d6 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/directives.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/directives.js
@@ -30,8 +30,8 @@ define(['angular', 'require'], function(angular, require) {
templateUrl: require.toUrl('./partials/home-header.html'),
};
});
-
- app.directive('homeToggle', function(){
+
+ app.directive('homeToggle', function() {
return {
restrict: 'E',
templateUrl: require.toUrl('./partials/home-toggle.html'),
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/services.js b/angularjs-portal-home/src/main/webapp/my-app/layout/services.js
index 8c6e6c44c..e59950e48 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/services.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/services.js
@@ -1,26 +1,39 @@
'use strict';
define(['angular', 'jquery'], function(angular, $) {
- var app = angular.module('my-app.layout.services', []);
- var accessDeniedTemplate='
Sorry, you\'re not authorized to access this.
If you\'re here by accident, head back to your My-UW homepage.
For help with authorization, contact the DoIT Help Desk.
';
-
- app.factory('layoutService', ['$sce', '$http', 'miscService', 'mainService', '$sessionStorage', '$q', 'SERVICE_LOC', function($sce, $http, miscService, mainService, $sessionStorage, $q, SERVICE_LOC) {
+ var app = angular.module('my-app.layout.services', []);
+ var accessDeniedTemplate=
+ 'Sorry, you\'re not authorized to access this.
' +
+ '' +
+ '
' +
+ 'If you\'re here by accident, head back to your My-UW ' +
+ 'homepage.
' +
+ 'For help with authorization, contact the ' +
+ 'DoIT Help Desk.
';
+
+ app.factory('layoutService',
+ ['$sce', '$http', '$log', 'miscService',
+ 'mainService', '$sessionStorage', '$q', 'SERVICE_LOC',
+ function($sce, $http, $log, miscService,
+ mainService, $sessionStorage, $q, SERVICE_LOC) {
var addToHome = function addToHomeFunction(portlet) {
var fname = portlet.fname;
var tabName = SERVICE_LOC.layoutTab;
return $.ajax({
- url: SERVICE_LOC.base + 'layout?action=addPortlet&fname=' + fname + '&tabName=' + tabName,
+ url: SERVICE_LOC.base + 'layout?action=addPortlet&fname=' +
+ fname + '&tabName=' + tabName,
type: 'POST',
data: null,
dataType: 'json',
async: true,
success: function(request, text) {
- console.log('Added ' + portlet.fname + ' successfully');
- miscService.pushGAEvent('Layout Modification', 'Add', portlet.name);
+ $log.log('Added ' + portlet.fname + ' successfully');
+ miscService.pushGAEvent(
+ 'Layout Modification', 'Add', portlet.name);
return true;
},
error: function(request, text, error) {
- console.warn('failed to add app to home.');
+ $log.warn('failed to add app to home.');
return false;
},
});
@@ -28,14 +41,16 @@ define(['angular', 'jquery'], function(angular, $) {
var removeFromHome = function removeFromHomeFunction(nodeId, title) {
return $.ajax({
- url: SERVICE_LOC.base + 'layout?action=removeElement&elementID=' + nodeId,
+ url: SERVICE_LOC.base +
+ 'layout?action=removeElement&elementID=' + nodeId,
type: 'POST',
data: null,
dataType: 'json',
async: true,
success: function(request, text) {
- console.log('removed ' + title + ' successfully.');
- miscService.pushGAEvent('Layout Modification', 'Remove', title);
+ $log.log('removed ' + title + ' successfully.');
+ miscService.pushGAEvent(
+ 'Layout Modification', 'Remove', title);
},
error: function(request, text, error) {
},
@@ -45,8 +60,9 @@ define(['angular', 'jquery'], function(angular, $) {
var checkLayoutCache = function() {
var userPromise = mainService.getUser();
return userPromise.then(function(user) {
- if ($sessionStorage.sessionKey === user.sessionKey && $sessionStorage.layout) {
- return $sessionStorage.layout;
+ if ($sessionStorage.sessionKey === user.sessionKey &&
+ $sessionStorage.layout) {
+ return $sessionStorage.layout;
}
return null;
@@ -58,13 +74,18 @@ define(['angular', 'jquery'], function(angular, $) {
userPromise.then(function(user) {
$sessionStorage.sessionKey = user.sessionKey;
$sessionStorage.layout = data;
+ return user;
+ }).catch(function() {
+ $log.warn('Could not getUser');
});
};
var getLayout = function() {
return checkLayoutCache().then(function(data) {
- var successFn, errorFn, defer;
+ var successFn;
+ var errorFn;
+ var defer;
// first, check the local storage...
if (data) {
@@ -84,103 +105,118 @@ define(['angular', 'jquery'], function(angular, $) {
};
// no caching... request from the server
- return $http.get(SERVICE_LOC.base + SERVICE_LOC.layout).then(successFn, errorFn);
+ return $http.get(SERVICE_LOC.base + SERVICE_LOC.layout)
+ .then(successFn, errorFn);
});
};
var getApp = function(fname) {
- return $http.get(SERVICE_LOC.base + 'portlet/' +fname + '.json').then(
+ return $http.get(SERVICE_LOC.base + 'portlet/' +fname + '.json')
+ .then(
function(result) {
return result;
},
function(reason) {
miscService.redirectUser(reason.status, 'getApp call');
if(reason.status === 403) {
- reason.deniedTemplate = $sce.trustAsHtml(accessDeniedTemplate);
+ reason.deniedTemplate =
+ $sce.trustAsHtml(accessDeniedTemplate);
}
return reason;
}
);
};
- var moveStuff = function moveStuffFunction(index, length, sourceId, previousNodeId, nextNodeId) {
- var insertNode = function(sourceId, previousNodeId, nextNodeId) {
- var saveOrderURL = SERVICE_LOC.base + 'layout?action=movePortletAjax'
- + '&sourceId=' + sourceId
- + '&previousNodeId=' + previousNodeId
- + '&nextNodeId=' + nextNodeId;
- console.log(saveOrderURL);
- $.ajax({
- url: saveOrderURL,
- type: 'POST',
- data: null,
- dataType: 'json',
- async: true,
- success: function() {
- console.log('layout move successful.');
- },
- error: function(request, text, error) {
- console.error('Error persisting move ' + saveOrderURL);
- },
- });
- };
-
- insertNode(sourceId, previousNodeId, nextNodeId);
+ var moveStuff = function moveStuffFunction(
+ index, length, sourceId, previousNodeId, nextNodeId) {
+ var insertNode = function(sourceId, previousNodeId, nextNodeId) {
+ var saveOrderURL = SERVICE_LOC.base +
+ 'layout?action=movePortletAjax' +
+ '&sourceId=' + sourceId +
+ '&previousNodeId=' + previousNodeId +
+ '&nextNodeId=' + nextNodeId;
+ $log.log(saveOrderURL);
+ $.ajax({
+ url: saveOrderURL,
+ type: 'POST',
+ data: null,
+ dataType: 'json',
+ async: true,
+ success: function() {
+ $log.log('layout move successful.');
+ },
+ error: function(request, text, error) {
+ $log.error('Error persisting move ' + saveOrderURL);
+ },
+ });
+ };
+
+ insertNode(sourceId, previousNodeId, nextNodeId);
};
var getNewStuffFeed = function() {
- return $http.get(SERVICE_LOC.newstuffInfo, {cache: true}).then(
- function(result) {
- return result.data.stuff;
+ return $http.get(SERVICE_LOC.newstuffInfo, {cache: true})
+ .then(function(result) {
+ return result.data.stuff;
},
function(reason) {
- miscService.redirectUser(reason.status, 'new stuff json feed call');
+ miscService.redirectUser(reason.status,
+ 'new stuff json feed call');
}
- );
+ );
};
var getWidgetJson = function(portlet) {
- return $http.get(portlet.widgetURL, {cache: true}).then(
- function(result) {
- var data = result.data;
- if(data) {
- if(data.result) {
- portlet.widgetData = data.result;
- }
- if(data.content) {
- portlet.widgetContent = data.content;
- }
- console.log(portlet.fname + '\'s widget data came back with data');
+ return $http.get(portlet.widgetURL, {cache: true})
+ .then(function(result) {
+ var data = result.data;
+ if(data) {
+ if(data.result) {
+ portlet.widgetData = data.result;
}
- return data;
+ if(data.content) {
+ portlet.widgetContent = data.content;
+ }
+ $log.log(portlet.fname +
+ '\'s widget data came back with data');
+ }
+ return data;
},
function(reason) {
- miscService.redirectUser(reason.status, 'widget json for ' + portlet.fname + ' failed.');
+ miscService.redirectUser(reason.status,
+ 'widget json for ' + portlet.fname + ' failed.');
}
- );
+ );
};
var getExclusiveMarkup = function(portlet) {
- return $http.get(SERVICE_LOC.context + '/p/' + portlet.fname + '/exclusive/render.uP', {cache: true}).then(
- function(result) {
- var data = result.data;
- if(data) {
- portlet.exclusiveContent = $sce.trustAsHtml(data);
- console.log(portlet.fname + '\'s exclusive data came back with data');
- }else{
- portlet.exclusiveContent='This service is unavailable right now. Please check back later.
';
- }
-
- return data;
- },
- function(reason) {
- if(reason.status===403) {
- portlet.exclusiveContent=$sce.trustAsHtml(accessDeniedTemplate);
- }else{
- miscService.redirectUser(reason.status, 'exclusive markup for ' + portlet.fname + ' failed.');
- }
- }
- );
+ return $http.get(SERVICE_LOC.context +
+ '/p/' + portlet.fname + '/exclusive/render.uP', {cache: true})
+ .then(function(result) {
+ var data = result.data;
+ if(data) {
+ portlet.exclusiveContent = $sce.trustAsHtml(data);
+ $log.log(portlet.fname +
+ '\'s exclusive data came back with data');
+ } else {
+ portlet.exclusiveContent =
+ '' +
+ 'This service is unavailable right now. ' +
+ 'Please check back later.
';
+ }
+
+ return data;
+ },
+ function(reason) {
+ if (reason.status===403) {
+ portlet.exclusiveContent =
+ $sce.trustAsHtml(accessDeniedTemplate);
+ } else {
+ miscService.redirectUser(reason.status,
+ 'exclusive markup for ' + portlet.fname + ' failed.');
+ }
+ }
+ );
};
var getRSSJsonified = function(feedURL) {
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/spec/layout_controller_spec.js b/angularjs-portal-home/src/main/webapp/my-app/layout/spec/layout_controller_spec.js
index f2af9440c..9194bda5e 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/spec/layout_controller_spec.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/spec/layout_controller_spec.js
@@ -1,10 +1,11 @@
'use strict';
+/* eslint-env node, phantomjs, jasmine */
+/* global inject */
define(['angular-mocks', 'portal', 'my-app'], function() {
describe('LayoutController', function() {
var scope;
var controller;
var $localStorage;
- var $location;
var $sessionStorage;
var rootScope;
var layoutService;
@@ -23,7 +24,9 @@ define(['angular-mocks', 'portal', 'my-app'], function() {
module('my-app');
});
- beforeEach(inject(function(_$rootScope_, $controller, _$localStorage_, _$sessionStorage_, $location, $q, _APP_FLAGS_, _$httpBackend_, _SERVICE_LOC_) {
+ beforeEach(inject(function(
+ _$rootScope_, $controller, _$localStorage_, _$sessionStorage_,
+ $location, $q, _APP_FLAGS_, _$httpBackend_, _SERVICE_LOC_) {
q = $q;
scope = _$rootScope_.$new();
rootScope = _$rootScope_;
@@ -31,31 +34,32 @@ define(['angular-mocks', 'portal', 'my-app'], function() {
$sessionStorage = _$sessionStorage_;
httpBackend = _$httpBackend_;
layoutService = {
- 'getLayout': function() {
- deferred = q.defer();
- return deferred.promise;
- },
+ 'getLayout': function() {
+ deferred = q.defer();
+ return deferred.promise;
+ },
};
miscService = {
- 'pushPageview': function() {
- return;
- },
+ 'pushPageview': function() {
+ return;
+ },
};
groupURL = _SERVICE_LOC_.groupURL;
loginSilentURL = _SERVICE_LOC_.loginSilentURL;
sharedPortletService = {};
- controller = $controller('LayoutController', {'$localStorage': $localStorage,
- '$scope': scope,
- '$rootScope': rootScope,
- '$location': $location,
- '$sessionStorage': $sessionStorage,
- 'layoutService': layoutService,
- 'miscService': miscService,
- 'sharedPortletService': sharedPortletService,
- 'APP_FLAGS': _APP_FLAGS_,
- });
+ controller = $controller('LayoutController', {
+ '$localStorage': $localStorage,
+ '$scope': scope,
+ '$rootScope': rootScope,
+ '$location': $location,
+ '$sessionStorage': $sessionStorage,
+ 'layoutService': layoutService,
+ 'miscService': miscService,
+ 'sharedPortletService': sharedPortletService,
+ 'APP_FLAGS': _APP_FLAGS_,
+ });
}));
@@ -67,25 +71,31 @@ define(['angular-mocks', 'portal', 'my-app'], function() {
expect(scope.layoutEmpty).toBe(false);
});
- it('should set layoutEmpty to true after return empty layout', function() {
+ it('should set layoutEmpty to true after return empty layout',
+ function() {
httpBackend.whenGET(groupURL).respond([]);
- httpBackend.whenGET('/base/my-app/layout/partials/default-view.html').respond('');
+ httpBackend.whenGET('/base/my-app/layout/partials/default-view.html')
+ .respond('');
controller.init();
scope.$apply(function() {
- deferred.resolve({'layout': []});
+ deferred.resolve({'layout': []});
});
expect(scope.layoutEmpty).toBe(true);
- });
+ }
+ );
- it('should set layoutEmpty to false after return non empty layout', function() {
+ it('should set layoutEmpty to false after return non empty layout',
+ function() {
httpBackend.whenGET(groupURL).respond([]);
- httpBackend.whenGET('/base/my-app/layout/partials/default-view.html').respond('');
+ httpBackend.whenGET('/base/my-app/layout/partials/default-view.html')
+ .respond('');
controller.init();
if(loginSilentURL) {
- httpBackend.whenGET(loginSilentURL).respond({'status': 'success', 'username': 'admin'});
+ httpBackend.whenGET(loginSilentURL)
+ .respond({'status': 'success', 'username': 'admin'});
}
scope.$apply(function() {
- deferred.resolve({'layout': [{'fake': true}]});
+ deferred.resolve({'layout': [{'fake': true}]});
});
expect(scope.layoutEmpty).toBe(false);
});
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/spec/toggle_controller_spec.js b/angularjs-portal-home/src/main/webapp/my-app/layout/spec/toggle_controller_spec.js
index 8328084d1..41b6be536 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/spec/toggle_controller_spec.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/spec/toggle_controller_spec.js
@@ -1,4 +1,6 @@
'use strict';
+/* eslint-env node, phantomjs, jasmine */
+/* global inject */
define(['angular-mocks', 'portal', 'my-app'], function() {
describe('ToggleController', function() {
var scope;
@@ -8,7 +10,7 @@ define(['angular-mocks', 'portal', 'my-app'], function() {
var miscService;
var APP_FLAGS;
var currentPath;
- var gaPageViewHits;
+ // var gaPageViewHits;
// load the marketplace controller
@@ -17,55 +19,63 @@ define(['angular-mocks', 'portal', 'my-app'], function() {
module('my-app');
});
- beforeEach(inject(function(_$rootScope_, $controller, _$localStorage_, _APP_FLAGS_) {
+ beforeEach(inject(function(
+ _$rootScope_, $controller, _$localStorage_, $log, _APP_FLAGS_) {
scope = _$rootScope_.$new();
$localStorage = _$localStorage_;
APP_FLAGS = _APP_FLAGS_;
currentPath = '/';
- gaPageViewHits = 0;
+ // gaPageViewHits = 0;
$location = {
- 'path': function(newPath) {
- if(newPath) {
- currentPath = newPath;
- } else {
- return path;
- }
- },
- 'url': function() {
- return currentPath;
- },
+ 'path': function(newPath) {
+ if(newPath) {
+ currentPath = newPath;
+ } else {
+ return currentPath;
+ }
+ },
+ 'url': function() {
+ return currentPath;
+ },
};
miscService = {
- 'pushPageview': function() {
- gaPageViewHits++; console.log($location.url()); return;
-},
- 'pushGAEvent': function() {
- return;
-},
- };
+ 'pushPageview': function() {
+ // gaPageViewHits++;
+ $log.info($location.url());
+ return;
+ },
+ 'pushGAEvent': function() {
+ return;
+ },
+ };
- controller = $controller('ToggleController', {'$localStorage': $localStorage,
- '$scope': scope,
- '$location': $location,
- 'miscService': miscService,
- 'APP_FLAGS': APP_FLAGS,
- });
+ controller = $controller('ToggleController', {
+ '$localStorage': $localStorage,
+ '$scope': scope,
+ '$location': $location,
+ '$log': $log,
+ 'miscService': miscService,
+ 'APP_FLAGS': APP_FLAGS,
+ });
}));
it('should have toggle set', function() {
expect(scope.toggle).toBeTruthy();
});
- it('should switch to default if layoutMode is set to something weird', function() {
+ it('should switch to default if layoutMode is set to something weird',
+ function() {
$localStorage.layoutMode = 'fishy'; // basically not list or widgets
controller.init();
// verify it was reset properly
- expect($localStorage.layoutMode === APP_FLAGS.defaultView);
- });
+ expect($localStorage.layoutMode).toBe(APP_FLAGS.defaultView);
+ }
+ );
- it('should redirect if you go somewhere you are not supposed to be.', function() {
+ it('should redirect if you go somewhere you are not supposed to be.',
+ function() {
// setup
$location.path('/expanded');
$localStorage.layoutMode = 'compact';
@@ -75,23 +85,24 @@ define(['angular-mocks', 'portal', 'my-app'], function() {
expect($location.url()).toBe('/compact');
});
- it('should redirect you if you switch modes and have a new layoutMode', function() {
- // setup
- $location.path('/expanded');
- controller.init();
+ it('should redirect you if you switch modes and have a new layoutMode',
+ function() {
+ // setup
+ $location.path('/expanded');
+ controller.init();
- // switch!
- scope.switchMode('compact');
- controller.init();
+ // switch!
+ scope.switchMode('compact');
+ controller.init();
- // validate
- expect($localStorage.layoutMode).toBe('compact');
- expect($location.url()).toBe('/compact');
+ // validate
+ expect($localStorage.layoutMode).toBe('compact');
+ expect($location.url()).toBe('/compact');
});
it('should only have page hits if it didn\'t redirect', function() {
// setup
- gaPageViewHits = 0;
+ // gaPageViewHits = 0;
$localStorage.layoutMode = 'expanded';
$location.path('/compact');
controller.init();
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/static/controllers.js b/angularjs-portal-home/src/main/webapp/my-app/layout/static/controllers.js
index db1cc2949..581963191 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/static/controllers.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/static/controllers.js
@@ -3,8 +3,9 @@
define(['angular', 'jquery', 'require'], function(angular, $, require) {
var app = angular.module('my-app.layout.static.controllers', []);
- app.controller('ExclusiveContentController', ['$location', '$sessionStorage', '$routeParams', '$rootScope', '$scope', 'layoutService',
- function($location, $sessionStorage, $routeParams, $rootScope, $scope, layoutService) {
+ app.controller('ExclusiveContentController',
+ ['$location', '$log', '$routeParams', '$scope', 'layoutService',
+ function($location, $log, $routeParams, $scope, layoutService) {
// BINDABLE MEMBERS
$scope.portlet = {};
$scope.loaded = false;
@@ -12,7 +13,8 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
// Resolve promises
var endFn = function() {
$scope.loaded = true;
- $scope.empty = $scope.portlet.exclusiveContent && $scope.portlet.exclusiveContent.length > 0 ? false : true;
+ $scope.empty = $scope.portlet.exclusiveContent &&
+ $scope.portlet.exclusiveContent.length > 0 ? false : true;
};
// Get the requested app from layoutService
@@ -33,13 +35,20 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
}
} else {
$scope.loaded = true;
- layoutService.getExclusiveMarkup($scope.portlet).then(endFn, endFn);
+ layoutService.getExclusiveMarkup($scope.portlet)
+ .then(endFn).catch(endFn);
}
+ return result;
+ }).catch(function() {
+ $log.warn('Could not getApp ' + $routeParams.fname);
});
}]);
- app.controller('StaticContentController', ['$location', '$sessionStorage', '$routeParams', '$rootScope', '$scope', 'layoutService',
- function($location, $sessionStorage, $routeParams, $rootScope, $scope, layoutService) {
+ app.controller('StaticContentController',
+ ['$location', '$log', '$sessionStorage', '$routeParams',
+ '$rootScope', '$scope', 'layoutService',
+ function($location, $log, $sessionStorage, $routeParams,
+ $rootScope, $scope, layoutService) {
// BINDABLE MEMBERS
$scope.portlet = {};
$scope.loaded = false;
@@ -63,17 +72,26 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
} else {
$scope.loaded = true;
}
+ return result;
+ }).catch(function() {
+ $log.warn('Could not getApp ' + $routeParams.fname);
});
this.addToHome = function(portlet) {
var ret = layoutService.addToHome(portlet);
ret.success(function(request, text) {
- $('.fname-' + portlet.fname).html(' Added Successfully').prop('disabled', true);
+ angular.element('.fname-' + portlet.fname)
+ .html('' +
+ ' Added Successfully')
+ .prop('disabled', true);
$scope.$apply(function() {
if (typeof $sessionStorage.marketplace !== 'undefined') {
- var marketplaceEntries = $.grep($sessionStorage.marketplace, function(e) {
- return e.fname === portlet.fname;
- });
+ var marketplaceEntries = $.grep(
+ $sessionStorage.marketplace,
+ function(e) {
+ return e.fname === portlet.fname;
+ }
+ );
if (marketplaceEntries.length > 0) {
marketplaceEntries[0].hasInLayout = true;
}
@@ -84,9 +102,14 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
$sessionStorage.layout = null;
});
})
- .error(function(request, text, error) {
- $('.fname-' + portlet.fname).html('Issue adding to home, please try again later');
- });
+ .error(function(request, text, error) {
+ angular.element('.fname-' + portlet.fname)
+ .html(
+ '' +
+ 'Issue adding to home, please try again later' +
+ ''
+ );
+ });
};
this.inLayout = function() {
@@ -99,7 +122,11 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
var portlets = $.grep($rootScope.layout, function(e) {
return e.fname === $routeParams.fname;
});
- $scope.inFavorites = portlets.length > 0; // change scope variable to trigger apply
+ // change scope variable to trigger apply
+ $scope.inFavorites = portlets.length > 0;
+ return data;
+ }).catch(function() {
+ $log.warn('Could not getLayout');
});
} else {
var portlets = $.grep($rootScope.layout, function(e) {
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/static/directives.js b/angularjs-portal-home/src/main/webapp/my-app/layout/static/directives.js
index b6330ac39..e1c856a03 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/static/directives.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/static/directives.js
@@ -9,18 +9,18 @@ define(['angular', 'require'], function(angular, require) {
app.directive('staticContentCard', function() {
return {
- restrict: 'E',
- templateUrl: require.toUrl('./partials/static-content-card.html'),
+ restrict: 'E',
+ templateUrl: require.toUrl('./partials/static-content-card.html'),
};
});
app.directive('staticContentCardMax', function() {
return {
- restrict: 'E',
- templateUrl: require.toUrl('./partials/static-content-card-max.html'),
+ restrict: 'E',
+ templateUrl:
+ require.toUrl('./partials/static-content-card-max.html'),
};
});
return app;
});
-
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/static/routes.js b/angularjs-portal-home/src/main/webapp/my-app/layout/static/routes.js
index b2baaad53..980359e76 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/static/routes.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/static/routes.js
@@ -1,7 +1,10 @@
define(['require'], function(require) {
- return {
- staticMax: {templateUrl: require.toUrl('./partials/static-content-max.html')},
- exclusiveMax: {templateUrl: require.toUrl('./partials/static-content-exclusive.html')},
- };
+ return {
+ staticMax: {
+ templateUrl: require.toUrl('./partials/static-content-max.html'),
+ },
+ exclusiveMax: {
+ templateUrl: require.toUrl('./partials/static-content-exclusive.html'),
+ },
+ };
});
-
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/widget/controllers.js b/angularjs-portal-home/src/main/webapp/my-app/layout/widget/controllers.js
index 492ebb2b0..20a6d6ba4 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/widget/controllers.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/widget/controllers.js
@@ -6,7 +6,8 @@ define(['angular'], function(angular) {
/**
* Controller for 'optionLink' directive (/widget/directives.js)
*/
- app.controller('OptionLinkController', ['$scope', 'layoutService', function($scope, layoutService) {
+ app.controller('OptionLinkController', ['$scope', '$log', 'layoutService',
+ function($scope, $log, layoutService) {
/**
* Set up default configuration if no config exists
*/
@@ -29,15 +30,21 @@ define(['angular'], function(angular) {
// Fetch widget JSON
layoutService.getWidgetJson($scope.portlet).then(function(data) {
if (data) {
+ var arr = $scope.portlet.widgetData[$scope.config.arrayName];
if ($scope.config.singleElement) {
// Set the default selected url
- $scope.portlet.selectedUrl = $scope.portlet.widgetData[$scope.config.value];
- } else if ($scope.portlet.widgetData[$scope.config.arrayName] && $scope.portlet.widgetData[$scope.config.arrayName].length > 0) {
- $scope.portlet.selectedUrl = $scope.portlet.widgetData[$scope.config.arrayName][0][$scope.config.value];
+ $scope.portlet.selectedUrl =
+ $scope.portlet.widgetData[$scope.config.value];
+ } else if (arr && arr.length > 0) {
+ $scope.portlet.selectedUrl = arr[0][$scope.config.value];
}
} else {
- console.warn('Got nothing back from widget fetch for ' + $scope.portlet.fname);
+ $log.warn('Got nothing back from widget fetch for ' +
+ $scope.portlet.fname);
}
+ return data;
+ }).catch(function() {
+ $log.warn('Could not getWidgetJson ' + $scope.portlet);
});
}
};
@@ -53,7 +60,9 @@ define(['angular'], function(angular) {
/**
* Controller for weather widget (/widget/directives.js)
*/
- app.controller('WeatherController', ['$scope', 'layoutService', 'keyValueService', '$q', function($scope, layoutService, keyValueService, $q) {
+ app.controller('WeatherController',
+ ['$scope', '$log', 'layoutService', 'keyValueService', '$q',
+ function($scope, $log, layoutService, keyValueService, $q) {
// Bindable members
$scope.weatherData = [];
$scope.loading = false;
@@ -76,7 +85,7 @@ define(['angular'], function(angular) {
$scope.loading = false;
if (data) {
- console.log(data);
+ $log.debug(data);
var allTheWeathers = data[0];
var myPref = data[1];
$scope.portlet.widgetData = allTheWeathers.weathers;
@@ -84,7 +93,8 @@ define(['angular'], function(angular) {
$scope.currentUnits = 'F';
$scope.nextUnits = 'C';
var userPreference = myPref.userWeatherPreference;
- if (userPreference === null || userPreference === '' || typeof userPreference === 'undefined') {
+ if (userPreference === null || userPreference === '' ||
+ typeof userPreference === 'undefined') {
userPreference = 'F';
}
@@ -93,9 +103,10 @@ define(['angular'], function(angular) {
}
} else {
$scope.error = true;
- console.warn('Got nothing back from widget fetch');
+ $log.warn('Got nothing back from widget fetch');
}
- }, function() {
+ return data;
+ }).catch(function() {
$scope.loading = false;
$scope.error = true;
});
@@ -136,11 +147,19 @@ define(['angular'], function(angular) {
* Change from farenheit to celsius
*/
$scope.changeFToC = function() {
+ var ratio = (5 / 9);
+ var offset = 32;
for (var i = 0; i < $scope.weatherData.length; i++) {
- $scope.weatherData[i].currentWeather.temperature = ($scope.weatherData[i].currentWeather.temperature - 32) * (5 / 9);
+ $scope.weatherData[i].currentWeather.temperature =
+ ($scope.weatherData[i].currentWeather.temperature -
+ offset) * ratio;
for (var j = 0; j < $scope.weatherData[i].forecast.length; j++) {
- $scope.weatherData[i].forecast[j].highTemperature = ($scope.weatherData[i].forecast[j].highTemperature - 32) * (5 / 9);
- $scope.weatherData[i].forecast[j].lowTemperature = ($scope.weatherData[i].forecast[j].lowTemperature - 32) * (5 / 9);
+ $scope.weatherData[i].forecast[j].highTemperature =
+ ($scope.weatherData[i].forecast[j].highTemperature -
+ offset) * ratio;
+ $scope.weatherData[i].forecast[j].lowTemperature =
+ ($scope.weatherData[i].forecast[j].lowTemperature -
+ offset) * ratio;
}
}
};
@@ -149,12 +168,16 @@ define(['angular'], function(angular) {
* Change from celsius to kelvin
*/
$scope.changeCToK = function() {
+ var offset = 273;
for (var i = 0; i < $scope.weatherData.length; i++) {
- $scope.weatherData[i].currentWeather.temperature = ($scope.weatherData[i].currentWeather.temperature + 273);
+ $scope.weatherData[i].currentWeather.temperature =
+ ($scope.weatherData[i].currentWeather.temperature + offset);
for (var j = 0; j < $scope.weatherData[i].forecast.length; j++) {
- $scope.weatherData[i].forecast[j].highTemperature = ($scope.weatherData[i].forecast[j].highTemperature + 273);
- $scope.weatherData[i].forecast[j].lowTemperature = ($scope.weatherData[i].forecast[j].lowTemperature + 273);
+ $scope.weatherData[i].forecast[j].highTemperature =
+ ($scope.weatherData[i].forecast[j].highTemperature + offset);
+ $scope.weatherData[i].forecast[j].lowTemperature =
+ ($scope.weatherData[i].forecast[j].lowTemperature + offset);
}
}
};
@@ -163,12 +186,16 @@ define(['angular'], function(angular) {
* Change kelvin to celsius
*/
$scope.changeKToC = function() {
+ var offset = 273;
for (var i = 0; i < $scope.weatherData.length; i++) {
- $scope.weatherData[i].currentWeather.temperature = ($scope.weatherData[i].currentWeather.temperature - 273);
+ $scope.weatherData[i].currentWeather.temperature =
+ ($scope.weatherData[i].currentWeather.temperature - offset);
for (var j = 0; j < $scope.weatherData[i].forecast.length; j++) {
- $scope.weatherData[i].forecast[j].highTemperature = ($scope.weatherData[i].forecast[j].highTemperature - 273);
- $scope.weatherData[i].forecast[j].lowTemperature = ($scope.weatherData[i].forecast[j].lowTemperature - 273);
+ $scope.weatherData[i].forecast[j].highTemperature =
+ ($scope.weatherData[i].forecast[j].highTemperature - offset);
+ $scope.weatherData[i].forecast[j].lowTemperature =
+ ($scope.weatherData[i].forecast[j].lowTemperature - offset);
}
}
};
@@ -177,12 +204,20 @@ define(['angular'], function(angular) {
* Change celsius to farenheit
*/
$scope.changeCToF = function() {
+ var ratio = (9 / 5);
+ var offset = 32;
for (var i = 0; i < $scope.weatherData.length; i++) {
- $scope.weatherData[i].currentWeather.temperature = ($scope.weatherData[i].currentWeather.temperature) * (9 / 5) + 32;
+ $scope.weatherData[i].currentWeather.temperature =
+ ($scope.weatherData[i].currentWeather.temperature *
+ ratio) + offset;
for (var j = 0; j < $scope.weatherData[i].forecast.length; j++) {
- $scope.weatherData[i].forecast[j].highTemperature = ($scope.weatherData[i].forecast[j].highTemperature) * (9 / 5) + 32;
- $scope.weatherData[i].forecast[j].lowTemperature = ($scope.weatherData[i].forecast[j].lowTemperature) * (9 / 5) + 32;
+ $scope.weatherData[i].forecast[j].highTemperature =
+ ($scope.weatherData[i].forecast[j].highTemperature *
+ ratio) + offset;
+ $scope.weatherData[i].forecast[j].lowTemperature =
+ ($scope.weatherData[i].forecast[j].lowTemperature *
+ ratio) + offset;
}
}
};
@@ -203,7 +238,9 @@ define(['angular'], function(angular) {
/**
* Controller for 'rss' widget type (/widget/directives.js)
*/
- app.controller('RSSWidgetController', ['$scope', 'layoutService', function($scope, layoutService) {
+ app.controller('RSSWidgetController',
+ ['$scope', 'layoutService',
+ function($scope, layoutService) {
/**
*
* @param dateString
@@ -220,20 +257,22 @@ define(['angular'], function(angular) {
var init = function() {
$scope.loading = true;
// Only initialize if everything is provided
- if ($scope.portlet && $scope.portlet.widgetURL && $scope.portlet.widgetType) {
+ if ($scope.portlet &&
+ $scope.portlet.widgetURL &&
+ $scope.portlet.widgetType) {
// Set defaults if any config attributes are missing
if (!$scope.config) {
- $scope.config = {};
-}
+ $scope.config = {};
+ }
if (!$scope.config.lim) {
- $scope.config.lim = 5;
-}
+ $scope.config.lim = 5;
+ }
if (!$scope.config.titleLim) {
- $scope.config.titleLim = 40;
-}
+ $scope.config.titleLim = 40;
+ }
if (!$scope.config.showShowing) {
- $scope.config.showShowing = false;
-}
+ $scope.config.showShowing = false;
+ }
// If we got JSON, display it in the widget
var successFn = function(result) {
@@ -249,7 +288,8 @@ define(['angular'], function(angular) {
$scope.loading = false;
$scope.error = true;
} else {
- if (!$scope.config.showShowing && $scope.data.items.length > $scope.config.lim) {
+ if (!$scope.config.showShowing &&
+ $scope.data.items.length > $scope.config.lim) {
$scope.config.showShowing = true;
}
}
@@ -264,7 +304,8 @@ define(['angular'], function(angular) {
};
// Get rss as JSON feed
- layoutService.getRSSJsonified($scope.portlet.widgetURL).then(successFn, errorFn);
+ layoutService.getRSSJsonified($scope.portlet.widgetURL)
+ .then(successFn).catch(errorFn);
}
};
@@ -274,14 +315,18 @@ define(['angular'], function(angular) {
/**
* Controller for 'swl' widget type (/widget/directives.js)
*/
- app.controller('SearchWithLinksController', ['$scope', '$sce', function($scope, $sce) {
+ app.controller('SearchWithLinksController',
+ ['$scope', '$sce', function($scope, $sce) {
$scope.secureURL = $sce.trustAsResourceUrl($scope.config.actionURL);
}]);
/**
- * Controller for 'generic' and 'custom' widget types (/widget/partials/widget-card.html)
+ * Controller for 'generic' and 'custom' widget types
+ * (/widget/partials/widget-card.html)
*/
- app.controller('CustomWidgetController', ['$scope', 'layoutService', function($scope, layoutService) {
+ app.controller('CustomWidgetController',
+ ['$scope', 'layoutService', '$log',
+ function($scope, layoutService, $log) {
$scope.loading = false;
/**
* Configure widget content
@@ -298,17 +343,21 @@ define(['angular'], function(angular) {
$scope.content = $scope.portlet.widgetData;
if (Array.isArray($scope.content) && $scope.content.length == 0) {
$scope.isEmpty = true;
- } else if ($scope.portlet.widgetConfig && $scope.portlet.widgetConfig.evalString
+ } else if ($scope.portlet.widgetConfig &&
+ $scope.portlet.widgetConfig.evalString
&& eval($scope.portlet.widgetConfig.evalString)) {
- // ideally this would do a check on an embedded object for emptiness
+ // ideally this would do a check on an embedded
+ // object for emptiness
// example : '$scope.content.report.length === 0'
$scope.isEmpty = true;
}
} else {
- console.warn('Got nothing back from widget fetch from ' + $scope.portlet.widgetURL);
+ $log.warn('Got nothing back from widget fetch from ' +
+ $scope.portlet.widgetURL);
$scope.isEmpty = true;
}
- }, function() {
+ return data;
+ }).catch(function() {
$scope.loading = false;
});
}
@@ -338,7 +387,8 @@ define(['angular'], function(angular) {
$scope.portlet.widgetData = [];
populateWidgetContent();
} else {
- console.error($scope.portlet.fname + ' said its a widget, but no template defined.');
+ $log.error($scope.portlet.fname +
+ ' said its a widget, but no template defined.');
$scope.isEmpty = true;
}
}]);
@@ -346,7 +396,9 @@ define(['angular'], function(angular) {
/**
* Widget creator controller (/widget/partials/widget-creator.html)
*/
- app.controller('WidgetCreatorController', ['$scope', '$route', '$localStorage', function($scope, $route, $localStorage) {
+ app.controller('WidgetCreatorController',
+ ['$scope', '$route', '$localStorage',
+ function($scope, $route, $localStorage) {
// SCOPE FUNCTIONS
// Reload widget preview
@@ -364,9 +416,12 @@ define(['angular'], function(angular) {
// Change to newly-selected template type
$scope.changeTemplate = function() {
- $scope.storage.content = $scope.storage.starterTemplate.contentIsJSON ? JSON.stringify($scope.storage.starterTemplate.content) : $scope.storage.starterTemplate.content;
+ $scope.storage.content = $scope.storage.starterTemplate.contentIsJSON ?
+ JSON.stringify($scope.storage.starterTemplate.content) :
+ $scope.storage.starterTemplate.content;
$scope.storage.portlet = $scope.storage.starterTemplate;
- $scope.storage.widgetConfig = JSON.stringify($scope.storage.starterTemplate.widgetConfig);
+ $scope.storage.widgetConfig =
+ JSON.stringify($scope.storage.starterTemplate.widgetConfig);
$scope.reload();
};
@@ -396,16 +451,20 @@ define(['angular'], function(angular) {
$scope.isEmpty = $scope.storage.isEmpty;
if ($scope.storage.content && validJSON($scope.storage.content)) {
$scope.content = JSON.parse($scope.storage.content);
- $scope.isEmpty = $scope.storage.evalString ? eval($scope.storage.evalString) : false;
+ $scope.isEmpty = $scope.storage.evalString ?
+ eval($scope.storage.evalString) : false;
} else {
$scope.content = {};
$scope.isEmpty = true;
$scope.errorJSON = $scope.storage.content ? 'JSON NOT VALID' : '';
}
- if ($scope.storage.widgetConfig && validJSON($scope.storage.widgetConfig)) {
- $scope.portlet.widgetConfig = JSON.parse($scope.storage.widgetConfig);
+ if ($scope.storage.widgetConfig &&
+ validJSON($scope.storage.widgetConfig)) {
+ $scope.portlet.widgetConfig =
+ JSON.parse($scope.storage.widgetConfig);
} else {
- $scope.errorConfigJSON = $scope.storage.widgetConfig ? 'JSON NOT VALID' : '';
+ $scope.errorConfigJSON = $scope.storage.widgetConfig ?
+ 'JSON NOT VALID' : '';
}
$scope.template = $scope.portlet.widgetTemplate;
@@ -416,7 +475,8 @@ define(['angular'], function(angular) {
*/
var init = function() {
$localStorage.widgetCreator = $localStorage.widgetCreator || {};
- $scope.storage = $localStorage.widgetCreator; // Makes the widget creator stuff contained
+ // Makes the widget creator stuff contained
+ $scope.storage = $localStorage.widgetCreator;
// Mock the widget controller
$scope.widgetCtrl = {
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/widget/directives.js b/angularjs-portal-home/src/main/webapp/my-app/layout/widget/directives.js
index bc34979d6..01fd609ed 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/widget/directives.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/widget/directives.js
@@ -5,13 +5,15 @@ define(['angular', 'require'], function(angular, require) {
/**
* directive is used to display widget content.
- * You need to setup a config JSON object, or just use the defaults defined below
+ * You need to setup a config JSON object,
+ * or just use the defaults defined below
* config = {
- * singleElement : false, //flags if your widgetData object as a single set in addition to the array
- * arrayName : 'array', //the array name under widgetData
- * value : 'value', //what you want the value to be (usually a URL)
- * display : 'display' // what to display in the drop down
- * }
+ * //is your widgetData object a single set in addition to the array
+ * 'singleElement': false,
+ * 'arrayName': 'array', //the array name under widgetData
+ * 'value': 'value', //what you want the value to be (usually a URL)
+ * 'display': 'display' // what to display in the drop down
+ * }
*/
app.directive('optionLink', function() {
return {
@@ -104,12 +106,14 @@ define(['angular', 'require'], function(angular, require) {
controller: function($scope,
$controller,
$location,
+ $log,
layoutService) {
var that = this;
$scope.portlet = {title: 'loading...'};
$scope.cantRemove = true;
this.$onInit = function() {
- var base = $controller('BaseWidgetFunctionsController', {$scope: $scope, childController: that});
+ $controller('BaseWidgetFunctionsController',
+ {$scope: $scope, childController: that});
};
this.$onChanges = function(changesObj) {
@@ -133,6 +137,9 @@ define(['angular', 'require'], function(angular, require) {
} else {
$scope.loaded = true;
}
+ return result;
+ }).catch(function() {
+ $log.warn('Could not getApp');
});
}
};
diff --git a/angularjs-portal-home/src/main/webapp/my-app/layout/widget/routes.js b/angularjs-portal-home/src/main/webapp/my-app/layout/widget/routes.js
index e184a198d..ae3b3d9ad 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/layout/widget/routes.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/layout/widget/routes.js
@@ -1,12 +1,17 @@
define(['require'], function(require) {
- return {
- widgetView: {templateUrl: require.toUrl('./partials/home-widget-view.html')},
- widgetFullScreen: {
- template: '
',
- controller: function($routeParams, $scope) {
- $scope.$routeParams = $routeParams;
- },
- },
- widgetCreator: {templateUrl: require.toUrl('./partials/widget-creator.html')},
- };
+ return {
+ widgetView: {
+ templateUrl: require.toUrl('./partials/home-widget-view.html'),
+ },
+ widgetFullScreen: {
+ template: '' +
+ '
',
+ controller: function($routeParams, $scope) {
+ $scope.$routeParams = $routeParams;
+ },
+ },
+ widgetCreator: {
+ templateUrl: require.toUrl('./partials/widget-creator.html'),
+ },
+ };
});
diff --git a/angularjs-portal-home/src/main/webapp/my-app/main.js b/angularjs-portal-home/src/main/webapp/my-app/main.js
index 212439ae9..b0f8ea109 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/main.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/main.js
@@ -1,85 +1,87 @@
define([
- 'angular',
- 'require',
- './marketplace/routes',
- './layout/list/route',
- 'portal/notifications/route',
- 'portal/settings/routes',
- 'portal/features/route',
- 'portal/about/route',
- './layout/route',
- './layout/static/routes',
- './layout/widget/routes',
- './search/routes',
- 'portal',
- 'app-config',
- '../js/web-config',
+ 'angular',
+ 'require',
+ './marketplace/routes',
+ './layout/list/route',
+ 'portal/notifications/route',
+ 'portal/settings/routes',
+ 'portal/features/route',
+ 'portal/about/route',
+ './layout/route',
+ './layout/static/routes',
+ './layout/widget/routes',
+ './search/routes',
+ 'portal',
+ 'app-config',
+ '../js/web-config',
+ 'ngRoute',
+ 'ngSanitize',
+ 'ngStorage',
+ './layout/controllers',
+ './layout/directives',
+ './layout/services',
+ './layout/static/controllers',
+ './layout/static/directives',
+ './layout/widget/controllers',
+ './layout/widget/directives',
+ './marketplace/controllers',
+ './marketplace/directives',
+ './marketplace/services',
+ './rating/components',
+ './rating/controllers',
+ './search/controllers',
+ './search/directives',
+ './search/services',
+], function(angular, require, marketplaceRoutes, listRoute, notificationsRoute,
+ portalSettingsRoutes, featuresRoute, aboutRoute, layoutRoute, staticRoutes,
+ widgetRoutes, searchRoutes) {
+ var app = angular.module('my-app', [
'ngRoute',
'ngSanitize',
+ 'app-config',
+ 'my-app.layout.controllers',
+ 'my-app.layout.directives',
+ 'my-app.layout.services',
+ 'my-app.layout.static.controllers',
+ 'my-app.layout.static.directives',
+ 'my-app.layout.widget.controllers',
+ 'my-app.layout.widget.directives',
+ 'my-app.marketplace.controllers',
+ 'my-app.marketplace.directives',
+ 'my-app.marketplace.services',
+ 'my-app.rating.components',
+ 'my-app.rating.controllers',
+ 'my-app.search.controllers',
+ 'my-app.search.directives',
+ 'my-app.search.services',
'ngStorage',
- './layout/controllers',
- './layout/directives',
- './layout/services',
- './layout/static/controllers',
- './layout/static/directives',
- './layout/widget/controllers',
- './layout/widget/directives',
- './marketplace/controllers',
- './marketplace/directives',
- './marketplace/services',
- './rating/components',
- './rating/controllers',
- './search/controllers',
- './search/directives',
- './search/services',
-], function(angular, require, marketplaceRoutes, listRoute, notificationsRoute, portalSettingsRoutes,
- featuresRoute, aboutRoute, layoutRoute, staticRoutes, widgetRoutes, searchRoutes) {
- var app = angular.module('my-app', [
- 'app-config',
- 'web-config',
- 'my-app.layout.controllers',
- 'my-app.layout.directives',
- 'my-app.layout.services',
- 'my-app.layout.static.controllers',
- 'my-app.layout.static.directives',
- 'my-app.layout.widget.controllers',
- 'my-app.layout.widget.directives',
- 'my-app.marketplace.controllers',
- 'my-app.marketplace.directives',
- 'my-app.marketplace.services',
- 'my-app.rating.components',
- 'my-app.rating.controllers',
- 'my-app.search.controllers',
- 'my-app.search.directives',
- 'my-app.search.services',
- 'ngRoute',
- 'ngSanitize',
- 'ngStorage',
- 'portal',
- ]);
+ 'portal',
+ 'web-config',
+ ]);
- // TODO: Think of a more extensible approach such that frame and app can each manage their own routing without conflict
- app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
- $locationProvider.html5Mode(true);
- $routeProvider.
- when('/apps', marketplaceRoutes.main).
- when('/apps/browse/:initFilter', marketplaceRoutes.main).
- when('/apps/details/:fname', marketplaceRoutes.details).
- when('/apps/search/:initFilter', searchRoutes.search).
- when('/compact', listRoute).
- when('/expanded', widgetRoutes.widgetView).
- when('/notifications', notificationsRoute).
- when('/settings', portalSettingsRoutes.betaSettings).
- when('/user-settings', portalSettingsRoutes.userSettings).
- when('/features', featuresRoute).
- when('/static/:fname', staticRoutes.staticMax).
- when('/exclusive/:fname', staticRoutes.exclusiveMax).
- when('/widget/:fname', widgetRoutes.widgetFullScreen).
- when('/about', aboutRoute).
- when('/widget-creator', widgetRoutes.widgetCreator).
- otherwise(layoutRoute);
+ // TODO: Think of a more extensible approach such that frame and app can
+ // each manage their own routing without conflict
+ app.config(['$locationProvider', '$routeProvider',
+ function($locationProvider, $routeProvider) {
+ $locationProvider.html5Mode(true);
+ $routeProvider
+ .when('/apps', marketplaceRoutes.main)
+ .when('/apps/browse/:initFilter', marketplaceRoutes.main)
+ .when('/apps/details/:fname', marketplaceRoutes.details)
+ .when('/apps/search/:initFilter', searchRoutes.search)
+ .when('/compact', listRoute)
+ .when('/expanded', widgetRoutes.widgetView)
+ .when('/notifications', notificationsRoute)
+ .when('/settings', portalSettingsRoutes.betaSettings)
+ .when('/user-settings', portalSettingsRoutes.userSettings)
+ .when('/features', featuresRoute)
+ .when('/static/:fname', staticRoutes.staticMax)
+ .when('/exclusive/:fname', staticRoutes.exclusiveMax)
+ .when('/widget/:fname', widgetRoutes.widgetFullScreen)
+ .when('/about', aboutRoute)
+ .when('/widget-creator', widgetRoutes.widgetCreator)
+ .otherwise(layoutRoute);
}]);
-
- return app;
+ return app;
});
diff --git a/angularjs-portal-home/src/main/webapp/my-app/marketplace/controllers.js b/angularjs-portal-home/src/main/webapp/my-app/marketplace/controllers.js
index 74d35b7c2..31b5351c8 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/marketplace/controllers.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/marketplace/controllers.js
@@ -3,12 +3,23 @@
define(['angular', 'jquery', 'require'], function(angular, $, require) {
var app = angular.module('my-app.marketplace.controllers', []);
- app.controller('marketplaceCommonFunctions', ['googleCustomSearchService', 'miscSearchService', 'layoutService', 'marketplaceService',
- 'miscService', 'MISC_URLS', '$sessionStorage', '$localStorage', '$rootScope', '$scope', '$routeParams', '$timeout', '$location',
- function(googleCustomSearchService, miscSearchService, layoutService, marketplaceService, miscService, MISC_URLS, $sessionStorage,
- $localStorage, $rootScope, $scope, $routeParams, $timeout, $location) {
- var currentThemePrimary = ($sessionStorage.portal.theme && $sessionStorage.portal.theme.materialTheme) ? $sessionStorage.portal.theme.materialTheme.primary['500'] : {value: ['0', '0', '0']};
- $scope.primaryColorRgb = 'rgb('+ currentThemePrimary.value[0] + ',' + currentThemePrimary.value[1] + ',' + currentThemePrimary.value[2] + ')';
+ app.controller('marketplaceCommonFunctions',
+ ['googleCustomSearchService', 'miscSearchService', 'layoutService',
+ '$log', 'marketplaceService', 'miscService', 'MISC_URLS',
+ '$sessionStorage', '$localStorage', '$rootScope', '$scope',
+ '$routeParams', '$timeout', '$location',
+ function(googleCustomSearchService, miscSearchService, layoutService,
+ $log, marketplaceService, miscService, MISC_URLS,
+ $sessionStorage, $localStorage, $rootScope, $scope,
+ $routeParams, $timeout, $location) {
+ var currentThemePrimary = ($sessionStorage.portal.theme &&
+ $sessionStorage.portal.theme.materialTheme) ?
+ $sessionStorage.portal.theme.materialTheme.primary['500'] :
+ {value: ['0', '0', '0']};
+ $scope.primaryColorRgb = 'rgb('+
+ currentThemePrimary.value[0] + ',' +
+ currentThemePrimary.value[1] + ',' +
+ currentThemePrimary.value[2] + ')';
$scope.navToDetails = function(marketplaceEntry, location) {
marketplaceService.setFromInfo(location, $scope.searchTerm);
@@ -16,18 +27,21 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
};
$scope.isStatic = function(portlet) {
- return portlet.maxUrl.indexOf('portal') !== -1 // max url is a portal hit
+ return portlet.maxUrl.indexOf('portal') !== -1 // a portal hit
&& portlet.portletName // there is a portletName
- && portlet.portletName.indexOf('cms') != -1; // the portlet is static content portlet
+ && portlet.portletName.indexOf('cms') != -1; // static content portlet
};
$scope.getLaunchURL = function(marketplaceEntry) {
var layoutObj = marketplaceEntry.layoutObject;
- if($rootScope.GuestMode && !marketplaceEntry.hasInLayout) {
- return $scope.loginToAuthPage + '/web/apps/details/'+ marketplaceEntry.fname;
- } else if(layoutObj.altMaxUrl == false && (layoutObj.renderOnWeb || $localStorage.webPortletRender)) {
+ if ($rootScope.GuestMode && !marketplaceEntry.hasInLayout) {
+ return $scope.loginToAuthPage +
+ '/web/apps/details/'+ marketplaceEntry.fname;
+ } else if (layoutObj.altMaxUrl == false &&
+ (layoutObj.renderOnWeb || $localStorage.webPortletRender)) {
return 'exclusive/' + layoutObj.fname;
- } else if(layoutObj.altMaxUrl == false && $scope.isStatic(marketplaceEntry)) {
+ } else if (layoutObj.altMaxUrl == false &&
+ $scope.isStatic(marketplaceEntry)) {
return 'static/' + layoutObj.fname;
} else {
return marketplaceEntry.maxUrl;
@@ -38,11 +52,18 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
var fname = portlet.fname;
var ret = layoutService.addToHome(portlet);
ret.success(function(request, text) {
- $('.fname-'+fname).html(' Added Successfully').prop('disabled', true).removeClass('btn-add').addClass('btn-added');
+ angular.element('.fname-'+fname)
+ .html(' Added Successfully')
+ .prop('disabled', true)
+ .removeClass('btn-add')
+ .addClass('btn-added');
$scope.$apply(function() {
- var marketplaceEntries = $.grep($sessionStorage.marketplace, function(e) {
- return e.fname === portlet.fname;
-});
+ var marketplaceEntries = $.grep(
+ $sessionStorage.marketplace,
+ function(e) {
+ return e.fname === portlet.fname;
+ }
+ );
if(marketplaceEntries.length > 0) {
marketplaceEntries[0].hasInLayout = true;
}
@@ -51,16 +72,24 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
});
})
.error(function(request, text, error) {
- $('.fname-'+fname).parent().append('Issue adding to home, please try again later');
+ angular.element('.fname-'+fname)
+ .parent()
+ .append(
+ 'Issue adding to home, please try again later'
+ );
});
};
$scope.searchTermFilter = function(portlet) {
- return marketplaceService.portletMatchesSearchTerm(portlet, $scope.searchTerm, {
- searchDescription: true,
- searchKeywords: true,
- defaultReturn: true,
- });
+ return marketplaceService.portletMatchesSearchTerm(
+ portlet,
+ $scope.searchTerm,
+ {
+ searchDescription: true,
+ searchKeywords: true,
+ defaultReturn: true,
+ }
+ );
};
$scope.selectFilter = function(filter, category) {
@@ -96,9 +125,11 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
};
this.setupSearchTerm = function() {
- var tempFilterText = '', filterTextTimeout;
+ var tempFilterText = '';
+ var filterTextTimeout;
$scope.searchTerm = marketplaceService.getInitialFilter();
- if($routeParams.initFilter !== null && ($scope.searchTerm === null || $scope.searchTerm === '')) {
+ if($routeParams.initFilter !== null &&
+ ($scope.searchTerm === null || $scope.searchTerm === '')) {
$scope.searchTerm = $routeParams.initFilter;
} else {
marketplaceService.initialFilter('');
@@ -122,22 +153,42 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
};
this.initializeConstants = function() {
+ var errorFn = function(name) {
+ return function() {
+ $log.warn('Could not ' + name);
+ };
+ };
// initialize constants
- googleCustomSearchService.getPublicWebSearchURL().then(function(webSearchURL) {
- $scope.webSearchUrl = webSearchURL;
- });
- googleCustomSearchService.getDomainResultsLabel().then(function(domainResultsLabel) {
- $scope.domainResultsLabel = domainResultsLabel;
- });
- miscSearchService.getKBSearchURL().then(function(kbSearchURL) {
- $scope.kbSearchUrl = kbSearchURL;
- });
- miscSearchService.getEventSearchURL().then(function(eventsSearchURL) {
- $scope.eventsSearchUrl = eventsSearchURL;
- });
- miscSearchService.getHelpDeskHelpURL().then(function(helpdeskURL) {
- $scope.helpdeskUrl = helpdeskURL;
- });
+ googleCustomSearchService.getPublicWebSearchURL().then(
+ function(webSearchURL) {
+ $scope.webSearchUrl = webSearchURL;
+ return webSearchURL;
+ }
+ ).catch(errorFn('getPublicWebSearchURL'));
+ googleCustomSearchService.getDomainResultsLabel().then(
+ function(domainResultsLabel) {
+ $scope.domainResultsLabel = domainResultsLabel;
+ return domainResultsLabel;
+ }
+ ).catch(errorFn('getDomainResultsLabel'));
+ miscSearchService.getKBSearchURL().then(
+ function(kbSearchURL) {
+ $scope.kbSearchUrl = kbSearchURL;
+ return kbSearchURL;
+ }
+ ).catch(errorFn('getKBSearchURL'));
+ miscSearchService.getEventSearchURL().then(
+ function(eventsSearchURL) {
+ $scope.eventsSearchUrl = eventsSearchURL;
+ return eventsSearchURL;
+ }
+ ).catch(errorFn('getEventSearchURL'));
+ miscSearchService.getHelpDeskHelpURL().then(
+ function(helpdeskURL) {
+ $scope.helpdeskUrl = helpdeskURL;
+ return helpdeskURL;
+ }
+ ).catch(errorFn('getHelpDeskHelpURL'));
$scope.directorySearchUrl = MISC_URLS.directorySearchURL;
$scope.feedbackUrl = MISC_URLS.feedbackURL;
$scope.loginToAuthPage = MISC_URLS.myuwHome;
@@ -149,8 +200,8 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
var currentCategory = '';
app.controller('MarketplaceController', [
- '$rootScope', '$scope', '$controller', 'marketplaceService',
- function($rootScope, $scope, $controller, marketplaceService) {
+ '$log', '$rootScope', '$scope', '$controller', 'marketplaceService',
+ function($log, $rootScope, $scope, $controller, marketplaceService) {
var base = $controller('marketplaceCommonFunctions', {$scope: $scope});
var init = function() {
@@ -159,6 +210,9 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
marketplaceService.getPortlets().then(function(data) {
$scope.portlets = data.portlets;
$scope.categories = data.categories;
+ return data;
+ }).catch(function() {
+ $log.warn('Could not getPortlets');
});
base.setupSearchTerm();
@@ -170,7 +224,8 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
if(currentPage === 'details') {
// Empty string indicates no categories, show all portlets
$scope.categoryToShow = '';
- // Default filter is to sort by category for marketplaceDetails back to marketplace
+ // Default filter is to sort by category for
+ // marketplaceDetails back to marketplace
$scope.selectedFilter = 'category';
// To sort by category, angular will use name to filter
$scope.sortParameter = 'name';
@@ -201,10 +256,10 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
}]);
app.controller('MarketplaceDetailsController', [
- '$controller', '$scope', '$routeParams', '$mdDialog', 'marketplaceService',
- 'SERVICE_LOC',
- function($controller, $scope, $routeParams, $mdDialog, marketplaceService,
- SERVICE_LOC) {
+ '$controller', '$document', '$scope', '$routeParams',
+ '$mdDialog', 'marketplaceService', 'SERVICE_LOC',
+ function($controller, $document, $scope, $routeParams,
+ $mdDialog, marketplaceService, SERVICE_LOC) {
$controller('marketplaceCommonFunctions', {$scope: $scope});
$scope.specifyCategory = function(category) {
@@ -239,7 +294,7 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
$mdDialog.show({
controller: 'MarketplaceRatingReviewAdminController',
templateUrl: require.toUrl('./partials/rating-review-admin.html'),
- parent: angular.element(document.body),
+ parent: angular.element($document.body),
scope: $scope,
preserveScope: true,
clickOutsideToClose: true,
@@ -254,17 +309,21 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
$scope.obj = [];
$scope.ratingPrefix = SERVICE_LOC.base +
SERVICE_LOC.marketplace.base;
- $scope.errorMessage = 'There was an issue loading details, please click back to apps.';
- marketplaceService.getPortlet($routeParams.fname).then(function(result) {
- $scope.loading = false;
- if(!result) {
- $scope.error = true;
- $scope.portlet = null;
- } else {
- $scope.portlet = result;
- $scope.error = false;
+ $scope.errorMessage =
+ 'There was an issue loading details, please click back to apps.';
+ marketplaceService.getPortlet($routeParams.fname).then(
+ function(result) {
+ $scope.loading = false;
+ if (!result) {
+ $scope.error = true;
+ $scope.portlet = null;
+ } else {
+ $scope.portlet = result;
+ $scope.error = false;
+ }
+ return result;
}
- }, function(reason) {
+ ).catch(function(reason) {
$scope.loading = false;
$scope.error = true;
});
@@ -274,24 +333,28 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
);
app.controller('MarketplaceRatingReviewAdminController', [
- '$scope', 'marketplaceService',
- function($scope, marketplaceService) {
+ '$log', '$scope', 'marketplaceService',
+ function($log, $scope, marketplaceService) {
var init = function() {
$scope.ratings = [];
- marketplaceService.getAllRatings($scope.portlet.fname).then(function(ratings) {
- if(!ratings) {
- return;
- }
- $scope.ratings = ratings;
- $scope.average =0;
- $scope.totalReviews = 0;
- angular.forEach(ratings, function(value, key) {
- $scope.average+= value.rating;
- if(value.review) {
- $scope.totalReviews += 1;
+ marketplaceService.getAllRatings($scope.portlet.fname).then(
+ function(ratings) {
+ if (ratings) {
+ $scope.ratings = ratings;
+ $scope.average =0;
+ $scope.totalReviews = 0;
+ angular.forEach(ratings, function(value, key) {
+ $scope.average+= value.rating;
+ if(value.review) {
+ $scope.totalReviews += 1;
+ }
+ });
+ $scope.average = Math.round($scope.average / ratings.length);
}
- });
- $scope.average = Math.round($scope.average / ratings.length);
+ return ratings;
+ }
+ ).catch(function() {
+ $log.warn('Could not getAllRatings');
});
};
diff --git a/angularjs-portal-home/src/main/webapp/my-app/marketplace/services.js b/angularjs-portal-home/src/main/webapp/my-app/marketplace/services.js
index e72d20887..25e85584c 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/marketplace/services.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/marketplace/services.js
@@ -3,7 +3,11 @@
define(['angular', 'jquery'], function(angular, $) {
var app = angular.module('my-app.marketplace.services', []);
- app.factory('marketplaceService', ['$q', '$http', '$sessionStorage', 'layoutService', 'miscService', 'mainService', 'SERVICE_LOC', 'APP_FLAGS', function($q, $http, $sessionStorage, layoutService, miscService, mainService, SERVICE_LOC, APP_FLAGS) {
+ app.factory('marketplaceService',
+ ['$q', '$http', '$sessionStorage', 'layoutService', '$log',
+ 'miscService', 'mainService', 'SERVICE_LOC', 'APP_FLAGS',
+ function($q, $http, $sessionStorage, layoutService, $log,
+ miscService, mainService, SERVICE_LOC, APP_FLAGS) {
var marketplacePromise;
// local variables
var filter = '';
@@ -37,11 +41,12 @@ define(['angular', 'jquery'], function(angular, $) {
var checkMarketplaceCache = function() {
var userPromise = mainService.getUser();
return userPromise.then(function(user) {
- if ($sessionStorage.sessionKey === user.sessionKey && $sessionStorage.marketplace) {
- return {
- portlets: $sessionStorage.marketplace,
- categories: $sessionStorage.categories,
- };
+ if ($sessionStorage.sessionKey === user.sessionKey &&
+ $sessionStorage.marketplace) {
+ return {
+ portlets: $sessionStorage.marketplace,
+ categories: $sessionStorage.categories,
+ };
}
return null;
});
@@ -53,12 +58,17 @@ define(['angular', 'jquery'], function(angular, $) {
$sessionStorage.sessionKey = user.sessionKey;
$sessionStorage.marketplace = data.portlets;
$sessionStorage.categories = data.categories;
+ return user;
+ }).catch(function() {
+ $log.warn('Could not getUser');
});
};
var getPortlets = function() {
return checkMarketplaceCache().then(function(data) {
- var successFn, errorFn, defer;
+ var successFn;
+ var errorFn;
+ var defer;
// first, check the local storage...
if (data) {
@@ -67,14 +77,15 @@ define(['angular', 'jquery'], function(angular, $) {
return defer.promise;
}
- // then check for outstanding requests that may have not yet been cached.
+ // check for outstanding requests that have not yet been cached.
// Downside of adding caching in getUser() is that the
// promise in getUser blocks till we get results. That blocks
// the call to getMarketplace. So, they pile up. Then, when
// getUser clears, all the getUser promises fire immediately.
// They all fire so fast that the layout data doesn't make it
- // to cache between calls. So, cache the very first promise locally.
+ // to cache between calls.
+ // So, cache the very first promise locally.
// Then, if the marketplace promise exists use it again.
if (marketplacePromise) {
return marketplacePromise;
@@ -88,28 +99,37 @@ define(['angular', 'jquery'], function(angular, $) {
};
errorFn = function(reason) {
- miscService.redirectUser(reason.status, 'marketplace entries call');
+ miscService.redirectUser(
+ reason.status,
+ 'marketplace entries call'
+ );
};
// no caching... request from the server
- marketplacePromise = $q.all([$http.get(SERVICE_LOC.base + SERVICE_LOC.marketplace.base + SERVICE_LOC.marketplace.entries, {cache: true}), layoutService.getLayout()]).then(successFn, errorFn);
+ marketplacePromise = $q.all([$http.get(
+ SERVICE_LOC.base + SERVICE_LOC.marketplace.base +
+ SERVICE_LOC.marketplace.entries, {cache: true}),
+ layoutService.getLayout()]).then(successFn, errorFn);
return marketplacePromise;
});
};
/**
- returns portlet if one exists in user's marketplace, or goes and gets entry from server
- **/
+ * returns portlet if one exists in user's marketplace,
+ * or goes and gets entry from server
+ */
var getPortlet = function(fname) {
- var successFn, errorFn, defer;
+ var successFn;
+ var errorFn;
+ var defer;
// first check cache, if there use that (it'll be faster)
return checkMarketplaceCache().then(function(data) {
if (data) {
defer = $q.defer();
// find portlet and resolve with it if exists
var portlets = $.grep(data.portlets, function(e) {
- return e.fname === fname;
-});
+ return e.fname === fname;
+ });
var portlet = portlets ? portlets[0] : null;
defer.resolve(portlet);
return defer.promise;
@@ -124,46 +144,63 @@ define(['angular', 'jquery'], function(angular, $) {
};
errorFn = function(reason) {
- miscService.redirectUser(reason.status, 'marketplace entry service call');
+ miscService.redirectUser(
+ reason.status,
+ 'marketplace entry service call'
+ );
};
- return $q.all([$http.get(SERVICE_LOC.base + SERVICE_LOC.marketplace.base + SERVICE_LOC.marketplace.entry + fname + '.json', {cache: true}), layoutService.getLayout()]).then(successFn, errorFn);
+ return $q.all(
+ [$http.get(
+ SERVICE_LOC.base + SERVICE_LOC.marketplace.base +
+ SERVICE_LOC.marketplace.entry + fname + '.json',
+ {cache: true}),
+ layoutService.getLayout()])
+ .then(successFn, errorFn);
}
});
};
var getUserRating = function(fname) {
- return $http.get(SERVICE_LOC.base + SERVICE_LOC.marketplace.base + fname + '/getRating').then(function(result) {
+ return $http.get(SERVICE_LOC.base + SERVICE_LOC.marketplace.base +
+ fname + '/getRating')
+ .then(function(result) {
return result.data.rating;
- });
+ });
};
var saveRating = function(fname, rating) {
- return $http.post(SERVICE_LOC.base + SERVICE_LOC.marketplace.base + fname + '/rating/' + rating.rating, {}, {params: {review: rating.review}}).
- success(function(data, status, headers, config) {
- if(APP_FLAGS.debug) {
- console.log('successfully saved marketplace rating for ' + fname + ' with data ' + rating);
- }
- return data;
- }).
- error(function(data, status, headers, config) {
- if(APP_FLAGS.debug) {
- console.error('Failed to save marketplace rating for ' + fname + ' with data ' + rating);
- }
- return data;
- });
+ return $http.post(
+ SERVICE_LOC.base + SERVICE_LOC.marketplace.base + fname +
+ '/rating/' + rating.rating,
+ {},
+ {params: {review: rating.review}})
+ .success(function(data, status, headers, config) {
+ if(APP_FLAGS.debug) {
+ $log.log('successfully saved marketplace rating for ' +
+ fname + ' with data ' + rating);
+ }
+ return data;
+ })
+ .error(function(data, status, headers, config) {
+ if(APP_FLAGS.debug) {
+ $log.error('Failed to save marketplace rating for ' +
+ fname + ' with data ' + rating);
+ }
+ return data;
+ });
};
// private functions
var processInLayout = function(portlet, layout) {
var inLayout = $.grep(layout, function(e) {
- return e.fname === portlet.fname;
-}).length;
+ return e.fname === portlet.fname;
+ }).length;
if (inLayout > 0) {
- portlet.hasInLayout = true;
+ portlet.hasInLayout = true;
} else {
- portlet.hasInLayout = false;
+ portlet.hasInLayout = false;
}
};
@@ -182,8 +219,9 @@ define(['angular', 'jquery'], function(angular, $) {
var categoriesOfThisPortlet = cur.categories;
$.each(categoriesOfThisPortlet, function(index, category) {
- if ($.inArray(category, categories) == -1 && cur.canAdd == true) {
- categories.push(category);
+ if ($.inArray(category, categories) == -1 &&
+ cur.canAdd == true) {
+ categories.push(category);
}
});
});
@@ -193,57 +231,66 @@ define(['angular', 'jquery'], function(angular, $) {
};
var portletMatchesSearchTerm = function(portlet, searchTerm, opts) {
- if (!searchTerm) {
- return opts && opts.defaultReturn;
- }
+ if (!searchTerm) {
+ return opts && opts.defaultReturn;
+ }
- var lowerSearchTerm = searchTerm.toLowerCase(); // create local var for searchTerm
+ // create local var for searchTerm
+ var lowerSearchTerm = searchTerm.toLowerCase();
- if(portlet.title.toLowerCase().indexOf(lowerSearchTerm) !== -1) {// check title
- return true;
- }
+ // check title
+ if(portlet.title.toLowerCase().indexOf(lowerSearchTerm) !== -1) {
+ return true;
+ }
- if (opts && opts.searchDescription) {
- // check description match
- if(portlet.description && portlet.description.toLowerCase().indexOf(lowerSearchTerm) !== -1) {
- return true;
- }
+ if (opts && opts.searchDescription) {
+ var desc = portlet.description;
+ // check description match
+ if (desc &&
+ desc.toLowerCase().indexOf(lowerSearchTerm) !== -1) {
+ return true;
}
+ }
- // last ditch effort, check keywords
- if (opts && opts.searchKeywords) {
- if (portlet.keywords) {
- for (var i = 0; i < portlet.keywords.length; i++) {
- if (portlet.keywords[i].toLowerCase().indexOf(lowerSearchTerm) !== -1) {
- return true;
- }
- }
+ // last ditch effort, check keywords
+ if (opts && opts.searchKeywords) {
+ var keys = portlet.keywords;
+ if (keys) {
+ for (var i = 0; i < keys.length; i++) {
+ if (keys[i].toLowerCase().indexOf(lowerSearchTerm) !== -1) {
+ return true;
}
+ }
}
- return false;
+ }
+ return false;
};
- var filterPortletsBySearchTerm = function(portletList, searchTerm, opts) {
+ var filterPortletsBySearchTerm =
+ function(portletList, searchTerm, opts) {
var matches;
if (!angular.isArray(portletList)) {
- return null;
+ return null;
}
matches = [];
angular.forEach(portletList, function(portlet) {
- if (portletMatchesSearchTerm(portlet, searchTerm, opts)) {
- matches.push(portlet);
- }
+ if (portletMatchesSearchTerm(portlet, searchTerm, opts)) {
+ matches.push(portlet);
+ }
});
-
return matches;
- };
+ };
var getAllRatings = function(fname) {
- return $http.get(SERVICE_LOC.base + SERVICE_LOC.marketplace.base + fname + '/ratings').then(function(result) {
+ return $http.get(
+ SERVICE_LOC.base +
+ SERVICE_LOC.marketplace.base + fname +
+ '/ratings')
+ .then(function(result) {
return result.data.ratings;
- });
+ });
};
// return list of avaliable functions
diff --git a/angularjs-portal-home/src/main/webapp/my-app/rating/components.js b/angularjs-portal-home/src/main/webapp/my-app/rating/components.js
index 523f370f6..300d43b32 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/rating/components.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/rating/components.js
@@ -17,16 +17,14 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
},
templateUrl: require.toUrl('./partials/rating-button.html'),
controllerAs: 'ratingCtrl',
- controller: function($scope,
- $location,
- $mdDialog) {
+ controller: function($document, $scope, $location, $mdDialog) {
this.$onInit = function() {
// initialize
$scope.openModal = function() {
$mdDialog.show({
controller: 'RatingsModalController',
templateUrl: require.toUrl('./partials/rating-review.html'),
- parent: angular.element(document.body),
+ parent: angular.element($document.body),
scope: $scope,
preserveScope: true,
clickOutsideToClose: true,
diff --git a/angularjs-portal-home/src/main/webapp/my-app/rating/controllers.js b/angularjs-portal-home/src/main/webapp/my-app/rating/controllers.js
index 1965ad7bb..0aae62720 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/rating/controllers.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/rating/controllers.js
@@ -23,6 +23,7 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
};
$scope.loading = false;
}
+ return data;
}).catch(function() {
$scope.loading = false;
$scope.rating = {
@@ -40,6 +41,7 @@ define(['angular', 'jquery', 'require'], function(angular, $, require) {
.then(function() {
$mdDialog.hide();
$scope.saved = true;
+ return;
})
.catch(function() {
$scope.error = 'Issue saving rating';
diff --git a/angularjs-portal-home/src/main/webapp/my-app/search/controllers.js b/angularjs-portal-home/src/main/webapp/my-app/search/controllers.js
index 9fd77d615..884ba4a40 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/search/controllers.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/search/controllers.js
@@ -1,62 +1,83 @@
'use strict';
-define(['angular', 'portal/search/controllers', 'my-app/marketplace/controllers'], function(angular) {
- var app = angular.module('my-app.search.controllers', ['portal.search.controllers', 'my-app.marketplace.controllers']);
- app.controller('SearchController', ['marketplaceService', '$location', '$scope', '$localStorage', function(marketplaceService, $location, $scope, $localStorage) {
+define([
+ 'angular',
+ 'portal/search/controllers',
+ 'my-app/marketplace/controllers'],
+ function(angular) {
+ var app = angular.module('my-app.search.controllers',
+ ['my-app.marketplace.controllers', 'portal.search.controllers']);
+ app.controller('SearchController',
+ ['marketplaceService', '$log', '$location', '$scope', '$localStorage',
+ function(marketplaceService, $log, $location, $scope, $localStorage) {
$scope.initialFilter = '';
$scope.filterMatches = [];
$scope.portletListLoading = true;
if($localStorage && $localStorage.typeaheadSearch) {
marketplaceService.getPortlets().then(function(data) {
- $scope.portlets = data.portlets;
- $scope.portletListLoading = false;
+ $scope.portlets = data.portlets;
+ $scope.portletListLoading = false;
+ return data;
+ }).catch(function() {
+ $log.warn('Could not getPortlets');
});
}
$scope.$watch('initialFilter', function(newVal, oldVal) {
- if (!newVal || !$scope.portlets) {
- $scope.filterMatches = [];
- return;
- }
- $scope.filterMatches = marketplaceService.filterPortletsBySearchTerm($scope.portlets, newVal);
+ if (!newVal || !$scope.portlets) {
+ $scope.filterMatches = [];
+ } else {
+ $scope.filterMatches =
+ marketplaceService.filterPortletsBySearchTerm(
+ $scope.portlets,
+ newVal
+ );
+ }
});
$scope.onSelect = function(portlet) {
- $location.path('apps/details/'+ portlet.fname);
- $scope.initialFilter = '';
- $scope.showSearch = false;
- $scope.showSearchFocus = false;
+ $location.path('apps/details/'+ portlet.fname);
+ $scope.initialFilter = '';
+ $scope.showSearch = false;
+ $scope.showSearchFocus = false;
};
$scope.submit = function() {
- if($scope.initialFilter != '') {
- $location.path('apps/search/'+ $scope.initialFilter);
- $scope.initialFilter = '';
- $scope.showSearch = false;
- $scope.showSearchFocus = false;
- }
+ if($scope.initialFilter != '') {
+ $location.path('apps/search/'+ $scope.initialFilter);
+ $scope.initialFilter = '';
+ $scope.showSearch = false;
+ $scope.showSearchFocus = false;
+ }
};
}]);
app.controller('SearchResultController',
- ['$location', '$rootScope', '$scope', '$controller', 'marketplaceService', 'googleCustomSearchService', 'directorySearchService', 'PortalSearchService',
- function($location, $rootScope, $scope, $controller, marketplaceService, googleCustomSearchService, directorySearchService, PortalSearchService) {
+ ['$log', '$rootScope', '$scope', '$controller',
+ 'marketplaceService', 'googleCustomSearchService',
+ 'directorySearchService', 'PortalSearchService',
+ function($log, $rootScope, $scope, $controller,
+ marketplaceService, googleCustomSearchService,
+ directorySearchService, PortalSearchService) {
var base = $controller('marketplaceCommonFunctions', {$scope: $scope});
var initWiscEduSearch = function() {
googleCustomSearchService.googleSearch($scope.searchTerm).then(
function(data) {
- if(data && data.results) {
+ if (data && data.results) {
$scope.googleResults = data.results;
if(data.estimatedResultCount) {
$scope.googleResultsEstimatedCount = data.estimatedResultCount;
}
if(!data.estimatedResultCount || data.estimatedResultCount == 0) {
- $scope.googleEmptyResults = true;
+ $scope.googleEmptyResults = true;
}
}
+ return data;
}
- );
+ ).catch(function() {
+ $log.warn('Could not googleSearch');
+ });
};
var initDirectorySearch = function() {
@@ -64,21 +85,26 @@ define(['angular', 'portal/search/controllers', 'my-app/marketplace/controllers'
directorySearchService.directorySearch($scope.searchTerm).then(
function(results) {
$scope.wiscDirectoryLoading = false;
- if(results) {
- if(results.records && results.count) {
+ if (results) {
+ if (results.records && results.count) {
$scope.wiscDirectoryResults = results.records;
$scope.wiscDirectoryResultCount = results.count;
} else {
$scope.wiscDirectoryResultsEmpty = true;
}
- if(results.errors && results.errors[0] && results.errors[0].code && results.errors[1] && results.errors[1].error_msg) {
- if(results.errors[0].code == 4) {
+ if (results.errors &&
+ results.errors[0] &&
+ results.errors[0].code &&
+ results.errors[1] &&
+ results.errors[1].error_msg) {
+ if (results.errors[0].code == 4) {
$scope.wiscDirectoryTooManyResults = true;
}
$scope.wiscDirectoryErrorMessage= results.errors[1].error_msg;
}
}
- }, function() {
+ return results;
+ }).catch(function() {
$scope.wiscDirectoryLoading = false;
$scope.wiscDirectoryError = true;
}
@@ -86,7 +112,7 @@ define(['angular', 'portal/search/controllers', 'my-app/marketplace/controllers'
};
var initwiscDirectoryResultLimit = function() {
- $scope.wiscDirectoryResultLimit = 3;
+ $scope.wiscDirectoryResultLimit = 3;
};
var init = function() {
@@ -105,38 +131,54 @@ define(['angular', 'portal/search/controllers', 'my-app/marketplace/controllers'
$scope.searchResultLimit = 20;
$scope.showAll = $rootScope.GuestMode || false;
base.setupSearchTerm();
- PortalSearchService.setQuery($scope.searchTerm); // in case the search field is not set for whatever reason, reset it
+ // in case the search field is not set for whatever reason, reset it
+ PortalSearchService.setQuery($scope.searchTerm);
base.initializeConstants();
// get marketplace entries
marketplaceService.getPortlets().then(function(data) {
$scope.myuwResults = data.portlets;
+ return data;
+ }).catch(function() {
+ $log.warn('Could not getPortlets');
});
- $scope.$watchGroup(['googleResultsEstimatedCount', 'myuwFilteredResults.length', 'wiscDirectoryResultCount'], function() {
- $scope.totalCount = 0;
- if($scope.googleResultsEstimatedCount) {
- $scope.totalCount+= parseInt($scope.googleResultsEstimatedCount);
- }
- if($scope.myuwFilteredResults) {
- $scope.totalCount+= parseInt($scope.myuwFilteredResults.length);
- }
- if($scope.wiscDirectoryResultCount) {
- $scope.totalCount+= parseInt($scope.wiscDirectoryResultCount);
- }
- });
+ $scope.$watchGroup([
+ 'googleResultsEstimatedCount',
+ 'myuwFilteredResults.length',
+ 'wiscDirectoryResultCount'],
+ function() {
+ $scope.totalCount = 0;
+ if($scope.googleResultsEstimatedCount) {
+ $scope.totalCount+= parseInt($scope.googleResultsEstimatedCount);
+ }
+ if($scope.myuwFilteredResults) {
+ $scope.totalCount+= parseInt($scope.myuwFilteredResults.length);
+ }
+ if($scope.wiscDirectoryResultCount) {
+ $scope.totalCount+= parseInt($scope.wiscDirectoryResultCount);
+ }
+ });
};
init();
- googleCustomSearchService.googleSearchEnabled().then(function(googleSearchEnabled) {
- $scope.googleSearchEnabled = googleSearchEnabled;
- if(googleSearchEnabled) {
- initWiscEduSearch();
- }
+ googleCustomSearchService.googleSearchEnabled()
+ .then(function(googleSearchEnabled) {
+ $scope.googleSearchEnabled = googleSearchEnabled;
+ if (googleSearchEnabled) {
+ initWiscEduSearch();
+ }
+ return googleSearchEnabled;
+ }).catch(function() {
+ $log.warn('Could not googleSearchEnabled');
});
- directorySearchService.directorySearchEnabled().then(function(directoryEnabled) {
- $scope.directoryEnabled = directoryEnabled;
- if(directoryEnabled) {
- initDirectorySearch();
- }
+ directorySearchService.directorySearchEnabled()
+ .then(function(directoryEnabled) {
+ $scope.directoryEnabled = directoryEnabled;
+ if (directoryEnabled) {
+ initDirectorySearch();
+ }
+ return directoryEnabled;
+ }).catch(function() {
+ $log.warn('Could not directorySearchEnabled');
});
}]);
diff --git a/angularjs-portal-home/src/main/webapp/my-app/search/services.js b/angularjs-portal-home/src/main/webapp/my-app/search/services.js
index 8a77c60cd..8d1dec904 100644
--- a/angularjs-portal-home/src/main/webapp/my-app/search/services.js
+++ b/angularjs-portal-home/src/main/webapp/my-app/search/services.js
@@ -3,15 +3,23 @@
define(['angular', 'jquery'], function(angular, $) {
var app = angular.module('my-app.search.services', []);
- app.factory('googleCustomSearchService', ['$http', '$q', 'PortalGroupService', 'filterFilter', 'miscSearchService', 'miscService', 'SERVICE_LOC',
- function($http, $q, PortalGroupService, filterFilter, miscSearchService, miscService, SERVICE_LOC) {
+ app.factory('googleCustomSearchService',
+ ['$log', '$http', '$q', 'PortalGroupService',
+ 'miscSearchService', 'miscService',
+ function($log, $http, $q, PortalGroupService,
+ miscSearchService, miscService) {
var googleSearchURLPromise;
var googleSearchEnabledPromise;
var webSearchURLPromise;
var domainResultsLabelPromise;
+ /**
+ * Get the Domain Results Label
+ * @return {Promise} domainResultsLabelPromise
+ */
function getDomainResultsLabel() {
- var successFn, errorFn;
+ var successFn;
+ var errorFn;
if(domainResultsLabelPromise) {
return domainResultsLabelPromise;
}
@@ -25,36 +33,52 @@ define(['angular', 'jquery'], function(angular, $) {
});
};
errorFn = function(reason) {
- miscService.redirectUser(reason.status, 'Could not get appropriate domain results label');
+ miscService.redirectUser(
+ reason.status,
+ 'Could not get appropriate domain results label'
+ );
};
- domainResultsLabelPromise = PortalGroupService.getGroups().then(successFn, errorFn);
+ domainResultsLabelPromise = PortalGroupService.getGroups()
+ .then(successFn, errorFn);
return domainResultsLabelPromise;
}
/**
* Returns a public web search url. Useful for 'See more results here'
+ * @return {Promise} webSearchURLPromise
*/
function getPublicWebSearchURL() {
- var successFn, errorFn;
- if(webSearchURLPromise) {
- return webSearchURLPromise;
- }
- successFn = function(groups) {
- return miscSearchService.getSearchURLS(groups).then(function(result) {
+ var successFn;
+ var errorFn;
+ if(webSearchURLPromise) {
+ return webSearchURLPromise;
+ }
+ successFn = function(groups) {
+ return miscSearchService.getSearchURLS(groups)
+ .then(function(result) {
if(result && result.webSearchURL) {
return result.webSearchURL;
} else{
return null;
}
});
- };
- errorFn = function(reason) {
- miscService.redirectUser(reason.status, 'Could not get appropriate public web search url');
- };
- webSearchURLPromise = PortalGroupService.getGroups().then(successFn, errorFn);
- return webSearchURLPromise;
+ };
+ errorFn = function(reason) {
+ miscService.redirectUser(
+ reason.status,
+ 'Could not get appropriate public web search url'
+ );
+ };
+ webSearchURLPromise = PortalGroupService.getGroups()
+ .then(successFn, errorFn);
+ return webSearchURLPromise;
}
+ /**
+ * Search Google for term
+ * @param {string} term
+ * @return {Promise} Promise of google search results
+ */
function googleSearch(term) {
return getGoogleSearchURL().then(function(googleSearchURL) {
return $q(function(resolve, reject) {
@@ -66,24 +90,35 @@ define(['angular', 'jquery'], function(angular, $) {
estimatedResultCount: null,
};
// Standardize data
- if(response.data) {
+ if (response.data) {
// Find the results
- if(response.data.results) { // uwrf
+ if (response.data.results) { // uwrf
data.results = response.data.results;
- }else if(response.data.responseData && response.data.responseData.results) { // uwmad
- data.results = response.data.responseData.results;
+ } else if ( // uwmad
+ response.data.responseData &&
+ response.data.responseData.results) {
+ data.results = response.data.responseData.results;
}
// Find the estimated count
- if(response.data.cursor && response.data.cursor.estimatedResultCount) { // uwrf
- data.estimatedResultCount = response.data.cursor.estimatedResultCount;
- }else if(response.data.responseData && response.data.responseData.cursor && response.data.responseData.cursor.estimatedResultCount) { // uwmad
- data.estimatedResultCount = response.data.responseData.cursor.estimatedResultCount;
+ var respData = response.data;
+ if ( // uwrf
+ respData.cursor &&
+ respData.cursor.estimatedResultCount) {
+ data.estimatedResultCount =
+ respData.cursor.estimatedResultCount;
+ } else if ( // uwmad
+ respData.responseData &&
+ respData.responseData.cursor &&
+ respData.responseData.cursor.estimatedResultCount) {
+ data.estimatedResultCount =
+ respData.responseData.cursor.estimatedResultCount;
}
}
resolve(data);
+ return response;
}
);
- }else{
+ } else {
reject('User has no group for google URL search');
}
});
@@ -95,7 +130,8 @@ define(['angular', 'jquery'], function(angular, $) {
* for a users group or null if one does not exists.
*/
function getGoogleSearchURL() {
- var successFn, errorFn;
+ var successFn;
+ var errorFn;
if(googleSearchURLPromise) {
return googleSearchURLPromise;
@@ -112,10 +148,14 @@ define(['angular', 'jquery'], function(angular, $) {
};
errorFn = function(reason) {
- miscService.redirectUser(reason.status, 'Could not get appropriate google search url');
+ miscService.redirectUser(
+ reason.status,
+ 'Could not get appropriate google search url'
+ );
};
- googleSearchURLPromise = PortalGroupService.getGroups().then(successFn, errorFn);
+ googleSearchURLPromise =
+ PortalGroupService.getGroups().then(successFn, errorFn);
return googleSearchURLPromise;
}
@@ -125,7 +165,8 @@ define(['angular', 'jquery'], function(angular, $) {
* a directorySearchURL for any of the users groups
*/
function googleSearchEnabled() {
- var successFn, errorFn;
+ var successFn;
+ var errorFn;
if(googleSearchEnabledPromise) {
return googleSearchEnabledPromise;
@@ -140,11 +181,13 @@ define(['angular', 'jquery'], function(angular, $) {
};
errorFn = function(response) {
- console.log('error determing if google search is enabled: ' + response.status);
+ $log.log('error determing if google search is enabled: ' +
+ response.status);
return false;
};
- googleSearchEnabledPromise = getGoogleSearchURL().then(successFn, errorFn);
+ googleSearchEnabledPromise =
+ getGoogleSearchURL().then(successFn, errorFn);
return googleSearchEnabledPromise;
}
@@ -156,8 +199,15 @@ define(['angular', 'jquery'], function(angular, $) {
};
}]);
- app.factory('miscSearchService', ['$q', '$sessionStorage', 'PortalGroupService', 'filterFilter', 'SEARCH_CONFIG',
- function($q, $sessionStorage, PortalGroupService, filterFilter, SEARCH_CONFIG) {
+ app.factory('miscSearchService',
+ ['$q', '$sessionStorage', 'PortalGroupService',
+ 'filterFilter', 'SEARCH_CONFIG',
+ function($q, $sessionStorage, PortalGroupService,
+ filterFilter, SEARCH_CONFIG) {
+ /**
+ * retrieve the KB Search URL from the Group Service
+ * @return {string} kbSearchURL
+ */
function getKBSearchURL() {
return PortalGroupService.getGroups().then(
function(groups) {
@@ -174,6 +224,10 @@ define(['angular', 'jquery'], function(angular, $) {
);
}
+ /**
+ * retrieve the Events Search URL from the Group Service
+ * @return {string} eventsSearchURL
+ */
function getEventSearchURL() {
return PortalGroupService.getGroups().then(
function(groups) {
@@ -190,6 +244,10 @@ define(['angular', 'jquery'], function(angular, $) {
);
}
+ /**
+ * retrieve the Help Desk URL from the Group Service
+ * @return {string} helpdeskURL
+ */
function getHelpDeskHelpURL() {
return PortalGroupService.getGroups().then(
function(groups) {
@@ -206,6 +264,9 @@ define(['angular', 'jquery'], function(angular, $) {
);
}
+ /**
+ * retrieve the search URLs
+ */
function getSearchURLS(groups) {
return $q(function(resolve, reject) {
if($sessionStorage.search) {
@@ -232,92 +293,105 @@ define(['angular', 'jquery'], function(angular, $) {
};
}]);
- app.factory('directorySearchService', [
- '$http', '$q', 'PortalGroupService', 'miscSearchService', 'filterFilter', 'miscService',
- function($http, $q, PortalGroupService, miscSearchService, filterFilter, miscService) {
- var directoryUrlPromise;
- var directorySearchEnabledPromise;
-
- function directorySearch(term) {
- return getDirectorySearchURL().then(function(searchDirectoryURL) {
- return $q(function(resolve, reject) {
- if(searchDirectoryURL) {
- return $http.get(searchDirectoryURL + '/?name=' + term).then(
- function(response) {
- return resolve(response.data);
- },
- function(response) {
- return reject('error searching the directory: ' + response.status);
- }
- );
- }else{
- return reject('User has no group for directory search');
- }
- });
- });
- }
-
- /**
- * Returns promise that will return true or false if there exists
- * a directorySearchURL for any of the users groups
- */
- function directorySearchEnabled() {
- var successFn, errorFn;
+ app.factory('directorySearchService',
+ ['$log', '$http', '$q', 'PortalGroupService',
+ 'miscSearchService', 'miscService',
+ function($log, $http, $q, PortalGroupService,
+ miscSearchService, miscService) {
+ var directoryUrlPromise;
+ var directorySearchEnabledPromise;
- if(directorySearchEnabledPromise) {
- return directorySearchEnabledPromise;
+ /**
+ * Search the directory for term
+ * @param {string} term
+ */
+ function directorySearch(term) {
+ return getDirectorySearchURL().then(function(searchDirectoryURL) {
+ return $q(function(resolve, reject) {
+ if(searchDirectoryURL) {
+ return $http.get(searchDirectoryURL + '/?name=' + term).then(
+ function(response) {
+ return resolve(response.data);
+ },
+ function(response) {
+ return reject('error searching the directory: ' +
+ response.status);
+ }
+ );
+ }else{
+ return reject('User has no group for directory search');
}
+ });
+ });
+ }
- successFn = function(directoryURL) {
- if(directoryURL) {
- return true;
- }else{
- return false;
- }
- };
-
- errorFn = function(response) {
- console.log('error determing if directory search is enabled: ' + response.status);
- return false;
- };
+ /**
+ * Returns promise that will return true or false if there exists
+ * a directorySearchURL for any of the users groups
+ */
+ function directorySearchEnabled() {
+ var successFn;
+ var errorFn;
- directorySearchEnabledPromise = getDirectorySearchURL().then(successFn, errorFn);
+ if(directorySearchEnabledPromise) {
return directorySearchEnabledPromise;
- }
-
- /**
- * Returns a promise that will return a directorySearchURL if any exist
- * for a users group or null if one does not exists.
- */
- function getDirectorySearchURL() {
- var successFn, errorFn;
-
- if(directoryUrlPromise) {
- return directoryUrlPromise;
}
- successFn = function(groups) {
- return miscSearchService.getSearchURLS(groups).then(function(result) {
- if(result && result.directorySearchURL) {
- return result.directorySearchURL;
- } else{
- return null;
- }
- });
+ successFn = function(directoryURL) {
+ if(directoryURL) {
+ return true;
+ }else{
+ return false;
+ }
};
- errorFn = function(reason) {
- miscService.redirectUser(reason.status, 'search directory url call');
+ errorFn = function(response) {
+ $log.log('error determing if directory search is enabled: ' +
+ response.status);
+ return false;
};
- directoryUrlPromise = PortalGroupService.getGroups().then(successFn, errorFn);
+ directorySearchEnabledPromise = getDirectorySearchURL()
+ .then(successFn, errorFn);
+ return directorySearchEnabledPromise;
+ }
+ /**
+ * Returns a promise that will return a directorySearchURL if any exist
+ * for a users group or null if one does not exists.
+ * @return {Promise} directoryUrlPromise
+ */
+ function getDirectorySearchURL() {
+ var successFn;
+ var errorFn;
+
+ if(directoryUrlPromise) {
return directoryUrlPromise;
}
- return {
- directorySearch: directorySearch,
- directorySearchEnabled: directorySearchEnabled,
+ successFn = function(groups) {
+ return miscSearchService.getSearchURLS(groups).then(function(result) {
+ if(result && result.directorySearchURL) {
+ return result.directorySearchURL;
+ } else{
+ return null;
+ }
+ });
};
- }]);
+
+ errorFn = function(reason) {
+ miscService.redirectUser(reason.status, 'search directory url call');
+ };
+
+ directoryUrlPromise = PortalGroupService.getGroups()
+ .then(successFn, errorFn);
+
+ return directoryUrlPromise;
+ }
+
+ return {
+ directorySearch: directorySearch,
+ directorySearchEnabled: directorySearchEnabled,
+ };
+ }]);
});
diff --git a/package.json b/package.json
index cc24d1dac..a9f94f0eb 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"lint-css": "stylelint --syntax less angularjs-portal-home/src/**/*.less",
"pretest": "mvn clean package",
"test": "karma start angularjs-portal-home/target/web/karma.conf.js --single-run",
+ "dev-lint-js": "eslint --ext js --ext json --ext md --format html --output-file angularjs-portal-home/target/web/lint-out.html . --ignore-path .gitignore",
"lint-js": "eslint --ext js --ext json --ext md . --ignore-path .gitignore",
"lint-md": "remark . --ignore-path .gitignore",
"lint-less": "stylelint --syntax less angularjs-portal-home/src/**/*.less",
@@ -60,7 +61,7 @@
"stylelint": {
"extends": "stylelint-config-standard",
"rules": {
- "selector-type-no-unknown": false
+ "selector-type-no-unknown": null
}
},
"remarkConfig": {
@@ -102,14 +103,14 @@
],
"rules": {
"angular/angularelement": "error",
- "angular/di": "error",
- "angular/di-order": "error",
+ "angular/di": "warn",
+ "angular/di-order": "warn",
"angular/di-unused": "error",
"angular/document-service": "error",
"angular/log": "error",
"angular/module-dependency-order": "error",
"angular/no-service-method": "error",
- "angular/no-services": "error",
+ "angular/no-services": "warn",
"angular/window-service": "error",
"compat/compat": "error",
"arrow-parens": "off",
@@ -117,9 +118,11 @@
"generator-star-spacing": "off",
"no-new-symbol": "off",
"no-this-before-super": "off",
+ "no-invalid-this": "off",
"no-var": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
+ "valid-jsdoc": "warn",
"rest-spread-spacing": "off",
"yield-star-spacing": "off"
}