Commit 1f7997fc authored by Piotr Gawron's avatar Piotr Gawron
Browse files

refresh only project that requires it

parent 846139d4
Pipeline #28805 passed with stage
in 11 minutes and 31 seconds
......@@ -10,6 +10,8 @@ minerva (15.1.0) unstable; urgency=medium
defining font color
* Bug fix: export to image from selected polygon contained all elements
inside rectangle bounded by the polygon coordinates (#1096)
* Bug fix: continuous refreshing list of project when uploading/removing
project did not allow to change other project details (#996)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 18 Jun 2020 16:00:00 +0200
......
......@@ -315,7 +315,6 @@ MapsAdminPanel.prototype.setProjects = function (projects) {
var self = this;
return self.getServerConnector().getLoggedUser().then(function (user) {
var requireUpdate = false;
var dataTable = $("[name='projectsTable']", self.getElement()).DataTable();
var data = [];
var page = dataTable.page();
......@@ -325,19 +324,10 @@ MapsAdminPanel.prototype.setProjects = function (projects) {
var rowData = self.projectToTableRow(project, undefined, user);
self.addUpdateListener(project);
data.push(rowData);
if (project.getStatus().toLowerCase() !== "ok" && project.getStatus().toLowerCase() !== "failure") {
requireUpdate = true;
}
}
//it should be simplified, but I couldn't make it work
dataTable.clear().rows.add(data).page(page).draw(false).page(page).draw(false);
if (requireUpdate) {
setTimeout(function () {
logger.debug("Projects auto refresh");
return self.onRefreshClicked();
}, MapsAdminPanel.AUTO_REFRESH_TIME);
}
});
};
......@@ -355,6 +345,17 @@ MapsAdminPanel.prototype.addUpdateListener = function (project) {
project.removeListener("onreload", listeners[i]);
}
}
var createRefreshEventFunction = function () {
var projectId = project.getProjectId();
setTimeout(function () {
console.log("Refreshing project: " + projectId);
return self.getServerConnector().getProject(projectId).then(function (project) {
if (project === null) {
return self.onRefreshClicked();
}
});
}, MapsAdminPanel.AUTO_REFRESH_TIME);
};
var listener = function () {
return self.getServerConnector().getLoggedUser().then(function (user) {
var dataTable = $($("[name='projectsTable']", self.getElement())[0]).DataTable();
......@@ -363,17 +364,25 @@ MapsAdminPanel.prototype.addUpdateListener = function (project) {
for (var i = 0; i < length; i++) {
var row = dataTable.row(i);
var data = row.data();
if (data[0].indexOf(">" + project.getProjectId() + "<") >= 0) {
if (data[0].indexOf(">" + project.getProjectId() + "<") >= 0 || data[0].indexOf(project.getProjectId()) === 0) {
self.projectToTableRow(project, data, user);
var page = dataTable.page();
row.data(data).draw();
dataTable.page(page).draw(false);
}
}
if (project.getStatus().toLowerCase() !== "ok" && project.getStatus().toLowerCase() !== "failure") {
createRefreshEventFunction();
}
});
};
listener.listenerName = listenerName;
project.addListener("onreload", listener);
if (project.getStatus().toLowerCase() !== "ok" && project.getStatus().toLowerCase() !== "failure") {
createRefreshEventFunction();
}
};
/**
......
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