Permalink
Browse files

New wsgi script to get data from table and add query parameter for se…

…arch
  • Loading branch information...
uprel committed Feb 2, 2019
1 parent 954f9dc commit ff224ee9601790fa96be555a28bdf6a7d2be9eff
Showing with 23 additions and 50 deletions.
  1. +2 −44 client/site/js/TriStateTree.js
  2. +21 −6 client/wsgi/data.wsgi
@@ -124,50 +124,8 @@ Ext.override(Ext.tree.TreeNodeUI, {
if(!this.disabled){
this.toggleCheck();
}
// Modified code, AN
var wasChecked = this.node.attributes.checked == null ? false : !this.node.attributes.checked;
var isChecked = !wasChecked;
var isParent = !this.node.isLeaf();

if(isParent) {
if(wasChecked && !this.node.isExpanded()) {
this.node.expand(true, false, function(node) {
node.cascade(function(node) {
if (node.isLeaf() && layerOrderPanel != null) {
if (isChecked != layerOrderPanel.layerVisible(wmsLoader.layerTitleNameMapping[node.text])) {
layerOrderPanel.toggleLayerVisibility(wmsLoader.layerTitleNameMapping[node.text]);
}
}
}, this);
});
this.node.ownerTree.fireEvent('leafschange');
this.node.collapse(true,false);
}
else {
var i = 0;
this.node.cascade(function(node) {
if (node.isLeaf() && layerOrderPanel != null) {
if (isChecked != layerOrderPanel.layerVisible(wmsLoader.layerTitleNameMapping[node.text])) {
layerOrderPanel.toggleLayerVisibility(wmsLoader.layerTitleNameMapping[node.text]);
}
}
if (i == this.node.childNodes.length) {
this.node.ownerTree.fireEvent('leafschange');
}
i++;
}, this);
}
}
else {
wasChecked ? this.node.ownerTree.checkedLeafs.push(this.node) : this.node.ownerTree.checkedLeafs.remove(this.node);
if (layerOrderPanel != null) {
if (isChecked != layerOrderPanel.layerVisible(wmsLoader.layerTitleNameMapping[this.node.text])) {
layerOrderPanel.toggleLayerVisibility(wmsLoader.layerTitleNameMapping[this.node.text]);
}
}
this.node.ownerTree.fireEvent('leafschange');
}
// End of Modified code, AN
this.node.ownerTree.fireEvent('checkboxclick', this.node);
this.node.ownerTree.fireEvent('leafschange');
},
onCheckboxOver:function() {
this.addClass('x-tree-checkbox-over');
@@ -1,7 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#sample queries
#http://localhost/wsgi/data.wsgi?table=lookup.temakode&filter=SOSI%20kode&gtype=2&cb=bla
#if query paramater is missing whole table is returned
#http://localhost/wsgi/data.wsgi?table=lookup.temakode&category=SOSI%20kode&gtype=2&query=1234&cb=bla

import re #regular expression support
import string #string manipulation support
@@ -26,8 +27,13 @@ def application(environ, start_response):

table = request.params["table"]
gtype = request.params["gtype"]

filterString = request.params["filter"]
categoryString = request.params["category"]

queryString = ''
if "query" in request.params:
queryString = request.params["query"]
#strip away leading and trailing whitespaces
queryString = queryString.strip()

sql = ""
errorText = ''
@@ -44,16 +50,25 @@ def application(environ, start_response):
# else:
# filt.extend(filterString.split(','))

filt.extend(filterString.split(','))
filt.extend(categoryString.split(','))
filtLength = len(filt)

#add single quotes
for i in range(filtLength):
filt[i] = "'"+filt[i]+"'"

sql += "SELECT code, description FROM " + table + " WHERE category IN("+','.join(filt)+") AND geom_type="+gtype+";"
sql += "SELECT code, description FROM " + table + " WHERE category IN("+','.join(filt)+") AND geom_type="+gtype

if queryString:
#sql += " AND (description ILIKE '%"+query+"%' OR code::text ILIKE '%"+query+"%')"
sql += " AND (description ILIKE %s"
data += ("%" + queryString + "%",)
sql += " OR code::text ILIKE %s)"
data += ("%" + queryString + "%",)

sql += ";"

#sql += "SELECT * FROM " + table + ";"
#return [sql]

conn = qwc_connect.getConnection(environ, start_response)

0 comments on commit ff224ee

Please sign in to comment.