- Browse {metrics.length} metric{metrics.length > 1 ? 's' : ''} by text, by type, alphabetically or select a
+ Browse {totalMetricCount} metric{totalMetricCount > 1 ? 's' : ''} by text, by type, alphabetically or select a
variable.
{isLoading && (
@@ -364,11 +433,16 @@ export const MetricEncyclopediaModal = (props: Props) => {
// get all metrics data if a user erases everything in the input
updateMetricsMetadata();
} else if (useBackend) {
- setIsLoading(true);
debouncedBackendSearch(value);
} else {
- // do the search on the frontend
- debouncedFuzzySearch(value);
+ // search either the names or all metadata
+ // fuzzy search go!
+
+ if (fullMetaSearch) {
+ debouncedFuzzySearch(metaHaystack, value, setFuzzyMetaSearchResults);
+ } else {
+ debouncedFuzzySearch(nameHaystack, value, setFuzzyNameSearchResults);
+ }
}
setPageNum(1);
@@ -462,69 +536,8 @@ export const MetricEncyclopediaModal = (props: Props) => {
}}
/>
-
Results
-
- {[
- 'A',
- 'B',
- 'C',
- 'D',
- 'E',
- 'F',
- 'G',
- 'H',
- 'I',
- 'J',
- 'K',
- 'L',
- 'M',
- 'N',
- 'O',
- 'P',
- 'Q',
- 'R',
- 'S',
- 'T',
- 'U',
- 'V',
- 'W',
- 'X',
- 'Y',
- 'Z',
- ].map((letter, idx, coll) => {
- const active: boolean = filterMetrics(metrics, true).some((m: MetricData) => {
- return m.value[0] === letter || m.value[0] === letter?.toLowerCase();
- });
-
- // starts with letter search
- // filter by starts with letter
- // if same letter searched null out remove letter search
- function updateLetterSearch() {
- if (letterSearch === letter) {
- setLetterSearch(null);
- } else {
- setLetterSearch(letter);
- }
- setPageNum(1);
- }
- // selected letter to filter by
- const selectedClass: string = letterSearch === letter ? styles.selAlpha : '';
- // these letters are represented in the list of metrics
- const activeClass: string = active ? styles.active : styles.gray;
-
- return (
- {}}
- className={`${selectedClass} ${activeClass}`}
- key={letter}
- data-testid={'letter-' + letter}
- >
- {letter + ' '}
- {/* {idx !== coll.length - 1 ? '|': ''} */}
-
- );
- })}
-
+
{filteredMetricCount} Results
+
{letterSearchComponent()}
{metrics &&
displayedMetrics(metrics).map((metric: MetricData, idx) => {
return (
@@ -656,22 +669,6 @@ function alphabetically(ascending: boolean, metadataFilters: boolean) {
};
}
-function UseUfuzzy(): uFuzzy {
- const ref = useRef
();
-
- if (!ref.current) {
- ref.current = new uFuzzy({
- intraMode: 1,
- intraIns: 1,
- intraSub: 1,
- intraTrn: 1,
- intraDel: 1,
- });
- }
-
- return ref.current;
-}
-
const getStyles = (theme: GrafanaTheme2) => {
return {
cardsContainer: css`
@@ -733,3 +730,32 @@ export const testIds = {
resultsPerPage: 'results-per-page',
setUseBackend: 'set-use-backend',
};
+
+const alphabet = [
+ 'A',
+ 'B',
+ 'C',
+ 'D',
+ 'E',
+ 'F',
+ 'G',
+ 'H',
+ 'I',
+ 'J',
+ 'K',
+ 'L',
+ 'M',
+ 'N',
+ 'O',
+ 'P',
+ 'Q',
+ 'R',
+ 'S',
+ 'T',
+ 'U',
+ 'V',
+ 'W',
+ 'X',
+ 'Y',
+ 'Z',
+];