Skip to content

Commit

Permalink
#134 Login screen has create option, removed server.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lomilar committed Apr 22, 2019
1 parent f6bb83b commit 0928c3e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/main/webapp/css/cass-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ li {
vertical-align: baseline;
}

#cassUiLoginBtn {
#cassUiLoginContainer button {
margin-top: 1.75em;
}

Expand Down
122 changes: 70 additions & 52 deletions src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html class="no-js" lang="en" dir="ltr">

<head>
<meta charset="utf-8" />
<meta charset="utf-8"/>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
Expand All @@ -12,77 +12,95 @@
<meta name="apple-mobile-web-app-title" content="CaSS">
<meta name="application-name" content="CaSS">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CaSS Explorer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>CaSS</title>
<link rel="stylesheet" href="css/jquery-ui.min.css">
<link rel="stylesheet" href="css/foundation.min.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/cass-ui.css">
</head>

<body class="login">
<div id="cassUiLoginContainer">
<div class="grid-container">
<div class="grid-x grid-padding-x">
<div class="cell medium-6 medium-offset-3">
<h1><img class="loginHeaderImg" src="img/CASS-Logo-website-white.png"> Explorer</h1>
</div>
<div class="credentials cell medium-6 medium-offset-3">
<label>Username
<input id="cassUiLoginUsername" type="text" onkeypress="checkForLoginInputEnter(event)" placeholder="Username" value="">
</label>
<label>Password
<input id="cassUiLoginPassword" type="password" onkeypress="checkForLoginInputEnter(event)" placeholder="Password" value="">
</label>
</div>
<div class="credentials cell medium-6 medium-offset-3">
<div class="grid-x grid-padding-x">
<div class="cell medium-6">
<label>Server
<select id="cassUiLoginServer">
<option value="autoDetect">Local System</option>
<option value="https://sandbox.cassproject.org/api/">CaSS Sandbox</option>
<option value="https://dev.cassproject.org/api/">CaSS Dev</option>
</select>
</label>
</div>
<div class="cell medium-4 medium-offset-2 text-right">
<button id="cassUiLoginBtn" onclick="attemptCassUiLogin()" type="button" class="warning button expanded">Log in</button>
</div>
<div id="cassUiLoginContainer">
<div class="grid-container">
<div class="grid-x grid-padding-x">
<div class="cell medium-6 medium-offset-3">
<h1><img class="loginHeaderImg" src="img/CASS-Logo-website-white.png"></h1>
</div>
<div class="credentials cell medium-6 medium-offset-3">
<label>Username
<input id="cassUiLoginUsername" type="text" onkeypress="checkForLoginInputEnter(event)"
placeholder="Username" value="">
</label>
<label>Password
<input id="cassUiLoginPassword" type="password" onkeypress="checkForLoginInputEnter(event)"
placeholder="Password" value="">
</label>
<label class="createScreen" style="display:none;">Name (Optional)
<input id="cassUiLoginName" type="text" onkeypress="checkForLoginInputEnter(event)"
placeholder="Name" value="">
</label>
<label class="createScreen" style="display:none;">Email Address (Optional)
<input id="cassUiLoginEmail" type="text" onkeypress="checkForLoginInputEnter(event)"
placeholder="[email protected]" value="">
</label>
</div>
<div class="credentials cell medium-6 medium-offset-3">
<div class="grid-x grid-padding-x">
<div class="loginScreen cell medium-6 text-right">
<button id="cassUiLoginInitBtn" onclick="$('.createScreen').show();$('.loginScreen').hide();createAccount = true;" type="button"
class="button expanded">Create Account
</button>
</div>
<div class="createScreen cell medium-6 text-right" style="display:none;">
<button id="cassUiCreateInitBtn" onclick="$('.createScreen').hide();$('.loginScreen').show();createAccount = false;" type="button"
class=" button expanded">Log in
</button>
</div>
<div class="createScreen cell medium-6 text-right" style="display:none;">
<button id="cassUiCreateBtn" onclick="attemptCassUiLogin()" type="button"
class="warning button expanded">Create Account
</button>
</div>
<div class="loginScreen cell medium-6 text-right">
<button id="cassUiLoginBtn" onclick="attemptCassUiLogin()" type="button"
class="warning button expanded">Log in
</button>
</div>
</div>
</div>
</div>
<div class="grid-x">
<div id="cassUiLoginBusyCtr" class="cell" style="display:none">
<div class="grid-container">
<div class="grid-x grid-padding-x grid-padding-y">
<div class="cell medium-12 text-center">
<img class="cassUiBusyImg" src="img/CASS-loading-white-128px.gif" />
</div>
</div>
<div class="grid-x">
<div id="cassUiLoginBusyCtr" class="cell" style="display:none">
<div class="grid-container">
<div class="grid-x grid-padding-x grid-padding-y">
<div class="cell medium-12 text-center">
<img class="cassUiBusyImg" src="img/CASS-loading-white-128px.gif"/>
</div>
</div>
</div>
<div id="cassUiLoginErrorCtr" class="cell" style="display:none">
<div class="grid-container">
<div class="grid-x grid-padding-x grid-padding-y">
<div class="cell medium-12 text-center cassUiError">
<i class="fa fa-exclamation-triangle"></i>
<h5 id="cassUiLoginErrorText"></h5>
</div>
</div>
<div id="cassUiLoginErrorCtr" class="cell" style="display:none">
<div class="grid-container">
<div class="grid-x grid-padding-x grid-padding-y">
<div class="cell medium-12 text-center cassUiError">
<i class="fa fa-exclamation-triangle"></i>
<h5 id="cassUiLoginErrorText"></h5>
</div>
</div>
</div>
</div>
</div>
</div>

