Merge lp:~patrickas/ensoft-sextant/no-caching into lp:ensoft-sextant

Proposed by Patrick Stevens
Status: Merged
Approved by: Phil Connell
Approved revision: 24
Merged at revision: 22
Proposed branch: lp:~patrickas/ensoft-sextant/no-caching
Merge into: lp:ensoft-sextant
Diff against target: 277 lines (+117/-116)
1 file modified
resources/sextant/web/queryjavascript.js (+117/-116)
To merge this branch: bzr merge lp:~patrickas/ensoft-sextant/no-caching
Reviewer Review Type Date Requested Status
Phil Connell Approve
Review via email: mp+233341@code.launchpad.net

Commit message

Make Sextant Web ask browsers not to cache the SVGs generated.

Description of the change

Make Sextant Web ask browsers not to cache the SVGs generated. (This is done by adding a random query parameter to the image request.)

To post a comment you must log in.
22. By Patrick Stevens <email address hidden>

Merge trunk changes

23. By Patrick Stevens <email address hidden>

Revert change to sextant.conf

Revision history for this message
Phil Connell (pconnell) wrote :

Change looks fine, but sadly the file's indentation is utterly screwed up (so needs a change for consistency).

Revision history for this message
Phil Connell (pconnell) :
review: Needs Fixing
24. By Patrick Stevens <email address hidden>

Expand tabs into spaces

