import { User, Clock, Info } from 'lucide-react'; import moment from 'moment'; import { useEffect, useState } from 'react'; import { Pod } from 'kubernetes-types/core/v1'; import { useCurrentStateAndParams } from '@uirouter/react'; import { Authorized } from '@/react/hooks/useUser'; import { notifyError, notifySuccess } from '@/portainer/services/notifications'; import { DetailsTable } from '@@/DetailsTable'; import { Badge } from '@@/Badge'; import { Link } from '@@/Link'; import { LoadingButton } from '@@/buttons'; import { WidgetBody, Widget } from '@@/Widget'; import { InlineLoader } from '@@/InlineLoader'; import { Icon } from '@@/Icon'; import { Note } from '@@/Note'; import { isSystemNamespace } from '../../namespaces/utils'; import { appStackNameLabel, appKindToDeploymentTypeMap, appOwnerLabel, appDeployMethodLabel, appNoteAnnotation, } from '../constants'; import { applicationIsKind, bytesToReadableFormat, getResourceRequests, getRunningPods, getTotalPods, isExternalApplication, } from '../utils'; import { useApplication, usePatchApplicationMutation, } from '../application.queries'; import { Application, ApplicationPatch } from '../types'; export function ApplicationSummaryWidget() { const stateAndParams = useCurrentStateAndParams(); const { params: { namespace, name, 'resource-type': resourceType, endpointId: environmentId, }, } = stateAndParams; const { data: application, ...applicationQuery } = useApplication( environmentId, namespace, name, resourceType ); const systemNamespace = isSystemNamespace(namespace); const externalApplication = application && isExternalApplication(application); const applicationRequests = application && getResourceRequests(application); const applicationOwner = application?.metadata?.labels?.[appOwnerLabel]; const applicationDeployMethod = getApplicationDeployMethod(application); const applicationNote = application?.metadata?.annotations?.[appNoteAnnotation]; const [applicationNoteFormValues, setApplicationNoteFormValues] = useState(''); useEffect(() => { setApplicationNoteFormValues(applicationNote || ''); }, [applicationNote]); const failedCreateCondition = application?.status?.conditions?.find( (condition) => condition.reason === 'FailedCreate' ); const patchApplicationMutation = usePatchApplicationMutation( environmentId, namespace, name ); return (
{getRunningPods(application)}
{' '}
/ {getTotalPods(application)}