add search stub, hide behind feature flag

This commit is contained in:
Thomas Rudin 2019-04-14 19:17:43 +02:00
parent fb782ffbaf
commit 1d91e94321
11 changed files with 87 additions and 3 deletions

View File

@ -14,6 +14,7 @@ type Config struct {
Port int `json:"port"`
EnablePrometheus bool `json:"enableprometheus"`
EnableRendering bool `json:"enablerendering"`
EnableSearch bool `json:"enablesearch"`
EnableInitialRendering bool `json:"enableinitialrendering"`
EnableTransparency bool `json:"enabletransparency"`
Webdev bool `json:"webdev"`
@ -135,9 +136,9 @@ func ParseConfig(filename string) (*Config, error) {
Travelnet: true,
MapserverPlayer: true,
MapserverPOI: true,
MapserverLabel: true,
MapserverLabel: false,
MapserverTrainline: true,
MapserverBorder: true,
MapserverBorder: false,
TileServerLegacy: true,
Mission: true,
Jumpdrive: true,
@ -164,6 +165,7 @@ func ParseConfig(filename string) (*Config, error) {
Port: 8080,
EnableRendering: true,
EnablePrometheus: true,
EnableSearch: false,
EnableInitialRendering: true,
EnableTransparency: false,
Webdev: false,

7
server/static/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -15,3 +15,12 @@ body {
background: #fff;
padding: 5px;
}
#search-menu {
position: absolute;
top: 20%;
bottom: 20%;
left: 20%;
right: 20%;
z-index: 99999;
}

View File

@ -9,6 +9,7 @@
</head>
<body>
<div id="image-map"></div>
<div id="search-content"></div>
<script src="js/bundle.js"></script>
</body>
</html>

View File

@ -0,0 +1,22 @@
/* exported SearchControl */
var SearchControl = L.Control.extend({
initialize: function(wsChannel, opts) {
L.Control.prototype.initialize.call(this, opts);
},
onAdd: function() {
var div = L.DomUtil.create('div', 'leaflet-bar leaflet-custom-display');
var View = {
view: function(){
return m("input[type=text]", { placeholder: "Search", class: "form-control" });
}
};
m.mount(div, SearchInput);
m.mount(document.getElementById("search-content"), SearchMenu);
return div;
}
});

View File

@ -34,11 +34,17 @@ api.getConfig().then(function(cfg){
//All overlays
Overlaysetup(cfg, map, overlays, wsChannel, layerMgr);
L.control.layers(layers, overlays).addTo(map);
new CoordinatesDisplay({ position: 'bottomleft' }).addTo(map);
new WorldInfoDisplay(wsChannel, { position: 'bottomright' }).addTo(map);
if (cfg.enablesearch){
new SearchControl(wsChannel, { position: 'topright' }).addTo(map);
}
//layer control
L.control.layers(layers, overlays, { position: "topright" }).addTo(map);
Hashroute.setup(map, layerMgr);
}).catch(function(e){

View File

@ -0,0 +1,10 @@
var SearchInput = {
view: function(){
function handleInput(e){
SearchStore.search = e.target.value;
}
return m("input[type=text]", { placeholder: "Search", class: "form-control", oninput: handleInput });
}
}

View File

@ -0,0 +1,16 @@
var SearchMenu = {
view: function(){
var style = {};
if (!SearchStore.search) {
style.display = "none";
}
return m("div", { class: "card", id: "search-menu", style: style }, [
m("div", { class: "card-header" }, "Search"),
m("div", { class: "card-body" })
]);
}
}

View File

@ -0,0 +1,4 @@
var SearchStore = {
search: ""
};

View File

@ -9,8 +9,12 @@
"/js/SimpleCRS.js",
"/js/WebSocketChannel.js",
"/js/RealtimeTileLayer.js",
"/js/SearchControl.js",
"/js/CoordinatesDisplay.js",
"/js/WorldInfoDisplay.js",
"/js/search/SearchStore.js",
"/js/search/SearchMenu.js",
"/js/search/SearchInput.js",
"/js/overlays/AbstractIconOverlay.js",
"/js/overlays/AbstractGeoJsonOverlay.js",
"/js/overlays/TravelnetOverlay.js",
@ -36,6 +40,7 @@
"/js/main.js"
],
"styles": [
"/css/bootstrap.min.css",
"/css/leaflet.css",
"/css/custom.css"
]

View File

@ -13,6 +13,7 @@ type PublicConfig struct {
Layers []*layer.Layer `json:"layers"`
MapObjects *app.MapObjectConfig `json:"mapobjects"`
DefaultOverlays []string `json:"defaultoverlays"`
EnableSearch bool `json:"enablesearch"`
}
type ConfigHandler struct {
@ -27,6 +28,7 @@ func (h *ConfigHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
webcfg.MapObjects = h.ctx.Config.MapObjects
webcfg.Version = app.Version
webcfg.DefaultOverlays = h.ctx.Config.DefaultOverlays
webcfg.EnableSearch = h.ctx.Config.EnableSearch
json.NewEncoder(resp).Encode(webcfg)
}