Revision history for this message
Phil Connell (pconnell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'resources/sextant/web/queryjavascript.js'
--- resources/sextant/web/queryjavascript.js 2014-09-04 09:46:18 +0000
+++ resources/sextant/web/queryjavascript.js 2014-09-04 16:05:30 +0000
@@ -7,13 +7,13 @@
77
88
9function get_names_for_autocomplete(info_needed){9function get_names_for_autocomplete(info_needed){
10 //Function queries to database to create a list 10 //Function queries to database to create a list
11 //which is used to populate the auto-complete text boxes.11 //which is used to populate the auto-complete text boxes.
12 var xmlhttp = new XMLHttpRequest();12 var xmlhttp = new XMLHttpRequest();
13 xmlhttp.onreadystatechange = function(){13 xmlhttp.onreadystatechange = function(){
14 if (xmlhttp.status = 200){14 if (xmlhttp.status = 200){
15 var values_list = xmlhttp.responseText;15 var values_list = xmlhttp.responseText;
16 if (values_list != "") {16 if (values_list != "") {
17 values_list = JSON.parse(values_list);17 values_list = JSON.parse(values_list);
18 if (info_needed =='programs'){18 if (info_needed =='programs'){
19 //We need to populate the program names list19 //We need to populate the program names list
@@ -22,42 +22,42 @@
22 if (info_needed =='funcs'){22 if (info_needed =='funcs'){
23 //We need to populate the functions list for the arguments23 //We need to populate the functions list for the arguments
24 add_options("function_names", values_list);24 add_options("function_names", values_list);
25 } 25 }
26 }26 }
27 }27 }
28 }28 }
29 if (info_needed == 'programs'){29 if (info_needed == 'programs'){
30 var string = "/database_properties?query=" + info_needed + "&program_name=";30 var string = "/database_properties?query=" + info_needed + "&program_name=";
31 }31 }
32 else{32 else{
33 var string = "/database_properties?query=" + "functions" + 33 var string = "/database_properties?query=" + "functions" +
34 "&program_name=" + document.getElementById("program_name").value;34 "&program_name=" + document.getElementById("program_name").value;
35 if (info_needed == 'programs'){35 if (info_needed == 'programs'){
36 var string = "/database_properties?query=" + 36 var string = "/database_properties?query=" +
37 info_needed + "&program_name=" + prog_name;37 info_needed + "&program_name=" + prog_name;
38 }38 }
39 //"GET" information from the specified url (string)39 //"GET" information from the specified url (string)
40 xmlhttp.open("GET", string, true);40 xmlhttp.open("GET", string, true);
41 xmlhttp.send();41 xmlhttp.send();
42 }42 }
43 xmlhttp.open("GET", string, true);43 xmlhttp.open("GET", string, true);
44 xmlhttp.send();44 xmlhttp.send();
45}45}
4646
4747
48function add_options(selectedlist, values_list){48function add_options(selectedlist, values_list){
49 //Adds all the options obtained from the list of program 49 //Adds all the options obtained from the list of program
50 //names or function names to an auto complete drop-down box50 //names or function names to an auto complete drop-down box
51 var options = ''51 var options = ''
52 if (values_list.length == 1 || values_list.length ==0){52 if (values_list.length == 1 || values_list.length ==0){
53 options += '<option value="'+values_list+'"/>';53 options += '<option value="'+values_list+'"/>';
54 }54 }
55 else{55 else{
56 for (var i=0; i < values_list.length;++i){56 for (var i=0; i < values_list.length;++i){
57 options += '<option value="'+values_list[i]+'"/>';57 options += '<option value="'+values_list[i]+'"/>';
58 }58 }
59 }59 }
60 document.getElementById(selectedlist).innerHTML = options;60 document.getElementById(selectedlist).innerHTML = options;
61}61}
6262
6363
@@ -83,32 +83,32 @@
83 = (label1 == "" && label2 == "") ? "none" : "block";83 = (label1 == "" && label2 == "") ? "none" : "block";
84}84}
8585
86 86
87function display_when(){87function display_when(){
88 //For each query specifies when auto-complete text boxes should be made 88 //For each query specifies when auto-complete text boxes should be made
89 //visible or invisible and makes them read only89 //visible or invisible and makes them read only
90 var query_list = document.getElementById("query_list");90 var query_list = document.getElementById("query_list");
9191
92 var no_functions = new Array();92 var no_functions = new Array();
93 var prog_name = document.getElementById("program_name").value;93 var prog_name = document.getElementById("program_name").value;
94 if (query_list.options[query_list.selectedIndex].value == "functions_calling"){94 if (query_list.options[query_list.selectedIndex].value == "functions_calling"){
95 set_arguments("Function being called", "");95 set_arguments("Function being called", "");
96 }96 }
97 if (query_list.options[query_list.selectedIndex].value == "functions_called_by"){97 if (query_list.options[query_list.selectedIndex].value == "functions_called_by"){
98 set_arguments("Function calling", "");98 set_arguments("Function calling", "");
99 }99 }
100 if (query_list.options[query_list.selectedIndex].value == "all_call_paths"){100 if (query_list.options[query_list.selectedIndex].value == "all_call_paths"){
101 set_arguments("Function calling", "Function being called");101 set_arguments("Function calling", "Function being called");
102 }102 }
103 if (query_list.options[query_list.selectedIndex].value == "shortest_call_path"){103 if (query_list.options[query_list.selectedIndex].value == "shortest_call_path"){
104 set_arguments("Function calling", "Function being called");104 set_arguments("Function calling", "Function being called");
105 }105 }
106 if (query_list.options[query_list.selectedIndex].value == "whole_program") {106 if (query_list.options[query_list.selectedIndex].value == "whole_program") {
107 set_arguments("", "");107 set_arguments("", "");
108 }108 }
109 if (query_list.options[query_list.selectedIndex].value == "function_names"){109 if (query_list.options[query_list.selectedIndex].value == "function_names"){
110 set_arguments("", "");110 set_arguments("", "");
111 }111 }
112}112}
113113
114114
@@ -116,66 +116,67 @@
116function execute_query(){116function execute_query(){
117 document.getElementById("output_image").src = "";117 document.getElementById("output_image").src = "";
118118
119 //Returns error in alert window if query not executed properly, 119 //Returns error in alert window if query not executed properly,
120 //otherwise performs the query and outputs it120 //otherwise performs the query and outputs it
121 show_item("please-wait");121 show_item("please-wait");
122 var query_id = document.getElementById("query_list").value;122 var query_id = document.getElementById("query_list").value;
123 if (query_id == "function_names"){123 if (query_id == "function_names"){
124 //url for page containing all function names124 //url for page containing all function names
125 var string = "/database_properties?program_name=" + 125 var string = "/database_properties?program_name=" +
126 document.getElementById("program_name").value + "&query=functions";126 document.getElementById("program_name").value + "&query=functions";
127 }127 }
128 else{128 else{
129 //If not function names we will want a graph as an output; 129 //If not function names we will want a graph as an output;
130 //url returns svg file of graph.130 //url returns svg file of graph.
131 var string = "/output_graph.svg?program_name=" + 131 // We use a random number argument to prevent caching.
132 document.getElementById("program_name").value + 132 var string = "/output_graph.svg?stop_cache=" + String(Math.random()) + "&program_name=" +
133 "&query=" + query_id + "&func1=";133 document.getElementById("program_name").value +
134 "&query=" + query_id + "&func1=";
134 string = string + document.getElementById("function_1").value + 135 string = string + document.getElementById("function_1").value +
135 "&func2=" + document.getElementById("function_2").value;136 "&func2=" + document.getElementById("function_2").value;
136 string = string + "&suppress_common=" + 137 string = string + "&suppress_common=" +
137 document.getElementById('suppress_common').checked.toString();138 document.getElementById('suppress_common').checked.toString();
138139
139 }140 }
140 var xmlhttp = new XMLHttpRequest();141 var xmlhttp = new XMLHttpRequest();
141 xmlhttp.open("GET", string, true);142 xmlhttp.open("GET", string, true);
142 xmlhttp.send();143 xmlhttp.send();
143 xmlhttp.onreadystatechange = function(){144 xmlhttp.onreadystatechange = function(){
144 if (xmlhttp.readyState == 4 && xmlhttp.status == 200){145 if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
145 //readyState == 4 means query has finished executing.146 //readyState == 4 means query has finished executing.
146 //status == 200 means "GET"ing has been successful.147 //status == 200 means "GET"ing has been successful.
147 if (query_id == "function_names"){148 if (query_id == "function_names"){
148 //Text output displayed in paragraph.149 //Text output displayed in paragraph.
149 document.getElementById("function_names_output").innerHTML = 150 document.getElementById("function_names_output").innerHTML =
150 xmlhttp.responseText;151 xmlhttp.responseText;
151 show_item("function_names_output");152 show_item("function_names_output");
152 }153 }
153 else{154 else{
154 show_item("output_image");155 show_item("output_image");
155 document.getElementById("output_image").src = string;156 document.getElementById("output_image").src = string;
156 }157 }
157 }158 }
158 else if (xmlhttp.readyState == 4 && xmlhttp.status == 400){159 else if (xmlhttp.readyState == 4 && xmlhttp.status == 400){
159 //Error occurred during query; display response.160 //Error occurred during query; display response.
160 show_error(xmlhttp.responseText);161 show_error(xmlhttp.responseText);
161 }162 }
162 else if(xmlhttp.readyState == 4 && xmlhttp.status == 404){163 else if(xmlhttp.readyState == 4 && xmlhttp.status == 404){
163 //Error occurred during query; display response.164 //Error occurred during query; display response.
164 show_error(xmlhttp.responseText);165 show_error(xmlhttp.responseText);
165 }166 }
166 else if(xmlhttp.readyState ==4 && xmlhttp.status == 204){167 else if(xmlhttp.readyState ==4 && xmlhttp.status == 204){
167 //Query executed correctly but graph returned is empty168 //Query executed correctly but graph returned is empty
168 show_error("Graph returned was empty");169 show_error("Graph returned was empty");
169 }170 }
170 else if (xmlhttp.readyState == 4 && xmlhttp.status == 502) {171 else if (xmlhttp.readyState == 4 && xmlhttp.status == 502) {
171 //Error occurs if Neo4j isn't running172 //Error occurs if Neo4j isn't running
172 show_error("Bad Gateway received - are you sure the database server is running?");173 show_error("Bad Gateway received - are you sure the database server is running?");
173 }174 }
174 else if(xmlhttp.readyState ==4){175 else if(xmlhttp.readyState ==4){
175 //query executed correctly176 //query executed correctly
176 show_error("An unknown error occurred");177 show_error("An unknown error occurred");
177 }178 }
178 }179 }
179}180}
180181
181function show_item(id) {182function show_item(id) {

Subscribers

People subscribed via source and target branches