Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic way to find a label in detail page #314

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 93 additions & 13 deletions verifier/detail_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
check_boxes: [], // The widgets associated with characterized items
widget_label_sets: [], // A parallel array of sets of labels for each.
box_labels: [],
selected_set: null
selected_set: null,
pagination_container: null
},
'fail': {
json: null,
Expand All @@ -123,7 +124,8 @@
check_boxes: [],
widget_label_sets: [],
box_labels: [],
selected_set: null
selected_set: null,
pagination_container: null
},
'error': {
json: null,
Expand All @@ -133,7 +135,8 @@
check_boxes: [],
widget_label_sets: [],
box_labels: [],
selected_set: null
selected_set: null,
pagination_container: null
},
'unsupported': {
json: null,
Expand All @@ -144,6 +147,7 @@
widget_label_sets: [],
box_labels: [],
selected_set: null,
pagination_container: null
},
'known_issue': {
json: null,
Expand All @@ -154,6 +158,7 @@
widget_label_sets: [],
box_labels: [],
selected_set: null,
pagination_container: null
}

};
Expand Down Expand Up @@ -426,6 +431,7 @@
'-pagination-container';
let data_container_name = '#' + c_type + '-data-container';

test_results[c_type]['pagination_container'] =
fill_pagination(pagination_container_name,
data_container_name,
data,
Expand Down Expand Up @@ -470,6 +476,7 @@
data_container.html(html);
}
});
return pagination_container;
}

// -----------------------
Expand Down Expand Up @@ -660,6 +667,65 @@
const ds = dmp.diff_prettyHtml(diff_text);
diff_area.innerHTML = ds;
}

// Given a label query, look for that label in all the categories.
function findLabelInResults(label_input) {
const label = label_input.value;
const result_types = ['pass', 'fail', 'error', 'known_issue', 'unsupported'];

let found = false;
const label_data = document.getElementById('label_data');
label_data.innerHTML = "???";

let item_index;
let pagination_container;
let pagination_obj;

for (const type of result_types) {
const results = test_results[type].all_labels;

if (results.has(label)) {
// Show the result type and the data for this one,
// i.e., label, expected result, result, input_data.
const label_category = document.getElementById('label_category');
label_category.innerHTML = type;

label_data.innerHTML = "TO BE FOUND";
const json_items = test_results[type].json;
item_index = 0; // reset.
for (const item of json_items) {
if (item['label'] == label) {
found = true;
const to_show = 'Input: ' + JSON.stringify(item['input_data']) + ' ' +
'Expected: ' + item['expected'] + ", Actual =" +
item['result'];
label_data.innerHTML = to_show;
// TODO: ??? How to open the correct part of the detail category to this item.
const detail_id = type + "_details";
const detail_obj = document.getElementById(detail_id);

// Open the detail.
detail_obj.open = true;

// Get the pagination controller for this category.
pagination_container = test_results[type]['pagination_container'];
pagination_obj = pagination_container.pagination;


break;
}
item_index += 1;
}
// How to get the right page based on the item_index and page size?
// Use item_index and page size to figure which page has this one.
// If we get page size, then the page to show is (item_index // page_size).

// But how to get page size?
// How to set the new page
break;
}
}
}
</script>

<!-- diff-match-patch code from
Expand All @@ -686,16 +752,24 @@ <h2>$platform_info</h2>
<div bp="8">
<h2>Test details</h2>
<p>$test_environment</p>
</div>
<div bp="4">
<h2>Acknowledgements</h2>
<p><a href='https://github.com/google/diff-match-patch/wiki/Language:-JavaScript'>diff-match-patch</a></p>
<h3>Find label</h3>
<label for="label_input">Label to find:</label>
<input type="text" name="label_input" id="label_input_id" onchange="findLabelInResults(this);">
<label for="label_category">Category of this label:</label>
<span id="label_category">unknown</span>
</p>
<p>
<label for="label_data">Label data:</label>
<span id="label_data">___</span>
<p>

</div>
</div>
<br>
<div id='test_result_details' class='test_results'>
<details>
<details id="pass_details">
<summary>Passing tests <span id='pass_count'>($passing_tests)</span></summary>
<div id="diff_area_pass" class="diff_area_class"><p></p></div>
<!-- Using pagination.js -->
<div id="pass-pagination-container"></div>
<div id="pass-data-container"></div>
Expand All @@ -721,7 +795,7 @@ <h2>Acknowledgements</h2>

</details>

<details>
<details id="fail_details">
<summary>Failing tests <span id='fail_count'>($failing_tests)</span></summary>
<div id="diff_area_fail" class="diff_area_class"><p></p></div>
<div id="fail-pagination-container"></div>
Expand All @@ -747,7 +821,7 @@ <h2>Acknowledgements</h2>
</div>
</details> <!-- failing tests -->

<details>
<details id="known_issue_details">
<summary>Known issues <span id='known_issue_count'>($known_issue_count)</span></summary>
<div id="diff_area_known_issue" class="diff_area_class"><p></p></div>
<div id="known_issue-pagination-container"></div>
Expand All @@ -773,7 +847,7 @@ <h2>Acknowledgements</h2>
</div>
</details>

<details>
<details id="error_details">
<summary>Test errors <span id='error_count'>($error_count)</span></summary>
<h2 id='testErrors'>Test Errors ($error_count)</h2>
<div id="error-pagination-container"></div>
Expand All @@ -800,7 +874,7 @@ <h2 id='testErrors'>Test Errors ($error_count)</h2>
</div>
</details>

<details>
<details id="unsupported_details">
<summary>Unsupported tests <span id='unsupported_count'>($unsupported_count)</span></summary>
<div id="unsupported-pagination-container"></div>
<div id="unsupported-data-container"></div>
Expand All @@ -826,6 +900,12 @@ <h2 id='testErrors'>Test Errors ($error_count)</h2>
</details>

</div>

<div bp="4">
<h2>Acknowledgements</h2>
<p><a href='https://github.com/google/diff-match-patch/wiki/Language:-JavaScript'>diff-match-patch</a></p>
<p><a href="https:/developers.google.com/chart>Google Charts</a></p>
<p><a href='https://pagnination.js.org'>pagination.js.org</a></p>
</div>

</body>
</html>
Loading