2022-02-04 05:46:27 -06:00
|
|
|
import { omit } from 'lodash';
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
|
2022-02-04 05:46:27 -06:00
|
|
|
import { DataQuery, DataSourceApi, dateTimeFormat, ExploreUrlState, urlUtil } from '@grafana/data';
|
2020-06-30 07:51:04 -05:00
|
|
|
import { serializeStateToUrlParam } from '@grafana/data/src/utils/url';
|
2020-12-04 07:24:55 -06:00
|
|
|
import { getDataSourceSrv } from '@grafana/runtime';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { notifyApp } from 'app/core/actions';
|
2023-04-28 10:03:51 -05:00
|
|
|
import { createErrorNotification, createWarningNotification } from 'app/core/copy/appNotification';
|
2023-10-30 05:36:08 -05:00
|
|
|
import { t } from 'app/core/internationalization';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { dispatch } from 'app/store/store';
|
|
|
|
import { RichHistoryQuery } from 'app/types/explore';
|
|
|
|
|
|
|
|
import {
|
2022-05-23 07:43:38 -05:00
|
|
|
RichHistoryResults,
|
2022-04-22 08:33:13 -05:00
|
|
|
RichHistoryServiceError,
|
|
|
|
RichHistoryStorageWarning,
|
|
|
|
RichHistoryStorageWarningDetails,
|
|
|
|
} from '../history/RichHistoryStorage';
|
|
|
|
import { getRichHistoryStorage } from '../history/richHistoryStorageProvider';
|
|
|
|
|
2022-04-27 08:07:44 -05:00
|
|
|
import { RichHistorySearchFilters, RichHistorySettings, SortOrder } from './richHistoryTypes';
|
2022-02-04 05:46:27 -06:00
|
|
|
|
2022-04-27 08:07:44 -05:00
|
|
|
export { RichHistorySearchFilters, RichHistorySettings, SortOrder };
|
2020-08-06 11:35:49 -05:00
|
|
|
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
/*
|
|
|
|
* Add queries to rich history. Save only queries within the retention period, or that are starred.
|
|
|
|
* Side-effect: store history in local storage
|
|
|
|
*/
|
|
|
|
|
2022-02-04 05:46:27 -06:00
|
|
|
export async function addToRichHistory(
|
2022-02-10 06:59:43 -06:00
|
|
|
datasourceUid: string,
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
datasourceName: string | null,
|
2020-04-24 11:23:31 -05:00
|
|
|
queries: DataQuery[],
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
starred: boolean,
|
|
|
|
comment: string | null,
|
2021-10-11 02:48:25 -05:00
|
|
|
showQuotaExceededError: boolean,
|
|
|
|
showLimitExceededWarning: boolean
|
2022-04-06 06:49:25 -05:00
|
|
|
): Promise<{ richHistoryStorageFull?: boolean; limitExceeded?: boolean }> {
|
2020-04-24 11:23:31 -05:00
|
|
|
/* Save only queries, that are not falsy (e.g. empty object, null, ...) */
|
2021-01-20 00:59:48 -06:00
|
|
|
const newQueriesToSave: DataQuery[] = queries && queries.filter((query) => notEmptyQuery(query));
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
|
2020-04-24 11:23:31 -05:00
|
|
|
if (newQueriesToSave.length > 0) {
|
2022-02-04 05:46:27 -06:00
|
|
|
let richHistoryStorageFull = false;
|
2021-10-11 02:48:25 -05:00
|
|
|
let limitExceeded = false;
|
2022-02-04 05:46:27 -06:00
|
|
|
let warning: RichHistoryStorageWarningDetails | undefined;
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
|
2020-04-20 08:13:02 -05:00
|
|
|
try {
|
2022-02-10 06:59:43 -06:00
|
|
|
const result = await getRichHistoryStorage().addToRichHistory({
|
|
|
|
datasourceUid: datasourceUid,
|
|
|
|
datasourceName: datasourceName ?? '',
|
|
|
|
queries: newQueriesToSave,
|
|
|
|
starred,
|
|
|
|
comment: comment ?? '',
|
|
|
|
});
|
|
|
|
warning = result.warning;
|
2020-04-20 08:13:02 -05:00
|
|
|
} catch (error) {
|
2022-06-15 02:59:29 -05:00
|
|
|
if (error instanceof Error) {
|
|
|
|
if (error.name === RichHistoryServiceError.StorageFull) {
|
|
|
|
richHistoryStorageFull = true;
|
|
|
|
showQuotaExceededError && dispatch(notifyApp(createErrorNotification(error.message)));
|
|
|
|
} else if (error.name !== RichHistoryServiceError.DuplicatedEntry) {
|
2023-10-30 05:36:08 -05:00
|
|
|
dispatch(
|
|
|
|
notifyApp(
|
|
|
|
createErrorNotification(
|
|
|
|
t('explore.rich-history-utils-notification.update-failed', 'Rich History update failed'),
|
|
|
|
error.message
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2022-06-15 02:59:29 -05:00
|
|
|
}
|
2022-02-04 05:46:27 -06:00
|
|
|
}
|
|
|
|
// Saving failed. Do not add new entry.
|
2022-04-06 06:49:25 -05:00
|
|
|
return { richHistoryStorageFull, limitExceeded };
|
2022-02-04 05:46:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Limit exceeded but new entry was added. Notify that old entries have been removed.
|
|
|
|
if (warning && warning.type === RichHistoryStorageWarning.LimitExceeded) {
|
|
|
|
limitExceeded = true;
|
|
|
|
showLimitExceededWarning && dispatch(notifyApp(createWarningNotification(warning.message)));
|
2020-03-17 10:06:02 -05:00
|
|
|
}
|
2022-02-04 05:46:27 -06:00
|
|
|
|
2022-04-06 06:49:25 -05:00
|
|
|
return { richHistoryStorageFull, limitExceeded };
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:49:25 -05:00
|
|
|
// Nothing to change
|
|
|
|
return {};
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2022-05-23 07:43:38 -05:00
|
|
|
export async function getRichHistory(filters: RichHistorySearchFilters): Promise<RichHistoryResults> {
|
2022-04-27 08:07:44 -05:00
|
|
|
return await getRichHistoryStorage().getRichHistory(filters);
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2022-04-12 11:55:39 -05:00
|
|
|
export async function updateRichHistorySettings(settings: RichHistorySettings): Promise<void> {
|
|
|
|
await getRichHistoryStorage().updateSettings(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getRichHistorySettings(): Promise<RichHistorySettings> {
|
|
|
|
return await getRichHistoryStorage().getSettings();
|
|
|
|
}
|
|
|
|
|
2022-02-04 05:46:27 -06:00
|
|
|
export async function deleteAllFromRichHistory(): Promise<void> {
|
|
|
|
return getRichHistoryStorage().deleteAll();
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:49:25 -05:00
|
|
|
export async function updateStarredInRichHistory(id: string, starred: boolean) {
|
2020-04-20 08:13:02 -05:00
|
|
|
try {
|
2022-04-06 06:49:25 -05:00
|
|
|
return await getRichHistoryStorage().updateStarred(id, starred);
|
2020-04-20 08:13:02 -05:00
|
|
|
} catch (error) {
|
2022-06-15 02:59:29 -05:00
|
|
|
if (error instanceof Error) {
|
2023-10-30 05:36:08 -05:00
|
|
|
dispatch(
|
|
|
|
notifyApp(
|
|
|
|
createErrorNotification(
|
|
|
|
t('explore.rich-history-utils-notification.saving-failed', 'Saving rich history failed'),
|
|
|
|
error.message
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2022-06-15 02:59:29 -05:00
|
|
|
}
|
2022-04-06 06:49:25 -05:00
|
|
|
return undefined;
|
2020-04-20 08:13:02 -05:00
|
|
|
}
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:49:25 -05:00
|
|
|
export async function updateCommentInRichHistory(id: string, newComment: string | undefined) {
|
2020-04-20 08:13:02 -05:00
|
|
|
try {
|
2022-04-06 06:49:25 -05:00
|
|
|
return await getRichHistoryStorage().updateComment(id, newComment);
|
2020-04-20 08:13:02 -05:00
|
|
|
} catch (error) {
|
2022-06-15 02:59:29 -05:00
|
|
|
if (error instanceof Error) {
|
2023-10-30 05:36:08 -05:00
|
|
|
dispatch(
|
|
|
|
notifyApp(
|
|
|
|
createErrorNotification(
|
|
|
|
t('explore.rich-history-utils-notification.saving-failed', 'Saving rich history failed'),
|
|
|
|
error.message
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2022-06-15 02:59:29 -05:00
|
|
|
}
|
2022-04-06 06:49:25 -05:00
|
|
|
return undefined;
|
2020-04-20 08:13:02 -05:00
|
|
|
}
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2022-04-06 06:49:25 -05:00
|
|
|
export async function deleteQueryInRichHistory(id: string) {
|
2020-04-20 08:13:02 -05:00
|
|
|
try {
|
2022-02-10 06:59:43 -06:00
|
|
|
await getRichHistoryStorage().deleteRichHistory(id);
|
2022-04-06 06:49:25 -05:00
|
|
|
return id;
|
2020-04-20 08:13:02 -05:00
|
|
|
} catch (error) {
|
2022-06-15 02:59:29 -05:00
|
|
|
if (error instanceof Error) {
|
2023-10-30 05:36:08 -05:00
|
|
|
dispatch(
|
|
|
|
notifyApp(
|
|
|
|
createErrorNotification(
|
|
|
|
t('explore.rich-history-utils-notification.saving-failed', 'Saving rich history failed'),
|
|
|
|
error.message
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2022-06-15 02:59:29 -05:00
|
|
|
}
|
2022-04-06 06:49:25 -05:00
|
|
|
return undefined;
|
2020-04-20 08:13:02 -05:00
|
|
|
}
|
2020-03-19 02:47:27 -05:00
|
|
|
}
|
|
|
|
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
export const createUrlFromRichHistory = (query: RichHistoryQuery) => {
|
|
|
|
const exploreState: ExploreUrlState = {
|
|
|
|
/* Default range, as we are not saving timerange in rich history */
|
2023-10-30 05:36:08 -05:00
|
|
|
range: {
|
|
|
|
from: t('explore.rich-history-utils.default-from', 'now-1h'),
|
|
|
|
to: t('explore.rich-history-utils.default-to', 'now'),
|
|
|
|
},
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
datasource: query.datasourceName,
|
2020-04-24 11:23:31 -05:00
|
|
|
queries: query.queries,
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
};
|
|
|
|
|
2022-01-27 05:23:56 -06:00
|
|
|
const serializedState = serializeStateToUrlParam(exploreState);
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
const baseUrl = /.*(?=\/explore)/.exec(`${window.location.href}`)![0];
|
2020-04-20 00:37:38 -05:00
|
|
|
const url = urlUtil.renderUrl(`${baseUrl}/explore`, { left: serializedState });
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
return url;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Needed for slider in Rich history to map numerical values to meaningful strings */
|
|
|
|
export const mapNumbertoTimeInSlider = (num: number) => {
|
|
|
|
let str;
|
|
|
|
switch (num) {
|
|
|
|
case 0:
|
2023-10-30 05:36:08 -05:00
|
|
|
str = t('explore.rich-history-utils.today', 'today');
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
break;
|
|
|
|
case 1:
|
2023-10-30 05:36:08 -05:00
|
|
|
str = t('explore.rich-history-utils.yesterday', 'yesterday');
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
break;
|
|
|
|
case 7:
|
2023-10-30 05:36:08 -05:00
|
|
|
str = t('explore.rich-history-utils.a-week-ago', 'a week ago');
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
break;
|
|
|
|
case 14:
|
2023-10-30 05:36:08 -05:00
|
|
|
str = t('explore.rich-history-utils.two-weeks-ago', 'two weeks ago');
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
break;
|
|
|
|
default:
|
2023-10-30 05:36:08 -05:00
|
|
|
str = t('explore.rich-history-utils.days-ago', '{{num}} days ago', { num: `${num}` });
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
};
|
|
|
|
|
|
|
|
export function createDateStringFromTs(ts: number) {
|
2020-04-27 08:28:06 -05:00
|
|
|
return dateTimeFormat(ts, {
|
|
|
|
format: 'MMMM D',
|
|
|
|
});
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getQueryDisplayText(query: DataQuery): string {
|
2020-04-24 11:23:31 -05:00
|
|
|
/* If datasource doesn't have getQueryDisplayText, create query display text by
|
|
|
|
* stringifying query that was stripped of key, refId and datasource for nicer
|
|
|
|
* formatting and improved readability
|
|
|
|
*/
|
2021-04-21 02:38:00 -05:00
|
|
|
const strippedQuery = omit(query, ['key', 'refId', 'datasource']);
|
2020-04-24 11:23:31 -05:00
|
|
|
return JSON.stringify(strippedQuery);
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export function createQueryHeading(query: RichHistoryQuery, sortOrder: SortOrder) {
|
|
|
|
let heading = '';
|
|
|
|
if (sortOrder === SortOrder.DatasourceAZ || sortOrder === SortOrder.DatasourceZA) {
|
|
|
|
heading = query.datasourceName;
|
|
|
|
} else {
|
2022-02-10 06:59:43 -06:00
|
|
|
heading = createDateStringFromTs(query.createdAt);
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
return heading;
|
|
|
|
}
|
|
|
|
|
2023-02-01 04:11:17 -06:00
|
|
|
export function createQueryText(query: DataQuery, dsApi?: DataSourceApi) {
|
|
|
|
if (dsApi?.getQueryDisplayText) {
|
|
|
|
return dsApi.getQueryDisplayText(query);
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:23:31 -05:00
|
|
|
return getQueryDisplayText(query);
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export function mapQueriesToHeadings(query: RichHistoryQuery[], sortOrder: SortOrder) {
|
2023-03-14 04:51:44 -05:00
|
|
|
let mappedQueriesToHeadings: Record<string, RichHistoryQuery[]> = {};
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
|
2021-01-20 00:59:48 -06:00
|
|
|
query.forEach((q) => {
|
Explore: Rich History (#22570)
* Explore: Refactor active buttons css
* Explore: Add query history button
* WIP: Creating drawer
* WIP: Create custom drawer (for now)
* Revert changes to Drawer.tsx
* WIP: Layout finished
* Rich History: Set up boilerplate for Settings
* WIP: Query history cards
* Refactor, split components
* Add resizability, interactivity
* Save history to local storage
* Visualise queries from queryhistory local storage
* Set up query history settings
* Refactor
* Create link, un-refactored verison
* Copyable url
* WIP: Add slider
* Commenting feature
* Slider filtration
* Add headings
* Hide Rich history behind feature toggle
* Cleaning up, refactors
* Update tests
* Implement getQueryDisplayText
* Update lockfile for new dependencies
* Update heading based on sorting
* Fix typescript strinctNullCheck errors
* Fix Forms, new forms
* Fixes based on provided feedback
* Fixes, splitting component into two
* Add tooltips, add delete history button
* Clicking on card adds queries to query rows
* Delete history, width of drawers
* UI/UX changes, updates
* Add number of queries to headings, box shadows
* Fix slider, remove feature toggle
* Fix typo in the beta announcement
* Fix how the rich history state is rendered when initialization
* Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code
* Fix typescript strictnull errors, not used variables errors
2020-03-10 09:08:15 -05:00
|
|
|
let heading = createQueryHeading(q, sortOrder);
|
|
|
|
if (!(heading in mappedQueriesToHeadings)) {
|
|
|
|
mappedQueriesToHeadings[heading] = [q];
|
|
|
|
} else {
|
|
|
|
mappedQueriesToHeadings[heading] = [...mappedQueriesToHeadings[heading], q];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return mappedQueriesToHeadings;
|
|
|
|
}
|
2020-03-19 02:47:27 -05:00
|
|
|
|
2022-04-27 08:07:44 -05:00
|
|
|
/*
|
|
|
|
* Create a list of all available data sources
|
2020-03-19 02:47:27 -05:00
|
|
|
*/
|
2022-04-27 08:07:44 -05:00
|
|
|
export function createDatasourcesList() {
|
|
|
|
return getDataSourceSrv()
|
2023-07-17 06:25:49 -05:00
|
|
|
.getList({ mixed: true })
|
2022-04-27 08:07:44 -05:00
|
|
|
.map((dsSettings) => {
|
|
|
|
return {
|
|
|
|
name: dsSettings.name,
|
|
|
|
uid: dsSettings.uid,
|
|
|
|
};
|
|
|
|
});
|
2020-03-19 02:47:27 -05:00
|
|
|
}
|
2020-04-24 11:23:31 -05:00
|
|
|
|
|
|
|
export function notEmptyQuery(query: DataQuery) {
|
|
|
|
/* Check if query has any other properties besides key, refId and datasource.
|
|
|
|
* If not, then we consider it empty query.
|
|
|
|
*/
|
2021-04-21 02:38:00 -05:00
|
|
|
const strippedQuery = omit(query, ['key', 'refId', 'datasource']);
|
2020-04-24 11:23:31 -05:00
|
|
|
const queryKeys = Object.keys(strippedQuery);
|
|
|
|
|
|
|
|
if (queryKeys.length > 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|