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

Commit

Permalink
[BZ 1069667] - (JON3-17) Make JON login look like other Red Hat produ…
Browse files Browse the repository at this point in the history
…cts - RHQ branding & handling error cases during login process.
  • Loading branch information
jkremser committed Apr 7, 2014
1 parent b942688 commit 8f3d81d
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Timer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import java.util.Map;
import java.util.Set;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
Expand Down Expand Up @@ -114,6 +114,8 @@ public class LoginView extends Canvas {
private static final String USERNAME_ID = "inputUsername";
private static final String PASSWORD_ID = "inputPassword";
private static final String LOGIN_DIV_ID = "patternFlyLogin";
private static final String LOGIN_ERROR_DIV_ID = "loginError";
private static final String ERROR_FEEDBACK_DIV_ID = "errorFeedback";
private static final String HTML_ID = "htmlId";

private ProductInfo productInfo;
Expand All @@ -125,6 +127,11 @@ public void showLoginDialog(String message) {

public void showLoginDialog() {
if (!loginShowing) {
if (!com.google.gwt.user.client.Window.Location.getHref().contains("login")) {
redirectTo("login");
return;
}

loginShowing = true;
UserSessionManager.logout();

Expand Down Expand Up @@ -198,7 +205,7 @@ public void onKeyPress(KeyPressEvent event) {
window.setAutoCenter(true);

window.addItem(form);
setLoginVisible(true);
// setLoginVisible(true);

form.addSubmitValuesHandler(new SubmitValuesHandler() {
public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
Expand Down Expand Up @@ -564,10 +571,12 @@ public void onResponseReceived(Request request, Response response) {
int statusCode = response.getStatusCode();
if (statusCode == 200) {
window.destroy();
setLoginVisible(false);
// setLoginVisible(false);
fakeForm.setVisible(false);
loginShowing = false;
UserSessionManager.login(username, password);
redirectTo(""); // root path
setLoginError(null);
} else {
handleError(statusCode);
}
Expand Down Expand Up @@ -596,10 +605,13 @@ public void onTypesLoaded(Map<Integer, ResourceType> types) {
private void handleError(int statusCode) {
if (statusCode == 401) {
form.setFieldErrors("login", MSG.view_login_noUser(), true);
setLoginError(MSG.view_login_noUser());
} else if (statusCode == 503) {
form.setFieldErrors("login", MSG.view_core_serverInitializing(), true);
setLoginError(MSG.view_core_serverInitializing());
} else {
form.setFieldErrors("login", MSG.view_login_noBackend(), true);
setLoginError(MSG.view_login_noBackend());
}
loginButton.setDisabled(false);
}
Expand Down Expand Up @@ -636,9 +648,14 @@ private void setUsername(String username) {
((InputElement) Document.get().getElementById(USERNAME_ID)).setValue(username);
}

private void setLoginVisible(boolean show) {
DOM.getElementById(LOGIN_DIV_ID).getStyle().setDisplay(show ? Display.BLOCK : Display.NONE);
DOM.getElementById(HTML_ID).setClassName(show ? "login-pf" : "");
// private void setLoginVisible(boolean show) {
// DOM.getElementById(LOGIN_DIV_ID).getStyle().setDisplay(show ? Display.BLOCK : Display.NONE);
// DOM.getElementById(HTML_ID).setClassName(show ? "login-pf" : "");
// }

private void setLoginError(String error) {
DOM.getElementById(LOGIN_ERROR_DIV_ID).setInnerHTML(error);
DOM.getElementById(ERROR_FEEDBACK_DIV_ID).setClassName(error != null ? "showError" : "hideError");
}

// This is our JSNI method that will be called on form submit
Expand All @@ -647,5 +664,8 @@ private native void injectLoginFunction(LoginView view) /*-{
view.@org.rhq.coregui.client.LoginView::doLogin()();
});
}-*/;


private void redirectTo(String path) {
com.google.gwt.user.client.Window.Location.replace(GWT.getHostPageBaseURL() + path);
}
}
54 changes: 1 addition & 53 deletions modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<html id="htmlId" xmlns="http://www.w3.org/1999/html">
<html xmlns="http://www.w3.org/1999/html">
<head>
<!-- this forces us to emulate IE8 "quirks" mode regardless of IE browser version. It:
1) Follows the SmartGWT recommendation of not declaring a DOCTYPE and instead using these meta elements.
Expand All @@ -13,11 +13,6 @@
<link rel="stylesheet" href="CoreGUI-4.10.0.css">
<!-- for d3 charting -->
<link rel="stylesheet" href="css/charts-4.10.0.css">

<!-- PatternFly -->
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<link href="css/patternfly.min.css" rel="stylesheet" media="screen, print">
<script src="js/bootstrap.min.js"></script>

<script type="text/javascript">
var search = location.search;
Expand Down Expand Up @@ -75,53 +70,6 @@ <h1>Your browser does not support JavaScript!</h1>
<h2>Please turn it on or use a different browser.</h2>
</noscript>

<div id="patternFlyLogin" style="display: none;">
<span id="badge">
<img src="img/logo.svg" alt="" />
</span>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div id="brand">
<img src="img/brand.svg">
</div><!--/#brand-->
</div><!--/.col-*-->
<div class="col-sm-7 col-md-6 col-lg-5 login">
<form action="login" id="loginForm" autocomplete="on" class="form-horizontal" role="form">
<div class="form-group">
<label for="inputUsername" class="col-sm-2 col-md-2 control-label">Username</label>
<div class="col-sm-10 col-md-10">
<input type="text" class="form-control" id="inputUsername" placeholder="" tabindex="1">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-sm-2 col-md-2 control-label">Password</label>
<div class="col-sm-10 col-md-10">
<input type="password" class="form-control" id="inputPassword" placeholder="" tabindex="2">
</div>
</div>
<div class="form-group">
<div class="col-xs-8 col-sm-offset-2 col-sm-6 col-md-offset-2 col-md-6">
<div class="checkbox">
<label>
<input type="checkbox" tabindex="3"> Remember Username
</label>
</div>
<span class="help-block"> Forgot <a href="#" tabindex="5">Username</a> or <a href="#" tabindex="6">Password</a>?</span>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 submit">
<button id="loginSubmit" type="submit" class="btn btn-primary btn-lg" tabindex="4">Log In</button>
</div>
</div>
</form>
</div><!--/.col-*-->
<div class="col-sm-5 col-md-6 col-lg-7 details">
<p><strong>Welcome to PatternFly!</strong>
This is placeholder text, only. Use this area to place any information or introductory message about your application that may be relevant for users. For example, you might include news or information about the latest release of your product here&mdash;such as a version number.</p>
</div><!--/.col-*-->
</div><!--/.row-->
</div><!--/.container-->
</div>

<iframe src="javascript:''" id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe>

Expand Down

Large diffs are not rendered by default.

Binary file modified modules/enterprise/gui/coregui/src/main/webapp/img/bg-login.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
84 changes: 0 additions & 84 deletions modules/enterprise/gui/coregui/src/main/webapp/img/brand.svg

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified modules/enterprise/gui/coregui/src/main/webapp/img/logo.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8f3d81d

Please sign in to comment.