Commit e0a4a2c8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

LoginDialog contains request an account link

parent 3b80906b
"use strict";
var ConfigurationType = {
DEFAULT_MAP : "DEFAULT_MAP",
GOOGLE_ANALYTICS_IDENTIFIER : "GOOGLE_ANALYTICS_IDENTIFIER",
LOGO_IMG : "LOGO_IMG",
LOGO_LINK : "LOGO_LINK",
LEGEND_FILES : "LEGEND_FILES",
MIN_COLOR_VAL : "MIN_COLOR_VAL",
MAX_COLOR_VAL : "MAX_COLOR_VAL",
SIMPLE_COLOR_VAL : "SIMPLE_COLOR_VAL",
SEARCH_DISTANCE : "SEARCH_DISTANCE",
USER_MANUAL_FILE : "USER_MANUAL_FILE",
DEFAULT_MAP: "DEFAULT_MAP",
GOOGLE_ANALYTICS_IDENTIFIER: "GOOGLE_ANALYTICS_IDENTIFIER",
LOGO_IMG: "LOGO_IMG",
LOGO_LINK: "LOGO_LINK",
LEGEND_FILES: "LEGEND_FILES",
MIN_COLOR_VAL: "MIN_COLOR_VAL",
MAX_COLOR_VAL: "MAX_COLOR_VAL",
REQUEST_ACCOUNT_EMAIL: "REQUEST_ACCOUNT_EMAIL",
SIMPLE_COLOR_VAL: "SIMPLE_COLOR_VAL",
SEARCH_DISTANCE: "SEARCH_DISTANCE",
USER_MANUAL_FILE: "USER_MANUAL_FILE",
};
module.exports = ConfigurationType;
This diff is collapsed.
......@@ -6,6 +6,7 @@ var AbstractGuiElement = require('./AbstractGuiElement');
var GuiConnector = require('../GuiConnector');
var InvalidCredentialsError = require('../InvalidCredentialsError');
var PanelControlElementType = require('./PanelControlElementType');
var ConfigurationType = require("../ConfigurationType");
var Functions = require('../Functions');
var logger = require('../logger');
......@@ -15,18 +16,18 @@ function LoginDialog(params) {
var self = this;
self._createLoginTab();
$(self.getElement()).dialog({
autoOpen : false,
resizable : false,
autoOpen: false,
resizable: false,
});
var loginButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON);
loginButton.onclick = function() {
loginButton.onclick = function () {
var login = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT).value;
var password = self.getControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT).value;
return ServerConnector.login(login, password).then(function() {
return ServerConnector.login(login, password).then(function () {
window.location.reload(false);
}).then(null, function(error) {
}).then(null, function (error) {
if (error instanceof InvalidCredentialsError) {
GuiConnector.alert("invalid credentials");
} else {
......@@ -40,16 +41,16 @@ function LoginDialog(params) {
LoginDialog.prototype = Object.create(AbstractGuiElement.prototype);
LoginDialog.prototype.constructor = LoginDialog;
LoginDialog.prototype.createTableRow = function(elements) {
LoginDialog.prototype.createTableRow = function (elements) {
var row = Functions.createElement({
type : "div",
style : "display: table-row;"
type: "div",
style: "display: table-row;"
});
for (var i = 0; i < elements.length; i++) {
var cell = Functions.createElement({
type : "div",
style : "display: table-cell;"
type: "div",
style: "display: table-cell;"
});
cell.appendChild(elements[i]);
row.appendChild(cell);
......@@ -57,65 +58,81 @@ LoginDialog.prototype.createTableRow = function(elements) {
return row;
};
LoginDialog.prototype._createLoginTab = function() {
LoginDialog.prototype._createLoginTab = function () {
var self = this;
var authorizationFormTab = Functions.createElement({
type : "div",
style : "width:100%;display: table;border-spacing: 10px;"
type: "div",
style: "width:100%;display: table;border-spacing: 10px;"
});
this.getElement().appendChild(authorizationFormTab);
var loginLabel = Functions.createElement({
type : "div",
content : "LOGIN:"
type: "div",
content: "LOGIN:"
});
var loginInput = Functions.createElement({
type : "input",
inputType : "text",
style : "width:100%",
name : "loginText"
type: "input",
inputType: "text",
style: "width:100%",
name: "loginText"
});
this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT, loginInput);
authorizationFormTab.appendChild(self.createTableRow([ loginLabel, loginInput ]));
authorizationFormTab.appendChild(self.createTableRow([loginLabel, loginInput]));
var passwordLabel = Functions.createElement({
type : "div",
content : "PASSWORD:"
type: "div",
content: "PASSWORD:"
});
var passwordInput = Functions.createElement({
type : "input",
inputType : "password",
style : "width:100%",
name : "passwordText"
type: "input",
inputType: "password",
style: "width:100%",
name: "passwordText"
});
this.setControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT, passwordInput);
authorizationFormTab.appendChild(self.createTableRow([ passwordLabel, passwordInput ]));
authorizationFormTab.appendChild(self.createTableRow([passwordLabel, passwordInput]));
var centerTag = Functions.createElement({
type : "center"
type: "center"
});
this.getElement().appendChild(centerTag);
var loginButton = Functions.createElement({
type : "button",
name : "loginButton",
content : "LOGIN"
type: "button",
name: "loginButton",
content: "LOGIN"
});
centerTag.appendChild(loginButton);
this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON, loginButton);
this.getElement().appendChild(Functions.createElement({type: "br"}));
this.getElement().appendChild(Functions.createElement({
type: "a",
name: "requestAccount",
content: "Request an account",
href: "#",
}));
};
LoginDialog.prototype.init = function () {
var self = this;
return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_EMAIL).then(function (value) {
var link = $("[name=requestAccount]", self.getElement());
link.attr("href", "mailto:" + value + "?subject=MINERVA account request");
});
};
LoginDialog.prototype.open = function() {
LoginDialog.prototype.open = function () {
var self = this;
$(self.getElement()).dialog('option', 'title', 'AUTHORIZATION FORM');
$(self.getElement()).dialog("open");
};
LoginDialog.prototype.destroy = function() {
LoginDialog.prototype.destroy = function () {
$(this.getElement()).dialog("destroy");
};
......
......@@ -151,6 +151,7 @@ LeftPanel.prototype.init = function() {
resolve();
});
promises.push(initEvents);
promises.push(self.getLoginDialog().init());
return Promise.all(promises);
};
......
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