Skip to content

Commit

Permalink
Merge pull request #134 from bodom0015/NDS-576
Browse files Browse the repository at this point in the history
NDS-576 / NDS-572: Landing Page + Help Links
  • Loading branch information
craig-willis authored Sep 23, 2016
2 parents 59fb023 + 67820ec commit 5e193a2
Show file tree
Hide file tree
Showing 28 changed files with 375 additions and 268 deletions.
4 changes: 2 additions & 2 deletions apiserver/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ func (s *Server) RegisterAccount(w rest.ResponseWriter, r *rest.Request) {
return
}

verifyUrl := s.origin + "/#/register/verify?t=" + account.Token + "&u=" + account.Namespace
verifyUrl := s.origin + "/#/?t=" + account.Token + "&u=" + account.Namespace
err = s.email.SendVerificationEmail(account.Name, account.EmailAddress, verifyUrl)
if err != nil {
glog.Error(err)
Expand Down Expand Up @@ -2536,7 +2536,7 @@ func (s *Server) ResetPassword(w rest.ResponseWriter, r *rest.Request) {
}

if account.Status == api.AccountStatusUnverified {
verifyUrl := s.origin + "/#/register/verify?t=" + account.Token + "&u=" + account.Namespace
verifyUrl := s.origin + "/#/?t=" + account.Token + "&u=" + account.Namespace
err = s.email.SendVerificationEmail(account.Name, account.EmailAddress, verifyUrl)
} else {
resetUrl := s.origin + "/#/recover?t=" + token
Expand Down
153 changes: 83 additions & 70 deletions gui/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
*/
.constant('_', window._)

/**
* The route to our "Landing Page" View
*/
.constant('LandingRoute', '/')

/**
* The route to our "Login" View
*/
Expand Down Expand Up @@ -97,6 +102,13 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
.constant('ProductName', 'Labs Workbench')
.constant('ProductUrl', 'http://www.nationaldataservice.org/projects/labs.html')

.value('HelpLinks', [
{ name: "Feature Overview", icon: 'fa-info-circle', url: 'https://nationaldataservice.atlassian.net/wiki/display/NDSC/Feature+Overview' },
{ name: "F.A.Q.", icon: 'fa-question-circle', url: 'https://nationaldataservice.atlassian.net/wiki/display/NDSC/Frequently+Asked+Questions'},
{ name: "User's Guide", icon: 'fa-book', url: 'https://nationaldataservice.atlassian.net/wiki/display/NDSC/User%27s+Guide' },
{ name: "Developer's Guide", icon: 'fa-code-fork', url: 'https://nationaldataservice.atlassian.net/wiki/display/NDSC/Developer%27s+Guide' },
])

/**
* The version/revision of this GUI
*/
Expand Down Expand Up @@ -185,8 +197,8 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
/**
* Configure routes / HTTP for our app using the services defined above
*/
.config([ '$routeProvider', '$httpProvider', '$logProvider', 'DEBUG', 'AuthInfoProvider', 'LoginRoute', 'AppStoreRoute', 'HomeRoute', 'ConsoleRoute', 'AddServiceRoute', 'EditServiceRoute', 'AddSpecRoute', 'EditSpecRoute', 'VerifyAccountRoute', 'ResetPasswordRoute', 'SignUpRoute', 'ContactUsRoute', 'ProductName',
function($routeProvider, $httpProvider, $logProvider, DEBUG, authInfo, LoginRoute, AppStoreRoute, HomeRoute, ConsoleRoute, AddServiceRoute, EditServiceRoute, AddSpecRoute, EditSpecRoute, VerifyAccountRoute, ResetPasswordRoute, SignUpRoute, ContactUsRoute, ProductName) {
.config([ '$routeProvider', '$httpProvider', '$logProvider', 'DEBUG', 'AuthInfoProvider', 'LoginRoute', 'AppStoreRoute', 'HomeRoute', 'ConsoleRoute', 'AddServiceRoute', 'EditServiceRoute', 'AddSpecRoute', 'EditSpecRoute', 'VerifyAccountRoute', 'ResetPasswordRoute', 'SignUpRoute', 'ContactUsRoute', 'ProductName', 'LandingRoute',
function($routeProvider, $httpProvider, $logProvider, DEBUG, authInfo, LoginRoute, AppStoreRoute, HomeRoute, ConsoleRoute, AddServiceRoute, EditServiceRoute, AddSpecRoute, EditSpecRoute, VerifyAccountRoute, ResetPasswordRoute, SignUpRoute, ContactUsRoute, ProductName, LandingRoute) {
// Squelch debug-level log messages
$logProvider.debugEnabled(DEBUG);

Expand Down Expand Up @@ -244,9 +256,12 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
$cookies.remove('namespace');

// Route to Login Page to prompt for credentials
if ($location.path() !== LoginRoute) {
$location.path(LoginRoute);
var path = $location.path();
if (path !== LoginRoute) {
$log.debug("Routing to landing...");
$location.path(LandingRoute);
}

return $q.reject(rejection);
}
}
Expand All @@ -264,6 +279,11 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
controller: 'LoginController',
templateUrl: 'app/login/login.html'
})
.when(LandingRoute, {
title: ProductName + ' Landing Page',
controller: 'LandingController',
templateUrl: 'app/landing/landing.html'
})
.when(SignUpRoute, {
title: 'Sign Up for ' + ProductName,
controller: 'SignUpController',
Expand Down Expand Up @@ -319,27 +339,73 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
controller: 'ConsoleController',
templateUrl: 'app/dashboard/console/console.html'
})
.otherwise({ redirectTo: LoginRoute });
.otherwise({ redirectTo: LandingRoute });
}])

/**
* Once configured, run this section of code to finish bootstrapping our app
*/
.run([ '$rootScope', '$window', '$location', '$log', '$interval', '$cookies', '$uibModalStack', 'Stacks', '_', 'AuthInfo', 'LoginRoute', 'AppStoreRoute', 'HomeRoute', 'NdsLabsApi', 'AutoRefresh', 'ServerData', 'Loading',
function($rootScope, $window, $location, $log, $interval, $cookies, $uibModalStack, Stacks, _, authInfo, LoginRoute, AppStoreRoute, HomeRoute, NdsLabsApi, AutoRefresh, ServerData, Loading) {
.run([ '$rootScope', '$window', '$location', '$log', '$interval', '$cookies', '$uibModalStack', 'Stacks', '_', 'AuthInfo', 'LoginRoute', 'AppStoreRoute', 'HomeRoute', 'NdsLabsApi', 'AutoRefresh', 'ServerData', 'Loading', 'LandingRoute', 'VerifyAccountRoute',
function($rootScope, $window, $location, $log, $interval, $cookies, $uibModalStack, Stacks, _, authInfo, LoginRoute, AppStoreRoute, HomeRoute, NdsLabsApi, AutoRefresh, ServerData, Loading, LandingRoute, VerifyAccountRoute) {

// Make _ bindable in partial views
// TODO: Investigate performance concerns here...
$rootScope._ = window._;

// Check our token every 60s
var tokenCheckMs = 60000;

// Define the logic for ending a user's session in the browser
var authInterval = null;
var terminateSession = authInfo.purge = function() {
// Cancel the auth check interval
if (authInterval) {
$interval.cancel(authInterval);
authInfo.tokenInterval = authInterval = null;
}

if (authInfo.get().token) {
// Purge current session data
authInfo.get().token = null;
$cookies.remove('token');
$cookies.remove('namespace');

// Close any open modals
$uibModalStack.dismissAll();

// Stop any running auto-refresh interval
AutoRefresh.stop();

// Purge any server data
ServerData.purgeAll();

$log.debug("Terminating session... routing to Landing");

// redirect user to landing page
$location.path(LandingRoute);
}
};

// Grab saved auth data from cookies and attempt to use the leftover session
var token = $cookies.get('token');
var namespace = $cookies.get('namespace');
var path = $location.path();
if (token && namespace) {
// Pull our token / namespace from cookies
authInfo.get().token = token;
authInfo.get().namespace = namespace;
} else if (path !== VerifyAccountRoute) {
$log.debug("App started... routing to Landing");
$location.path(LandingRoute);
}

// Make _ bindable in partial views
// TODO: Investigate performance concerns here...
$rootScope._ = window._;

// Every so often, check that our token is still valid
var checkToken = function() {
NdsLabsApi.getCheckToken().then(function() { $log.debug('Token is still valid.'); }, function() {
$log.error('Token expired, redirecting to login.');
terminateSession();
});
};

// Change the tab/window title when we change routes
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
Expand All @@ -353,56 +419,13 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
// When user changes routes, check that they are still authed
$rootScope.$on( "$routeChangeStart", function(event, next, current) {
// Skip token checking for the "Verify Account" View
if (next.$$route.templateUrl === 'app/login/verify/verify.html') {
if (next.$$route.templateUrl === 'app/login/verify/verify.html'
|| next.$$route.templateUrl === 'app/landing/landing.html'
|| next.$$route.templateUrl === 'app/help/help.html'
|| next.$$route.templateUrl === 'app/login/reset/reset.html'
|| next.$$route.templateUrl === 'app/login/login.html') {
return;
}

// Define the logic for ending a user's session in the browser
var authInterval = null;
var terminateSession = authInfo.purge = function() {
// Cancel the auth check interval
if (authInterval) {
$interval.cancel(authInterval);
authInfo.tokenInterval = authInterval = null;
}

if (authInfo.get().token) {

// Purge current session data
authInfo.get().token = null;
$cookies.remove('token');
$cookies.remove('namespace');

// Close any open modals
$uibModalStack.dismissAll();

// Stop any running auto-refresh interval
AutoRefresh.stop();

// Purge any server data
ServerData.purgeAll();


// user needs to log in, redirect to /login
if (!_.includes(next.templateUrl, "app/login/login.html")
&& !_.includes(next.templateUrl, "app/login/signUp/signUp.html")
&& !_.includes(next.templateUrl, "app/login/verify/verify.html")) {
$location.path(LoginRoute);
}
}
};

// Check our token every 60s
var tokenCheckMs = 60000;

// Every so often, check that our token is still valid
var checkToken = function() {
NdsLabsApi.getCheckToken().then(function() { $log.debug('Token is still valid.'); }, function() {
$log.error('Token expired, redirecting to login.');
terminateSession();
authInfo.purge();
});
};

// Check if the token is still valid on route changes
var token = $cookies.get('token');
Expand All @@ -411,15 +434,7 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil
authInfo.get().namespace = $cookies.get('namespace');
NdsLabsApi.getRefreshToken().then(function() {
$log.debug('Token refreshed: ' + authInfo.get().token);

Loading.set(ServerData.populateAll(authInfo.get().namespace).finally(function() {
/*if (InitialRedirect) {
InitialRedirect = false;
var dest = Stacks.all.length > 0 ? HomeRoute : AppStoreRoute;
debugger;
$location.path(dest);
}*/
}));
Loading.set(ServerData.populateAll(authInfo.get().namespace));

// Restart our token check interval
if (authInterval) {
Expand All @@ -437,8 +452,6 @@ angular.module('ndslabs', [ 'navbar', 'footer', 'ndslabs-services', 'ndslabs-fil

terminateSession();
});
} else {
terminateSession();
}
});
}]);
8 changes: 5 additions & 3 deletions gui/js/app/appStore/CatalogController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ angular
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
*/
.controller('CatalogController', [ '$scope', '$filter', '$interval', '$uibModal', '$location', '$log', '_', 'NdsLabsApi', 'Project', 'Stack', 'Stacks',
'StackService', 'Specs', 'clipboard', 'Vocabulary', 'RandomPassword', 'AuthInfo', 'LoginRoute',
function($scope, $filter, $interval, $uibModal, $location, $log, _, NdsLabsApi, Project, Stack, Stacks, StackService, Specs, clipboard, Vocabulary, RandomPassword, AuthInfo, LoginRoute) {
'StackService', 'Specs', 'clipboard', 'Vocabulary', 'RandomPassword', 'AuthInfo', 'LandingRoute', 'ProductName',
function($scope, $filter, $interval, $uibModal, $location, $log, _, NdsLabsApi, Project, Stack, Stacks, StackService, Specs, clipboard, Vocabulary, RandomPassword, AuthInfo, LandingRoute, ProductName) {


if (!AuthInfo.get().token) {
$location.path(LoginRoute);
$location.path(LandingRoute);
return;
}

$scope.productName = ProductName;

$scope.tags = { all: [], selected: [] };
Vocabulary.populate("tags").then(function(data) {
Expand Down
8 changes: 5 additions & 3 deletions gui/js/app/appStore/addOrEdit/AddOrEditSpecController.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ angular
* @author lambert8
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
*/
.controller('AddOrEditSpecController', [ '$scope', '$log', '$location', '$routeParams', '_', 'NdsLabsApi', 'Specs', 'Spec', 'Vocabulary', 'Project', 'AuthInfo', 'LoginRoute',
function($scope, $log, $location, $routeParams, _, NdsLabsApi, Specs, Spec, Vocabulary, Project, AuthInfo, LoginRoute) {
.controller('AddOrEditSpecController', [ '$scope', '$log', '$location', '$routeParams', '_', 'NdsLabsApi', 'Specs', 'Spec', 'Vocabulary', 'Project', 'AuthInfo', 'LandingRoute', 'ProductName',
function($scope, $log, $location, $routeParams, _, NdsLabsApi, Specs, Spec, Vocabulary, Project, AuthInfo, LandingRoute, ProductName) {

if (!AuthInfo.get().token) {
$location.path(LoginRoute);
$location.path(LandingRoute);
return;
}

$scope.productName = ProductName;

var path = $location.path();
//$scope.editingSpec = (path.indexOf('edit') !== -1);
$scope.editingSpec = (path.indexOf('/edit/') !== -1);
Expand Down
2 changes: 1 addition & 1 deletion gui/js/app/appStore/addOrEdit/addOrEditSpec.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h3>{{ editingSpec ? 'Edit' : 'Add' }} Application<span ng-if="spec.label">: {{

<ol class="breadcrumb">
<!-- <li><a ng-href="{{ productUrl }}">{{ productName }}</a></li> -->
<li><a href="#/home">Applications</a></li>
<li><a href="#/">{{ productName }}</a></li>
<li><a ng-href="#/store">Catalog</a></li>
<li class="active">{{ editingSpec ? spec.label : 'Add Application' }}</li>
</ol>
Expand Down
2 changes: 1 addition & 1 deletion gui/js/app/appStore/catalog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h3>Catalog</h3>

<ol class="breadcrumb">
<!-- <li><a ng-href="{{ productUrl }}">{{ productName }}</a></li> -->
<li><a href="#/home">Applications</a></li>
<li><a href="#/">{{ productName }}</a></li>
<li class="active">Catalog</li>
</ol>

Expand Down
12 changes: 7 additions & 5 deletions gui/js/app/dashboard/DashboardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ angular
* @author lambert8
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
*/
.controller('DashboardController', [ '$scope', 'Loading', '$log', '$routeParams', '$location', '$interval', '$q', '$window', '$filter', '$uibModal', '_', 'Project', 'RandomPassword', 'Stack', 'Stacks', 'Specs', 'AlertService', 'AutoRefresh', 'AuthInfo', 'LoginRoute',
'StackService', 'NdsLabsApi', function($scope, Loading, $log, $routeParams, $location, $interval, $q, $window, $filter, $uibModal, _, Project, RandomPassword, Stack, Stacks, Specs, AlertService,AutoRefresh, AuthInfo, LoginRoute,

StackService, NdsLabsApi) {
.controller('DashboardController', [ '$scope', 'Loading', '$log', '$routeParams', '$location', '$interval', '$q', '$window', '$filter', '$uibModal', '_', 'Project', 'RandomPassword', 'Stack', 'Stacks', 'Specs', 'AlertService', 'AutoRefresh', 'AuthInfo', 'LandingRoute',
'StackService', 'NdsLabsApi', 'ProductName',
function($scope, Loading, $log, $routeParams, $location, $interval, $q, $window, $filter, $uibModal, _, Project, RandomPassword, Stack, Stacks, Specs, AlertService,AutoRefresh, AuthInfo, LandingRoute,
StackService, NdsLabsApi, ProductName) {

if (!AuthInfo.get().token) {
$location.path(LoginRoute);
$location.path(LandingRoute);
return;
}

$scope.productName = ProductName;

$scope.expandedStacks = {};

/**
Expand Down
6 changes: 4 additions & 2 deletions gui/js/app/dashboard/console/ConsoleController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ angular
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
*/

.controller('ConsoleController', [ '$scope', '$routeParams', '$location', '$window', '_', 'Stacks', 'AuthInfo', 'LoginRoute', function($scope, $routeParams, $location, $window, _, Stacks, AuthInfo, LoginRoute) {
.controller('ConsoleController', [ '$scope', '$routeParams', '$location', '$window', '_', 'Stacks', 'AuthInfo', 'LandingRoute', 'ProductName', function($scope, $routeParams, $location, $window, _, Stacks, AuthInfo, LandingRoute, ProductName) {

if (!AuthInfo.get().token) {
$location.path(LoginRoute);
$location.path(LandingRoute);
return;
}

$scope.productName = ProductName;

$scope.$watch(function () { return Stacks.all }, function() {

$scope.stacks = Stacks.all;
Expand Down
1 change: 1 addition & 0 deletions gui/js/app/dashboard/console/console.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ <h3><i class="fa fa-fw fa-terminal"></i> Console<span ng-if="svcId">: {{ svcId }

<ol class="breadcrumb">
<!-- <li><a ng-href="{{ productUrl }}">{{ productName }}</a></li> -->
<li><a href="#/">{{ productName }}</a></li>
<li><a href="#/home">Applications</a></li>
<li><a ng-href="#/home?expand={{ stack.key }}">{{ stack.key | specProperty:'label'}} ({{ stack.id }})</a></li>
<li><a ng-href="#/home?expand={{ stack.key }}">{{ service.id }}</a></li>
Expand Down
2 changes: 1 addition & 1 deletion gui/js/app/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3>{{ project.name | capitalize }}</h3>
</div>

<ol class="breadcrumb">
<!-- <li><a ng-href="{{ productUrl }}">{{ productName }}</a></li> -->
<li><a href="#/">{{ productName }}</a></li>
<li class="active">Applications</li>
</ol>

Expand Down
9 changes: 5 additions & 4 deletions gui/js/app/dashboard/service/AddOrEditServiceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ angular
* @author lambert8
* @see https://opensource.ncsa.illinois.edu/confluence/display/~lambert8/3.%29+Controllers%2C+Scopes%2C+and+Partial+Views
*/
.controller('AddOrEditServiceController', [ '$scope', '$routeParams', '$location', '$log', '_', 'NdsLabsApi', 'Project', 'Stacks', 'StackService', 'Specs', 'RandomPassword', 'ProductName', 'ProductUrl', 'AuthInfo', 'LoginRoute',
function($scope, $routeParams, $location, $log, _, NdsLabsApi, Project, Stacks, StackService, Specs, RandomPassword, ProductName, ProductUrl, AuthInfo, LoginRoute) {
.controller('AddOrEditServiceController', [ '$scope', '$routeParams', '$location', '$log', '_', 'NdsLabsApi', 'Project', 'Stacks', 'StackService', 'Specs', 'RandomPassword', 'ProductName', 'AuthInfo', 'LandingRoute',
function($scope, $routeParams, $location, $log, _, NdsLabsApi, Project, Stacks, StackService, Specs, RandomPassword, ProductName, AuthInfo, LandingRoute) {


if (!AuthInfo.get().token) {
$location.path(LoginRoute);
$location.path(LandingRoute);
return;
}


$scope.productName = ProductName;
$scope.productUrl = ProductUrl;


var path = $location.path();
Expand Down
2 changes: 1 addition & 1 deletion gui/js/app/dashboard/service/addOrEditService.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h3>{{ editingService ? 'Edit' : 'Add' }} {{ service.service | specProperty:'label' }}<span ng-if="service.id"> ({{ service.id }})</span></h3>

<ol class="breadcrumb">
<!-- <li><a ng-href="{{ productUrl }}">{{ productName }}</a></li> -->
<li><a href="#/">{{ productName }}</a></li>
<li><a href="#/home">Applications</a></li>
<li><a ng-href="#/home?expand={{ stack.key }}">{{ stack.key | specProperty:'label'}} ({{ stack.id }})</a></li>
<li class="active">{{ editingService ? service.id : 'New ' + (service.service | specProperty:'label') }}</li>
Expand Down
Loading

0 comments on commit 5e193a2

Please sign in to comment.