Skip to content
Draft
Show file tree
Hide file tree
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
38 changes: 27 additions & 11 deletions robotframework_dashboard/js/eventlisteners.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
setup_project_versions_in_select_filter_buttons,
setup_suite_path_navigator,
setup_custom_filters_in_select_filter_buttons,
update_overview_version_select_list,
setup_metadata_filter,
build_profile_from_checks,
apply_filter_profile,
Expand Down Expand Up @@ -59,6 +58,8 @@ import {
set_filter_show_current_project,
set_filter_show_current_version,
update_overview_filter_visibility,
update_duration_comparison_for_all_projects,
update_overview_version_select_list,
} from "./graph_creation/overview.js";
import { update_run_donut_total_graph, update_run_heatmap_graph } from "./graph_creation/run.js";
import {
Expand Down Expand Up @@ -158,6 +159,14 @@ function update_merge_result_preview() {

// ---- end of merge profiles helpers ----

function update_filters_button_indicator() {
const indicator = document.getElementById("filtersActiveIndicator");
if (!indicator) return;
const anyActive = [...document.querySelectorAll("#filtersModal .version-selected-dot")]
.some(el => el.style.display !== "none");
indicator.style.display = anyActive ? "inline-block" : "none";
}

// function to setup filter modal eventlisteners
function setup_filter_modal() {
// eventlistener to catch the closing of the filter modal
Expand Down Expand Up @@ -317,6 +326,7 @@ function setup_filter_modal() {
add_alert(`Filter profile "${name}" applied`, "success");
update_profile_select_display();
populate_filter_profile_select();
update_filters_button_indicator();
}
}
});
Expand Down Expand Up @@ -402,13 +412,21 @@ function setup_filter_modal() {
add_alert(`Filter profile "${newName}" saved!`, "success");
bootstrap.Modal.getInstance(document.getElementById("mergeProfilesModal")).hide();
});
// Listen for filter changes to update the profile display
// Show indicator dot when a specific run is selected in the dropdown
document.getElementById("runs").addEventListener("change", function () {
const indicator = document.getElementById("filterRunSelectedIndicator");
if (indicator) indicator.style.display = this.value !== "All" ? "inline-block" : "none";
update_filters_button_indicator();
});
// Listen for filter changes to update the profile display and the navbar dot
const filterModal = document.getElementById("filtersModal");
filterModal.addEventListener("change", function () {
update_profile_select_display();
update_filters_button_indicator();
});
filterModal.addEventListener("input", function () {
update_profile_select_display();
update_filters_button_indicator();
});
}

