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} ${nf.login.script.tags}
</head> </head>
<body class="login-body"> <body class="login-body">
<div id="user-logout-container" class="hidden"> <div id="login-user-links-container">
<span id="user-logout" class="link">logout</span> <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>
<div id="login-contents-container"> <div id="login-contents-container">
<jsp:include page="/WEB-INF/partials/login/login-message.jsp"/> <jsp:include page="/WEB-INF/partials/login/login-message.jsp"/>

View File

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

View File

@ -16,8 +16,15 @@
--%> --%>
<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %> <%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %>
<div id="message-pane" class="message-pane hidden"> <div id="message-pane" class="message-pane hidden">
<div id="user-logout-container" class="hidden"> <div id="user-links-container">
<span id="user-logout" class="link">logout</span> <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>
<div class="message-pane-message-box"> <div class="message-pane-message-box">
<div id="message-title" class="message-pane-title"></div> <div id="message-title" class="message-pane-title"></div>

View File

@ -658,27 +658,10 @@ div.bulletin-board-hover {
#header-links-container { #header-links-container {
position: absolute; position: absolute;
top: 1px; right: 10px;
right: 0px;
z-index: 100; 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 { #has-pending-accounts {
background-image: url(../images/starburst.png); background-image: url(../images/starburst.png);
width: 9px; width: 9px;

View File

@ -48,6 +48,21 @@
color: #000; 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 Login
*/ */

View File

@ -77,14 +77,26 @@ div.context-menu-provenance {
background-position: top left; background-position: top left;
} }
#user-logout-container { #user-links-container {
position: absolute; position: absolute;
left: 478px; left: 550px;
top: 100px; top: 100px;
z-index: 1300; 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; text-decoration: underline;
} }

View File

@ -109,12 +109,25 @@ nf.Login = (function () {
// check to see if they actually have access now // check to see if they actually have access now
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: config.urls.identity, url: config.urls.accessStatus,
dataType: 'json' dataType: 'json'
}).done(function (response) { }).done(function (response) {
if (response.identity === 'anonymous') { var accessStatus = response.accessStatus;
showLogoutLink();
// 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 // schedule automatic token refresh
nf.Common.scheduleTokenRefresh(); nf.Common.scheduleTokenRefresh();
@ -128,7 +141,7 @@ nf.Login = (function () {
// update the form visibility // update the form visibility
$('#login-submission-container').show(); $('#login-submission-container').show();
$('#login-progress-container').hide(); $('#login-progress-container').hide();
} else { } else if (accessStatus.status === 'ACTIVE') {
// reload as appropriate - no need to schedule token refresh as the page is reloading // reload as appropriate - no need to schedule token refresh as the page is reloading
if (top !== window) { if (top !== window) {
parent.window.location = '/nifi'; parent.window.location = '/nifi';
@ -137,31 +150,14 @@ nf.Login = (function () {
} }
} }
}).fail(function (xhr, status, error) { }).fail(function (xhr, status, error) {
showLogoutLink(); $('#login-message-title').text('Unable to log in');
$('#login-message').text(xhr.responseText);
// schedule automatic token refresh // update visibility
nf.Common.scheduleTokenRefresh(); $('#login-container').hide();
$('#login-submission-container').hide();
// show the user $('#login-progress-container').hide();
$('#nifi-user-submit-justification').text(token['preferred_username']); $('#login-message-container').show();
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();
}
}); });
}).fail(function (xhr, status, error) { }).fail(function (xhr, status, error) {
nf.Dialog.showOkDialog({ 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 // shows the logout link in the message-pane when appropriate and schedule token refresh
if (nf.Storage.getItem('jwt') !== null) { if (nf.Storage.getItem('jwt') !== null) {
$('#user-logout-container').show(); $('#user-logout-container').css('display', 'block');
nf.Common.scheduleTokenRefresh(); nf.Common.scheduleTokenRefresh();
} }
@ -83,6 +83,15 @@ $(document).ready(function () {
nf.Storage.removeItem('jwt'); nf.Storage.removeItem('jwt');
window.location = '/nifi/login'; 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. // Define a common utility class used across the entire application.
@ -447,9 +456,9 @@ nf.Common = (function () {
*/ */
showLogoutLink: function () { showLogoutLink: function () {
if (nf.Storage.getItem('jwt') === null) { if (nf.Storage.getItem('jwt') === null) {
$('#user-logout-container').hide(); $('#user-logout-container').css('display', 'none');
} else { } else {
$('#user-logout-container').show(); $('#user-logout-container').css('display', 'block');
} }
}, },