From 91a0022c33abf221223e4a122a5515d6b01f89e1 Mon Sep 17 00:00:00 2001 From: Just van den Broecke <just@justobjects.nl> Date: Tue, 22 Apr 2014 17:55:18 +0200 Subject: [PATCH] issue #230 - display server title and URL above capsgrid --- src/script/plugins/AddLayers.js | 54 +++++++++++++++++++++++++++---- src/script/plugins/LayerSource.js | 7 ++++ src/script/plugins/WFSSource.js | 5 +-- src/script/plugins/WMSSource.js | 6 ++-- 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/script/plugins/AddLayers.js b/src/script/plugins/AddLayers.js index 70a169c6..595a9c0a 100644 --- a/src/script/plugins/AddLayers.js +++ b/src/script/plugins/AddLayers.js @@ -255,6 +255,18 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { */ catalogSourceKey: null, + /** api: config[catalogPanelWidth] + * ``Number`` + * Initial width of the CSW catalog panel. + */ + catalogPanelWidth: 440, + + /** api: config[catalogPanelHeight] + * ``Number`` + * Initial height of the CSW catalog panel. + */ + catalogPanelHeight: 300, + /** api: config[templatedLayerGrid] * ``Boolean`` * Show the layer grid as single-column and using an ExtJS Template from ``layerGridTemplate``. Default is ``false``. @@ -441,8 +453,8 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { var output = gxp.plugins.AddLayers.superclass.addOutput.apply(this, [{ sources: sources, title: this.searchText, - height: 300, - width: 315, + height: this.catalogPanelHeight, + width: this.catalogPanelWidth, selectedSource: selectedSource, xtype: 'gxp_cataloguesearchpanel', map: this.target.mapPanel.map @@ -649,7 +661,8 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { this.addLayers(recordsToAdd); } } - for (var i=0, ii=records.length; i<ii; ++i) { + + for (var i = 0, ii = records.length; i < ii; ++i) { var record = source.createLayerRecord({ name: records[i].get("name"), source: source.id @@ -737,7 +750,7 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { var sourceComboBox = new Ext.form.ComboBox({ ref: "../sourceComboBox", - width: 165, + width: 240, store: sources, valueField: "id", displayField: "title", @@ -936,7 +949,34 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { } } - var items = { + var panelItems = []; + panelItems.push(capGridPanel); + + var serverInfoItem = { + xtype: "box", + region: "north", + height: 24, + autoWidth: true, + tpl: new Ext.Template('<div style="margin-left:6px; margin-top:2px; margin-bottom: 2px"><span style="font-weight: bold">{serverTitle}</span><br><span style="color: #aaaaaa">{serverUrl}</span></div>'), + listeners: { + 'afterrender': function (e) { + var box = this; + if (sources) { + var sourceRec = sources.getAt(0); + box.update({serverTitle: sourceRec.data.title, serverUrl: sourceRec.data.url}); + + } + sourceComboBox.on('select', + function (obj) { + var title = self.selectedSource.serviceTitle ? self.selectedSource.serviceTitle : self.selectedSource.title; + box.update({serverTitle: title, serverUrl: self.selectedSource.url}); + } + ); + } + } + }; + + var items = [serverInfoItem, { xtype: "panel", region: "center", layout: "fit", @@ -946,8 +986,8 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { top: 8 }, tbar: sourceToolsItems, - items: [capGridPanel] - }; + items: panelItems + }]; if (this.instructionsText) { items.items.push({ diff --git a/src/script/plugins/LayerSource.js b/src/script/plugins/LayerSource.js index 7fe4adf5..6ef0ae15 100644 --- a/src/script/plugins/LayerSource.js +++ b/src/script/plugins/LayerSource.js @@ -52,11 +52,18 @@ gxp.plugins.LayerSource = Ext.extend(Ext.util.Observable, { */ title: "", + /** private: property[serviceTitle] + * ``String`` + * The title returned by the service. + */ + serviceTitle: "", + /** private: method[constructor] */ constructor: function(config) { this.initialConfig = config; Ext.apply(this, config); + this.serviceTitle = this.title; this.addEvents( /** api: event[ready] diff --git a/src/script/plugins/WFSSource.js b/src/script/plugins/WFSSource.js index 6a1dd86d..48896bf9 100644 --- a/src/script/plugins/WFSSource.js +++ b/src/script/plugins/WFSSource.js @@ -340,8 +340,9 @@ gxp.plugins.WFSSource = Ext.extend(gxp.plugins.LayerSource, { if (!this.store.reader.raw || !(this.store.reader.raw.service || this.store.reader.raw.serviceIdentification)) { this.fireEvent("failure", this, "Invalid capabilities document."); } else { - if (!this.title) { - this.title = this.store.reader.raw.service ? this.store.reader.raw.service.title : this.store.reader.raw.serviceIdentification.title; + this.serviceTitle = this.store.reader.raw.service ? this.store.reader.raw.service.title : this.store.reader.raw.serviceIdentification.title; + if (!this.title || this.title.length == 0) { + this.title = this.serviceTitle; } if (!this.ready) { this.ready = true; diff --git a/src/script/plugins/WMSSource.js b/src/script/plugins/WMSSource.js index fda63c02..7161654c 100644 --- a/src/script/plugins/WMSSource.js +++ b/src/script/plugins/WMSSource.js @@ -384,9 +384,11 @@ gxp.plugins.WMSSource = Ext.extend(gxp.plugins.LayerSource, { if (!this.store.reader.raw || !this.store.reader.raw.service) { this.fireEvent("failure", this, "Invalid capabilities document."); } else { - if (!this.title) { - this.title = this.store.reader.raw.service.title; + this.serviceTitle = this.store.reader.raw.service.title; + if (!this.title || this.title.length == 0) { + this.title = this.serviceTitle; } + if (!this.ready) { this.ready = true; this.fireEvent("ready", this);