import { User, Clock, Edit, ChevronRight, ChevronUp } 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 { Button, LoadingButton } from '@@/buttons'; 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 applicationQuery = useApplication( environmentId, namespace, name, resourceType ); const application = applicationQuery.data; 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 [isNoteOpen, setIsNoteOpen] = useState(true); const [applicationNoteFormValues, setApplicationNoteFormValues] = useState(''); useEffect(() => { setApplicationNoteFormValues(applicationNote || ''); }, [applicationNote]); const patchApplicationMutation = usePatchApplicationMutation( environmentId, namespace, name ); return (
{getRunningPods(application)}
/ {getTotalPods(application)}