Skip to content

Commit

Permalink
Manage worldmap client using client hooksets standard approach. Refs #…
Browse files Browse the repository at this point in the history
…4019 (#4023)

* Manage worldmap client using client hooksets standard approach. Ref #4019

* Forgot to add these files in previous commit

* we use geoext client by default
  • Loading branch information
capooti committed Oct 26, 2018
1 parent 34ac634 commit aba1eb7
Show file tree
Hide file tree
Showing 19 changed files with 353 additions and 206 deletions.
61 changes: 61 additions & 0 deletions geonode/client/hooksets.py
Expand Up @@ -198,3 +198,64 @@ def map_embed_template(self, context=None):

def map_download_template(self, context=None):
return 'maploom/maps/maploom.html'


class WorldMapHookSet(object):

# Layers
def layer_detail_template(self, context=None):
return 'worldmap/layers/layer_worldmap_map.html'

def layer_new_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

def layer_view_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

def layer_edit_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

def layer_update_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

def layer_embed_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

def layer_download_template(self, context=None):
return 'geoext/layers/layer_geoext_map.html'

# Maps
def map_detail_template(self, context=None):
return 'worldmap/maps/map_include.html'

def map_new_template(self, context=None):
return 'worldmap/maps/map_worldmap.html'

def map_view_template(self, context=None):
return 'worldmap/maps/map_worldmap.html'

def map_edit_template(self, context=None):
return 'geoext/maps/map_geoexplorer.js'

def map_update_template(self, context=None):
return 'geoext/maps/map_geoexplorer.js'

def map_embed_template(self, context=None):
return 'geoext/maps/map_geoexplorer_viewer.js'

def map_download_template(self, context=None):
return 'geoext/maps/map_geoexplorer.js'

# Map Persisting
def viewer_json(self, conf, context=None):
if not context:
context = {}

if isinstance(conf, basestring):
conf = json.loads(conf)
return conf

def update_from_viewer(self, conf, context=None):
conf = self.viewer_json(conf, context=context)
context['config'] = conf
return 'geoext/maps/map_geoexplorer.js'
3 changes: 3 additions & 0 deletions geonode/client/templates/worldmap/app_header.html
@@ -0,0 +1,3 @@
{% load static from staticfiles %}
<script src="{% static "worldmap_client/script/ux.js" %}?v={{ VERSION }}"></script>
<script src="{% static "worldmap_client/script/GeoNode.js" %}?v={{ VERSION }}"></script>
10 changes: 10 additions & 0 deletions geonode/client/templates/worldmap/ext_header.html
@@ -0,0 +1,10 @@
{% load static from staticfiles %}
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/ext/resources/css/ext-all.css" %}?v={{ VERSION }}" />
<script type="text/javascript" src="{% static "worldmap_client/externals/ext/adapter/ext/ext-base.js" %}?v={{ VERSION }}"></script>
<script type="text/javascript" src="{% static "worldmap_client/externals/ext/ext-all.js" %}?v={{ VERSION }}"></script>

<script type="text/javascript">
Ext.Ajax.defaultHeaders = { 'X-CSRFToken': '{{ csrf_token|escapejs }}' };
Ext.BLANK_IMAGE_URL = "{% static "worldmap_client/externals/ext/resources/images/default/s.gif" %}";
</script>
24 changes: 24 additions & 0 deletions geonode/client/templates/worldmap/geo_header.html
@@ -0,0 +1,24 @@
{% load api_basemaps_tags %}
{% load i18n %}
{% load static from staticfiles %}

<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/site.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/ext/resources/css/ext-all.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/openlayers/theme/default/style.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/geoext/resources/css/geoext-all.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/gxp/theme/all.css" %}?v={{ VERSION }}">
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/ext/resources/css/xtheme-white.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/app/geoexplorer_white.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/ux/colorpicker/color-picker.ux.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/theme/ux/spinner/Spinner.css" %}?v={{ VERSION }}" />

<script src="{% static "worldmap_client/script/OpenLayers.js" %}?v={{ VERSION }}" type="text/javascript"></script>
<script src="{% static "worldmap_client/script/GeoExt.js" %}?v={{ VERSION }}" type="text/javascript"></script>
<script src="{% static "worldmap_client/script/gxp.js" %}?v={{ VERSION }}" type="text/javascript"></script>
<script src="{% static "worldmap_client/script/GeoExplorer.js" %}?v={{ VERSION }}" type="text/javascript"></script>

<script src="https://maps.googleapis.com/maps/api/js?key={% google_api_key %}" type="text/javascript"></script>

<script type="text/javascript" src="/static/geonode/js/utils/thumbnail.js"></script>
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
24 changes: 24 additions & 0 deletions geonode/client/templates/worldmap/geo_header_debug.html
@@ -0,0 +1,24 @@
{% load api_basemaps_tags %}
{% load i18n %}
{% load static from staticfiles %}

<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/site.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/ext/resources/css/ext-all.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/openlayers/theme/default/style.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/geoext/resources/css/geoext-all.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/gxp/theme/all.css" %}?v={{ VERSION }}">
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/externals/ext/resources/css/xtheme-white.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/app/geoexplorer_white.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/ux/colorpicker/color-picker.ux.css" %}?v={{ VERSION }}" />
<link rel="stylesheet" type="text/css" href="{% static "worldmap_client/theme/theme/ux/spinner/Spinner.css" %}?v={{ VERSION }}" />

<script src="http://localhost:9090/script/OpenLayers.js" type="text/javascript"></script>
<script src="http://localhost:9090/script/GeoExt.js" type="text/javascript"></script>
<script src="http://localhost:9090/script/gxp.js" type="text/javascript"></script>
<script src="http://localhost:9090/script/GeoExplorer.js" type="text/javascript"></script>

<script src="https://maps.googleapis.com/maps/api/js?key={% google_api_key %}" type="text/javascript"></script>

<script type="text/javascript" src="/static/geonode/js/utils/thumbnail.js"></script>
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
61 changes: 61 additions & 0 deletions geonode/client/templates/worldmap/layers/layer_worldmap_map.html
@@ -0,0 +1,61 @@
{% include "worldmap/ext_header.html" %}
{% include "worldmap/app_header.html" %}
{% include "worldmap/geo_header.html" %}

{% load i18n %}
{% load static from staticfiles %}

<script type="text/javascript">
{% autoescape off %}

var styleEditor, modified = false;
Ext.onReady(function() {
var config = {
tools: [{
ptype: "gxp_wmsgetfeatureinfo",
format: "grid",
actionTarget: "main.tbar",
outputConfig: {width: 400, height: 200, panIn: false}
}],
proxy: "/proxy/?url=",
siteUrl: "{{ SITE_URL }}",
localGeoServerBaseUrl: "{{GEOSERVER_BASE_URL}}",
rest: "/maps/",
portalConfig: {
renderTo: "preview_map",
height: 350
},
createTools: function() {
return [new Ext.Button({
tooltip: GeoExplorer.prototype.backgroundContainerText,
iconCls: 'icon-layer-switcher',
menu: new gxp.menu.LayerMenu({
layers: this.mapPanel.layers
})
})]
},
listeners: {
"ready": function() {
var map = app.mapPanel.map;
layerExtent = map.layers.slice(-1)[0].maxExtent;
if (layerExtent.left <= map.maxExtent.left || layerExtent.right >= map.maxExtent.right || layerExtent.top >= map.maxExtent.top || layerExtent.bottom <= map.maxExtent.bottom)
{map.zoomTo(1)}
else
{map.zoomToExtent(layerExtent)};
},
"beforeunload": function() {
if (modified) {
styleEditor.show();
return false;
}
}
}
};

config = Ext.apply(config, {{ viewer|safe }});
app = new GeoExplorer.Viewer(config);

});

{% endautoescape %}
</script>
40 changes: 40 additions & 0 deletions geonode/client/templates/worldmap/maps/map_include.html
@@ -0,0 +1,40 @@
{% include "worldmap/ext_header.html" %}
{% include "worldmap/app_header.html" %}
{% include "worldmap/geo_header.html" %}
{% load static from staticfiles %}
<script type="text/javascript" src="{% static "geonode/js/extjs/GeoNode-mixin.js" %}"></script>
<script type="text/javascript" src="{% static "geonode/js/extjs/Geonode-CatalogueApiSearch.js" %}"></script>
<script type="text/javascript" src="{% static "geonode/js/extjs/GeoNode-GeoExplorer.js" %}"></script>
<script type="text/javascript" src="{% static "geonode/js/utils/thumbnail.js" %}"></script>
<script type="text/javascript">
var app;
Ext.onReady(function() {
{% autoescape off %}
GeoExt.Lang.set("{{ LANGUAGE_CODE }}");
var config = Ext.apply({
tools: [{
ptype: "gxp_wmsgetfeatureinfo",
format: "grid",
actionTarget: "main.tbar",
outputConfig: {width: 400, height: 200, panIn: false}
}],
useToolbar: true,
{% if PROXY_URL %}
proxy: '{{ PROXY_URL }}',
{% endif %}
{% if MAPFISH_PRINT_ENABLED %}
printService: "{{GEOSERVER_BASE_URL}}pdf/",
{% else %}
printService: "",
{% endif %}
rest: "/maps/",
// tell the map viewer where and how to be rendered
portalConfig: {
height: 600,
renderTo: "the_map"
}
}, {{ config }});
app = new GeoExplorer.Viewer(config);
{% endautoescape %}
});
</script>

0 comments on commit aba1eb7

Please sign in to comment.