<script src="js/vendor/jquery.js"></script>
<script src="js/vendor/foundation.js"></script>
<script src="js/cass/cass.min.js"></script>
<script src="/auth/js/keycloak.js"></script>
<script src="js/util/cass-ui-util.js"></script>
<script src="js/util/cass-ui-session-util.js"></script>
<script src="js/page/cass-ui-login.js"></script>
<script src="js/vendor/jquery.js"></script>
<script src="js/vendor/foundation.js"></script>
<script src="js/cass/cass.min.js"></script>
<script src="/auth/js/keycloak.js"></script>
<script src="js/util/cass-ui-util.js"></script>
<script src="js/util/cass-ui-session-util.js"></script>
<script src="js/page/cass-ui-login.js"></script>

</body>

Expand Down
31 changes: 22 additions & 9 deletions src/main/webapp/js/page/cass-ui-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
//**************************************************************************************************
// Constants

const CASSUI_LOGIN_SRV = "#cassUiLoginServer";
const CASSUI_LOGIN_UN = "#cassUiLoginUsername";
const CASSUI_LOGIN_PW = "#cassUiLoginPassword";
const CASSUI_LOGIN_NAME = "#cassUiLoginName";
const CASSUI_LOGIN_EMAIL = "#cassUiLoginEmail";
const CASSUI_LOGIN_BTN = "#cassUiLoginBtn";
const CASSUI_LOGIN_BTN = "#cassUiCreateBtn";
const CASSUI_LOGIN_BUSY_CTR = "#cassUiLoginBusyCtr";
const CASSUI_LOGIN_ERR_CTR = "#cassUiLoginErrorCtr";
const CASSUI_LOGIN_ERR_TXT = "#cassUiLoginErrorText";
Expand All @@ -21,6 +23,7 @@ const CASSUI_AFTER_LOGIN_PAGE = "cass-ui-home.html";
var inputUn;
var inputPw;
var ecIdentMgr;
var createAccount = false;

