/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import React from "react"; import FormItem from "components/FormItem"; import TextInput from "components/TextInput"; import Select from "components/Select"; import { LOG_CONFIG_TYPE_LIST, MULTI_LINE_LOG_PARSER_LIST, SYSLOG_CONFIG_TYPE_LIST, SYS_LOG_PARSER_LIST, } from "assets/js/const"; import { LogConf, LogConfFilterInput, LogSourceType, LogType, MultiLineLogParser, ProcessorFilterRegexInput, SyslogParser, } from "API"; import TextArea from "components/TextArea"; import HeaderPanel from "components/HeaderPanel"; import SampleLogParsing, { RegexListType } from "./SampleLogParsing"; import { ActionType, InfoBarTypes } from "reducer/appReducer"; import { useDispatch } from "react-redux"; import { useTranslation } from "react-i18next"; import LoadingText from "components/LoadingText"; import ConfigFilter from "./ConfigFilter"; import { OptionType } from "components/AutoComplete/autoComplete"; export interface ProcessorFilterRegexInputExt extends Omit { filters: LogConfFilterInput[]; } export interface ExLogConf extends Omit { smapleLogDateFormatStr?: string; regexKeyList?: RegexListType[]; processorFilterRegex?: ProcessorFilterRegexInput; selectKeyList?: OptionType[]; } export enum PageType { Edit = "Edit", New = "New", } interface LogConfigProps { pageType: PageType; logSourceType?: LogSourceType; headerTitle: string; curConfig: ExLogConf | undefined; changeLogConfName: (name: string) => void; changeLogType: (type: LogType) => void; changeUserLogFormat: (format: string) => void; changeRegExpSpecs: (specs: any) => void; changeLogParser: (parser: MultiLineLogParser) => void; changeSyslogParser: (parser: SyslogParser) => void; changeUserSmapleLog: (log: string) => void; showNameRequiredError: boolean; showTypeRequiedError: boolean; userLogFormatError: boolean; sampleLogRequiredError: boolean; isLoading: boolean; sampleLogInvalid: boolean; changeSampleLogInvalid: (invalid: boolean) => void; changeTimeKey: (key: string) => void; changeRegexKeyList: (list: RegexListType[]) => void; changeFilterRegex: (filter: ProcessorFilterRegexInput) => void; changeSelectKeyList: (list: OptionType[]) => void; changeTimeOffset: (offset: string) => void; } const LogConfigComp: React.FC = (props: LogConfigProps) => { const { headerTitle, logSourceType, curConfig, changeLogConfName, changeLogType, changeUserLogFormat, changeRegExpSpecs, changeLogParser, changeSyslogParser, changeUserSmapleLog, showNameRequiredError, showTypeRequiedError, userLogFormatError, sampleLogRequiredError, isLoading, sampleLogInvalid, changeSampleLogInvalid, changeTimeKey, changeRegexKeyList, changeFilterRegex, changeSelectKeyList, changeTimeOffset, } = props; const { t } = useTranslation(); const dispatch = useDispatch(); return (
{isLoading ? ( ) : (
{ changeLogConfName && changeLogConfName(event.target.value); }} placeholder="log-example-config" /> { console.info("event:", event); changeSyslogParser && changeSyslogParser(event.target.value); }} placeholder={t("resource:config.common.chooseParser")} /> )} {curConfig?.logType === LogType.Syslog && curConfig?.syslogParser === SyslogParser.CUSTOM && (
{ changeUserLogFormat && changeUserLogFormat(event.target.value); }} />
{t("resource:config.common.regName") + curConfig.regularExpression}
)} {curConfig?.logType === LogType.MultiLineText && (