Expand Down Expand Up @@ -500,11 +518,15 @@ function setup_settings_modal() {
{ key: "show.convertTimezone", elementId: "toggleTimezone" },
{ key: "show.suitesSelectionInSuiteStats", elementId: "toggleSuitesSelectionInSuiteStats", datatype: "string", event: "change" },
{ key: "show.suitesSelectionInTestStats", elementId: "toggleSuitesSelectionInTestStats", datatype: "string", event: "change" },
{ key: "show.overviewDurationPercentage", elementId: "overviewDurationPercentage", datatype: "number", event: "change" },
].forEach(def => {
const handler = create_toggle_handler(def);
handler(true);
document.getElementById(def.elementId).addEventListener(def.event || "click", () => handler());
});
document.getElementById("overviewDurationPercentage").addEventListener("change", () => {
if (settings.menu.overview) update_duration_comparison_for_all_projects();
});
// Re-populate the date filter pickers when either timezone toggle changes,
// since the displayed timestamps change and the defaults need to match.
document.getElementById("toggleTimezone").addEventListener("click", () => setup_lowest_highest_dates());
Expand Down Expand Up @@ -757,7 +779,6 @@ function setup_sections_filters() {
update_switch_local_storage("switch.runName", settings.switch.runName, true);
update_switch_local_storage("switch.totalStats", settings.switch.totalStats, true);
update_switch_local_storage("switch.latestRuns", settings.switch.latestRuns, true);
update_switch_local_storage("switch.percentageFilters", settings.switch.percentageFilters, true);
update_switch_local_storage("switch.versionFilters", settings.switch.versionFilters, true);
update_switch_local_storage("switch.sortFilters", settings.switch.sortFilters, true);
document.getElementById("switchRunTags").addEventListener("click", function () {
Expand Down Expand Up @@ -808,21 +829,16 @@ function setup_sections_filters() {
update_switch_local_storage("switch.totalStats", settings.switch.totalStats);
update_overview_sections_visibility();
});
document.getElementById("switchPercentageFilters").addEventListener("click", function () {
settings.switch.percentageFilters = !settings.switch.percentageFilters
update_switch_local_storage("switch.percentageFilters", settings.switch.percentageFilters);
document.getElementById("switchVersionFilters").addEventListener("click", function () {
settings.switch.versionFilters = !settings.switch.versionFilters
update_switch_local_storage("switch.versionFilters", settings.switch.versionFilters);
update_overview_filter_visibility();
});
document.getElementById("switchSortFilters").addEventListener("click", function () {
settings.switch.sortFilters = !settings.switch.sortFilters
update_switch_local_storage("switch.sortFilters", settings.switch.sortFilters);
update_overview_filter_visibility();
});
document.getElementById("switchVersionFilters").addEventListener("click", function () {
settings.switch.versionFilters = !settings.switch.versionFilters
update_switch_local_storage("switch.versionFilters", settings.switch.versionFilters);
update_overview_filter_visibility();
});
document.getElementById("suiteSelectSuites").addEventListener("change", () => {
const mostGraphIds = settings.switch.sectionFiltersApplySuite
? ["suiteMostFailedGraph", "suiteMostTimeConsumingGraph"]
Expand Down
73 changes: 9 additions & 64 deletions robotframework_dashboard/js/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,69 +902,6 @@ function unselect_checkboxes(checkBoxesToUnselect) {
}
}

function handle_overview_latest_version_selection(overviewVersionSelectorList, latestRunByProject) {
show_loading_overlay();
requestAnimationFrame(() => {
requestAnimationFrame(() => {
const selectedOptions = Array.from(
overviewVersionSelectorList.querySelectorAll("input:checked")
).map(inputElement => inputElement.value);
if (selectedOptions.includes("All")) {
create_overview_latest_graphs(latestRunByProject);
} else {
const filteredLatestRunByProject = Object.fromEntries(
Object.entries(latestRunByProject)
.filter(([projectName, run]) => selectedOptions.includes(run.project_version ?? "None"))
);
create_overview_latest_graphs(filteredLatestRunByProject);
}
update_overview_latest_heading();
hide_loading_overlay();
});
});
}

// this function updates the version select list in the latest runs bar
function update_overview_version_select_list() {
const overviewLatestVersionSelectorList = document.getElementById("overviewLatestVersionSelectorList");
if (overviewLatestVersionSelectorList) {
overviewLatestVersionSelectorList.innerHTML = '';
if (settings.switch.runName || settings.switch.runTags) {
const filteredLatestRunByProject = {};
settings.switch.runName && Object.assign(filteredLatestRunByProject, latestRunByProjectName);
settings.switch.runTags && Object.assign(filteredLatestRunByProject, latestRunByProjectTag);
const runAmountByVersion = {};
for (const run of Object.values(filteredLatestRunByProject)) {
const projectVersion = run.project_version ?? "None";
runAmountByVersion[projectVersion] ??= 0;
runAmountByVersion[projectVersion]++;
}
const allVersionAmountInFilter = Object.keys(runAmountByVersion).length;
const versionFilterListItemAllHtml = generate_version_filter_list_item_html("All", "overviewLatest", "checked", allVersionAmountInFilter, "version");
const specificVersionFilterListItemHtml = Object.keys(runAmountByVersion)
.sort()
.reverse()
.map(version => {
return generate_version_filter_list_item_html(
version,
"overviewLatest",
"", //not checked
runAmountByVersion[version],
"run"
)
}).join('');
overviewLatestVersionSelectorList.innerHTML = versionFilterListItemAllHtml + specificVersionFilterListItemHtml;
const allCheckBox = document.getElementById("overviewLatestVersionFilterListItemAllInput");
setup_filter_checkbox_handler_listeners(
overviewLatestVersionSelectorList,
allCheckBox,
"overviewLatestVersionSelectedIndicator",
() => { handle_overview_latest_version_selection(overviewLatestVersionSelectorList, filteredLatestRunByProject) }
);
}
}
}

// for runTag/version filter popup and overview
function setup_filter_checkbox_handler_listeners(
checkBoxContainerElement,
Expand Down Expand Up @@ -1044,6 +981,10 @@ function clear_all_filters() {
document.getElementById("amount").value = filteredAmountDefault;
document.getElementById("metadata").value = "All";
setup_lowest_highest_dates();
const runsIndicator = document.getElementById("filterRunSelectedIndicator");
if (runsIndicator) runsIndicator.style.display = "none";
const filtersActiveIndicator = document.getElementById("filtersActiveIndicator");
if (filtersActiveIndicator) filtersActiveIndicator.style.display = "none";
}

function clear_suite_path_filter() {
Expand Down Expand Up @@ -1383,6 +1324,11 @@ function apply_filter_profile(profile, name) {
if (modeEl) modeEl.value = mode;
}
}
const runsIndicator = document.getElementById("filterRunSelectedIndicator");
const runsVal = document.getElementById("runs")?.value;
if (runsIndicator)
runsIndicator.style.display =
runsVal && runsVal !== "All" ? "inline-block" : "none";
}

// Load filter profiles from settings (cumulative — never deletes existing ones)
Expand Down Expand Up @@ -1608,7 +1554,6 @@ export {
setup_suite_path_navigator,
setup_custom_filters_in_select_filter_buttons,
setup_filter_checkbox_handler_listeners,
update_overview_version_select_list,
clear_all_filters,
set_filter_show_current_version,
generate_version_filter_list_item_html,
Expand Down
7 changes: 5 additions & 2 deletions robotframework_dashboard/js/graph_creation/all.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { settings } from "../variables/settings.js";

import {
import {
create_overview_latest_graphs,
create_overview_total_graphs,
update_donut_charts
update_donut_charts,
update_grouped_data_for_filter
} from "./overview.js";
import {
create_run_statistics_graph,
Expand Down Expand Up @@ -102,6 +103,7 @@ import { update_custom_stat_widgets } from "../statwidgets.js";
// function that creates all graphs from scratch - used on first load of each tab
function create_dashboard_graphs() {
if (settings.menu.overview) {
update_grouped_data_for_filter();
create_overview_latest_graphs();
create_overview_total_graphs();
update_donut_charts();
Expand Down Expand Up @@ -156,6 +158,7 @@ function create_dashboard_graphs() {
// each update function falls back to create if the chart doesn't exist yet
function update_dashboard_graphs() {
if (settings.menu.overview) {
update_grouped_data_for_filter();
create_overview_latest_graphs();
create_overview_total_graphs();
update_donut_charts();
Expand Down
Loading
Loading