diff --git a/geonode/geoserver/context_processors.py b/geonode/geoserver/context_processors.py
index 464cfffa772..572a02469a1 100644
--- a/geonode/geoserver/context_processors.py
+++ b/geonode/geoserver/context_processors.py
@@ -30,6 +30,7 @@ def geoserver_urls(request):
GEOSERVER_BASE_URL=ogc_server_settings.public_url,
UPLOADER_URL=reverse("importer_upload"),
LAYER_ANCILLARY_FILES_UPLOAD_URL=reverse("importer_upload"),
+ EXECUTION_STATUS_ENDPOINT=reverse("executionrequest-list"),
MAPFISH_PRINT_ENABLED=getattr(ogc_server_settings, "MAPFISH_PRINT_ENABLED", False),
PRINT_NG_ENABLED=getattr(ogc_server_settings, "PRINT_NG_ENABLED", False),
GEONODE_SECURITY_ENABLED=getattr(ogc_server_settings, "GEONODE_SECURITY_ENABLED", False),
diff --git a/geonode/layers/templates/datasets/dataset_metadata_upload.html b/geonode/layers/templates/datasets/dataset_metadata_upload.html
index 37a737436cd..d2d832ec20e 100644
--- a/geonode/layers/templates/datasets/dataset_metadata_upload.html
+++ b/geonode/layers/templates/datasets/dataset_metadata_upload.html
@@ -79,6 +79,7 @@
{% trans "Files to be uploaded" %}
csrf_token = "{{ csrf_token }}",
form_target = "{{ LAYER_ANCILLARY_FILES_UPLOAD_URL }}",
+ executions_status_endpoint = "{{EXECUTION_STATUS_ENDPOINT}}",
time_enabled = false,
mosaic_enabled = false,
userLookup = "{% url "account_ajax_lookup" %}"
diff --git a/geonode/layers/templates/datasets/dataset_style_upload.html b/geonode/layers/templates/datasets/dataset_style_upload.html
index c230838a4a8..86d8a8f8fd6 100644
--- a/geonode/layers/templates/datasets/dataset_style_upload.html
+++ b/geonode/layers/templates/datasets/dataset_style_upload.html
@@ -80,6 +80,7 @@ {% trans "Files to be uploaded" %}
csrf_token = "{{ csrf_token }}",
form_target = "{{ LAYER_ANCILLARY_FILES_UPLOAD_URL }}",
+ executions_status_endpoint = "{{EXECUTION_STATUS_ENDPOINT}}",
time_enabled = false,
mosaic_enabled = false,
userLookup = "{% url "account_ajax_lookup" %}"
diff --git a/geonode/settings.py b/geonode/settings.py
index c8cdcea39fe..8c1356199a0 100644
--- a/geonode/settings.py
+++ b/geonode/settings.py
@@ -2328,7 +2328,9 @@ def get_geonode_catalogue_service():
'importer.handlers.shapefile.handler.ShapeFileHandler',\
'importer.handlers.kml.handler.KMLFileHandler',\
'importer.handlers.csv.handler.CSVFileHandler',\
- 'importer.handlers.geotiff.handler.GeoTiffFileHandler'\
+ 'importer.handlers.geotiff.handler.GeoTiffFileHandler',\
+ 'importer.handlers.xml.handler.XMLFileHandler',\
+ 'importer.handlers.sld.handler.SLDFileHandler',\
]",
)
)
diff --git a/geonode/static/geonode/js/upload/LayerInfo.js b/geonode/static/geonode/js/upload/LayerInfo.js
index 4d4c4385172..25ada87d17d 100644
--- a/geonode/static/geonode/js/upload/LayerInfo.js
+++ b/geonode/static/geonode/js/upload/LayerInfo.js
@@ -404,6 +404,14 @@ define(function (require, exports) {
});
};
+ LayerInfo.prototype.markEnd = function () {
+ this.logStatus({
+ msg: 'Your upload was succesfull!',
+ level: 'alert-success',
+ empty: 'true'
+ });
+ };
+
LayerInfo.prototype.doResume = function (event) {
$(this).text(gettext('Finalizing')).attr('disabled', 'disabled').after('
');
var id = (new Date()).getTime();
@@ -479,13 +487,36 @@ define(function (require, exports) {
});
};
- LayerInfo.prototype.startPolling = function() {
+ LayerInfo.prototype.startPolling = function(execution_id) {
var self = this;
+ const baseUrl = siteUrl + executions_status_endpoint;
if (self.polling) {
- $.ajax({ url: updateUrl(siteUrl + "upload/progress", 'id', self.id), type: 'GET', success: function(data){
+ $.ajax({
+ url: baseUrl + "?import&filter{source}=resource_file_upload&page=1&page_size=99999", type: 'GET', success: function(data){
// TODO: Not sure we need to do anything here?
//console.log('polling');
- }, dataType: "json", complete: setTimeout(function() {self.startPolling()}, 3000), timeout: 30000 });
+ },
+ dataType: "json",
+ success: function(resp, code) {
+ if (resp.requests && resp.requests.length>0) {
+ const execution_data = resp.requests.find((req) => req.exec_id === execution_id);
+ if (execution_data.status == 'finished'){
+ self.polling = false;
+ self.markEnd();
+ $.ajax({url: baseUrl + "/" + execution_id, type: "DELETE"});
+ if (execution_data.output_params && execution_data.output_params['detail_url']) {
+ const detail_url = execution_data.output_params['detail_url'];
+ if (detail_url != '') {
+ window.location = detail_url;
+ }
+ }
+
+ }
+ }
+ setTimeout(function() {self.startPolling(execution_id)}, 3000)
+ },
+ timeout: 30000
+ })
}
};
@@ -675,8 +706,6 @@ define(function (require, exports) {
},
beforeSend: function () {
self.markStart();
- self.polling = true;
- self.startPolling();
},
error: function (jqXHR) {
self.polling = false;
@@ -713,13 +742,16 @@ define(function (require, exports) {
callback(array);
},
success: function (resp, status) {
- self.logStatus({
+ /*self.logStatus({
msg: '' + gettext('Layer files uploaded, configuring in GeoServer') + '
',
level: 'alert-success',
empty: 'true'
});
self.id = resp.id;
self.doStep(resp, callback, array);
+ */
+ self.polling = true;
+ self.startPolling(resp.execution_id);
}
});
};