From ea38834e32eb680d31cfa50b3bfee1b69df3fd21 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 3 May 2018 15:44:19 +0200 Subject: [PATCH] ServerConnector is not used as a global variable --- .../src/main/js/gui/AbstractGuiElement.js | 29 +++++++++++++++++++ .../src/main/js/gui/AddOverlayDialog.js | 1 + frontend-js/src/main/js/gui/CommentDialog.js | 4 +-- frontend-js/src/main/js/gui/ContextMenu.js | 8 ++--- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/frontend-js/src/main/js/gui/AbstractGuiElement.js b/frontend-js/src/main/js/gui/AbstractGuiElement.js index 970d335640..b44f29a2d7 100644 --- a/frontend-js/src/main/js/gui/AbstractGuiElement.js +++ b/frontend-js/src/main/js/gui/AbstractGuiElement.js @@ -5,6 +5,7 @@ var ObjectWithListeners = require('../ObjectWithListeners'); var PanelControlElementType = require('./PanelControlElementType'); +// noinspection JSUnusedLocalSymbols var logger = require('../logger'); /** @@ -31,6 +32,10 @@ function AbstractGuiElement(params) { AbstractGuiElement.prototype = Object.create(ObjectWithListeners.prototype); AbstractGuiElement.prototype.constructor = AbstractGuiElement; +/** + * + * @param {CustomMap} map + */ AbstractGuiElement.prototype.setMap = function (map) { if (map === undefined) { throw new Error("map must be defined"); @@ -46,6 +51,10 @@ AbstractGuiElement.prototype.getMap = function () { return this._map; }; +/** + * + * @param {HTMLElement} element + */ AbstractGuiElement.prototype.setElement = function (element) { if (element === undefined || element === null) { throw new Error("DOM Element must be defined"); @@ -53,10 +62,18 @@ AbstractGuiElement.prototype.setElement = function (element) { this._element = element; }; +/** + * + * @returns {HTMLElement} + */ AbstractGuiElement.prototype.getElement = function () { return this._element; }; +/** + * + * @param {Project} project + */ AbstractGuiElement.prototype.setProject = function (project) { this._project = project; }; @@ -73,6 +90,7 @@ AbstractGuiElement.prototype.getProject = function () { } }; + AbstractGuiElement.prototype.setControlElement = function (type, element) { if (type === null || type === undefined) { throw new Error("Unknown control element type"); @@ -104,6 +122,10 @@ AbstractGuiElement.prototype.getLastDownloadUrl = function () { return this._downloadFile; }; +/** + * + * @param {Configuration} configuration + */ AbstractGuiElement.prototype.setConfiguration = function (configuration) { this._configuration = configuration; }; @@ -116,6 +138,13 @@ AbstractGuiElement.prototype.getConfiguration = function () { return this._configuration; }; +/** + * + * @param {string} [params.content] + * @param {string} params.title + * @param {boolean} [params.input] + * @returns {Promise} + */ AbstractGuiElement.prototype.askConfirmRemoval = function (params) { return new Promise(function (resolve) { var html; diff --git a/frontend-js/src/main/js/gui/AddOverlayDialog.js b/frontend-js/src/main/js/gui/AddOverlayDialog.js index e879287aa7..2e4cd33aa1 100644 --- a/frontend-js/src/main/js/gui/AddOverlayDialog.js +++ b/frontend-js/src/main/js/gui/AddOverlayDialog.js @@ -11,6 +11,7 @@ var NetworkError = require('../NetworkError'); var OverlayParser = require('../map/OverlayParser'); var Functions = require('../Functions'); +// noinspection JSUnusedLocalSymbols var logger = require('../logger'); var HttpStatus = require('http-status-codes'); diff --git a/frontend-js/src/main/js/gui/CommentDialog.js b/frontend-js/src/main/js/gui/CommentDialog.js index 8b8634944f..53432445b7 100644 --- a/frontend-js/src/main/js/gui/CommentDialog.js +++ b/frontend-js/src/main/js/gui/CommentDialog.js @@ -55,7 +55,7 @@ CommentDialog.prototype.open = function (types) { } return Promise.all(promises).then(function (elements) { self.setTypes(elements); - return ServerConnector.getLoggedUser(); + return self.getMap().getServerConnector().getLoggedUser(); }).then(function (user) { if (user.getLogin() !== "anonymous") { self.setEmail(user.getEmail()); @@ -285,7 +285,7 @@ CommentDialog.prototype.getSelectedTypeClass = function () { CommentDialog.prototype.addComment = function () { var self = this; var name = self.getName(); - return ServerConnector.addComment({ + return self.getMap().getServerConnector().addComment({ modelId: self.getMap().getActiveSubmapId(), coordinates: self.getMap().getActiveSubmapClickCoordinates(), name: name, diff --git a/frontend-js/src/main/js/gui/ContextMenu.js b/frontend-js/src/main/js/gui/ContextMenu.js index b1e4f03878..f942ae1578 100644 --- a/frontend-js/src/main/js/gui/ContextMenu.js +++ b/frontend-js/src/main/js/gui/ContextMenu.js @@ -114,7 +114,7 @@ function extractDataOverlayIds(dataOverlays) { ContextMenu.prototype.createExportAsImageSubmenu = function () { var self = this; - return ServerConnector.getImageConverters().then(function (converters) { + return self.getMap().getServerConnector().getImageConverters().then(function (converters) { var li = Functions.createElement({ type: "li" }); @@ -129,7 +129,7 @@ ContextMenu.prototype.createExportAsImageSubmenu = function () { submenu.addOption(converter.name, function () { return map.getVisibleDataOverlays().then(function (visibleDataOverlays) { - return ServerConnector.getImageDownloadUrl({ + return map.getServerConnector().getImageDownloadUrl({ polygonString: map.getSelectedPolygon(), modelId: map.getActiveSubmapId(), handlerClass: converter.handler, @@ -148,7 +148,7 @@ ContextMenu.prototype.createExportAsImageSubmenu = function () { ContextMenu.prototype.createExportAsModelSubmenu = function () { var self = this; - return ServerConnector.getModelConverters().then(function (converters) { + return self.getMap().getServerConnector().getModelConverters().then(function (converters) { var li = Functions.createElement({ type: "li" }); @@ -162,7 +162,7 @@ ContextMenu.prototype.createExportAsModelSubmenu = function () { converters.forEach(function (converter) { submenu.addOption(converter.name, function () { return map.getVisibleDataOverlays().then(function (visibleDataOverlays) { - return ServerConnector.getModelDownloadUrl({ + return map.getServerConnector().getModelDownloadUrl({ polygonString: map.getSelectedPolygon(), modelId: map.getActiveSubmapId(), handlerClass: converter.handler, -- GitLab