From c9f6174db5693fe5d91c171bd658a4ba90773cd7 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 15 Nov 2016 14:09:00 +0100
Subject: [PATCH] confiugartion will not crash when some params are missing

---
 frontend-js/src/main/js/Configuration.js | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/frontend-js/src/main/js/Configuration.js b/frontend-js/src/main/js/Configuration.js
index fa5aa5bdef..c14121af11 100644
--- a/frontend-js/src/main/js/Configuration.js
+++ b/frontend-js/src/main/js/Configuration.js
@@ -41,7 +41,7 @@ Configuration.prototype.constructor = Configuration;
  * Updates configuration data from object passed from server side.
  * 
  * @param modelView
- *            object retrieved from server side
+ *          object retrieved from server side
  */
 Configuration.prototype.loadFromModelView = function(modelView) {
   if (typeof modelView === "string") {
@@ -54,11 +54,10 @@ Configuration.prototype.loadFromModelView = function(modelView) {
   this.MAX_ZOOM = modelView.maxZoom;
   this.MIN_ZOOM = modelView.minZoom;
   this.MAP_NAME = modelView.version;
-  this.CENTER_LAT = modelView.centerLatLng.lat;
-  this.CENTER_LNG = modelView.centerLatLng.lng;
+  this.setCenter(modelView.centerLatLng);
 
-  this.MAPS = modelView.layouts;
-  this.MAPS = this.MAPS.concat(modelView.customLayouts);
+  this.addLayouts(modelView.layouts);
+  this.addLayouts(modelView.customLayouts);
 
   this.SUBMODELS = [];
   if (modelView.submodels !== undefined) {
@@ -83,8 +82,21 @@ Configuration.prototype.getId = function() {
   return this.ID_MODEL;
 };
 
+Configuration.prototype.setCenter = function(center) {
+  if (center !== undefined) {
+    this.CENTER_LAT = center.lat;
+    this.CENTER_LNG = center.lng;
+  }
+};
+
 Configuration.prototype.addLayout = function(layout) {
   this.MAPS.push(layout);
 };
 
+Configuration.prototype.addLayouts = function(layouts) {
+  if (layouts !== undefined) {
+    this.MAPS = this.MAPS.concat(layouts);
+  }
+};
+
 module.exports = Configuration;
-- 
GitLab