mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-07 12:15:51 +00:00
f9933703d1
- add widget for selecting corresponding branch(es) for testgroups - limit available subgroups based on chosen product/branch b=314938 - changed schema for test runs, allowing multiple testgroups per test run (also addresses b=337496), combining test run limiting criteria into a single table, and adding more audit/tracking info to the main test_runs table Misc: - fix nesting issue whereby first item in a list wasn't being selected properly when a default/already selected value was not found. This affected most of the management interfaces. - removed extra <br/>s in management interface filtering divs
268 lines
9.3 KiB
JavaScript
Executable File
268 lines
9.3 KiB
JavaScript
Executable File
function selects_onload() {
|
|
load_products(getElementByClass("select_product"));
|
|
load_testgroups(getElementByClass("select_testgroup"));
|
|
load_subgroups(getElementByClass("select_subgroup"));
|
|
|
|
load_platforms(getElementByClass("select_platform"));
|
|
load_opsyses(getElementByClass("select_opsys"));
|
|
load_branches(getElementByClass("select_branch"));
|
|
}
|
|
|
|
function load_products(selects) {
|
|
if (!selects) { return; }
|
|
// for each select box in selects, load in the list of products
|
|
for (var select=0; select<selects.length; select++) {
|
|
var productbox = selects[select];
|
|
clearSelect(productbox);
|
|
addNullEntry(productbox);
|
|
for (var i=0; i<litmusconfig.length; i++) {
|
|
var option = makeOption(litmusconfig[i]);
|
|
productbox.add(option, null);
|
|
// handle the default selection
|
|
if (isDefault(document.getElementById(productbox.name+"_default"), litmusconfig[i]['id'])) {
|
|
productbox.selectedIndex = i+1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function load_testgroups(selects) {
|
|
if (!selects[0]) { return; }
|
|
// load the proper list of testgroups for the
|
|
// currently selected product for each testgroup
|
|
// select:
|
|
for (var select=0; select<selects.length; select++) {
|
|
var groupbox = selects[select];
|
|
clearSelect(groupbox);
|
|
addNullEntry(groupbox);
|
|
// find the currently selected product that goes with this select
|
|
var productbox = document.getElementById("product"+groupbox.name.substr(9));
|
|
var productid = productbox.options[productbox.selectedIndex].value;
|
|
var product = getProductById(productid);
|
|
if (!product) {
|
|
return;
|
|
}
|
|
// now get the list of testgroups that goes with that product:
|
|
var testgroups = product['testgroups'];
|
|
for (var group=0; group<testgroups.length; group++) {
|
|
var option = makeOption(testgroups[group])
|
|
groupbox.add(option, null);
|
|
// handle the default selection
|
|
if (isDefault(document.getElementById(groupbox.name+"_default"), testgroups[group]['id'])) {
|
|
groupbox.selectedIndex = group+1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function load_subgroups(selects) {
|
|
if (!selects[0]) { return; }
|
|
for (var select=0; select<selects.length; select++) {
|
|
var subgroupbox = selects[select];
|
|
clearSelect(subgroupbox);
|
|
addNullEntry(subgroupbox);
|
|
// find the currently selected testgroup that goes with this select
|
|
var testgroupbox = document.getElementById("testgroup"+subgroupbox.name.substr(8));
|
|
var testgroupid = testgroupbox.options[testgroupbox.selectedIndex].value;
|
|
var testgroup = getTestgroupById(testgroupid);
|
|
if (!testgroup) {
|
|
// no testgroup set
|
|
return;
|
|
}
|
|
// now get the list of subgroups that goes with that testgroup
|
|
var subgroups = testgroup['subgroups'];
|
|
for (var i=0; i<subgroups.length; i++) {
|
|
var option = makeOption(subgroups[i]);
|
|
subgroupbox.add(option, null);
|
|
if (isDefault(document.getElementById(subgroupbox.name+"_default"), subgroups[i]['id'])) {
|
|
subgroupbox.selectedIndex = i+1;
|
|
}
|
|
}
|
|
}
|
|
} // wow, that was fun
|
|
|
|
|
|
function load_platforms(selects) {
|
|
if (!selects[0]) { return; }
|
|
for (var select=0; select<selects.length; select++) {
|
|
var platformbox = selects[select];
|
|
clearSelect(platformbox);
|
|
addNullEntry(platformbox);
|
|
// find the currently selected product that goes with this select
|
|
var productbox = document.getElementById("product"+platformbox.name.substr(8));
|
|
var productid = productbox.options[productbox.selectedIndex].value;
|
|
var product = getProductById(productid);
|
|
if (!product) {
|
|
// no product set
|
|
return;
|
|
}
|
|
var platforms = product['platforms'];
|
|
for (var i=0; i<platforms.length; i++) {
|
|
var option = makeOption(platforms[i]);
|
|
platformbox.add(option, null);
|
|
if (isDefault(document.getElementById(platformbox.name+"_default"), platforms[i]['id'])) {
|
|
platformbox.selectedIndex = i+1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function load_branches(selects) {
|
|
if (!selects[0]) { return; }
|
|
for (var select=0; select<selects.length; select++) {
|
|
var branchbox = selects[select];
|
|
clearSelect(branchbox);
|
|
addNullEntry(branchbox);
|
|
// find the currently selected product that goes with this select
|
|
var productbox = document.getElementById("product"+branchbox.name.substr(6));
|
|
var productid = productbox.options[productbox.selectedIndex].value;
|
|
var product = getProductById(productid);
|
|
if (!product) {
|
|
// no product set
|
|
return;
|
|
}
|
|
var branches = product['branches'];
|
|
for (var i=0; i<branches.length; i++) {
|
|
var option = makeOption(branches[i]);
|
|
branchbox.add(option, null);
|
|
if (isDefault(document.getElementById(branchbox.name+"_default"), branches[i]['id'])) {
|
|
branchbox.selectedIndex = i+1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function load_opsyses(selects) {
|
|
if (!selects[0]) { return; }
|
|
for (var select=0; select<selects.length; select++) {
|
|
var opsysbox = selects[select];
|
|
clearSelect(opsysbox);
|
|
addNullEntry(opsysbox);
|
|
// find the currently selected platform
|
|
var platformbox = document.getElementById("platform"+opsysbox.name.substr(5));
|
|
var platformid = platformbox.options[platformbox.selectedIndex].value;
|
|
var platform = getPlatformById(platformid);
|
|
if (!platform) {
|
|
return;
|
|
}
|
|
var opsyses = platform['opsyses'];
|
|
for (var i=0; i<opsyses.length; i++) {
|
|
var option = makeOption(opsyses[i]);
|
|
opsysbox.add(option, null);
|
|
if (isDefault(document.getElementById(opsysbox.name+"_default"), opsyses[i]['id'])) {
|
|
opsysbox.selectedIndex = i+1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function changeProduct(testid) {
|
|
var testidflag = "";
|
|
if (testid) { testidflag = "_"+testid; }
|
|
|
|
load_testgroups([document.getElementById("testgroup"+testidflag)]);
|
|
changeTestgroup(testid);
|
|
|
|
load_platforms([document.getElementById("platform"+testidflag)]);
|
|
changePlatform(testid);
|
|
|
|
load_branches([document.getElementById("branch"+testidflag)]);
|
|
}
|
|
|
|
function changeTestgroup(testid) {
|
|
var testidflag = "";
|
|
if (testid) { testidflag = "_"+testid; }
|
|
|
|
load_subgroups([document.getElementById("subgroup"+testidflag)]);
|
|
}
|
|
|
|
function changePlatform(testid) {
|
|
var testidflag = "";
|
|
if (testid) { testidflag = "_"+testid; }
|
|
|
|
load_opsyses([document.getElementById("opsys"+testidflag)]);
|
|
}
|
|
|
|
function addNullEntry(select) {
|
|
// add a blank entry to the current select
|
|
// if possible, try to make the null entry reflect the select's
|
|
// contents based on it's name:
|
|
|
|
if (select.className == 'select_product') {
|
|
select.add(new Option("-Product-", "", false, false), null);
|
|
} else if (select.className == 'select_testgroup') {
|
|
select.add(new Option("-Testgroup-", "", false, false), null);
|
|
} else if (select.className == 'select_subgroup') {
|
|
select.add(new Option("-Subgroup-", "", false, false), null);
|
|
} else if (select.className == 'select_branch') {
|
|
select.add(new Option("-Branch-", "", false, false), null);
|
|
} else {
|
|
select.add(new Option("---", "", false, false), null);
|
|
}
|
|
}
|
|
|
|
function clearSelect(select) {
|
|
// remove all options from a select:
|
|
while (select.options[0]) {
|
|
select.remove(0);
|
|
}
|
|
}
|
|
|
|
function getProductById(prodid) {
|
|
for (var i=0; i<litmusconfig.length; i++) {
|
|
if (litmusconfig[i]['id'] == prodid) {
|
|
return(litmusconfig[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
function getTestgroupById(testgroupid) {
|
|
for (var i=0; i<litmusconfig.length; i++) {
|
|
for (var j=0; j<litmusconfig[i]['testgroups'].length; j++) {
|
|
if (litmusconfig[i]['testgroups'][j]['id'] == testgroupid) {
|
|
return(litmusconfig[i]['testgroups'][j]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function getPlatformById(platformid) {
|
|
for (var i=0; i<litmusconfig.length; i++) {
|
|
for (var j=0; j<litmusconfig[i]['platforms'].length; j++) {
|
|
if (litmusconfig[i]['platforms'][j]['id'] == platformid) {
|
|
return(litmusconfig[i]['platforms'][j]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// pass this the <input> containing the list of possible default values
|
|
// and the current value, returns true if the current value appears in
|
|
// defaultInput, otherwise returns false
|
|
function isDefault(defaultInput, curvalue) {
|
|
if (! defaultInput) { return false; }
|
|
var defaultarray = defaultInput.value.split(',');
|
|
for (var i=0; i<defaultarray.length; i++) {
|
|
if (defaultarray[i] == curvalue) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function makeOption(obj) {
|
|
return new Option(obj['name'], obj['id'], false, false)
|
|
}
|
|
|
|
function getElementByClass(theClass) {
|
|
var elements = new Array();
|
|
var all = document.getElementsByTagName("*");
|
|
for (var i=0; i<all.length; i++) {
|
|
if (all[i].className == theClass) {
|
|
elements.push(all[i]);
|
|
}
|
|
}
|
|
return elements;
|
|
} |