Changeset 5698 for cowsclient


Ignore:
Timestamp:
09/09/09 10:11:29 (10 years ago)
Author:
pnorton
Message:

Implemented the display options to hide and set defaults for named endpoints and layers. This was done to hide some of the less common display options provided by the server but also allow them to be set on specific datasets.

Location:
cowsclient/trunk
Files:
5 added
9 edited

Legend:

Unmodified
Added
Removed
  • cowsclient/trunk/buildout

    • Property svn:ignore
      •  

        old new  
        11.installed.cfg 
         2pnorton_buildout.cfg 
  • cowsclient/trunk/cowsclient/controllers/wmsviz.py

    r5685 r5698  
    1717from cowsclient.model import selectedItem 
    1818from cowsclient.lib.build_figure import build_figure 
     19from cowsclient.lib.display_options_config import getDisplayOptionsConfig 
    1920 
    2021import cowsclient.lib.utils as utils 
     
    145146             
    146147        c.initialSetupJSON = utils.toJSON(initialSetup)  
    147  
     148         
     149        displayOptsConfig = getDisplayOptionsConfig() 
     150         
     151        if 'HideOptions' in displayOptsConfig: 
     152            c.hideDisplayOptions = utils.toJSON(displayOptsConfig['HideOptions']) 
     153        else: 
     154            c.hideDisplayOptions = "" 
     155 
     156        if 'DefaultOptions' in displayOptsConfig: 
     157            c.defaultOptions = utils.toJSON(displayOptsConfig['DefaultOptions']) 
     158        else: 
     159            c.defaultOptions = "" 
     160         
     161        log.debug("c.defaultOptions = %s" % (c.defaultOptions,)) 
    148162         
    149163        params = {} 
  • cowsclient/trunk/cowsclient/lib/utils.py

    r5671 r5698  
    3535 
    3636def toJSON(obj): 
    37     return json.dumps(obj).replace('"', '\\"')  
     37    return json.dumps(obj).replace('"', '\\"') 
     38 
     39 
  • cowsclient/trunk/cowsclient/public/js/layerControl.js

    r5685 r5698  
    2929     *     NB, this control must include a method, updateDomainDiv(OpenLayers.Bounds) 
    3030     */ 
    31     initialize: function(treeDiv, layerDiv, wmcRetriever, newEndpointInputId, addNewEndpointBtnId )  
     31    initialize: function(treeDiv, layerDiv, wmcRetriever, newEndpointInputId, addNewEndpointBtnId, defaultOptionsList )  
    3232    { 
    3333        WMSC.log("Initialising Control"); 
     
    6060        this.idIndex = 0; 
    6161         
    62         this.defaultParams = { 
     62        globalDefaultParams = { 
    6363                format: 'image/png',  
    6464                version: '1.3.0',  
    6565                CRS: 'CRS:84',  
    6666                transparent: 'true'}; 
     67         
     68        this.defaultSetter = new LayerDefaultSetter(globalDefaultParams, defaultOptionsList); 
     69         
    6770         
    6871        this.layersToSelect = {}; 
     
    389392     */ 
    390393    makeNewLayer: function(url, layerName) { 
     394         
     395        var defaultParams = this.defaultSetter.getDefaults(url, layerName)  
     396         
    391397        var layer = new OpenLayers.Layer.WMS("#" + this.idIndex + " " + layerName,  
    392                 url, this.defaultParams); 
     398                url, defaultParams); 
    393399 
    394400        layer.params['LAYERS'] = layerName 
  • cowsclient/trunk/cowsclient/public/js/layerDisplayOptions.js

    r5690 r5698  
    2424 * @constructor 
    2525 */ 
    26 LayerDisplayOpts = function(layerDisplayOptionsFormId) { 
     26LayerDisplayOpts = function(layerDisplayOptionsFormId, hideDisplayOptions) { 
    2727     
    2828    this._form = document.getElementById(layerDisplayOptionsFormId); 
    2929    this.events = new OpenLayers.Events(this, null, this.EVENTS_RAISED); 
    3030    this.displayOptsRetriever = new DisplayOptionsRetriever(); 
     31    this.hideDisplayOptions = hideDisplayOptions; 
    3132    this.currentWMCLayer = null; 
    3233    this.currentOLLayer = null; 
     
    120121                this._clearForm(); 
    121122                 
     123                var endpoint = this.currentOLLayer.url; 
     124                var hideOptions = []; 
     125                 
     126                if (this.hideDisplayOptions != null) { 
     127                    for (var i=0;i<this.hideDisplayOptions.length;i++) { 
     128                         
     129                        if (reMatch(this.hideDisplayOptions[i].endpoint, endpoint)) { 
     130                            for (var j=0;j<this.hideDisplayOptions[i].options.length;j++) { 
     131                                hideOptions.push(this.hideDisplayOptions[i].options[j]); 
     132                            } 
     133                        } 
     134                         
     135                    } 
     136                } 
     137                 
     138                WMSC.log("Hideoptions =" + hideOptions) 
     139                 
    122140            var fs = document.createElement('fieldset'); 
    123141            var leg = document.createElement('legend'); 
     
    126144 
    127145            if (displayOptions.common != undefined) { 
    128                 fs.appendChild(this._buildDisplayOptionsList(displayOptions.common)); 
     146                fs.appendChild(this._buildDisplayOptionsList(displayOptions.common, hideOptions)); 
    129147            } 
    130148             
     
    134152            if (currentStyle != null) { 
    135153                if (displayOptions[currentStyle] != undefined) { 
    136                     fs.appendChild(this._buildDisplayOptionsList(displayOptions[currentStyle])); 
     154                    fs.appendChild(this._buildDisplayOptionsList(displayOptions[currentStyle], hideOptions)); 
    137155                } 
    138156            } 
     
    151169         * @returns a div object containing all the inputs objects 
    152170         */ 
    153         _buildDisplayOptionsList: function(optionsList) { 
     171        _buildDisplayOptionsList: function(optionsList, hideOptions) { 
    154172            var div = document.createElement('div'); 
    155173 
    156174            for (var i=0; i< optionsList.length; i++) { 
    157175                var opt = optionsList[i]; 
     176                 
     177                if (isValueInList(opt.name, hideOptions)) { 
     178                    continue; 
     179                } 
    158180 
    159181                if (opt.type == 'select') { 
  • cowsclient/trunk/cowsclient/public/js/layerParameters.js

    r5626 r5698  
    1414 * @constructor 
    1515 */ 
    16 LayerParameters = function(propertiesDivId, selectionFormId, wmcRetriever) { 
     16LayerParameters = function(propertiesDivId, selectionFormId, wmcRetriever, hideDisplayOptions) { 
    1717     
    1818     
    19     this.layerDisplay = new LayerDisplayOpts(selectionFormId); 
     19    this.layerDisplay = new LayerDisplayOpts(selectionFormId, hideDisplayOptions); 
    2020    this.layerInfo = new LayerInfo('layer_info_form'); 
    2121    this.layerDims = new LayerDimensions('WMSC_dimForm'); 
  • cowsclient/trunk/cowsclient/public/js/utils.js

    r5690 r5698  
    319319} 
    320320 
     321reMatch = function (expression, txt) { 
     322    var re = new RegExp(expression); 
     323    var result = re.test(txt); 
     324    WMSC.log("expression =" + expression + " text =" + txt + " match = " + result); 
     325    return result; 
     326}; 
  • cowsclient/trunk/cowsclient/templates/wmsviz.html

    r5690 r5698  
    102102<script src="$g.server/js/wmcRetriever.js"></script> 
    103103 
     104<script src="$g.server/js/layerDefaultSetter.js"></script> 
     105 
    104106<!-- END: WMSC library --> 
    105107<script type="text/javascript"> 
     
    113115var defaultEndpoints = JSON.parse("${c.defaultWMSEndpoints}"); 
    114116 
     117var hideDisplayOptions = JSON.parse("${c.hideDisplayOptions}"); 
     118var defaultOptions = JSON.parse("${c.defaultOptions}"); 
     119 
    115120<?python 
    116121from pylons import session  
    117122?>     
    118123 
     124 
    119125function alertWMC(wmc) { 
    120126        //alert("wmc = " + wmc); 
     
    124130{ 
    125131 
     132 
    126133        var initialSetupJSON = "${c.initialSetupJSON}"; 
    127134        var baseLayerJSON = "${c.baseLayerJSON}"; 
     
    138145         
    139146        layerList = new LayerList('layer_list');         
    140     layerParameters = new LayerParameters('layer_properties', 'selection_form', wmcRetriever); 
     147    layerParameters = new LayerParameters('layer_properties', 'selection_form', wmcRetriever, hideDisplayOptions); 
    141148     
    142149    var legendContainer = new LegendContainer('legend'); 
     
    147154     
    148155    var coordControl = null; 
    149     var layerControl = new WMSC.VisAppLayers('layerTree', 'layerLeaves',wmcRetriever, 'new_endpoint', 'add_new_endpoint');   
     156    var layerControl = new WMSC.VisAppLayers('layerTree', 'layerLeaves',wmcRetriever, 'new_endpoint', 'add_new_endpoint', defaultOptions);   
    150157 
    151158 
  • cowsclient/trunk/development.ini

    r5626 r5698  
    2020full_stack = true 
    2121cache_dir = %(here)s/data 
    22 #cache_dir = /data/pnorton/ui_cache/  
    2322beaker.session.key = cowsclient 
    2423beaker.session.secret = somesecret 
     
    3332#baselayer.params = layers:l,format:image/png 
    3433 
     34# Add a list of pre-defined endpoints to the UI 
     35#endpointList = %(here)s/endpoints.txt 
     36 
     37# Set some of the display options rules 
     38#displayOptionsConfig = %(here)s/displayOptions.ini 
    3539 
    3640# If you'd like to fine-tune the individual locations of the cache data dirs 
Note: See TracChangeset for help on using the changeset viewer.