Skip to content

Commit

Permalink
Refactor Markdown class to convert tags > and < to &gt; and &lt;
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Oct 28, 2024
1 parent 296791e commit 3865f6c
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 38 deletions.
4 changes: 4 additions & 0 deletions Common/Server/Types/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export default class Markdown {
markdown: string,
contentType: MarkdownContentType,
): Promise<string> {
// convert tags > and < to &gt; and &lt;
markdown = markdown.replace(/</g, "&lt;");
markdown = markdown.replace(/>/g, "&gt;");

let renderer: Renderer | null = null;

if (contentType === MarkdownContentType.Blog) {
Expand Down
22 changes: 13 additions & 9 deletions Dashboard/src/Components/Dashboard/Canvas/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,19 @@ const DashboardCanvas: FunctionComponent<ComponentProps> = (
setSelectedComponentId(component.componentId.toString());
}}
onComponentUpdate={(updatedComponent: DashboardBaseComponent) => {
const updatedComponents: Array<DashboardBaseComponent> = props.dashboardViewConfig.components.map(
(component: DashboardBaseComponent) => {
if (component.componentId.toString() === updatedComponent.componentId.toString()) {
return updatedComponent;
}

return component;
},
);
const updatedComponents: Array<DashboardBaseComponent> =
props.dashboardViewConfig.components.map(
(component: DashboardBaseComponent) => {
if (
component.componentId.toString() ===
updatedComponent.componentId.toString()
) {
return updatedComponent;
}

return component;
},
);

const updatedDashboardViewConfig: DashboardViewConfig = {
...props.dashboardViewConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,9 @@ const DashboardBaseComponentElement: FunctionComponent<ComponentProps> = (
left: "-9px",
}}
className="move-element cursor-move absolute w-4 h-4 bg-indigo-400 rounded-full cursor-pointer"
onDragStart={(_event: React.DragEvent<HTMLDivElement>) => {


}}
onDragEnd={(_event: React.DragEvent<HTMLDivElement>) => {


}}
>

</div>
onDragStart={(_event: React.DragEvent<HTMLDivElement>) => {}}
onDragEnd={(_event: React.DragEvent<HTMLDivElement>) => {}}
></div>
);
};

Expand Down Expand Up @@ -111,7 +103,6 @@ const DashboardBaseComponentElement: FunctionComponent<ComponentProps> = (
style={{
height: `${heightInRem}rem`,
}}

>
{getMoveElement()}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export interface ComponentProps extends DashboardBaseComponentProps {
component: DashboardChartComponent;
}

const DashboardChartComponentElement: FunctionComponent<ComponentProps> = (
_props: ComponentProps,
): ReactElement => {
const DashboardChartComponentElement: FunctionComponent = (): ReactElement => {
return <div>Chart Component</div>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export interface ComponentProps extends DashboardBaseComponentProps {
component: DashboardTextComponent;
}

const DashboardTextComponentElement: FunctionComponent<ComponentProps> = (
_props: ComponentProps,
): ReactElement => {
const DashboardTextComponentElement: FunctionComponent = (): ReactElement => {
return <div>Text Component</div>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export interface ComponentProps extends DashboardBaseComponentProps {
component: DashboardValueComponent;
}

const DashboardValueComponentElement: FunctionComponent<ComponentProps> = (
_props: ComponentProps,
): ReactElement => {
const DashboardValueComponentElement: FunctionComponent = (): ReactElement => {
return <div>Value Component</div>;
};

Expand Down
5 changes: 4 additions & 1 deletion Fluentd/Dockerfile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ FROM fluentd
USER root

# Install bash and curl.
RUN apk add bash curl
RUN apk add bash curl

EXPOSE 24224
EXPOSE 8888
15 changes: 14 additions & 1 deletion Fluentd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,18 @@ This guide will help you test fluentd logs with OneUptime.
- Telemetry Ingestion Key (Create one from the OneUptime dashboard, Click on More -> Project Settings -> Telemetry Ingestion Key)


## Configuration
## Configuration and Testing

- Please make sure the correct token and url is in the configuration file located at `Fluentd/fluent.conf`.
- Build the docker image using the command `npm run force-build fluentd`
- Run the docker image using the command `npm run dev fluentd`
- Send logs to the Fluentd container using the curl command

```bash
curl -X POST -d 'json={"action":"login","user":2}' http://localhost:8888/test.tag.here;
```

You should be able to see the logs in the OneUptime dashboard.



14 changes: 11 additions & 3 deletions Fluentd/fluent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@
bind 0.0.0.0
</source>

<source>
@type http
port 8888
bind 0.0.0.0
body_size_limit 32m
keepalive_timeout 10s
</source>

# Match all patterns
<match **>
@type http

# endpoint http://ingestor:3400/ingestor/fluentd/v1/logs # This is if you're testing in local development
endpoint http://ingestor:3400/ingestor/fluentd/v1/logs # This is for test environment
endpoint https://oneuptime.com/fluentd/logs # This is for prod environment
open_timeout 2

headers {"x-oneuptime-token":"6e16cfd0-5071-11ef-a5d5-e16a17b3db89", "x-oneuptime-service-name": "fluentd"}
# Please make sure you change the token and service name to your own
headers {"x-oneuptime-token":"caf42a30-8ace-11ef-b10a-eb9302809cb8", "x-oneuptime-service-name": "fluentd-logs"}

content_type application/json
json_array true
Expand Down
29 changes: 26 additions & 3 deletions Ingestor/API/FluentIngest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ router.post(

const dbLogs: Array<Log> = [];

const logItems: Array<JSONObject | string> = req.body as Array<
JSONObject | string
>;
let logItems: Array<JSONObject | string> | JSONObject = req.body as
| Array<JSONObject | string>
| JSONObject;

let oneuptimeServiceName: string | string[] | undefined =
req.headers["x-oneuptime-service-name"];
Expand All @@ -69,6 +69,20 @@ router.post(
projectId: (req as TelemetryRequest).projectId,
});

if (
logItems &&
typeof logItems === "object" &&
(logItems as JSONObject)["json"]
) {
logItems = (logItems as JSONObject)["json"] as
| Array<JSONObject | string>
| JSONObject;
}

if (!Array.isArray(logItems)) {
logItems = [logItems];
}

for (let logItem of logItems) {
const dbLog: Log = new Log();

Expand All @@ -81,6 +95,15 @@ router.post(

dbLog.severityText = LogSeverity.Unspecified;

if (typeof logItem === "string") {
// check if its parseable to json
try {
logItem = JSON.parse(logItem);
} catch (err) {
// do nothing
}
}

if (typeof logItem !== "string") {
logItem = JSON.stringify(logItem);
}
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ services:
ports:
- 24224:24224
- 24224:24224/udp
- 8888:8888
user: fluent
extends:
file: ./docker-compose.base.yml
Expand Down

0 comments on commit 3865f6c

Please sign in to comment.