refactor(ui): improve log highlighting and template formatting

This commit is contained in:
Mauricio Siu 2025-02-23 18:11:27 -06:00
parent 125e44812b
commit d3b2cee7fb
3 changed files with 53 additions and 54 deletions

View File

@ -35,34 +35,34 @@ export function TerminalLine({ log, noTimestamp, searchTerm }: LogLineProps) {
})
: "--- No time found ---";
const highlightMessage = (text: string, term: string) => {
if (!term) {
return (
<span
className="transition-colors"
dangerouslySetInnerHTML={{
__html: fancyAnsi.toHtml(text),
}}
/>
);
}
const htmlContent = fancyAnsi.toHtml(text);
const searchRegex = new RegExp(`(${escapeRegExp(term)})`, "gi");
const modifiedContent = htmlContent.replace(
searchRegex,
(match) =>
`<span class="bg-orange-200/80 dark:bg-orange-900/80 font-bold">${match}</span>`,
);
const highlightMessage = (text: string, term: string) => {
if (!term) {
return (
<span
className="transition-colors"
dangerouslySetInnerHTML={{ __html: modifiedContent }}
dangerouslySetInnerHTML={{
__html: fancyAnsi.toHtml(text),
}}
/>
);
};
}
const htmlContent = fancyAnsi.toHtml(text);
const searchRegex = new RegExp(`(${escapeRegExp(term)})`, "gi");
const modifiedContent = htmlContent.replace(
searchRegex,
(match) =>
`<span class="bg-orange-200/80 dark:bg-orange-900/80 font-bold">${match}</span>`,
);
return (
<span
className="transition-colors"
dangerouslySetInnerHTML={{ __html: modifiedContent }}
/>
);
};
const tooltip = (color: string, timestamp: string | null) => {
const square = (

View File

@ -1,38 +1,38 @@
import {
type DomainSchema,
type Schema,
type Template,
generateRandomDomain,
type DomainSchema,
type Schema,
type Template,
generateRandomDomain,
} from "../utils";
export function generate(schema: Schema): Template {
const dashboardDomain = generateRandomDomain(schema);
const backendDomain = generateRandomDomain(schema);
const actionsDomain = generateRandomDomain(schema);
const dashboardDomain = generateRandomDomain(schema);
const backendDomain = generateRandomDomain(schema);
const actionsDomain = generateRandomDomain(schema);
const domains: DomainSchema[] = [
{
host: dashboardDomain,
port: 6791,
serviceName: "dashboard",
},
{
host: backendDomain,
port: 3210,
serviceName: "backend",
},
{
host: actionsDomain,
port: 3211,
serviceName: "backend",
},
];
const domains: DomainSchema[] = [
{
host: dashboardDomain,
port: 6791,
serviceName: "dashboard",
},
{
host: backendDomain,
port: 3210,
serviceName: "backend",
},
{
host: actionsDomain,
port: 3211,
serviceName: "backend",
},
];
const envs = [
`NEXT_PUBLIC_DEPLOYMENT_URL=http://${backendDomain}`,
`CONVEX_CLOUD_ORIGIN=http://${backendDomain}`,
`CONVEX_SITE_ORIGIN=http://${actionsDomain}`,
];
const envs = [
`NEXT_PUBLIC_DEPLOYMENT_URL=http://${backendDomain}`,
`CONVEX_CLOUD_ORIGIN=http://${backendDomain}`,
`CONVEX_SITE_ORIGIN=http://${actionsDomain}`,
];
return { envs, domains };
return { envs, domains };
}

View File

@ -1619,4 +1619,3 @@ export const templates: TemplateData[] = [
load: () => import("./wikijs/index").then((m) => m.generate),
},
];