//**************************************************************************************************
// Identity Intialization
Expand All @@ -38,11 +41,16 @@ function handleFetchIdentitySuccess(obj) {
var p = new Person();
p.assignId(repo.selectedServer, ident.ppk.toPk().fingerprint());
p.addOwner(ident.ppk.toPk());
if (ssoName == null)
if ($("#cassUiLoginName").val() != null && $("#cassUiLoginName").val() != "")
p.name = $("#cassUiLoginName").val()
else if (ssoName == null)
p.name = "Unknown Person.";
else
p.name = ssoName;
p.email = ssoEmail;
if ($("#cassUiLoginEmail").val() != null && $("#cassUiLoginEmail").val() != "")
p.email = $("#cassUiLoginEmail").val();
else
p.email = ssoEmail;
EcRepository.save(p, console.log, console.error);
} else
handleFetchIdentitySuccess2(obj);
Expand All @@ -69,7 +77,7 @@ function handleFetchIdentitySuccess2(obj) {

function handleFetchIdentityFailure(failMsg) {
debugMessage("handleFetchIdentityFailure: " + failMsg);
if (failMsg.trim() == "User does not exist.") {
if ((createAccount||ssoName != null) && failMsg.trim() == "User does not exist.") {
ecIdentMgr.create(handleConfigureFromServerSuccess, handleFetchIdentityFailure);
} else {
showLoginErrorMessage("Identity fetch failed: " + failMsg);
Expand Down Expand Up @@ -111,21 +119,27 @@ function checkForLoginInputEnter(event) {

function disableAllLoginInputs() {
$(CASSUI_LOGIN_BTN).attr("disabled", "true");
$(CASSUI_LOGIN_SRV).attr("disabled", "true");
$(CASSUI_CREATE_BTN).attr("disabled", "true");
$(CASSUI_LOGIN_UN).attr("readonly", "true");
$(CASSUI_LOGIN_PW).attr("readonly", "true");
$(CASSUI_LOGIN_NAME).attr("readonly", "true");
$(CASSUI_LOGIN_EMAIL).attr("readonly", "true");
}

function enableAllLoginInputs() {
$(CASSUI_LOGIN_BTN).removeAttr("disabled");
$(CASSUI_LOGIN_SRV).removeAttr("disabled");
$(CASSUI_CREATE_BTN).removeAttr("disabled");
$(CASSUI_LOGIN_UN).removeAttr("readonly");
$(CASSUI_LOGIN_PW).removeAttr("readonly");
$(CASSUI_LOGIN_NAME).removeAttr("readonly");
$(CASSUI_LOGIN_EMAIL).removeAttr("readonly");
}

function clearLoginInputs() {
$(CASSUI_LOGIN_UN).val("");
$(CASSUI_LOGIN_PW).val("");
$(CASSUI_LOGIN_NAME).val("");
$(CASSUI_LOGIN_EMAIL).val("");
}

function hideLoginBusy() {
Expand All @@ -148,10 +162,9 @@ function showLoginErrorMessage(errMsg) {
}

function areLoginParamsValid() {
var srv = $(CASSUI_LOGIN_SRV).val();
var un = $(CASSUI_LOGIN_UN).val().trim();
var pw = $(CASSUI_LOGIN_PW).val().trim();
if (!srv || srv == null || !un || un == null || un.length == 0 || !pw || pw == null || pw.length == 0) {
if (!un || un == null || un.length == 0 || !pw || pw == null || pw.length == 0) {
showLoginErrorMessage("Username, password, and server are all required");
return false;
}
Expand All @@ -167,7 +180,7 @@ function attemptCassUiLogin() {
if (areLoginParamsValid()) {
disableAllLoginInputs();
showLoginBusy();
selectedServer = $(CASSUI_LOGIN_SRV).val();
selectedServer = "autoDetect";
inputUn = $(CASSUI_LOGIN_UN).val().trim();
inputPw = $(CASSUI_LOGIN_PW).val().trim();
$(CASSUI_LOGIN_PW).val("");
Expand Down

0 comments on commit 0928c3e

Please sign in to comment.