-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hironori Yamamoto
committed
Mar 9, 2023
1 parent
22ee4db
commit 5f408e0
Showing
12 changed files
with
418 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
LOG_LEVEL=INFO | ||
REDASH__URL= | ||
REDASH__API_KEY= | ||
NEXT_PUBLIC_APP__URL=http://localhost:3000 | ||
NEXT_PUBLIC_REDASH__URL=${REDASH__URL} | ||
OPEN_SEARCH__URL=http://opensearch-node-main:9200 | ||
OPEN_SEARCH__URL=http://localhost:9200 | ||
OPEN_SEARCH__USERNAME=admin | ||
OPEN_SEARCH__PASSWORD=admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
import { EuiCallOut, EuiText } from "@elastic/eui"; | ||
import dompurify from "dompurify"; | ||
import { EuiCallOut } from "@elastic/eui"; | ||
import { connectHighlight } from "react-instantsearch-dom"; | ||
|
||
export interface HighlightedQueryProps { | ||
query: string; | ||
} | ||
const deliminator = "|||"; | ||
const re = RegExp(`$\|\|\|(.*)${deliminator}\|\|\|`, "g"); | ||
|
||
export const HighlightedQuery: React.FC<HighlightedQueryProps> = ({ | ||
query, | ||
}: HighlightedQueryProps) => { | ||
const sanitizer = dompurify.sanitize; | ||
const HighlightQueryInner = ({ highlight, attribute, hit }: any) => { | ||
const parsedHit = highlight({ | ||
highlightProperty: "_highlightResult", | ||
attribute, | ||
hit, | ||
}); | ||
return ( | ||
<EuiCallOut> | ||
<p | ||
style={{ whiteSpace: "pre-wrap" }} | ||
dangerouslySetInnerHTML={{ | ||
__html: sanitizer(query), | ||
}} | ||
/> | ||
<EuiCallOut | ||
style={{ whiteSpace: "pre-wrap", maxWidth: "1000px" }} | ||
color={"success"} | ||
> | ||
<span className="ais-Highlight"> | ||
<span> | ||
{parsedHit.map((part: any, index: number) => | ||
part.isHighlighted ? ( | ||
<mark className="ais-Highlight-highlighted" key={index}> | ||
{part.value} | ||
</mark> | ||
) : ( | ||
<span className="ais-Highlight-nonHighlighted" key={index}> | ||
{part.value} | ||
</span> | ||
) | ||
)} | ||
</span> | ||
</span> | ||
</EuiCallOut> | ||
); | ||
}; | ||
|
||
const HighlightedQuery = connectHighlight(HighlightQueryInner); | ||
|
||
export default HighlightedQuery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import "instantsearch.css/themes/satellite-min.css"; | ||
import "../styles.css"; | ||
|
||
export default function App({ Component, pageProps }: any): JSX.Element { | ||
return <Component {...pageProps} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.