mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
refactor: improve data handling and component state management in various files
This commit is contained in:
@@ -16,7 +16,7 @@ import LogPipelineProcessor from "Common/Models/DatabaseModels/LogPipelineProces
|
||||
import ModelAPI from "Common/UI/Utils/ModelAPI/ModelAPI";
|
||||
import FieldLabelElement from "Common/UI/Components/Detail/FieldLabel";
|
||||
import SeverityMappingRow, { SeverityMapping } from "./SeverityMappingRow";
|
||||
import { JSONObject } from "Common/Types/JSON";
|
||||
import { JSONObject, JSONValue } from "Common/Types/JSON";
|
||||
import Modal, { ModalWidth } from "Common/UI/Components/Modal/Modal";
|
||||
|
||||
export interface ComponentProps {
|
||||
@@ -94,7 +94,7 @@ const ProcessorForm: FunctionComponent<ComponentProps> = (
|
||||
sourceKey: severitySourceKey,
|
||||
mappings: severityMappings.filter((m: SeverityMapping) => {
|
||||
return m.matchValue && m.severityText;
|
||||
}),
|
||||
}) as unknown as JSONValue,
|
||||
};
|
||||
case "AttributeRemapper":
|
||||
return {
|
||||
@@ -108,7 +108,7 @@ const ProcessorForm: FunctionComponent<ComponentProps> = (
|
||||
targetKey: categoryTargetKey,
|
||||
categories: categories.filter((c: CategoryRule) => {
|
||||
return c.name && c.filterQuery;
|
||||
}),
|
||||
}) as unknown as JSONValue,
|
||||
};
|
||||
default:
|
||||
return {};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import PageComponentProps from "../PageComponentProps";
|
||||
import SortOrder from "Common/Types/BaseDatabase/SortOrder";
|
||||
import FormFieldSchemaType from "Common/UI/Components/Forms/Types/FormFieldSchemaType";
|
||||
import { FormValues } from "Common/UI/Components/Forms/Types/FormValues";
|
||||
import FormValues from "Common/UI/Components/Forms/Types/FormValues";
|
||||
import ModelTable from "Common/UI/Components/ModelTable/ModelTable";
|
||||
import FieldType from "Common/UI/Components/Types/FieldType";
|
||||
import LogScrubRule from "Common/Models/DatabaseModels/LogScrubRule";
|
||||
|
||||
@@ -866,11 +866,14 @@ export class LogAggregationService {
|
||||
data?: Array<JSONObject>;
|
||||
}>();
|
||||
|
||||
const totalData: Array<JSONObject> = totalResponse.data || [];
|
||||
const matchData: Array<JSONObject> = matchResponse.data || [];
|
||||
|
||||
const totalLogs: number = Number(
|
||||
(totalResponse.data || [])[0]?.["cnt"] || 0,
|
||||
totalData[0]?.["cnt"] || 0,
|
||||
);
|
||||
const matchingLogs: number = Number(
|
||||
(matchResponse.data || [])[0]?.["cnt"] || 0,
|
||||
matchData[0]?.["cnt"] || 0,
|
||||
);
|
||||
const estimatedReductionPercent: number =
|
||||
totalLogs > 0 ? Math.round((matchingLogs / totalLogs) * 100) : 0;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React, {
|
||||
FunctionComponent,
|
||||
ReactElement,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import LiveLogsToggle from "./LiveLogsToggle";
|
||||
import LogTimeRangePicker from "./LogTimeRangePicker";
|
||||
@@ -52,12 +50,8 @@ const LogsViewerToolbar: FunctionComponent<LogsViewerToolbarProps> = (
|
||||
currentPage && totalPages && totalPages > 0,
|
||||
);
|
||||
|
||||
const exportDropdownRef: React.RefObject<HTMLDivElement | null> =
|
||||
useRef<HTMLDivElement | null>(null);
|
||||
const [isExportOpen, setIsExportOpen] = useState<boolean>(false);
|
||||
useComponentOutsideClick(exportDropdownRef, () => {
|
||||
setIsExportOpen(false);
|
||||
});
|
||||
const { ref: exportDropdownRef, isComponentVisible: isExportOpen, setIsComponentVisible: setIsExportOpen } =
|
||||
useComponentOutsideClick(false);
|
||||
|
||||
const showExport: boolean = Boolean(props.onExportCSV || props.onExportJSON);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user