Commit aa4bbb08 by kevalbhatt

ATLAS-3555 : UI: Make Beta UI as primary UI for Atlas

parent 30a275d4
......@@ -26,6 +26,10 @@ header.atlas-header {
background-color: $white;
border-bottom: 1px $color_mystic_approx solid;
table {
width: 100%;
}
.navbar-nav {
display: table;
......@@ -124,6 +128,10 @@ header.atlas-header {
overflow: hidden;
@include clearfix();
}
.tab-content>.tab-pane.active {
padding: 18px;
}
}
}
......
......@@ -73,9 +73,6 @@
</div>
</div>
</div>
<div class="footer-content">
<a href="javascript:void(0)" id="sUI">Switch to Beta UI</a>
</div>
</div>
<!-- build:js scripts/main.js -->
<script data-main="js/main.js?bust=<%- bust %>" src="js/libs/requirejs/require.js?bust=<%- bust %>"></script>
......
......@@ -175,7 +175,7 @@ require.config({
'sparkline': 'libs/sparkline/jquery.sparkline.min',
'table-dragger': 'libs/table-dragger/table-dragger',
'jstree': 'libs/jstree/jstree.min',
'jquery-steps': 'libs/jquery-steps/jquery.steps.min',
'jquery-steps': 'libs/jquery-steps/jquery.steps.min'
},
/**
......@@ -252,6 +252,9 @@ require(['App',
}
}
}
if (response['atlas.ui.default.version'] !== undefined) {
Globals.DEFAULT_UI = response['atlas.ui.default.version'];
}
}
--that.asyncFetchCounter;
startApp();
......
......@@ -16,11 +16,10 @@
* limitations under the License.
*/
//Define indexOf for IE
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0); i < this.length; i++) {
for (var i = start || 0; i < this.length; i++) {
if (this[i] == obj) {
return i;
}
......@@ -31,103 +30,128 @@ if (!Array.prototype.indexOf) {
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(str, matchStr) {
return str.lastIndexOf(matchStr, 0) === 0
}
return str.lastIndexOf(matchStr, 0) === 0;
};
}
function doLogin() {
var userName = $("#username")
.val()
.trim();
var passwd = $("#password")
.val()
.trim();
var userName = $('#username').val().trim();
var passwd = $('#password').val().trim();
if (userName === '' || passwd === '') {
$('#errorBox').show();
$('#signInLoading').hide();
$('#signIn').removeAttr('disabled');
$('#errorBox .errorMsg').text("The username or password you entered is blank..");
if (userName === "" || passwd === "") {
$("#errorBox").show();
$("#signInLoading").hide();
$("#signIn").removeAttr("disabled");
$("#errorBox .errorMsg").text("The username or password you entered is blank..");
return false;
}
var baseUrl = getBaseUrl();
if (baseUrl.lastIndexOf('/') != (baseUrl.length - 1)) {
if (baseUrl) {
baseUrl = baseUrl + '/';
} else {
baseUrl = '/';
}
}
var url = baseUrl + 'j_spring_security_check';
$.ajax({
data: {
j_username: userName,
j_password: passwd
},
url: url,
type: 'POST',
url: baseUrl + "j_spring_security_check",
type: "POST",
headers: {
"cache-control": "no-cache"
},
success: function() {
var indexpath = "index.html";
if (window.localStorage.atlas_ui === "beta") {
//load beta version
indexpath = '/n/index.html';
}
if (location.hash.length > 2) {
window.location.replace((indexpath + location.hash));
} else {
window.location.replace(indexpath);
}
redirect(baseUrl);
},
error: function(jqXHR, textStatus, err) {
$('#signIn').removeAttr('disabled');
$('#signInLoading').css("visibility", "hidden");
$("#signIn").removeAttr("disabled");
$("#signInLoading").css("visibility", "hidden");
if (jqXHR.status && jqXHR.status == 412) {
$('#errorBox').hide();
$('#errorBoxUnsynced').show();
$("#errorBox").hide();
$("#errorBoxUnsynced").show();
} else {
try {
var resp = JSON.parse(jqXHR.responseText);
if (resp.msgDesc.startsWith("Username not found") || resp.msgDesc.startsWith("Wrong password")) {
$('#errorBox .errorMsg').text("Invalid User credentials. Please try again.");
$("#errorBox .errorMsg").text("Invalid User credentials. Please try again.");
} else if (resp.msgDesc.startsWith("User role credentials is not set properly")) {
$('#errorBox .errorMsg').text("User role or credentials is not set properly");
$("#errorBox .errorMsg").text("User role or credentials is not set properly");
} else {
$('#errorBox .errorMsg').text("Error while authentication");
$("#errorBox .errorMsg").text("Error while authentication");
}
} catch (err) {
$('#errorBox .errorMsg').text("Something went wrong");
$("#errorBox .errorMsg").text("Something went wrong");
}
$('#errorBox').show();
$('#errorBoxUnsynced').hide();
$("#errorBox").show();
$("#errorBoxUnsynced").hide();
}
}
});
}
function redirect(baseUrl) {
$.ajax({
url: baseUrl + "api/atlas/admin/session",
success: function(data) {
var PRIMARY_UI = "v2",
indexpath = "/n/index.html";
if (data && data["atlas.ui.default.version"]) {
PRIMARY_UI = data["atlas.ui.default.version"];
}
if (PRIMARY_UI !== "v2") {
indexpath = "index.html";
}
if (window.localStorage.last_ui_load === "v1") {
indexpath = "index.html";
} else if (window.localStorage.last_ui_load === "v2") {
indexpath = "/n/index.html";
}
if (location.hash.length > 2) {
window.location.replace(indexpath + location.hash);
} else {
window.location.replace(indexpath);
}
},
error: function() {
window.location.replace("index.html");
}
});
}
function getBaseUrl() {
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
window.location.origin =
window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
}
var baseUrl = window.location.origin + window.location.pathname.substring(window.location.pathname.indexOf("/", 2) + 1, 0);
if (baseUrl.lastIndexOf("/") != baseUrl.length - 1) {
if (baseUrl) {
baseUrl = baseUrl + "/";
} else {
baseUrl = "/";
}
}
return window.location.origin + window.location.pathname.substring(window.location.pathname
.indexOf('/', 2) + 1, 0);
return baseUrl;
}
$(function() {
// register handlers
if (!('placeholder' in HTMLInputElement.prototype)) {
if (!("placeholder" in HTMLInputElement.prototype)) {
$("#username , #password").placeholder();
}
$('#signIn').on('click', function() {
$('#signIn').attr('disabled', true);
$('#signInLoading').css("visibility", "visible");
$("#signIn").on("click", function() {
$("#signIn").attr("disabled", true);
$("#signInLoading").css("visibility", "visible");
doLogin();
return false;
});
$('#loginForm').each(function() {
$('input').keypress(function(e) {
$("#loginForm").each(function() {
$("input").keypress(function(e) {
// Enter pressed?
if (e.which == 10 || e.which == 13) {
doLogin();
......@@ -135,11 +159,15 @@ $(function() {
});
});
$('#loginForm li[class^=control-group] > input').on('change', function(e) {
if (e.target.value === '') {
$(e.target).parent().addClass('error');
$("#loginForm li[class^=control-group] > input").on("change", function(e) {
if (e.target.value === "") {
$(e.target)
.parent()
.addClass("error");
} else {
$(e.target).parent().removeClass('error');
$(e.target)
.parent()
.removeClass("error");
}
});
$("#password").on("keyup", function() {
......
......@@ -45,7 +45,6 @@ define([
initialize: function(options) {
_.extend(this, _.pick(options, 'entityDefCollection', 'typeHeaders', 'enumDefCollection', 'classificationDefCollection', 'metricCollection'));
this.showRegions();
this.bindFooterEvent();
this.bindCommonEvents();
this.listenTo(this, 'route', this.postRouteExecute, this);
this.searchVent = new Backbone.Wreqr.EventAggregator();
......@@ -73,15 +72,6 @@ define([
}
}
},
bindFooterEvent: function() {
$("body").on("click", "#sUI", function() {
var path = Utils.getBaseUrl(window.location.pathname) + "/n/index.html";
if (window.location.hash.length > 2) {
path += window.location.hash;
}
window.location.href = path;
});
},
bindCommonEvents: function() {
var that = this;
$('body').on('click', 'a.show-stat', function() {
......
......@@ -40,9 +40,10 @@
<td><a target="_blank" href="http://atlas.apache.org/"><i class="fa fa-question-circle"></i></a></td>
<td>
<a href="javascript:void(0);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="user-dropdown"><i class="fa fa-user user-circle "></i><span class="userName"></span></a>
<ul class="dropdown-menu">
<ul class="dropdown-menu pull-right multi-level">
<li class="aboutAtlas"><a href="javascript:void(0)">About</a></li>
<li role="separator" class="divider"></li>
<li><a data-id="uiSwitch" href="javascript:void(0)">Switch to New</a></li>
<li>
<a href="javascript:void(0)" data-id="signOut"><i class="fa fa-sign-out"></i>Logout</a>
</li>
......
......@@ -16,8 +16,8 @@
* limitations under the License.
*/
define(['require'], function(require) {
'use strict';
define(["require"], function(require) {
"use strict";
var Globals = {};
Globals.settings = {};
......@@ -35,7 +35,8 @@ define(['require'], function(require) {
Globals.userLogedIn = {
status: false,
response: {}
}
Globals.entityImgPath = "/img/entity-icon/"
};
Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2";
return Globals;
});
\ No newline at end of file
......@@ -225,11 +225,15 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
skipDefaultError = options.skipDefaultError;
defaultErrorMessage = options.defaultErrorMessage;
}
var redirectToLoginPage = function() {
Utils.localStorage.setValue("last_ui_load", "v1");
window.location = 'login.jsp';
}
if (error && error.status) {
if (error.status == 401) {
window.location = 'login.jsp'
redirectToLoginPage();
} else if (error.status == 419) {
window.location = 'login.jsp'
redirectToLoginPage();
} else if (error.status == 403) {
Utils.serverErrorHandler(error, "You are not authorized");
} else if (error.status == "0" && error.statusText != "abort") {
......
......@@ -34,7 +34,8 @@ define(['require',
menuHamburger: "[data-id='menuHamburger']",
globalSearch: "[data-id='globalSearch']",
clearGlobalSearch: "[data-id='clearGlobalSearch']",
signOut: "[data-id='signOut']"
signOut: "[data-id='signOut']",
uiSwitch: "[data-id='uiSwitch']"
},
events: function() {
var events = {};
......@@ -70,13 +71,19 @@ define(['require',
$('body').toggleClass("full-screen");
};
events['click ' + this.ui.signOut] = function() {
Utils.localStorage.setValue("atlas_ui", "classic");
Utils.localStorage.setValue("last_ui_load", "v1");
var path = Utils.getBaseUrl(window.location.pathname);
window.location = path + "/logout.html";
};
return events;
events["click " + this.ui.uiSwitch] = function() {
var path = Utils.getBaseUrl(window.location.pathname) + "/n/index.html";
if (window.location.hash.length > 2) {
path += window.location.hash;
}
window.location.href = path;
};
return events;
},
initialize: function(options) {
this.bindEvent();
......
......@@ -116,9 +116,6 @@
</div>
</div>
</div>
<div class="footer-content">
<a href="javascript:void(0)" id="sUI">Switch to Classic UI</a>
</div>
</div>
<!-- build:js scripts/main.js -->
<script data-main="js/main.js?bust=<%- bust %>" src="js/libs/requirejs/require.js?bust=<%- bust %>"></script>
......
......@@ -262,6 +262,9 @@ require(['App',
}
}
}
if (response['atlas.ui.default.version'] !== undefined) {
Globals.DEFAULT_UI = response['atlas.ui.default.version'];
}
}
--that.asyncFetchCounter;
startApp();
......
......@@ -16,11 +16,10 @@
* limitations under the License.
*/
//Define indexOf for IE
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0); i < this.length; i++) {
for (var i = start || 0; i < this.length; i++) {
if (this[i] == obj) {
return i;
}
......@@ -31,103 +30,128 @@ if (!Array.prototype.indexOf) {
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(str, matchStr) {
return str.lastIndexOf(matchStr, 0) === 0
}
return str.lastIndexOf(matchStr, 0) === 0;
};
}
function doLogin() {
var userName = $("#username")
.val()
.trim();
var passwd = $("#password")
.val()
.trim();
var userName = $('#username').val().trim();
var passwd = $('#password').val().trim();
if (userName === '' || passwd === '') {
$('#errorBox').show();
$('#signInLoading').hide();
$('#signIn').removeAttr('disabled');
$('#errorBox .errorMsg').text("The username or password you entered is blank..");
if (userName === "" || passwd === "") {
$("#errorBox").show();
$("#signInLoading").hide();
$("#signIn").removeAttr("disabled");
$("#errorBox .errorMsg").text("The username or password you entered is blank..");
return false;
}
var baseUrl = getBaseUrl();
if (baseUrl.lastIndexOf('/') != (baseUrl.length - 1)) {
if (baseUrl) {
baseUrl = baseUrl + '/';
} else {
baseUrl = '/';
}
}
var url = baseUrl + 'j_spring_security_check';
$.ajax({
data: {
j_username: userName,
j_password: passwd
},
url: url,
type: 'POST',
url: baseUrl + "j_spring_security_check",
type: "POST",
headers: {
"cache-control": "no-cache"
},
success: function() {
var indexpath = "index.html";
if (window.localStorage.atlas_ui === "beta") {
//load beta version
indexpath = '/n/index.html';
}
if (location.hash.length > 2) {
window.location.replace((indexpath + location.hash));
} else {
window.location.replace(indexpath);
}
redirect(baseUrl);
},
error: function(jqXHR, textStatus, err) {
$('#signIn').removeAttr('disabled');
$('#signInLoading').css("visibility", "hidden");
$("#signIn").removeAttr("disabled");
$("#signInLoading").css("visibility", "hidden");
if (jqXHR.status && jqXHR.status == 412) {
$('#errorBox').hide();
$('#errorBoxUnsynced').show();
$("#errorBox").hide();
$("#errorBoxUnsynced").show();
} else {
try {
var resp = JSON.parse(jqXHR.responseText);
if (resp.msgDesc.startsWith("Username not found") || resp.msgDesc.startsWith("Wrong password")) {
$('#errorBox .errorMsg').text("Invalid User credentials. Please try again.");
$("#errorBox .errorMsg").text("Invalid User credentials. Please try again.");
} else if (resp.msgDesc.startsWith("User role credentials is not set properly")) {
$('#errorBox .errorMsg').text("User role or credentials is not set properly");
$("#errorBox .errorMsg").text("User role or credentials is not set properly");
} else {
$('#errorBox .errorMsg').text("Error while authentication");
$("#errorBox .errorMsg").text("Error while authentication");
}
} catch (err) {
$('#errorBox .errorMsg').text("Something went wrong");
$("#errorBox .errorMsg").text("Something went wrong");
}
$('#errorBox').show();
$('#errorBoxUnsynced').hide();
$("#errorBox").show();
$("#errorBoxUnsynced").hide();
}
}
});
}
function redirect(baseUrl) {
$.ajax({
url: baseUrl + "api/atlas/admin/session",
success: function(data) {
var PRIMARY_UI = "v2",
indexpath = "/n/index.html";
if (data && data["atlas.ui.default.version"]) {
PRIMARY_UI = data["atlas.ui.default.version"];
}
if (PRIMARY_UI !== "v2") {
indexpath = "index.html";
}
if (window.localStorage.last_ui_load === "v1") {
indexpath = "index.html";
} else if (window.localStorage.last_ui_load === "v2") {
indexpath = "/n/index.html";
}
if (location.hash.length > 2) {
window.location.replace(indexpath + location.hash);
} else {
window.location.replace(indexpath);
}
},
error: function() {
window.location.replace("index.html");
}
});
}
function getBaseUrl() {
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
window.location.origin =
window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
}
var baseUrl = window.location.origin + window.location.pathname.substring(window.location.pathname.indexOf("/", 2) + 1, 0);
if (baseUrl.lastIndexOf("/") != baseUrl.length - 1) {
if (baseUrl) {
baseUrl = baseUrl + "/";
} else {
baseUrl = "/";
}
}
return window.location.origin + window.location.pathname.substring(window.location.pathname
.indexOf('/', 2) + 1, 0);
return baseUrl;
}
$(function() {
// register handlers
if (!('placeholder' in HTMLInputElement.prototype)) {
if (!("placeholder" in HTMLInputElement.prototype)) {
$("#username , #password").placeholder();
}
$('#signIn').on('click', function() {
$('#signIn').attr('disabled', true);
$('#signInLoading').css("visibility", "visible");
$("#signIn").on("click", function() {
$("#signIn").attr("disabled", true);
$("#signInLoading").css("visibility", "visible");
doLogin();
return false;
});
$('#loginForm').each(function() {
$('input').keypress(function(e) {
$("#loginForm").each(function() {
$("input").keypress(function(e) {
// Enter pressed?
if (e.which == 10 || e.which == 13) {
doLogin();
......@@ -135,11 +159,15 @@ $(function() {
});
});
$('#loginForm li[class^=control-group] > input').on('change', function(e) {
if (e.target.value === '') {
$(e.target).parent().addClass('error');
$("#loginForm li[class^=control-group] > input").on("change", function(e) {
if (e.target.value === "") {
$(e.target)
.parent()
.addClass("error");
} else {
$(e.target).parent().removeClass('error');
$(e.target)
.parent()
.removeClass("error");
}
});
$("#password").on("keyup", function() {
......
......@@ -59,7 +59,6 @@ define([
_.pick(options, "entityDefCollection", "typeHeaders", "enumDefCollection", "classificationDefCollection", "metricCollection", "nameSpaceCollection")
);
this.showRegions();
this.bindFooterEvent();
this.bindCommonEvents();
this.listenTo(this, "route", this.postRouteExecute, this);
this.searchVent = new Backbone.Wreqr.EventAggregator();
......@@ -89,15 +88,6 @@ define([
}
};
},
bindFooterEvent: function() {
$("body").on("click", "#sUI", function() {
var path = Utils.getBaseUrl(window.location.pathname) + "/index.html";
if (window.location.hash.length > 2) {
path += window.location.hash;
}
window.location.href = path;
});
},
bindCommonEvents: function() {
var that = this;
$("body").on("click", "a.show-stat", function() {
......
......@@ -51,6 +51,7 @@
</ul>
</li>
<li class="divider"></li>
<li><a data-id="uiSwitch" href="javascript:void(0)">Switch to Classic</a></li>
<li><a data-id="signOut" href="javascript:void(0)"><i class="fa fa-sign-out"></i>Logout</a></li>
</ul>
</td>
......
......@@ -16,8 +16,8 @@
* limitations under the License.
*/
define(['require'], function(require) {
'use strict';
define(["require"], function(require) {
"use strict";
var Globals = {};
Globals.settings = {};
......@@ -36,7 +36,8 @@ define(['require'], function(require) {
Globals.userLogedIn = {
status: false,
response: {}
}
Globals.entityImgPath = "/img/entity-icon/"
};
Globals.entityImgPath = "/img/entity-icon/";
Globals.DEFAULT_UI = "v2";
return Globals;
});
\ No newline at end of file
......@@ -231,11 +231,15 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
skipDefaultError = options.skipDefaultError;
defaultErrorMessage = options.defaultErrorMessage;
}
var redirectToLoginPage = function() {
Utils.localStorage.setValue("last_ui_load", "v2");
window.location = 'login.jsp';
}
if (error && error.status) {
if (error.status == 401) {
window.location = 'login.jsp'
redirectToLoginPage();
} else if (error.status == 419) {
window.location = 'login.jsp'
redirectToLoginPage();
} else if (error.status == 403) {
Utils.serverErrorHandler(error, "You are not authorized");
} else if (error.status == "0" && error.statusText != "abort") {
......
......@@ -35,7 +35,8 @@ define(['require',
backButton: "[data-id='backButton']",
menuHamburger: "[data-id='menuHamburger']",
administrator: "[data-id='administrator']",
signOut: "[data-id='signOut']"
signOut: "[data-id='signOut']",
uiSwitch: "[data-id='uiSwitch']"
},
events: function() {
var events = {};
......@@ -49,7 +50,7 @@ define(['require',
$('body').toggleClass("full-screen");
};
events['click ' + this.ui.signOut] = function() {
Utils.localStorage.setValue("atlas_ui", "beta");
Utils.localStorage.setValue("last_ui_load", "v2");
var path = Utils.getBaseUrl(window.location.pathname);
window.location = path + "/logout.html";
};
......@@ -61,6 +62,13 @@ define(['require',
updateTabState: true
});
};
events["click " + this.ui.uiSwitch] = function() {
var path = Utils.getBaseUrl(window.location.pathname) + "/index.html";
if (window.location.hash.length > 2) {
path += window.location.hash;
}
window.location.href = path;
};
return events;
......
......@@ -271,3 +271,8 @@ atlas.search.gremlin.enable=false
#atlas.headers.Access-Control-Allow-Origin=*
#atlas.headers.Access-Control-Allow-Methods=GET,OPTIONS,HEAD,PUT,POST
#atlas.headers.<headerName>=<headerValue>
######### UI Configuration ########
#atlas.ui.default.version=v2
\ No newline at end of file
......@@ -124,6 +124,8 @@ public class AdminResource {
private static final String isEntityCreateAllowed = "atlas.entity.create.allowed";
private static final String editableEntityTypes = "atlas.ui.editable.entity.types";
private static final String DEFAULT_EDITABLE_ENTITY_TYPES = "hdfs_path";
private static final String DEFAULT_UI_VERSION = "atlas.ui.default.version";
private static final String UI_VERSION_V2 = "v2";
private static final List TIMEZONE_LIST = Arrays.asList(TimeZone.getAvailableIDs());
@Context
......@@ -148,6 +150,7 @@ public class AdminResource {
private final AtlasEntityStore entityStore;
private final AtlasPatchManager patchManager;
private final AtlasAuditService auditService;
private final String defaultUIVersion;
static {
try {
......@@ -177,6 +180,11 @@ public class AdminResource {
this.importExportOperationLock = new ReentrantLock();
this.patchManager = patchManager;
this.auditService = auditService;
if (atlasProperties != null) {
defaultUIVersion = atlasProperties.getString(DEFAULT_UI_VERSION, UI_VERSION_V2);
} else {
defaultUIVersion = UI_VERSION_V2;
}
}
/**
......@@ -317,6 +325,7 @@ public class AdminResource {
responseData.put(isEntityUpdateAllowed, isEntityUpdateAccessAllowed);
responseData.put(isEntityCreateAllowed, isEntityCreateAccessAllowed);
responseData.put(editableEntityTypes, getEditableEntityTypes(atlasProperties));
responseData.put(DEFAULT_UI_VERSION, defaultUIVersion);
responseData.put("userName", userName);
responseData.put("groups", groups);
responseData.put("timezones", TIMEZONE_LIST);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment