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

logged user can change password

parent 4490f196
......@@ -2,6 +2,7 @@ minerva (15.1.0) unstable; urgency=medium
* Small improvement: annotations are exported in SBGN extension that can be
opened by newt (#1296)
* Small improvement: plugin API allows to add/remove data overlays (#1153)
* Small improvement: logged user can change password (#1119)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 18 Jun 2020 16:00:00 +0200
......
......@@ -872,6 +872,10 @@ a.minerva-search-link:hover {
content: "\000a0\000a0\000a0\000a0\000a0\000a0"
}
.minerva-change-password-button {
margin-right: 5px;
}
.nav > li > a {
text-decoration: none;
}
......
......@@ -42,6 +42,75 @@ function ProjectInfoPanel(params) {
return ServerConnector.logout().catch(GuiConnector.alert);
};
$("button.minerva-change-password-button", self.getElement()).on('click', function () {
return self.getServerConnector().getLoggedUser().then(function (user) {
var content = $('<div/>').html("<div><table class='display'></table>" +
"<div class='minerva-menu-row'>" +
"<button class='minerva-save-button' disabled='disabled'><span class='ui-icon ui-icon-disk'></span>&nbsp;SAVE</button>" +
"<button class='minerva-cancel-button'><span class='ui-icon ui-icon-cancel'></span>&nbsp;CANCEL</button>" +
"</div>" +
"</div>");
$(content).dialog({
dialogClass: 'minerva-change-password-dialog',
title: "Change password",
width: 420,
height: 240,
close: function () {
$(content).dialog("destroy");
dataTable.destroy();
}
});
// noinspection JSCheckFunctionSignatures
var dataTable = $("table", content).DataTable({
columns: [{
title: "Name"
}, {
title: "Value"
}],
paging: false,
ordering: false,
searching: false,
bInfo: false
});
var data = [];
data.push(['Password', "<input type='password' class='minerva-password' autocomplete='new-password'>"]);
data.push(['Repeat password', "<input type='password' class='minerva-password-2' autocomplete='new-password'/>"]);
dataTable.clear().rows.add(data).draw();
$('.minerva-password, .minerva-password-2').on('keyup', function () {
if ($('.minerva-password').val() === $('.minerva-password-2').val()) {
if ($('.minerva-password').val() !== "") {
$(".minerva-save-button").prop('disabled', false);
} else {
$(".minerva-save-button").prop('disabled', true);
}
} else {
$(".minerva-save-button").prop('disabled', true);
}
});
$(".minerva-save-button", content).on("click", function () {
GuiConnector.showProcessing();
return self.getServerConnector().getLoggedUser().then(function (user) {
user.setPassword($('.minerva-password').val());
return self.getServerConnector().updateUser(user);
}).catch(GuiConnector.alert).finally(function () {
$(content).dialog("destroy");
dataTable.destroy();
GuiConnector.hideProcessing();
});
});
$(".minerva-cancel-button", content).on("click", function () {
$(content).dialog("destroy");
dataTable.destroy();
});
});
});
}
ProjectInfoPanel.prototype = Object.create(Panel.prototype);
......@@ -352,7 +421,7 @@ ProjectInfoPanel.prototype._createUserDataTab = function () {
var loginText = Functions.createElement({
type: "span",
name: "loginValue",
style:"padding-left:5px"
style: "padding-left:5px"
});
this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_TEXT, loginText);
userDataDiv.appendChild(guiUtils.createTableRow([loginLabel, loginText]));
......@@ -365,7 +434,7 @@ ProjectInfoPanel.prototype._createUserDataTab = function () {
var nameText = Functions.createElement({
type: "span",
name: "nameValue",
style:"padding-left:5px"
style: "padding-left:5px"
});
this.setControlElement(PanelControlElementType.USER_TAB_NAME_TEXT, nameText);
userDataDiv.appendChild(guiUtils.createTableRow([nameLabel, nameText]));
......@@ -378,7 +447,7 @@ ProjectInfoPanel.prototype._createUserDataTab = function () {
var surnameText = Functions.createElement({
type: "span",
name: "surnameValue",
style:"padding-left:5px"
style: "padding-left:5px"
});
this.setControlElement(PanelControlElementType.USER_TAB_SURNAME_TEXT, surnameText);
userDataDiv.appendChild(guiUtils.createTableRow([surnameLabel, surnameText]));
......@@ -391,7 +460,7 @@ ProjectInfoPanel.prototype._createUserDataTab = function () {
var emailText = Functions.createElement({
type: "span",
name: "emailValue",
style:"padding-left:5px"
style: "padding-left:5px"
});
self.setControlElement(PanelControlElementType.USER_TAB_EMAIL_TEXT, emailText);
userDataDiv.appendChild(guiUtils.createTableRow([emailLabel, emailText]));
......@@ -402,6 +471,12 @@ ProjectInfoPanel.prototype._createUserDataTab = function () {
});
userDataDiv.appendChild(centerTag);
centerTag.appendChild(Functions.createElement({
type: "button",
className: "minerva-change-password-button",
content: "Change Password"
}));
var logoutButton = Functions.createElement({
type: "button",
name: "logoutButton",
......
Supports Markdown
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