Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Fix Lint Errors for TravisCI #601

Merged
merged 6 commits into from
Mar 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion angularjs-portal-home/src/main/webapp/js/login-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
});
12 changes: 8 additions & 4 deletions angularjs-portal-home/src/main/webapp/js/master-override.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
],
});
Expand Down
18 changes: 13 additions & 5 deletions angularjs-portal-home/src/main/webapp/js/override.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
],
});
Expand Down
1 change: 1 addition & 0 deletions angularjs-portal-home/src/main/webapp/js/web-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint max-len: "off" */
define(['angular'], function(angular) {
var config = angular.module('web-config', []);
config.value('SEARCH_CONFIG', [
Expand Down
127 changes: 71 additions & 56 deletions angularjs-portal-home/src/main/webapp/main.js
Original file line number Diff line number Diff line change
@@ -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('<b style="padding: 10px;">An error has occured during loading, please try refreshing the page. If the issue persists please contact the helpdesk.</b>');
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(
'<b style="padding: 10px;">An error has occured during loading, ' +
'please try refreshing the page. If the issue persists please ' +
'contact the helpdesk.</b>');
});

// 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.');
}
});
}
});
});
Loading