diff options
author | Juha Sippola <juhasippola@ovi.com> | 2014-01-08 20:19:54 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-09 12:24:29 +0100 |
commit | 01d36f34170b2396605928ddc9105c1a8d962116 (patch) | |
tree | 3f09e0410bed451e937db6bd4e63ca9058785e49 /non-puppet/qtmetrics/ajaxrequest.js | |
parent | b335e24581fd4c4a0708a06f066f3f1a36cdb4bb (diff) |
Qt metrics v1.5.3: Ajax and metrics box structure refactoring
Some refactoring is needed to the Ajax module and its calls and
responses to make it easier to add new metrics pages and to avoid
duplicate code. This is pure implementation change and is not
visible to the user.
Changes include following:
The CI specific variable in metricsdefinitions.php was renamed to
be generic so that the same file structure can be used for new pages.
The multiple fixed filter parameters in get method changed to one
filter string so that the same interface can be used for different
needs.
The order of execution in initial page loading moved to one file
(metricspageci.php) to make it easier to adjust for different needs.
A common purpose function getLocalTime moved from ci/functions.php
to new file commonfunctions.php.
Change-Id: I899b8b7432f202ffbb67687b79ef9b8310a164bd
Reviewed-by: Tony SarajΓ€rvi <tony.sarajarvi@digia.com>
Diffstat (limited to 'non-puppet/qtmetrics/ajaxrequest.js')
-rw-r--r-- | non-puppet/qtmetrics/ajaxrequest.js | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/non-puppet/qtmetrics/ajaxrequest.js b/non-puppet/qtmetrics/ajaxrequest.js index 24bf72f..f501327 100644 --- a/non-puppet/qtmetrics/ajaxrequest.js +++ b/non-puppet/qtmetrics/ajaxrequest.js @@ -61,21 +61,16 @@ function createFilterRequestObject() } /* Request metric data (e.g. from database) */ -function getMetricData(metricId, filepath, project, conf, autotest, timescaleType, timescaleValue, sortBy) +function getMetricData(metricId, filepath, filters) { document.getElementById("metricsBox"+metricId).innerHTML = "<img src=\"images/ajax-loader.gif\" alt=\"loading\"> Loading..."; // Div content during the Ajax call - if (project == "") { + if (filters == "") { document.getElementById("metricsBox"+metricId).innerHTML = ""; return; } - if (typeof sortBy == "undefined") // sortBy is optional, set 0 as a default - var sortBy = 0; - project = encodeURIComponent(project); // Encode the parameters to follow correct URL encoding (e.g. possible "+" characters) - conf = encodeURIComponent(conf); // -,,- - autotest = encodeURIComponent(autotest); // -,,- + filters = encodeURIComponent(filters); // Encode the parameters to follow correct URL encoding (e.g. possible "+" characters) createMetricRequestObject(metricId); - metricRequest[metricId].open("GET",filepath+"?project="+project+"&conf="+conf+"&autotest="+autotest+"&tstype=" - +timescaleType+"&tsvalue="+timescaleValue+"&sort="+sortBy,true); + metricRequest[metricId].open("GET",filepath+"?filters="+filters,true); metricRequest[metricId].send(); metricRequest[metricId].onreadystatechange = function(index) { @@ -92,7 +87,8 @@ function showMetricData(metricId) if (metricRequest[metricId].readyState == 4 && metricRequest[metricId].status == 200) { var response = metricRequest[metricId].responseText; document.getElementById("metricsBox"+metricId).innerHTML = response; - loadDatabaseStatus(0); // Load the database status every time a metrics box is updated (to keep status updated when user uses the page) + getMetricDataRequestCompleted(); + return; } } @@ -117,7 +113,7 @@ function showFilters(div) if (filterRequest.readyState == 4 && filterRequest.status == 200) { var response = filterRequest.responseText; document.getElementById(div).innerHTML = response; - loadMetricsboxes(); // When filters are ready, load the metrics boxes next + getFiltersRequestCompleted(); return; } } @@ -160,7 +156,7 @@ function showDatabaseStatusInitial(div) if (filterRequest.readyState == 4 && filterRequest.status == 200) { var response = filterRequest.responseText; document.getElementById(div).innerHTML = response; - getFilters("filters", "ci/getfilters.php"); // Continue to load the filters next (initial loading of the page) + getDatabaseStatusInitialRequestCompleted(); return; } } @@ -171,6 +167,7 @@ function showDatabaseStatus(div) if (filterRequest.readyState == 4 && filterRequest.status == 200) { var response = filterRequest.responseText; document.getElementById(div).innerHTML = response; + getDatabaseStatusRequestCompleted(); return; } } |