Commit 50fab883 authored by Athanasios's avatar Athanasios
Browse files

add temporary layers

parent b7f450f5
No related merge requests found
Showing with 446 additions and 21 deletions
+446 -21
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<body> <body>
<div id="wrapper"> <div id="wrapper">
<div id="sidebar"> <div id="sidebar" class="overflow-hidden">
<form> <form>
<div class="form-row"> <div class="form-row">
...@@ -43,10 +43,15 @@ ...@@ -43,10 +43,15 @@
<select class="form-control" id="layersList" size="10"></select> <select class="form-control" id="layersList" size="10"></select>
</div> </div>
<div class="form-group col-12"> <div class="form-group col-6">
<button id="getLayers" class="btn btn-primary btn-block" type="button">Get Layers</button> <button id="getLayers" class="btn btn-primary btn-block" type="button">Get Layers</button>
</div> </div>
<div class="form-group col-6">
<button id="showAddTempLayer" class="btn btn-primary btn-block" type="button" data-toggle="modal"
data-target="#exampleModalCenter">Add Layer</button>
</div>
<div class="form-group col-12"> <div class="form-group col-12">
<label>bounding box</label> <label>bounding box</label>
<input id="boundingBoxInput" type="text" class="form-control" /> <input id="boundingBoxInput" type="text" class="form-control" />
...@@ -55,7 +60,7 @@ ...@@ -55,7 +60,7 @@
<div class="form-group col-6"> <div class="form-group col-6">
<button id="setBoundingBox" class="btn btn-primary btn-block" type="button">Set</button> <button id="setBoundingBox" class="btn btn-primary btn-block" type="button">Set</button>
</div> </div>
<div class="form-group col-6"> <div class="form-group col-6">
<button id="clearBoundingBox" class="btn btn-primary btn-block" type="button">Clear</button> <button id="clearBoundingBox" class="btn btn-primary btn-block" type="button">Clear</button>
</div> </div>
...@@ -84,6 +89,37 @@ ...@@ -84,6 +89,37 @@
<div id="statusBarLoader" class="loader"></div> <div id="statusBarLoader" class="loader"></div>
</div> </div>
</div> </div>
<div class="modal" id="addTempLayerModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Layer properties</h5>
</div>
<div class="modal-body">
<form>
<div class="form-group row">
<label class="col-2">Name</label>
<div class="col-10">
<input type="text" class="form-control" id="tempLayerName">
</div>
</div>
<div class="form-group row">
<label class="col-2">URL</label>
<div class="col-10">
<input type="text" class="form-control" id="tempLayerUrl">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button id="addTempLayer" type="button" class="btn btn-primary" data-dismiss="modal">Add</button>
<button id="cancelTempLayer" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</body> </body>
<script src="lib/jquery/jquery-3.1.1.min.js"></script> <script src="lib/jquery/jquery-3.1.1.min.js"></script>
<script src="lib/bootstrap/bootstrap.min.js"></script> <script src="lib/bootstrap/bootstrap.min.js"></script>
...@@ -100,7 +136,17 @@ ...@@ -100,7 +136,17 @@
{ name: "mappers", location: "lib/mappers" }, { name: "mappers", location: "lib/mappers" },
{ name: "gui", location: "lib/gui" }, { name: "gui", location: "lib/gui" },
{ name: "style", location: "lib/style" } { name: "style", location: "lib/style" }
] ],
app: {
host: "81.169.187.7",
port: "9001",
endpoint: "service/v1"
},
devel: {
host: "localhost",
port: "9000",
endpoint: "service/v1"
}
}; };
</script> </script>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.12.2/dojo/dojo.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.12.2/dojo/dojo.js"></script>
......
...@@ -70,13 +70,13 @@ define([ ...@@ -70,13 +70,13 @@ define([
} catch (e) { } catch (e) {
NodeCache.clearAll(); NodeCache.clearAll();
StatusBar.endProcess(); StatusBar.endProcess();
topic.publish("PortrayalResponseHandled", "BoundingBoxUndefined"); topic.publish("PortrayalResponseHandled", "ExceptionReturned");
} }
}, function (err) { }, function (err) {
NodeCache.clearAll(); NodeCache.clearAll();
StatusBar.endProcess(); StatusBar.endProcess();
topic.publish("PortrayalResponseHandled", "BoundingBoxUndefined"); topic.publish("PortrayalResponseHandled", "ExceptionReturned");
}); });
} }
......
require([ require([
"dojo/topic", "dojo/topic",
"dojo/_base/config",
"CesiumAdaptor/CesiumViewer", "CesiumAdaptor/CesiumViewer",
"helpers/NodeCache", "helpers/NodeCache",
"style/NodeStyler", "style/NodeStyler",
...@@ -10,7 +11,7 @@ require([ ...@@ -10,7 +11,7 @@ require([
"state/State", "state/State",
"state/Operations", "state/Operations",
"dojo/domReady!" "dojo/domReady!"
], function (topic, CesiumViewer, NodeCache, NodeStyler, DefaultStyle, NodeLevelStyle, Legend, Timeout, State, Operations) { ], function (topic, config, CesiumViewer, NodeCache, NodeStyler, DefaultStyle, NodeLevelStyle, Legend, Timeout, State, Operations) {
Cesium.BingMapsApi.defaultKey = "AmdoJEIiP8BcA__QO9SjBAgv4h73-uiH4lGinmzwyfjK-Fjs8t7GbmfpFjmyj1cl"; Cesium.BingMapsApi.defaultKey = "AmdoJEIiP8BcA__QO9SjBAgv4h73-uiH4lGinmzwyfjK-Fjs8t7GbmfpFjmyj1cl";
let osm = Cesium.createOpenStreetMapImageryProvider({ let osm = Cesium.createOpenStreetMapImageryProvider({
...@@ -45,9 +46,9 @@ require([ ...@@ -45,9 +46,9 @@ require([
let operations = new Operations(); let operations = new Operations();
let state = new State(operations); let state = new State(operations);
$("#host").val("81.169.187.7"); $("#host").val(config.app.host);
$("#port").val("9001"); $("#port").val(config.app.port);
$("#endpoint").val("service/v1"); $("#endpoint").val(config.app.endpoint);
$("#request").click(function (event) { $("#request").click(function (event) {
event.preventDefault(); event.preventDefault();
...@@ -105,4 +106,17 @@ require([ ...@@ -105,4 +106,17 @@ require([
state.getLayers(); state.getLayers();
}); });
}); $("#showAddTempLayer").click(function (event) {
\ No newline at end of file state.showAddTempLayer();
});
$("#addTempLayer").click(function (event) {
state.addTempLayer();
});
$("#cancelTempLayer").click(function (event) {
$("#tempLayerName").val("");
$("#tempLayerUrl").val("");
});
});
...@@ -44,8 +44,17 @@ define([ ...@@ -44,8 +44,17 @@ define([
gettingLayers: function (target) { gettingLayers: function (target) {
target.operations.getLayers(); target.operations.getLayers();
target.changeState("NoLayerSelected"); target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
} }
}); });
}); });
\ No newline at end of file
...@@ -37,8 +37,17 @@ define([ ...@@ -37,8 +37,17 @@ define([
gettingLayers: function (target) { gettingLayers: function (target) {
// no-op // no-op
},
showAddTempLayer: function (target) {
// no-op
},
addTempLayer: function (target) {
// no-op
} }
}); });
}); });
\ No newline at end of file
...@@ -34,14 +34,22 @@ define([ ...@@ -34,14 +34,22 @@ define([
}, },
selectingLayer: function (target, layer) { selectingLayer: function (target, layer) {
target.operations.clear();
target.operations.selectLayer(layer); target.operations.selectLayer(layer);
target.operations.invokeRequest({ layer: layer }); target.changeState("LayerSelected");
target.changeState("WaitingForPortrayal");
}, },
gettingLayers: function (target) { gettingLayers: function (target) {
target.operations.getLayers(); target.operations.getLayers();
target.changeState("NoLayerSelected"); target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
} }
}); });
......
define([
"dojo/_base/declare",
"helpers/NodeCache"
], function (declare, NodeCache) {
return declare(null, {
constructor: function () {
},
init(target, bb) {
bb.clear();
NodeCache.clearAll();
$("#boundingBoxInput").val("");
$('#toggleFreezeScene').prop('checked', false);
$('#toggleFreezeScene').prop('disabled', true);
},
settingBoundingBox: function (target, bb) {
// no-op
},
clearingBoundingBox: function (target, bb) {
// no-op
},
makingRequest: function (target) {
// no-op
},
toggleFreezingScene: function (target) {
// no-op
},
selectingLayer: function (target, layer) {
target.operations.clear();
target.operations.selectLayer(layer);
target.changeState("LayerSelected");
},
gettingLayers: function (target) {
target.operations.getLayers();
target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
}
});
});
\ No newline at end of file
...@@ -20,7 +20,11 @@ define([ ...@@ -20,7 +20,11 @@ define([
}, },
clearingBoundingBox: function (target, bb) { clearingBoundingBox: function (target, bb) {
// no-op if (bb.isDefined()) {
target.operations.clearBoundingBox();
target.changeState("LayerSelected");
target.makeRequest();
}
}, },
makingRequest: function (target) { makingRequest: function (target) {
...@@ -28,7 +32,7 @@ define([ ...@@ -28,7 +32,7 @@ define([
}, },
toggleFreezingScene: function (target) { toggleFreezingScene: function (target) {
target.changeState("BoundingBoxDefined"); target.changeState("UnfreezeScene");
}, },
selectingLayer: function (target, layer) { selectingLayer: function (target, layer) {
...@@ -40,6 +44,14 @@ define([ ...@@ -40,6 +44,14 @@ define([
gettingLayers: function (target) { gettingLayers: function (target) {
target.operations.getLayers(); target.operations.getLayers();
target.changeState("NoLayerSelected"); target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
} }
}); });
......
...@@ -35,13 +35,20 @@ define([ ...@@ -35,13 +35,20 @@ define([
}, },
selectingLayer: function (target, layer) { selectingLayer: function (target, layer) {
console.log("hihoho");
target.operations.selectLayer(layer); target.operations.selectLayer(layer);
}, },
gettingLayers: function (target) { gettingLayers: function (target) {
target.operations.getLayers(); target.operations.getLayers();
target.changeState("NoLayerSelected"); target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
// no-op
},
addTempLayer: function (target) {
// no-op
} }
}); });
......
...@@ -43,6 +43,14 @@ define([ ...@@ -43,6 +43,14 @@ define([
gettingLayers: function (target) { gettingLayers: function (target) {
target.operations.getLayers(); target.operations.getLayers();
target.changeState("NoLayerSelected"); target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
} }
}); });
......
define([
"dojo/_base/declare",
"helpers/NodeCache"
], function (declare, NodeCache) {
return declare(null, {
constructor: function () {
},
init(target, bb) {
bb.clear();
NodeCache.clearAll();
target.operations.clear();
$("#layersList").empty();
$("#boundingBoxInput").val("");
$('#toggleFreezeScene').prop('checked', false);
$('#toggleFreezeScene').prop('disabled', true);
},
settingBoundingBox: function (target, bb) {
// no-op
},
clearingBoundingBox: function (target, bb) {
// no-op
},
makingRequest: function (target) {
// no-op
},
toggleFreezingScene: function (target) {
// no-op
},
selectingLayer: function (target, layer) {
// no-op
},
gettingLayers: function (target) {
target.operations.getLayers();
target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
}
});
});
\ No newline at end of file
...@@ -4,8 +4,9 @@ define([ ...@@ -4,8 +4,9 @@ define([
"helpers/UrlBuilder", "helpers/UrlBuilder",
"CesiumAdaptor/CesiumViewer", "CesiumAdaptor/CesiumViewer",
"helpers/Layers", "helpers/Layers",
"helpers/RequestWrapper" "helpers/RequestWrapper",
], function (declare, request, UrlBuilder, CesiumViewer, Layers, RequestWrapper) { "dojo/topic"
], function (declare, request, UrlBuilder, CesiumViewer, Layers, RequestWrapper, topic) {
return declare(null, { return declare(null, {
...@@ -84,6 +85,36 @@ define([ ...@@ -84,6 +85,36 @@ define([
clearBoundingBox: function () { clearBoundingBox: function () {
this._bb = null; this._bb = null;
},
showAddTempLayer: function () {
$('#addTempLayerModal').modal('show');
},
addTempLayer: function () {
let data = {
name: $("#tempLayerName").val(),
url: $("#tempLayerUrl").val()
};
$("#tempLayerName").val("");
$("#tempLayerUrl").val("");
let url = new UrlBuilder(location.protocol.slice(0, -1), $("#host").val())
.port($("#port").val())
.path("tempassets")
.build();
request.post(url, {
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify(data),
}).then(function (message) {
topic.publish("TempLayerAdded", "TemporaryLayerAdded");
});
} }
}); });
......
...@@ -46,8 +46,17 @@ define([ ...@@ -46,8 +46,17 @@ define([
gettingLayers: function (target) { gettingLayers: function (target) {
target.operations.getLayers(); target.operations.getLayers();
target.changeState("NoLayerSelected"); target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
} }
}); });
}); });
\ No newline at end of file
...@@ -10,10 +10,11 @@ define([ ...@@ -10,10 +10,11 @@ define([
constructor: function (operations) { constructor: function (operations) {
this.operations = operations; this.operations = operations;
this._stateFactory = new StateFactory(); this._stateFactory = new StateFactory();
this._current = this._stateFactory.createState("NoLayerSelected"); this._current = this._stateFactory.createState("NothingSelected");
this._boundingBox = new BoundingBox(); this._boundingBox = new BoundingBox();
topic.subscribe("BoundingBoxCreated", this.changeState.bind(this)); topic.subscribe("BoundingBoxCreated", this.changeState.bind(this));
topic.subscribe("PortrayalResponseHandled", this.changeState.bind(this)); topic.subscribe("PortrayalResponseHandled", this.changeState.bind(this));
topic.subscribe("TempLayerAdded", this.changeState.bind(this));
}, },
setBoundingBox: function () { setBoundingBox: function () {
...@@ -49,6 +50,14 @@ define([ ...@@ -49,6 +50,14 @@ define([
this._current.gettingLayers(this); this._current.gettingLayers(this);
}, },
showAddTempLayer: function () {
this._current.showAddTempLayer(this);
},
addTempLayer: function () {
this._current.addTempLayer(this);
}
}); });
}); });
\ No newline at end of file
define([ define([
"dojo/_base/declare", "dojo/_base/declare",
"state/NothingSelected",
"state/NoLayerSelected", "state/NoLayerSelected",
"state/LayerSelected", "state/LayerSelected",
"state/BoundingBoxUndefined", "state/BoundingBoxUndefined",
...@@ -7,8 +8,25 @@ define([ ...@@ -7,8 +8,25 @@ define([
"state/BoundingBoxDefined", "state/BoundingBoxDefined",
"state/WaitingForPortrayal", "state/WaitingForPortrayal",
"state/FreezeScene", "state/FreezeScene",
"state/SceneRendered" "state/UnfreezeScene",
], function (declare, NoLayerSelected, LayerSelected, BoundingBoxUndefined, BoundingBoxDefining, BoundingBoxDefined, WaitingForPortrayal, FreezeScene, SceneRendered) { "state/SceneRendered",
"state/ExceptionReturned",
"state/TemporaryLayerAdded"
], function (
declare,
NothingSelected,
NoLayerSelected,
LayerSelected,
BoundingBoxUndefined,
BoundingBoxDefining,
BoundingBoxDefined,
WaitingForPortrayal,
FreezeScene,
UnfreezeScene,
SceneRendered,
ExceptionReturned,
TemporaryLayerAdded
) {
return declare(null, { return declare(null, {
...@@ -18,6 +36,8 @@ define([ ...@@ -18,6 +36,8 @@ define([
createState: function (stateName) { createState: function (stateName) {
switch (stateName) { switch (stateName) {
case "NothingSelected":
return new NothingSelected();
case "NoLayerSelected": case "NoLayerSelected":
return new NoLayerSelected(); return new NoLayerSelected();
case "LayerSelected": case "LayerSelected":
...@@ -32,8 +52,14 @@ define([ ...@@ -32,8 +52,14 @@ define([
return new WaitingForPortrayal(); return new WaitingForPortrayal();
case "FreezeScene": case "FreezeScene":
return new FreezeScene(); return new FreezeScene();
case "UnfreezeScene":
return new UnfreezeScene();
case "SceneRendered": case "SceneRendered":
return new SceneRendered(); return new SceneRendered();
case "ExceptionReturned":
return new ExceptionReturned();
case "TemporaryLayerAdded":
return new TemporaryLayerAdded();
default: default:
return new NoLayerSelected(); return new NoLayerSelected();
} }
......
define([
"dojo/_base/declare",
"helpers/NodeCache"
], function (declare, NodeCache) {
return declare(null, {
constructor: function () {
},
init(target, bb) {
bb.clear();
NodeCache.clearAll();
target.operations.clear();
$("#layersList").empty();
$("#boundingBoxInput").val("");
$('#toggleFreezeScene').prop('checked', false);
$('#toggleFreezeScene').prop('disabled', true);
target.getLayers();
},
settingBoundingBox: function (target, bb) {
// no-op
},
clearingBoundingBox: function (target, bb) {
// no-op
},
makingRequest: function (target) {
// no-op
},
toggleFreezingScene: function (target) {
// no-op
},
selectingLayer: function (target, layer) {
target.operations.clear();
target.operations.selectLayer(layer);
target.changeState("LayerSelected");
},
gettingLayers: function (target) {
target.operations.getLayers();
target.changeState("NoLayerSelected");
},
showAddTempLayer: function (target) {
target.operations.showAddTempLayer();
},
addTempLayer: function (target) {
target.operations.addTempLayer();
}
});
});
\ No newline at end of file
define([
"dojo/_base/declare",
"helpers/NodeCache"
], function (declare, NodeCache) {
return declare(null, {
constructor: function () { },
init(target, bb) {
// bb.unregister();
NodeCache.clearAll();
// $("#boundingBoxInput").val(bb.toString());
$('#toggleFreezeScene').prop('checked', false);
$("#toggleFreezeScene").prop("disabled", false);
// target.operations.setBoundingBox(bb.toString());
target.makeRequest();
},
settingBoundingBox: function (target, bb) {
// no-op
},
clearingBoundingBox: function (target, bb) {
// no-op
},
makingRequest: function (target) {
target.operations.invokeRequest();
target.changeState("WaitingForPortrayal");
},
toggleFreezingScene: function (target) {
target.changeState("FreezeScene");
},
selectingLayer: function (target, layer) {
// no-op
},
gettingLayers: function (target) {
// no-op
},
showAddTempLayer: function (target) {
// no-op
},
addTempLayer: function (target) {
// no-op
}
});
});
\ No newline at end of file
...@@ -32,6 +32,14 @@ define([ ...@@ -32,6 +32,14 @@ define([
gettingLayers: function (target) { gettingLayers: function (target) {
// no-op // no-op
},
showAddTempLayer: function (target) {
// no-op
},
addTempLayer: function (target) {
// no-op
} }
}); });
......
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