[Mapbender-commits] r8711 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Oct 4 03:20:37 PDT 2013


Author: armin11
Date: 2013-10-04 03:20:37 -0700 (Fri, 04 Oct 2013)
New Revision: 8711

Added:
   trunk/mapbender/http/plugins/mb_metadata_gml_import.js
Log:
First draft to upload a simple gml polygon to mb_metadata table

Added: trunk/mapbender/http/plugins/mb_metadata_gml_import.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_gml_import.js	                        (rev 0)
+++ trunk/mapbender/http/plugins/mb_metadata_gml_import.js	2013-10-04 10:20:37 UTC (rev 8711)
@@ -0,0 +1,88 @@
+var $gmlImport = $(this);
+var importGmlMetadataId;
+
+var GmlImportApi = function () {
+	var that = this;
+	var type;
+	
+	this.events = {
+		"uploadComplete" : new Mapbender.Event()
+	};
+	
+	this.events.uploadComplete.register(function () {
+		$gmlImport.dialog("close");
+	});
+	
+	var importUploadedFile = function(filename, metadataId, callback){
+		var req = new Mapbender.Ajax.Request({
+			url: "../plugins/mb_metadata_server.php",
+			method: "importGmlAddon",
+			parameters: {
+				filename: filename,
+				"metadataId": metadataId
+			},
+			callback: function (obj, result, message, errorCode) {				
+				if (!result) {
+					switch (errorCode) {
+						case -1002:
+							alert("file: "+filename+"has problems: "+message);
+							break;
+						default:
+							alert(message);
+							return;
+					}
+				}
+				alert(message);
+				$gmlImport.dialog("close");
+				//invoke external script from mb_metadata_showMetadataAddon.js
+				//that.fillLayerForm(layerId);
+				//Mapbender.modules.mb_md_showMetadataAddon.fillLayerForm(layerId);
+				if ($.isFunction(callback)) {
+					callback(obj.id);
+				}
+			}
+		});
+		req.send();
+	};
+
+	$gmlImport.upload({
+		size: 10,
+		timeout: 20000,
+		url: "../plugins/jq_upload.php",
+		callback: function(result,stat,msg){
+			if(!result){ 
+				alert(msg);
+				return;
+			}
+	        var uploadResultName = result.filename;
+	        var uploadResultOrigName = result.origFilename;
+	        
+	        importUploadedFile(result.filename, that.importGmlMetadataId, function (id) {
+		        that.events.uploadComplete.trigger({
+					"type": type,
+					"id": id
+				});
+			}); 
+    	}
+	}).dialog({
+		title: 'GML Import',
+		autoOpen: false,
+		modal: false,
+		width: 580
+	});
+
+
+	this.init = function (obj) {
+		type = obj.type;
+		$gmlImport.dialog("open");
+	};
+
+	initGmlImport = function (metadataId) {
+		that.importGmlMetadataId = metadataId;
+		$gmlImport.dialog("open");
+		return true;
+	};
+	
+};
+
+$gmlImport.mapbender(new GmlImportApi());



More information about the Mapbender_commits mailing list