Skip to content

Commit

Permalink
Save dashboard with time restore
Browse files Browse the repository at this point in the history
Dashboard can have the option to save with time filters or without time filters.

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
  • Loading branch information
abbyhu2000 committed Jun 22, 2023
1 parent f7969cf commit bf00495
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ export const useSavedDashboardInstance = (
} else if (dashboardIdFromUrl) {
try {
savedDashboard = await savedDashboards.get(dashboardIdFromUrl);

// Update time filter to match the saved dashboard if time restore has been set to true when saving the dashboard
// We should only set the time filter according to time restore once when we are loading the dashboard
if (savedDashboard && savedDashboard.timeRestore) {
if (savedDashboard.timeFrom && savedDashboard.timeTo) {
services.data.query.timefilter.timefilter.setTime({

Check warning on line 65 in src/plugins/dashboard/public/application/utils/use/use_saved_dashboard_instance.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/utils/use/use_saved_dashboard_instance.ts#L65

Added line #L65 was not covered by tests
from: savedDashboard.timeFrom,
to: savedDashboard.timeTo,
});
}
if (savedDashboard.refreshInterval) {
services.data.query.timefilter.timefilter.setRefreshInterval(

Check warning on line 71 in src/plugins/dashboard/public/application/utils/use/use_saved_dashboard_instance.ts

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/utils/use/use_saved_dashboard_instance.ts#L71

Added line #L71 was not covered by tests
savedDashboard.refreshInterval
);
}
}

chrome.recentlyAccessed.add(
savedDashboard.getFullPath(),
savedDashboard.title,
Expand Down

0 comments on commit bf00495

Please sign in to comment.