Skip to content

Commit

Permalink
filter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
evlach committed Jun 15, 2014
1 parent 88fbbc3 commit e9d0638
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 64 deletions.
2 changes: 1 addition & 1 deletion js/API.js
Expand Up @@ -62,7 +62,7 @@
URL_SERVICE_TESTRESULT_BYTEST_OVERVIEW: "testresult/browse/bytest/overview/", //{techNameId}

URL_SERVICE_TESTRESULT_FULLVIEWTECHNIQUE: "testresult/browse/fullviewtechnique/",
URL_SERVICE_TESTRESULT_FULLVIEWTEST: "testresult/browse/fullviewtest/", //{testUnitId}
URL_SERVICE_TESTRESULT_FULLVIEWTESTURL_SERVICE_TESTRESULT_FULLVIEWTEST: "testresult/browse/fullviewtest/", //{testUnitId}
URL_SERVICE_TESTRESULT_FILTER: "testresult/filter",
URL_SERVICE_TESTRESULT_VIEWTECHNIQUE: "testresult/browse/resultsview/",
URL_SERVICE_TESTRESULT_TREE_AT: "testresult/browse/at/tree",
Expand Down
31 changes: 19 additions & 12 deletions js/router.js
Expand Up @@ -7,8 +7,8 @@ window.accessdb.Models.AppRouter = Backbone.Router.extend({
"results.html": "results",
"results-technique.html/:id": "results-technique",
"results-test.html/:id": "results-test",
"results-details.html/ua/:ua/uaver/:uaVer/at/:at/atver/:atVer/filter/:filter": "results-details",
"results-details.html/ua/:ua/uaver/:uaVer/at/:at/atver/:atVer": "results-details",
"results-details.html/type/:type/typevalue/:typeValue/ua/:ua/uaver/:uaVer/at/:at/atver/:atVer/filter/:filter": "results-details",
"results-details.html/type/:type/typevalue/:typeValue/ua/:ua/uaver/:uaVer/at/:at/atver/:atVer": "results-details",
"test-run.html/:id": "test-run",
"test-run.html": "test-run",
"test.html/:id": "test",
Expand Down Expand Up @@ -83,24 +83,31 @@ window.accessdb.appRouter.on('route:results-test', function (id) {
accessdb.TestResultsFullViewByTest = new accessdb.Views.TestResultsFullViewByTest();
accessdb.TestResultsFullViewByTest.reload({testUnitId : id});
});
window.accessdb.appRouter.on('route:results-details', function (ua, uaVer, at, atVer, filter) {
window.accessdb.appRouter.on('route:results-details-filter', function (type, typeValue, ua, uaVer, at, atVer, filter) {
window.accessdb.appRouter.loadPage("results-details");

if(filter){
if(Utils.urlParam(filter)!==null)
filter = JSON.parse(decodeURI(filter));
else
filter = accessdb.filters[accessdb.appRouter.page] || new accessdb.Models.Filter(accessdb.appRouter.page);
accessdb.filters[accessdb.appRouter.page] = filter;
filter = JSON.parse(decodeURI(filter));
var params = {
ua : Utils.urlParam(ua),
uaVer : Utils.urlParam(uaVer),
at : Utils.urlParam(at),
atVer : Utils.urlParam(atVer),
filter : filter,
type: type,
typeValue : typeValue
}
accessdb.TestResultsDetails = new accessdb.Views.TestResultsDetails();
accessdb.TestResultsDetails.reload(params);
});
window.accessdb.appRouter.on('route:results-details', function (type, typeValue, ua, uaVer, at, atVer) {
window.accessdb.appRouter.loadPage("results-details");
var params = {
ua : Utils.urlParam(ua),
uaVer : Utils.urlParam(uaVer),
at : Utils.urlParam(at),
atVer : Utils.urlParam(atVer),
filter : filter
type: type,
typeValue : typeValue
}

accessdb.TestResultsDetails = new accessdb.Views.TestResultsDetails();
accessdb.TestResultsDetails.reload(params);
});
Expand Down
87 changes: 53 additions & 34 deletions js/testresult-views.js
Expand Up @@ -33,7 +33,7 @@ accessdb.Views.TestResultsDataOverview = function (){
}, this.$el);
}
};
this.reload = function(){
this.reload = function(params){
var pageId = accessdb.config.PAGE_ID_PREFIX+"results";
if(accessdb.appRouter.page === pageId){
var self = this;
Expand All @@ -45,7 +45,6 @@ accessdb.Views.TestResultsDataOverview = function (){
}
}
};

accessdb.Views.TestResultsDataTestCaseOverview = function (){
this.$el = null;
this.results = null;
Expand Down Expand Up @@ -89,7 +88,7 @@ accessdb.Views.TestResultsDataTestCaseOverview = function (){
}, this.$el);
}
};
this.reload = function(){
this.reload = function(params){
var pageId = accessdb.config.PAGE_ID_PREFIX+"results";
if(accessdb.appRouter.page === pageId){
var self = this;
Expand All @@ -101,28 +100,27 @@ accessdb.Views.TestResultsDataTestCaseOverview = function (){
}
}
};

accessdb.Views.TestResultsFullViewByTechnique = function (){
this.$el = $("#TestResultsFullViewByTechniqueDiv");
this.results = null;
this.params = null;
this.render = function(){
if(this.results){
var filter = accessdb.filters[accessdb.appRouter.page];
var template = _.template( $("#TestResultsFullViewByTechnique_template").html(), {results: this.results, filter: filter} );
var template = _.template( $("#TestResultsFullViewByTechnique_template").html(), {results: this.results, params: this.params} );
this.$el.html( template );
this.$el.find('.chart').peity("pie", {
fill: ["green", "#f98"]
});
}
};
this.fetch = function (params, callback){
this.fetch = function (callback){
var self = this;
if (!params || params.length<1 ){
if (!this.params || this.params.length<1 ){
console.warn("No filter defined!");
callback("No filter defined!", null);
}
else {
accessdb.API.TESTRESULT.getResultsFullViewByTechnique(params.filter, params.techNameId, function (error, data, status) {
accessdb.API.TESTRESULT.getResultsFullViewByTechnique(this.params.filter, this.params.techNameId, function (error, data, status) {
if(!error){
console.log(data);
self.results = data;
Expand All @@ -139,7 +137,10 @@ accessdb.Views.TestResultsFullViewByTechnique = function (){
var self = this;
params = params || {};
params.filter = accessdb.filters[pageId];
this.fetch(params, function(error, data){
params.type = "Technique";
params.typeValue = params.techNameId;
this.params = params;
this.fetch(function(error, data){
if(!error)
self.render();
});
Expand All @@ -149,6 +150,7 @@ accessdb.Views.TestResultsFullViewByTechnique = function (){
accessdb.Views.TestResultsFullViewByTechniqueRelatedTests = function (){
this.$el = $("#RelatedTestCasesDiv");
this.results = null;
this.params = null;
this.render = function(){
if(this.results){
var template = _.template( $("#RelatedTestCases_template").html(), {results: this.results} );
Expand All @@ -158,14 +160,14 @@ accessdb.Views.TestResultsFullViewByTechniqueRelatedTests = function (){
});
}
};
this.fetch = function (params, callback){
this.fetch = function (callback){
var self = this;
if (!params || params.length<2 ){
if (!this.params || this.params.length<2 ){
console.warn("No filter defined!");
callback("params not defined!", null);
}
else {
accessdb.API.TESTRESULT.findByFilterTestResultTestOveview(params.filter, params.techNameId, function (error, data, status) {
accessdb.API.TESTRESULT.findByFilterTestResultTestOveview(this.params.filter, this.params.techNameId, function (error, data, status) {
if(!error){
console.log(data);
self.results = data;
Expand All @@ -182,35 +184,39 @@ accessdb.Views.TestResultsFullViewByTechniqueRelatedTests = function (){
var self = this;
params = params || {};
params.filter = accessdb.filters[pageId];
this.fetch(params, function(error, data){
this.params = params;
this.fetch(function(error, data){
if(!error)
self.render();
});
}
}
};

accessdb.Views.TestResultsFullViewByTest = function (){
this.$el = $("#TestResultsFullViewByTestDiv");
this.results = null;
this.params = null;
this.render = function(){
if(this.results){
var filter = accessdb.filters[accessdb.appRouter.page];
var template = _.template( $("#TestResultsFullViewByTechnique_template").html(), {results: this.results, filter: filter} );
var template = _.template( $("#TestResultsFullViewByTechnique_template").html(), {
results: this.results,
params: this.params
} );
this.$el.html( template );
this.$el.find('.chart').peity("pie", {
fill: ["green", "#f98"]
});
}
};
this.fetch = function (params, callback){
this.fetch = function (callback){
var self = this;
if (!params || params.length<1 ){
if (!this.params || this.params.length<1 ){
console.warn("No filter defined!");
callback("No filter defined!", null);
}
else {
accessdb.API.TESTRESULT.getResultsFullViewByTest(params.filter, params.testUnitId, function (error, data, status) {
accessdb.API.TESTRESULT.getResultsFullViewByTest(this.params.filter, this.params.testUnitId, function (error, data, status) {
if(!error){
console.log(data);
self.results = data;
Expand All @@ -227,17 +233,20 @@ accessdb.Views.TestResultsFullViewByTest = function (){
var self = this;
params = params || {};
params.filter = accessdb.filters[pageId];
this.fetch(params, function(error, data){
params.type = "Test";
params.typeValue = params.testUnitId;
this.params = params;
this.fetch(function(error, data){
if(!error)
self.render();
});
}
}
};

accessdb.Views.TestResultsDetails = function (){
this.$el = $("#Results");
this.results = null;
this.params = null;
this.render = function(){
if(this.results){
var groupedResults = _.groupBy(this.results, 'testUnitId');
Expand All @@ -247,10 +256,9 @@ accessdb.Views.TestResultsDetails = function (){
var testResult = {
testUnitId: r,
testResults : []
}
};
for (ress in resPerTest) {
var res = resPerTest[ress];

if(res.testingProfile){
testResult.testResults.push({
id: res.id,
Expand All @@ -265,24 +273,34 @@ accessdb.Views.TestResultsDetails = function (){
results.push(testResult);
}
var filter = accessdb.filters[accessdb.appRouter.page];
var template = _.template( $("#Results_template").html(), {results: results} );
var template = _.template($("#Results_template").html(), {
results: results,
params: this.params}
);
this.$el.html( template );
Utils.UIRoleAdapt();
}
};
this.fetch = function (params, callback){
this.fetch = function (callback){
var self = this;
console.log(params);
if (!params || params.length<4 ){
if (!this.params || this.params.length<4 ){
console.warn("No filter defined!");
callback("No filter defined!", null);
}
else {
var filter = _.clone(params.filter);
if(params.ua)
filter.uas = [{id: "0", name: params.ua, type:"UAgent", version: params.uaVer}];
if(params.at)
filter.ats = [{id:"0", name: params.at, type:"AssistiveTechnology", version: params.atVer}];
var filter = _.clone(this.params.filter);
if(this.params.type){
if(this.params.type==="Test"){
filter.tests = [this.params.typeValue];
}
else if(this.params.type==="Technique"){
filter.techniques = [this.params.typeValue];
}
}
if(this.params.ua)
filter.uas = [{id: "0", name: this.params.ua, type:"UAgent", version: this.params.uaVer}];
if(this.params.at)
filter.ats = [{id:"0", name: this.params.at, type:"AssistiveTechnology", version: this.params.atVer}];
else
filter.ats = [];
accessdb.API.TESTRESULT.filter(filter, function (error, data, status) {
Expand All @@ -301,8 +319,9 @@ accessdb.Views.TestResultsDetails = function (){
if(accessdb.appRouter.page === pageId){
var self = this;
params = params || {};
params.filter = accessdb.filters[pageId];
this.fetch(params, function(error, data){
params.filter = _.clone(accessdb.filters[pageId]) || new accessdb.Models.Filter(accessdb.appRouter.page);
this.params = params;
this.fetch(function(error, data){
if(!error)
self.render();
});
Expand Down
2 changes: 1 addition & 1 deletion js/tree-helper.js
Expand Up @@ -45,7 +45,7 @@ accessdb.TreeHelper = {
if(accessdb.TestResultsFullViewByTechnique)
accessdb.TestResultsFullViewByTechnique.reload({techNameId : accessdb.appRouter.params.techniqueNameId});
if(accessdb.TestResultsFullViewByTest)
accessdb.TestResultsFullViewByTest.reload({techNameId : accessdb.appRouter.params.testUnitId});
accessdb.TestResultsFullViewByTest.reload({testUnitId : accessdb.appRouter.params.testUnitId});
TestUnit.loadTestsTree();
},
uncheckTestFromTree: function (liId) {
Expand Down
7 changes: 1 addition & 6 deletions pages/results-details.html
Expand Up @@ -8,12 +8,7 @@ <h1 class="page-title">
</nav>
<div class="content">
<div class="grid">
<h2>Browse Test Results for Technique H49, Internet Explorer 11 with Jaws 15</h2>
<div class="">
<div class="column-second">
<div id="Results"><!-- Template: Results_template --></div>
</div>
</div>
<div id="Results"><!-- Template: Results_template --></div>
</div>
</div>
</article>
22 changes: 14 additions & 8 deletions templates.html
Expand Up @@ -299,6 +299,12 @@ <h4>Test Results</h4>
</ul>
</script>
<script type="text/template" id="Results_template">
<h2>Browse Test Results for <%=params.type%> <%=params.typeValue%>, <%=params.ua%> <%=params.uaVer%> with <%=params.at%> <%=params.atVer%></h2>
<div class="">
<div class="column-second">
<div id="Results"><!-- Template: Results_template --></div>
</div>
</div>
<% _.each(results, function(r) { %>
<table class="testcase-details">
<caption><strong>Testcase:</strong> <a href="#/results-test.html/<%= r.testUnitId %>"><%= r.testUnitId %></a>: <%=r.testTitle%></caption>
Expand Down Expand Up @@ -346,14 +352,14 @@ <h4>Test Results</h4>
at: undefined,
atVer : undefined,
toUrl : function(){
var url = "ua/" + (this.ua || "null");
url = url + "/uaver/" + (this.uaVer || "null");
url = url + "/at/" + (this.at || "null");
url = url + "/atver/" + (this.atVer || "null");
console.log(filter);
url = url + "/filter/" + encodeURI(JSON.stringify(filter));
return url;
}
var url = "type/" + params.type + "/typevalue/" + params.typeValue;
url = url + "/ua/" + (this.ua || "null");
url = url + "/uaver/" + (this.uaVer || "null");
url = url + "/at/" + (this.at || "null");
url = url + "/atver/" + (this.atVer || "null");
// url = url + "/filter/" + encodeURI(JSON.stringify(params.filter));
return url;
}
};
%>
<% firstrow = true %>
Expand Down
2 changes: 1 addition & 1 deletion workbench/index.html
Expand Up @@ -9,7 +9,7 @@

<script type="text/javascript" src="../js/lib/jquery-2.1.0.min.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript" src="../js/accessdb.js"></script>
<script type="text/javascript" src="../js/API.js"></script>
<script type="text/javascript" src="js/WorkBench.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
Expand Down
2 changes: 1 addition & 1 deletion workbench/js/WorkBench.js
@@ -1,5 +1,5 @@
var nowDate = new Date();
var SERVICES_ROOT = accessdb.config.URL_API_ROOT;
var SERVICES_ROOT = window.accessdb.config.URL_API_ROOT;
var QUERY_URL = SERVICES_ROOT + "query/";

var WorkBench = {
Expand Down

0 comments on commit e9d0638

Please sign in to comment.