- Timestamp:
- May 26, 2011, 9:06:15 PM (13 years ago)
- Location:
- src/django_gheat/website
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/filters.py
r9213 r9217 16 16 import sys 17 17 import tempfile 18 import simplejson 18 19 19 20 20 # todo: Create one single json file with all relevent info needed for filters. 21 def get_filters(): 22 23 wlnodes = Accespoint.objects.filter(ssid__contains='WirelessLeiden').distinct() 24 wlnodelist = serializers.serialize('json', wlnodes, fields=('ssid')) 25 26 return wlnodelist 21 # todo: Create one single json file with all relevent info needed for filters. datum - meetrondje - gebruiker 22 def serve_filter(request, ftype): 23 filterlist = '' 24 if (ftype == 'filter_node'): 25 filterlist = get_node() 26 elif (ftype == 'filter_user'): 27 filterlist = get_user() 28 elif (ftype == 'filter_dataset'): 29 filterlist = get_dataset() 30 else: 31 print 'Invalid filter' 32 33 return HttpResponse(filterlist, content_type = 'application/javascript; charset=utf8') 27 34 28 35 29 def serve_filters(request):36 def get_node(): 30 37 31 filterlist = get_filters() 32 return HttpResponse(filterlist, content_type = 'application/javascript; charset=utf8') 38 nodes = Accespoint.objects.filter(ssid__contains='WirelessLeiden').distinct() 39 nodelist = serializers.serialize('json', nodes, fields=('ssid')) 40 return nodelist 41 42 43 def get_user(): 44 45 users = Gebruiker.objects.all() 46 userlist = serializers.serialize('json', users, fields=('naam')) 47 return userlist 48 49 50 def get_dataset(): 51 52 datasets = MeetRondje.objects.all() 53 datasetlist = serializers.serialize('json', datasets, fields=('naam', 'gebruiker')) 54 return datasetlist -
src/django_gheat/website/static/heatmap_extensions.js
r9216 r9217 37 37 function setNodeList(responseText) { 38 38 json=eval('(' + responseText + ')'); 39 var list = 'test';40 39 if (json.length>0){ 41 40 list = 'Wireless Leiden nodes on mouseposition:<br /><b>'; … … 52 51 53 52 54 55 /* 56 57 The following code is old, broken and for reference purposes. Will be removed when new code is done. 58 The above (new) code was used instead to make everything more easy when adding new pieces. 59 60 // Get filter values from django view and serve as option list 61 function getFilters(){ 62 var filterlist; 63 var nodelist; 64 var userlist; 65 var datasetlist; 66 67 if (window.XMLHttpRequest){ 68 nodelist=new XMLHttpRequest(); 69 userlist=new XMLHttpRequest(); 70 datasetlist=new XMLHttpRequest(); 71 } 72 else{ 73 nodelist=new ActiveXObject("Microsoft.XMLHTTP"); 74 userlist=new ActiveXObject("Microsoft.XMLHTTP"); 75 datasetlist=new ActiveXObject("Microsoft.XMLHTTP"); 76 } 77 78 var list = '<form method="get" action="">'; 79 80 81 // todo: Get new options if one option is selected; every user has different datasets, make sure when user 'John' is selected, you can only choose datasets who are his. 82 83 userlist.onreadystatechange=function(){ 84 if (userlist.readyState==4 && userlist.status==200){ 85 userlist=eval('(' + userlist.responseText + ')'); 86 87 list += '<select id="user" style="width:104px"><option></option>'; 88 for (var i=0; i<userlist.length; i++){ 89 list += '<option>' + userlist[i].fields.naam + '</option>'; 90 } 91 list += '</select> User<br />'; 92 93 document.getElementById('filter_list').innerHTML=list; 94 } 95 } 96 97 98 99 100 nodelist.onreadystatechange=function(){ 101 if (nodelist.readyState==4 && nodelist.status==200){ 102 nodelist=eval('(' + nodelist.responseText + ')'); 103 104 list += '<select id="wlnode" style="width:104px"><option></option>'; 105 for (var i=0; i<nodelist.length; i++){ 106 list += '<option>' + nodelist[i].fields.ssid + '</option>'; 107 } 108 list += '</select> WLnode<br />'; 109 110 document.getElementById('filter_list').innerHTML=list; 111 } 112 } 113 114 115 datasetlist.onreadystatechange=function(){ 116 if (datasetlist.readyState==4 && datasetlist.status==200){ 117 datasetlist=eval('(' + datasetlist.responseText + ')'); 118 119 list += '<select id="dataset" style="width:104px"><option></option>'; 120 for (var i=0; i<datasetlist.length; i++){ 121 list += '<option>' + datasetlist[i].fields.naam + '</option>'; 122 } 123 list += '</select> Dataset<br />'; 124 125 document.getElementById('filter_list').innerHTML=list; 126 } 127 } 128 129 130 list += '<input type="text" id="enc" name="enc" size="10"/> Encrypted<br />'; 131 list += '<input type="text" id="colour" name="colour" size="10"/> Colour<br />'; 132 list += '<input type="text" id="lname" name="lname" size="10"/> Layername<br />'; 133 list += '<input type="button" value="Add filter" onClick="addFilter()"/>'; 134 list += '</form>'; 135 136 137 138 139 140 nodelist.open("GET","/website/filters/1",true); 141 nodelist.send(); 142 userlist.open("GET","/website/filters/2",true); 143 userlist.send(); 144 datasetlist.open("GET","/website/filters/3",true); 145 datasetlist.send(); 146 } 147 148 149 // Some value checks, create an overlay using these values and place it on the map. 53 function filter_node() { 54 var url = "/website/filter/filter_node"; 55 var ajax = new AjaxRequest(url, set_filter_node); 56 ajax.doGet(); 57 } 58 59 60 function set_filter_node(responseText) { 61 json=eval('(' + responseText + ')'); 62 list = '<form method="get" action=""><select id="wlnode" style="width:104px"><option></option>'; 63 for (var i=0; i<json.length; i++){ 64 list += '<option>' + json[i].fields.ssid + '</option>'; 65 } 66 list += '</select> WLnode<br /><input type="button" value="Add filter" onClick="addFilter()"/></form>'; 67 document.getElementById('filter_list').innerHTML=list; 68 } 69 70 150 71 function addFilter(){ 151 72 … … 155 76 var enc =''; 156 77 var date = ''; 157 var colour = encodeURIComponent(document.getElementById("colour").value);158 var lname = encodeURIComponent(document.getElementById("lname").value);78 var colour = ''; 79 var lname = ''; 159 80 160 81 if (user != ''){user='&accespoint__id='+user;} … … 185 106 map.addLayer(filterlayer); 186 107 } 108 109 110 /* 111 112 The following code is old, broken and for reference purposes. Will be removed when new code is done. 113 The above (new) code was used instead to make everything more easy when adding new pieces. 114 115 // Get filter values from django view and serve as option list 116 function getFilters(){ 117 var filterlist; 118 var nodelist; 119 var userlist; 120 var datasetlist; 121 122 if (window.XMLHttpRequest){ 123 nodelist=new XMLHttpRequest(); 124 userlist=new XMLHttpRequest(); 125 datasetlist=new XMLHttpRequest(); 126 } 127 else{ 128 nodelist=new ActiveXObject("Microsoft.XMLHTTP"); 129 userlist=new ActiveXObject("Microsoft.XMLHTTP"); 130 datasetlist=new ActiveXObject("Microsoft.XMLHTTP"); 131 } 132 133 var list = '<form method="get" action="">'; 134 135 136 // todo: Get new options if one option is selected; every user has different datasets, make sure when user 'John' is selected, you can only choose datasets who are his. 137 138 userlist.onreadystatechange=function(){ 139 if (userlist.readyState==4 && userlist.status==200){ 140 userlist=eval('(' + userlist.responseText + ')'); 141 142 list += '<select id="user" style="width:104px"><option></option>'; 143 for (var i=0; i<userlist.length; i++){ 144 list += '<option>' + userlist[i].fields.naam + '</option>'; 145 } 146 list += '</select> User<br />'; 147 148 document.getElementById('filter_list').innerHTML=list; 149 } 150 } 151 152 153 154 155 nodelist.onreadystatechange=function(){ 156 if (nodelist.readyState==4 && nodelist.status==200){ 157 nodelist=eval('(' + nodelist.responseText + ')'); 158 159 list += '<select id="wlnode" style="width:104px"><option></option>'; 160 for (var i=0; i<nodelist.length; i++){ 161 list += '<option>' + nodelist[i].fields.ssid + '</option>'; 162 } 163 list += '</select> WLnode<br />'; 164 165 document.getElementById('filter_list').innerHTML=list; 166 } 167 } 168 169 170 datasetlist.onreadystatechange=function(){ 171 if (datasetlist.readyState==4 && datasetlist.status==200){ 172 datasetlist=eval('(' + datasetlist.responseText + ')'); 173 174 list += '<select id="dataset" style="width:104px"><option></option>'; 175 for (var i=0; i<datasetlist.length; i++){ 176 list += '<option>' + datasetlist[i].fields.naam + '</option>'; 177 } 178 list += '</select> Dataset<br />'; 179 180 document.getElementById('filter_list').innerHTML=list; 181 } 182 } 183 184 185 list += '<input type="text" id="enc" name="enc" size="10"/> Encrypted<br />'; 186 list += '<input type="text" id="colour" name="colour" size="10"/> Colour<br />'; 187 list += '<input type="text" id="lname" name="lname" size="10"/> Layername<br />'; 188 list += '<input type="button" value="Add filter" onClick="addFilter()"/>'; 189 list += '</form>'; 190 191 192 193 194 195 nodelist.open("GET","/website/filters/1",true); 196 nodelist.send(); 197 userlist.open("GET","/website/filters/2",true); 198 userlist.send(); 199 datasetlist.open("GET","/website/filters/3",true); 200 datasetlist.send(); 201 } 187 202 */ -
src/django_gheat/website/templates/home.html
r9216 r9217 29 29 30 30 31 <body onload="init() ">31 <body onload="init(), filter_node()"> 32 32 <div id="heatmap"></div> 33 33 <div id="container"> -
src/django_gheat/website/urls.py
r9213 r9217 39 39 urlpatterns += patterns('website.filters', 40 40 url( 41 regex = r'^filter s$',42 view = 'serve_filter s',43 name = 'serve_filter s',41 regex = r'^filter/(?P<ftype>[a-z_]+)$', 42 view = 'serve_filter', 43 name = 'serve_filter', 44 44 ), 45 45 )
Note:
See TracChangeset
for help on using the changeset viewer.