/* 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, { useState, useEffect } from "react"; import { RouteComponentProps } from "react-router-dom"; import Breadcrumb from "components/Breadcrumb"; import LoadingText from "components/LoadingText"; import HeaderPanel from "components/HeaderPanel"; import ValueWithLabel from "components/ValueWithLabel"; import ExtLink from "components/ExtLink"; import { AntTabs, AntTab, TabPanel } from "components/Tab"; import Ingestion from "./detail/Ingestion"; import Lifecycle from "./detail/Lifecycle"; import Tags from "./detail/Tags"; import { appSyncRequestQuery } from "assets/js/request"; import { getAppPipeline } from "graphql/queries"; import { AppPipeline, BufferType, PipelineStatus } from "API"; import { buildESLink, buildKDSLink, buildS3Link, formatLocalTime, } from "assets/js/utils"; import { AmplifyConfigType, S3_STORAGE_CLASS_OPTIONS } from "types"; import { useSelector } from "react-redux"; import { AppStateProps } from "reducer/appReducer"; import HelpPanel from "components/HelpPanel"; import SideMenu from "components/SideMenu"; import Permission from "./detail/Permission"; import { useTranslation } from "react-i18next"; import Status from "components/Status/Status"; import { getParamValueByKey } from "assets/js/applog"; interface MatchParams { id: string; } const ApplicationLogDetail: React.FC> = ( props: RouteComponentProps ) => { const id: string = props.match.params.id; const { t } = useTranslation(); const breadCrumbList = [ { name: t("name"), link: "/" }, { name: t("applog:name"), link: "/log-pipeline/application-log", }, { name: id, }, ]; const amplifyConfig: AmplifyConfigType = useSelector( (state: AppStateProps) => state.amplifyConfig ); console.info("amplifyConfig:", amplifyConfig); const [loadingData, setLoadingData] = useState(true); const [curPipeline, setCurPipeline] = useState(); const [activeTab, setActiveTab] = useState(0); const changeTab = (event: any, newTab: number) => { console.info("newTab:", newTab); setActiveTab(newTab); }; const getPipelineById = async () => { try { setLoadingData(true); const resData: any = await appSyncRequestQuery(getAppPipeline, { id: id, }); console.info("resData:", resData); const dataPipelne: AppPipeline = resData.data.getAppPipeline; setCurPipeline(dataPipelne); setLoadingData(false); } catch (error) { setLoadingData(false); console.error(error); } }; useEffect(() => { getPipelineById(); }, []); return (
{loadingData ? ( ) : (
{curPipeline?.aosParams?.indexPrefix || "-"}
{curPipeline?.aosParams?.indexSuffix && (
{curPipeline?.aosParams?.indexSuffix?.replaceAll( "_", "-" ) || "-"}
)} {curPipeline?.aosParams?.codec && (
{curPipeline?.aosParams?.codec || "-"}
)} {curPipeline?.bufferType === BufferType.KDS && (
{getParamValueByKey( "OpenShardCount", curPipeline?.bufferParams ) || "-"}
)}
{curPipeline?.aosParams?.shardNumbers || "-"}
{curPipeline?.aosParams?.domainName || "-"} {curPipeline?.aosParams?.rolloverSize && (
{curPipeline?.aosParams?.rolloverSize?.toUpperCase() || "-"}
)} {curPipeline?.bufferType === BufferType.KDS && (
{getParamValueByKey( "ConsumerCount", curPipeline?.bufferParams ) || "-"}
)}
{curPipeline?.aosParams?.replicaNumbers}
{curPipeline?.bufferType !== BufferType.None && curPipeline?.status === PipelineStatus.CREATING ? ( ({t("pendingCreation")}) ) : ( <> {curPipeline?.bufferType === BufferType.KDS && (
{curPipeline.bufferResourceName || "-"} {getParamValueByKey( "enableAutoScaling", curPipeline?.bufferParams ) === "true" ? t("applog:detail.autoScaling") : ""}
)} {curPipeline?.bufferType === BufferType.S3 && ( <> {getParamValueByKey( "logBucketName", curPipeline?.bufferParams ) || "-"} )} {curPipeline?.bufferType === BufferType.None && (
{t("none")}
)} )}
{curPipeline?.bufferType === BufferType.S3 && ( <>
{getParamValueByKey( "logBucketPrefix", curPipeline?.bufferParams ) || "-"}
{ S3_STORAGE_CLASS_OPTIONS.find((element) => { return ( getParamValueByKey( "s3StorageClass", curPipeline?.bufferParams ) === element.value ); })?.name }
)}
{formatLocalTime(curPipeline?.createdDt || "-")}
{curPipeline && (
{ changeTab(event, newTab); }} > { setActiveTab(id); }} pipelineInfo={curPipeline} />
)}
)}
); }; export default ApplicationLogDetail;