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

Merge branch '342-admin-panel-lost-privileges-to-the-map-upon-upload' into 'master'

Resolve "Admin panel: lost privileges to the map upon upload"

Closes #342

See merge request piotr.gawron/minerva!247
parents 40f1b78b 992e3964
Pipeline #4279 passed with stage
in 1 minute and 4 seconds
......@@ -8,6 +8,7 @@ var AddOverlayDialog = require('../AddOverlayDialog');
var Annotation = require('../../map/data/Annotation');
var CommentsTab = require('./CommentsAdminPanel');
var GuiConnector = require('../../GuiConnector');
var PrivilegeType = require('../../map/data/PrivilegeType');
var Functions = require('../../Functions');
// noinspection JSUnusedLocalSymbols
......@@ -119,6 +120,17 @@ EditProjectDialog.prototype.addTab = function (params) {
}
params.tabContentDiv.appendChild(contentDiv);
if (params.disabled) {
this.disableTab(params);
}
};
EditProjectDialog.prototype.disableTab = function (params) {
$("a[href='#" + params.id + "']", this.getElement()).hide();
};
EditProjectDialog.prototype.enableTab = function (params) {
$("a[href='#" + params.id + "']", this.getElement()).show();
};
EditProjectDialog.prototype.createGeneralTabContent = function () {
......@@ -554,10 +566,19 @@ EditProjectDialog.prototype.initUsersTab = function () {
EditProjectDialog.prototype.refreshOverlays = function () {
var self = this;
return ServerConnector.getOverlays({
projectId: self.getProject().getProjectId()
}).then(function (overlays) {
return self.setOverlays(overlays);
return ServerConnector.getLoggedUser().then(function (user) {
var privilege = self.getConfiguration().getPrivilegeType(PrivilegeType.USER_MANAGEMENT);
//we need to refresh users as well because of privileges
if (user.hasPrivilege(privilege)) {
return ServerConnector.getOverlays({
projectId: self.getProject().getProjectId()
}).then(function (overlays) {
return self.setOverlays(overlays);
});
} else {
self.disableTab({id: self.getProject().getProjectId() + "_overlays_tab"});
return Promise.resolve();
}
});
};
......@@ -570,8 +591,17 @@ EditProjectDialog.prototype.refreshMaps = function () {
EditProjectDialog.prototype.refreshUsers = function () {
var self = this;
return ServerConnector.getUsers().then(function (users) {
return self.setUsers(users);
return ServerConnector.getLoggedUser().then(function (user) {
var privilege = self.getConfiguration().getPrivilegeType(PrivilegeType.USER_MANAGEMENT);
//we need to refresh users as well because of privileges
if (user.hasPrivilege(privilege)) {
return ServerConnector.getUsers(true).then(function (users) {
return self.setUsers(users);
});
} else {
self.disableTab({id: self.getProject().getProjectId() + "_users_tab"});
return Promise.resolve();
}
});
};
......
......@@ -6,6 +6,7 @@ var AbstractAdminPanel = require('./AbstractAdminPanel');
var AddProjectDialog = require('./AddProjectDialog');
var EditProjectDialog = require('./EditProjectDialog');
var LogListDialog = require('./LogListDialog');
var PrivilegeType = require('../../map/data/PrivilegeType');
// noinspection JSUnusedLocalSymbols
var logger = require('../../logger');
......@@ -286,8 +287,15 @@ MapsAdminPanel.prototype.onRefreshClicked = function () {
return ServerConnector.getProjects(true).then(function (projects) {
return self.setProjects(projects);
}).then(function () {
return ServerConnector.getLoggedUser();
}).then(function (user) {
var privilege = self.getConfiguration().getPrivilegeType(PrivilegeType.USER_MANAGEMENT);
//we need to refresh users as well because of privileges
return ServerConnector.getUsers(true);
if (user.hasPrivilege(privilege)) {
return ServerConnector.getUsers(true);
} else {
return Promise.resolve();
}
});
};
......
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