Commit 33021fed authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '79-zoom-via-link-parameters' into 'master'

Resolve "Zoom via link parameters"

Closes #79

See merge request piotr.gawron/minerva!143
parents d1f0942c 9cbe83f7
Pipeline #2641 passed with stage
in 42 seconds
......@@ -15,5 +15,10 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="chai-DefinitelyTyped" level="application" />
<orderEntry type="library" name="js-cookie-DefinitelyTyped" level="application" />
<orderEntry type="library" name="bluebird-DefinitelyTyped" level="application" />
<orderEntry type="library" name="mocha-DefinitelyTyped" level="application" />
<orderEntry type="library" name="jQuery UI-1.10.2" level="application" />
<orderEntry type="library" name="jQuery-2.0.0" level="application" />
<orderEntry type="library" name="datatables.net-DefinitelyTyped" level="application" />
</component>
</module>
\ No newline at end of file
......@@ -408,6 +408,12 @@ ServerConnector.updateOverlayUrl = function (queryParams) {
});
};
ServerConnector.updateModelUrl = function (queryParams) {
return this.getApiUrl({
url: this.getModelsUrl(queryParams)
});
};
ServerConnector.deleteOverlayUrl = function (queryParams) {
return this.getApiUrl({
url: this.getOverlayByIdUrl(queryParams)
......@@ -1631,12 +1637,32 @@ ServerConnector.updateOverlay = function (overlay) {
name: overlay.getName(),
description: overlay.getDescription(),
creator: overlay.getCreator(),
publicOverlay: overlay.getPublicOverlay()
publicOverlay: overlay.getPublicOverlay(),
defaultOverlay: overlay.isDefaultOverlay()
}
};
return self.sendPatchRequest(self.updateOverlayUrl(queryParams), filterParams);
};
ServerConnector.updateModel = function (params) {
var self = this;
var model = params.model;
var queryParams = {
projectId: params.projectId,
modelId: model.getId()
};
var filterParams = {
model: {
id: model.getId(),
defaultCenterX: model.getDefaultCenterX(),
defaultCenterY: model.getDefaultCenterY(),
defaultZoomLevel: model.getDefaultZoomLevel()
}
};
return self.sendPatchRequest(self.updateModelUrl(queryParams), filterParams);
};
ServerConnector.removeOverlay = function (params) {
var self = this;
var queryParams = {
......
......@@ -243,6 +243,16 @@ GuiUtils.prototype.createTextArea = function (value) {
return result;
};
GuiUtils.prototype.createCheckbox = function (value) {
var result = document.createElement("input");
result.type = "checkbox";
if (value) {
result.checked = true;
}
return result;
};
GuiUtils.prototype.createParamLine = function (label, value) {
var result = document.createElement("div");
if (value !== undefined && value !== null && value !== "") {
......
......@@ -7,12 +7,11 @@ var Panel = require('../Panel');
var PanelControlElementType = require('../PanelControlElementType');
var GuiConnector = require('../../GuiConnector');
// noinspection JSUnusedLocalSymbols
var logger = require('../../logger');
var Functions = require('../../Functions');
var NetworkError = require('../../NetworkError');
var Promise = require('bluebird');
var HttpStatus = require('http-status-codes');
function OverlayPanel(params) {
params.panelName = "overlays";
......@@ -148,7 +147,7 @@ OverlayPanel.prototype.createOverlayRow = function (overlay, checked) {
var guiUtils = self.getGuiUtils();
var result = document.createElement("tr");
if (checked) {
if (checked && !overlay.getInputDataAvailable()) {
result.className = "active";
}
......@@ -262,11 +261,11 @@ OverlayPanel.prototype.openEditOverlayDialog = function (overlay) {
id: overlay.getId(),
buttons: buttons,
title: "Data overlay: " + overlay.getName(),
className: "minerva-overlay-dialog",
className: "minerva-overlay-dialog"
});
};
OverlayPanel.prototype.refresh = function () {
OverlayPanel.prototype.refresh = function (showDefault) {
var self = this;
var user = null;
......@@ -286,65 +285,83 @@ OverlayPanel.prototype.refresh = function () {
return ServerConnector.getOverlays({
publicOverlay: false,
creator: user.getLogin(),
creator: user.getLogin()
});
}).then(
function (customOverlays) {
}).then(function (customOverlays) {
var id = self.getMap().getGoogleMap().getMapTypeId().substring(2);
if (!showDefault) {
var id = self.getMap().getGoogleMap().getMapTypeId().replace(/\D/g, '');
selectedOverlay[id] = true;
}
self.clear();
self.clear();
var generalOverlays = [];
var overlay;
var generalOverlays = [];
var overlay;
var overlays = self.getMap().getLayouts();
for (var i = 0; i < overlays.length; i++) {
overlay = overlays[i];
if (overlay.getCreator() === undefined || overlay.getCreator() === "") {
generalOverlays.push(overlay);
var overlays = self.getMap().getLayouts();
for (var i = 0; i < overlays.length; i++) {
overlay = overlays[i];
if (overlay.getCreator() === undefined || overlay.getCreator() === "") {
generalOverlays.push(overlay);
if (showDefault && overlay.isDefaultOverlay()) {
selectedOverlay[overlay.getId()] = true;
}
}
}
var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE);
table.appendChild(self.createTableHeader());
var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE);
table.appendChild(self.createTableHeader());
var body = document.createElement("tbody");
table.appendChild(body);
for (i = 0; i < generalOverlays.length; i++) {
overlay = generalOverlays[i];
body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()]));
}
var body = document.createElement("tbody");
var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE);
var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON);
if (user.getLogin() === "anonymous") {
title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a>'
+ 'TO UPLOAD AND VIEW CUSTOM OVERLAYS<br/><center><button>LOGIN</button></center>';
var openLoginDialog = function () {
return self.getParent().getLoginDialog().open();
};
$(title).find("a")[0].onclick = openLoginDialog;
$(title).find("button")[0].onclick = openLoginDialog;
addButton.style.display = "none";
} else {
title.innerHTML = self.getCustomOverlaysMessage();
addButton.style.display = "block";
table = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE);
table.appendChild(self.createTableHeader(true));
body = document.createElement("tbody");
table.appendChild(body);
for (i = 0; i < generalOverlays.length; i++) {
overlay = generalOverlays[i];
for (i = 0; i < customOverlays.length; i++) {
overlay = customOverlays[i];
if (showDefault && overlay.isDefaultOverlay()) {
selectedOverlay[overlay.getId()] = true;
}
body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()]));
}
}
var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE);
var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON);
if (user.getLogin() === "anonymous") {
title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a>'
+ 'TO UPLOAD AND VIEW CUSTOM OVERLAYS<br/><center><button>LOGIN</button></center>';
var openLoginDialog = function () {
return self.getParent().getLoginDialog().open();
};
$(title).find("a")[0].onclick = openLoginDialog;
$(title).find("button")[0].onclick = openLoginDialog;
addButton.style.display = "none";
} else {
title.innerHTML = self.getCustomOverlaysMessage();
addButton.style.display = "block";
table = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE);
table.appendChild(self.createTableHeader(true));
self.onresize();
body = document.createElement("tbody");
table.appendChild(body);
for (i = 0; i < customOverlays.length; i++) {
overlay = customOverlays[i];
body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()]));
var promises = [];
if (showDefault) {
for (var key in selectedOverlay) {
if (selectedOverlay.hasOwnProperty(key) && selectedOverlay[key]) {
logger.debug(key);
promises.push(self.getMap().openDataOverlay(key));
}
}
self.onresize();
});
}
return Promise.all(promises);
});
};
OverlayPanel.prototype.setCustomOverlaysMessage = function (customOverlaysMessage) {
......@@ -364,7 +381,7 @@ OverlayPanel.prototype.openAddOverlayDialog = function () {
self._addOverlayDialog = new AddOverlayDialog({
project: self.getProject(),
customMap: self.getMap(),
element: document.createElement("div"),
element: document.createElement("div")
});
self._addOverlayDialog.addListener("onAddOverlay", function (e) {
self.getMap().getModel().addLayout(e.arg);
......@@ -376,7 +393,11 @@ OverlayPanel.prototype.openAddOverlayDialog = function () {
};
OverlayPanel.prototype.init = function () {
return this.refresh();
var backgroundOverlay = ServerConnector.getSessionData().getSelectedBackgroundOverlay();
var showDefault = (backgroundOverlay === undefined || backgroundOverlay === "undefined");
logger.debug(ServerConnector.getSessionData().getSelectedBackgroundOverlay());
logger.debug(showDefault);
return this.refresh(showDefault);
};
OverlayPanel.prototype.destroy = function () {
......
This diff is collapsed.
......@@ -2,8 +2,6 @@
var Promise = require("bluebird");
var logger = require('../../logger');
var IdentifiedElement = require('./IdentifiedElement');
var LayoutAlias = require('./LayoutAlias');
var LayoutReaction = require('./LayoutReaction');
......@@ -26,6 +24,7 @@ function LayoutData(layoutId, name) {
this.setContent(object.content);
this.setFilename(object.filename);
this.setPublicOverlay(object.publicOverlay);
this.setDefaultOverlay(object.defaultOverlay);
this.setInputDataAvailable(object.inputDataAvailable);
this.setType(object.type);
if (!this.getInputDataAvailable()) {
......@@ -141,7 +140,7 @@ LayoutData.prototype.getFullAliasById = function (id) {
if (alias.getType() === LayoutAlias.LIGTH) {
return ServerConnector.getFullOverlayElement({
element: new IdentifiedElement(alias),
overlay: self,
overlay: self
}).then(function (data) {
self.updateAlias(data);
return alias;
......@@ -196,6 +195,14 @@ LayoutData.prototype.setPublicOverlay = function (publicOverlay) {
this._publicOverlay = publicOverlay;
};
LayoutData.prototype.isDefaultOverlay = function () {
return this._defaultOverlay;
};
LayoutData.prototype.setDefaultOverlay = function (defaultOverlay) {
this._defaultOverlay = defaultOverlay;
};
LayoutData.prototype.getContent = function () {
return this._content;
};
......
......@@ -320,11 +320,11 @@ function create(params) {
return mapContextMenu.init();
}).then(function () {
if (GuiConnector.getParams["layout"] !== undefined) {
var layouts = params.getProject().getModel().getLayouts();
for (var j = 0; j < layouts.length; j++) {
var layout = layouts[j];
if (layout.getName() === GuiConnector.getParams["layout"]) {
return customMap.openDataOverlay(layout);
var overlays = params.getProject().getModel().getLayouts();
for (var j = 0; j < overlays.length; j++) {
var overlay = overlays[j];
if (overlay.getName() === GuiConnector.getParams["layout"]) {
return customMap.openDataOverlay(overlay);
}
}
}
......
"use strict";
/* exported assert */
/* exported logger */
require("../../mocha-config");
var EditProjectDialog = require('../../../../main/js/gui/admin/EditProjectDialog');
var logger = require('../../logger');
var assert = require('assert');
describe('EditProjectDialog', function () {
it('open', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.open();
}).then(function () {
dialog.destroy();
});
});
it('init', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.init();
}).then(function () {
dialog.destroy();
});
});
it('saveOverlay', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.init();
}).then(function () {
return dialog.saveOverlay(14081);
}).then(function () {
dialog.destroy();
});
});
it('saveUser', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.init();
}).then(function () {
return dialog.saveUser("anonymous");
}).then(function () {
dialog.destroy();
});
});
it('onSaveClicked', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
project.setVersion("2.01");
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.onSaveClicked();
}).then(function (result) {
assert.ok(project === result);
dialog.destroy();
});
});
it('openAddOverlayDialog', function () {
var dialog;
return ServerConnector.getProject().then(function (project) {
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.openAddOverlayDialog();
}).then(function () {
dialog.destroy();
});
});
});
"use strict";
require("../../mocha-config");
var EditProjectDialog = require('../../../../main/js/gui/admin/EditProjectDialog');
var ServerConnector = require('../../ServerConnector-mock');
var logger = require('../../logger');
var assert = require('assert');
describe('EditProjectDialog', function () {
it('open', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.open();
}).then(function () {
assert.equal(0, logger.getWarnings().length);
dialog.destroy();
});
});
it('init', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.init();
}).then(function () {
dialog.destroy();
});
});
it('saveOverlay', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.init();
}).then(function () {
return dialog.saveOverlay(14081);
}).then(function () {
dialog.destroy();
});
});
it('saveMap', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.init();
}).then(function () {
return dialog.saveMap(15781);
}).then(function () {
dialog.destroy();
});
});
it('saveUser', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.init();
}).then(function () {
return dialog.saveUser("anonymous");
}).then(function () {
dialog.destroy();
});
});
it('onSaveClicked', function () {
var dialog;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
project.setVersion("2.01");
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.onSaveClicked();
}).then(function (result) {
assert.ok(project === result);
dialog.destroy();
});
});
it('openAddOverlayDialog', function () {
var dialog;
return ServerConnector.getProject().then(function (project) {
dialog = new EditProjectDialog({
element: testDiv,
project: project,
customMap: null
});
return dialog.openAddOverlayDialog();
}).then(function () {
dialog.destroy();
});
});
});
......@@ -10,99 +10,99 @@ var logger = require('../../logger');
describe('OverlayPanel', function () {