NIFI-655:

- Updating available links during login, registration, and account status review.
This commit is contained in:
Matt Gilman 2015-11-24 00:37:47 -05:00
parent f2d82ee140
commit 1312bde498
8 changed files with 87 additions and 57 deletions

View File

@ -37,8 +37,16 @@
${nf.login.script.tags}
</head>
<body class="login-body">
<div id="user-logout-container" class="hidden">
<span id="user-logout" class="link">logout</span>
<div id="login-user-links-container">
<ul id="login-user-links" class="links">
<li id="user-logout-container" style="display: none;">
<span id="user-logout" class="link">logout</span>
</li>
<li>
<span id="user-home" class="link">home</span>
</li>
</ul>
<div class="clear"></div>
</div>
<div id="login-contents-container">
<jsp:include page="/WEB-INF/partials/login/login-message.jsp"/>

View File

@ -43,7 +43,7 @@
</div>
</div>
<div id="header-links-container">
<ul>
<ul class="links">
<li id="current-user-container">
<div id="anonymous-user-alert" class="hidden"></div>
<div id="current-user"></div>

View File

@ -16,8 +16,15 @@
--%>
<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
<div id="message-pane" class="message-pane hidden">
<div id="user-logout-container" class="hidden">
<span id="user-logout" class="link">logout</span>
<div id="user-links-container">
<ul class="links">
<li id="user-logout-container" style="display: none;">
<span id="user-logout" class="link">logout</span>
</li>
<li>
<span id="user-home" class="link">home</span>
</li>
</ul>
</div>
<div class="message-pane-message-box">
<div id="message-title" class="message-pane-title"></div>

View File

@ -658,27 +658,10 @@ div.bulletin-board-hover {
#header-links-container {
position: absolute;
top: 1px;
right: 0px;
right: 10px;
z-index: 100;
}
#header-links-container li {
float: left;
display: block;
margin-right: 10px;
padding: 4px;
text-align: center;
font-size: .8em;
font-weight: normal;
text-decoration: none;
}
#header-links-container span.header-link-over {
color: #264c58;
text-decoration: underline;
}
#has-pending-accounts {
background-image: url(../images/starburst.png);
width: 9px;

View File

@ -48,6 +48,21 @@
color: #000;
}
#login-user-links-container {
position: absolute;
top: 0px;
left: 0px;
padding-top: 100px;
padding-left: 100px;
font-family: Verdana, Geneva, sans-serif;
z-index: 1300;
width: 412px;
}
#login-user-links {
float: right;
}
/*
Login
*/

View File

@ -77,14 +77,26 @@ div.context-menu-provenance {
background-position: top left;
}
#user-logout-container {
#user-links-container {
position: absolute;
left: 478px;
left: 550px;
top: 100px;
z-index: 1300;
}
#user-logout {
ul.links li {
float: left;
display: block;
margin-left: 10px;
padding: 4px;
text-align: center;
font-size: 11px;
font-weight: normal;
text-decoration: none;
}
ul.links span.header-link-over {
color: #264c58;
text-decoration: underline;
}

View File

@ -109,12 +109,25 @@ nf.Login = (function () {
// check to see if they actually have access now
$.ajax({
type: 'GET',
url: config.urls.identity,
url: config.urls.accessStatus,
dataType: 'json'
}).done(function (response) {
if (response.identity === 'anonymous') {
showLogoutLink();
var accessStatus = response.accessStatus;
// update the logout link appropriately
showLogoutLink();
// update according to the access status
if (accessStatus.status === 'UNKNOWN' || accessStatus.status === 'NOT_ACTIVE') {
$('#login-message-title').text('Unable to log in');
$('#login-message').text(accessStatus.message);
// update visibility
$('#login-container').hide();
$('#login-submission-container').hide();
$('#login-progress-container').hide();
$('#login-message-container').show();
} else if (accessStatus.status === 'UNREGISTERED') {
// schedule automatic token refresh
nf.Common.scheduleTokenRefresh();
@ -128,7 +141,7 @@ nf.Login = (function () {
// update the form visibility
$('#login-submission-container').show();
$('#login-progress-container').hide();
} else {
} else if (accessStatus.status === 'ACTIVE') {
// reload as appropriate - no need to schedule token refresh as the page is reloading
if (top !== window) {
parent.window.location = '/nifi';
@ -137,31 +150,14 @@ nf.Login = (function () {
}
}
}).fail(function (xhr, status, error) {
showLogoutLink();
$('#login-message-title').text('Unable to log in');
$('#login-message').text(xhr.responseText);
// schedule automatic token refresh
nf.Common.scheduleTokenRefresh();
// show the user
$('#nifi-user-submit-justification').text(token['preferred_username']);
if (xhr.status === 401) {
initializeNiFiRegistration();
showNiFiRegistration();
// update the form visibility
$('#login-submission-container').show();
$('#login-progress-container').hide();
} else {
$('#login-message-title').text('Unable to log in');
$('#login-message').text(xhr.responseText);
// update visibility
$('#login-container').hide();
$('#login-submission-container').hide();
$('#login-progress-container').hide();
$('#login-message-container').show();
}
// update visibility
$('#login-container').hide();
$('#login-submission-container').hide();
$('#login-progress-container').hide();
$('#login-message-container').show();
});
}).fail(function (xhr, status, error) {
nf.Dialog.showOkDialog({

View File

@ -74,7 +74,7 @@ $(document).ready(function () {
// shows the logout link in the message-pane when appropriate and schedule token refresh
if (nf.Storage.getItem('jwt') !== null) {
$('#user-logout-container').show();
$('#user-logout-container').css('display', 'block');
nf.Common.scheduleTokenRefresh();
}
@ -83,6 +83,15 @@ $(document).ready(function () {
nf.Storage.removeItem('jwt');
window.location = '/nifi/login';
});
// handle home
$('#user-home').on('click', function () {
if (top !== window) {
parent.window.location = '/nifi';
} else {
window.location = '/nifi';
}
});
});
// Define a common utility class used across the entire application.
@ -447,9 +456,9 @@ nf.Common = (function () {
*/
showLogoutLink: function () {
if (nf.Storage.getItem('jwt') === null) {
$('#user-logout-container').hide();
$('#user-logout-container').css('display', 'none');
} else {
$('#user-logout-container').show();
$('#user-logout-container').css('display', 'block');
}
},