Commit 5204e860 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

frontend shows session expire button when session time runs below 10 minutes

parent 24ba5c12
Pipeline #6557 passed with stage
in 7 minutes
......@@ -148,6 +148,32 @@
border-right: 1px solid #9DE1F8;
}
.minerva-session-expire {
background: #EE0000;
display: inline;
width: auto;
height: 36px;
float: left;
line-height: 34px;
padding: 0 0 0 17px;
color: #FFFFFF;
font-weight: 900;
font-size: 13px;
text-align: center;
border-right: 1px solid #9DE1F8;
}
.minerva-extend-session-button {
background-color: #CC0000;
margin-left: 10px;
border: 0px;
}
.minerva-extend-session-button:hover {
background-color: #880000;
transition: background-color 0.4s ease-in-out 0s;
}
.minerva-legend {
position: absolute;
bottom: 10px;
......
......@@ -489,7 +489,7 @@ ServerConnector.getReferenceGenomeUrl = function (queryParams, filterParams) {
return this.getApiUrl({
type: "genomics/taxonomies/" + queryParams.organism + "/genomeTypes/" + queryParams.type + "/versions/" + version
+ "/",
+ "/",
params: filterParams
});
}
......@@ -539,7 +539,7 @@ ServerConnector.getReferenceGenomeGeneMappingsUrl = function (queryParams, filte
ServerConnector.getAvailableGenomeUrlsUrl = function (queryParams, filterParams) {
return this.getApiUrl({
type: "genomics/taxonomies/" + queryParams.organism.getResource() + "/genomeTypes/" + queryParams.type + "/versions/" + queryParams.version
+ ":getAvailableRemoteUrls",
+ ":getAvailableRemoteUrls",
params: filterParams
});
};
......@@ -933,6 +933,14 @@ ServerConnector.getConfiguration = function () {
}
};
/**
*
* @returns {Promise}
*/
ServerConnector.extendSession = function () {
return this.sendGetRequest(this.getConfigurationUrl())
};
ServerConnector.getConfigurationParam = function (paramId) {
if (paramId === undefined) {
return Promise.reject(new Error("Unknown param type"));
......
......@@ -81,6 +81,12 @@ TopMenu.prototype._createGui = function () {
self.getElement().appendChild(versionDiv);
self.setControlElement(PanelControlElementType.MENU_VERSION_DIV, versionDiv);
self.getElement().appendChild(Functions.createElement({
type: "div",
className: "minerva-session-expire",
style: "display:none;"
}));
var showOverviewDiv = Functions.createElement({
type: "div",
style: "float: left;"
......@@ -299,10 +305,12 @@ TopMenu.prototype.checkIfSessionIsGoingToExpire = function () {
//if session is going to expire in 10 minutes show information
if (sessionExpireTimestamp - currentTimestamp < 10 * 60) {
self.showSessionExpire(sessionExpireTimestamp - currentTimestamp);
} else {
self.hideSessionExpire();
}
//if session expired 10 seconds ago force logout
if (sessionExpireTimestamp < currentTimestamp - 10) {
//if session expired
if (sessionExpireTimestamp < currentTimestamp) {
return self.getServerConnector().logout();
}
return Promise.resolve();
......@@ -310,9 +318,29 @@ TopMenu.prototype.checkIfSessionIsGoingToExpire = function () {
/**
*
* @param {number} timeInSeconds
*/
TopMenu.prototype.showSessionExpire = function (timeInSeconds) {
console.log("Session is going to expire in " + timeInSeconds + " seconds");
var self = this;
var minutes = Math.floor(timeInSeconds / 60);
var seconds = Math.floor(timeInSeconds - minutes * 60);
var message = "Session expires in " + minutes + " minutes " + seconds + " seconds";
var button = Functions.createElement({
type: "button",
content: "EXTEND",
className: "minerva-extend-session-button",
onclick: function () {
return self.getServerConnector().extendSession();
}
});
$(".minerva-session-expire", self.getElement()).empty().append("<span>" + message + "</span>").append(button).show();
};
/**
*
*/
TopMenu.prototype.hideSessionExpire = function () {
$(".minerva-session-expire", this.getElement()).empty().hide();
};
module.exports = TopMenu;
\ No newline at end of file
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