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

fetch overlay information for all models in parallel

parent 7d1ac0cf
......@@ -1922,25 +1922,45 @@ ServerConnector.getOverlayElements = function (overlayId, projectId) {
if (overlayId === undefined) {
throw new Error("Overlay id must be defined");
}
var queryParams = {
overlayId: overlayId,
modelId: "*"
};
var filterParams = {};
var modelIds = ["*"];
return self.getProjectId(projectId).then(function (result) {
queryParams.projectId = result;
return self.sendGetRequest(self.getOverlayElementsUrl(queryParams, filterParams));
}).then(function (content) {
var arr = JSON.parse(content);
var queryParams = {
overlayId: overlayId,
projectId: result,
modelId: "*"
};
if (self.getSessionData().getProject()!==null) {
modelIds = [];
var project = self.getSessionData().getProject();
for (var i=0;i< project.getModels().length;i++) {
modelIds.push(project.getModels()[i].getId());
}
}
console.log(modelIds);
var promises = [];
for (var j=0;j<modelIds.length;j++) {
promises.push(self.sendGetRequest(self.getOverlayElementsUrl({
overlayId: overlayId,
projectId: result,
modelId: modelIds[j]
}, filterParams)));
}
return Promise.all(promises);
}).then(function (contentList) {
var result = [];
for (var i = 0; i < arr.length; i++) {
var element = arr[i];
if (element.type === "REACTION") {
result.push(new LayoutReaction(element.overlayContent));
} else if (element.type === "ALIAS") {
result.push(new LayoutAlias(element.overlayContent));
} else {
throw new Error("Unknown element type: " + element.type);
for (var j=0;j<contentList.length;j++) {
var content = contentList[j];
var arr = JSON.parse(content);
for (var i = 0; i < arr.length; i++) {
var element = arr[i];
if (element.type === "REACTION") {
result.push(new LayoutReaction(element.overlayContent));
} else if (element.type === "ALIAS") {
result.push(new LayoutAlias(element.overlayContent));
} else {
throw new Error("Unknown element type: " + element.type);
}
}
}
return result;
......
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