Skip to content

Commit

Permalink
issue planetfederal#230 - display server title and URL above capsgrid
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed Apr 22, 2014
1 parent 3cfda14 commit 91a0022
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
54 changes: 47 additions & 7 deletions src/script/plugins/AddLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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({
Expand Down
7 changes: 7 additions & 0 deletions src/script/plugins/LayerSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 3 additions & 2 deletions src/script/plugins/WFSSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/script/plugins/WMSSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 91a0022

Please sign in to comment.