Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull from constraint run table #1429

Merged
merged 12 commits into from
Aug 27, 2024
6 changes: 3 additions & 3 deletions src/components/constraints/ConstraintsPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import {
allowedConstraintPlanSpecMap,
allowedConstraintSpecs,
checkConstraintsStatus,
cachedConstraintsStatus,
constraintPlanSpecs,
constraintResponseMap,
constraintVisibilityMap,
Expand Down Expand Up @@ -232,7 +232,7 @@
permissionHandler,
{
hasPermission: $plan
? featurePermissions.constraintsPlanSpec.canCheck(user, $plan, $plan.model) && !$planReadOnly
? featurePermissions.constraintRuns.canCreate(user, $plan, $plan.model) && !$planReadOnly
: false,
permissionError: $planReadOnly
? PlanStatusMessages.READ_ONLY
Expand Down Expand Up @@ -326,7 +326,7 @@
{:else}
<div class="pt-1 st-typography-label filter-label-row">
<div class="filter-label">
{#if $checkConstraintsStatus}
{#if $cachedConstraintsStatus}
<FilterIcon />
{filteredConstraints.length} of {$allowedConstraintSpecs.length} constraints, {filteredViolationCount} of
{totalViolationCount} violations
Expand Down
2 changes: 1 addition & 1 deletion src/components/plan/PlanNavButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import PlayIcon from '@nasa-jpl/stellar/icons/play.svg?component';
import type { Status } from '../../enums/status';
import { permissionHandler } from '../../utilities/permissionHandler';
import { getHumanReadableStatus } from '../../utilities/simulation';
import { getHumanReadableStatus } from '../../utilities/status';
import { tooltip } from '../../utilities/tooltip';
import Menu from '../menus/Menu.svelte';
import MenuHeader from '../menus/MenuHeader.svelte';
Expand Down
8 changes: 4 additions & 4 deletions src/components/simulation/SimulationHistoryDataset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import { hexToRgba } from '../../utilities/color';
import {
formatSimulationQueuePosition,
getHumanReadableStatus,
getSimulationExtent,
getSimulationProgress,
getSimulationProgressColor,
getSimulationStatus,
getSimulationTimestamp,
} from '../../utilities/simulation';
import { getHumanReadableStatus } from '../../utilities/status';
import { formatDate, getUnixEpochTimeFromInterval, removeDateStringMilliseconds } from '../../utilities/time';
import { tooltip } from '../../utilities/tooltip';
import Card from '../ui/Card.svelte';
Expand Down Expand Up @@ -167,9 +167,9 @@
</div>
<div>
{#if extent}
<span use:tooltip={{ content: 'Simulation Time', placement: 'top' }} class="simulation-dataset-extent"
>{getSimulationTimestamp(simulationDataset)}</span
>,
<span use:tooltip={{ content: 'Simulation Time', placement: 'top' }} class="simulation-dataset-extent">
{getSimulationTimestamp(simulationDataset)}
</span>
{/if}
{progress.toFixed()}%
</div>
Expand Down
30 changes: 17 additions & 13 deletions src/routes/plans/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
selectedActivityDirectiveId,
} from '../../../stores/activities';
import {
cachedConstraintsStatus,
checkConstraintsStatus,
constraintResponseMap,
constraintsStatus,
constraintsViolationStatus,
resetConstraintStores,
resetPlanConstraintStores,
uncheckedConstraintCount,
Expand Down Expand Up @@ -120,6 +120,7 @@
import type { Extension } from '../../../types/extension';
import type { PlanSnapshot } from '../../../types/plan-snapshot';
import type { View, ViewSaveEvent, ViewToggleEvent } from '../../../types/view';
import { getConstraintStatus } from '../../../utilities/constraint';
import effects from '../../../utilities/effects';
import { getSearchParameterNumber, removeQueryParam, setQueryParam } from '../../../utilities/generic';
import { isSaveEvent } from '../../../utilities/keyboardEvents';
Expand All @@ -128,15 +129,14 @@
import { featurePermissions } from '../../../utilities/permissions';
import {
formatSimulationQueuePosition,
getHumanReadableStatus,
getSimulationExtent,
getSimulationProgress,
getSimulationProgressColor,
getSimulationQueuePosition,
getSimulationStatus,
getSimulationTimestamp,
} from '../../../utilities/simulation';
import { statusColors } from '../../../utilities/status';
import { getHumanReadableStatus, statusColors } from '../../../utilities/status';
import { pluralize } from '../../../utilities/text';
import { getUnixEpochTime } from '../../../utilities/time';
import { tooltip } from '../../../utilities/tooltip';
Expand Down Expand Up @@ -166,6 +166,7 @@
let compactNavMode = false;
let errorConsole: Console;
let consoleHeightString = '36px';
let constraintsStatusText: string | undefined;
let hasCreateViewPermission: boolean = false;
let hasUpdateViewPermission: boolean = false;
let hasExpandPermission: boolean = false;
Expand Down Expand Up @@ -229,7 +230,7 @@
$: hasUpdateViewPermission = $view !== null ? featurePermissions.view.canUpdate(data.user, $view) : false;
$: if ($initialPlan) {
hasCheckConstraintsPermission =
featurePermissions.constraintsPlanSpec.canCheck(data.user, $initialPlan, $initialPlan.model) && !$planReadOnly;
featurePermissions.constraintRuns.canCreate(data.user, $initialPlan, $initialPlan.model) && !$planReadOnly;
hasExpandPermission =
featurePermissions.expansionSequences.canExpand(data.user, $initialPlan, $initialPlan.model) && !$planReadOnly;
hasScheduleAnalysisPermission =
Expand Down Expand Up @@ -399,10 +400,16 @@
$: numConstraintsViolated = Object.values($constraintResponseMap).filter(
response => response.results.violations?.length,
).length;

$: numConstraintsWithErrors = Object.values($constraintResponseMap).filter(
response => response.errors?.length,
).length;
$: constraintsStatusText =
($constraintsStatus === Status.Complete ||
$constraintsStatus === Status.Failed ||
$constraintsStatus === Status.PartialSuccess) &&
numConstraintsViolated + numConstraintsWithErrors + $uncheckedConstraintCount > 0
? `${numConstraintsViolated + numConstraintsWithErrors + $uncheckedConstraintCount}`
: undefined;

$: if ($initialPlan && browser) {
// Asynchronously fetch resource types
Expand Down Expand Up @@ -699,10 +706,7 @@
buttonText="Check Constraints"
hasPermission={hasCheckConstraintsPermission}
disabled={$simulationStatus !== Status.Complete}
statusBadgeText={($checkConstraintsStatus === Status.Complete || $checkConstraintsStatus === Status.Failed) &&
numConstraintsViolated + numConstraintsWithErrors + $uncheckedConstraintCount > 0
? `${numConstraintsViolated + numConstraintsWithErrors + $uncheckedConstraintCount}`
: undefined}
statusBadgeText={constraintsStatusText}
buttonTooltipContent={$simulationStatus !== Status.Complete ? 'Completed simulation required' : ''}
permissionError={$planReadOnly
? PlanStatusMessages.READ_ONLY
Expand All @@ -715,14 +719,14 @@
<VerticalCollapseIcon />
<svelte:fragment slot="metadata">
<div class="st-typography-body constraints-status">
{#if $checkConstraintsStatus}
{#if $constraintsStatus}
<div class="constraints-status-item">
<StatusBadge status={$checkConstraintsStatus} indeterminate showTooltip={false} />
Check constraints: {getHumanReadableStatus($checkConstraintsStatus)}
Check constraints: {getConstraintStatus($checkConstraintsStatus)}
</div>
{#if $checkConstraintsStatus === Status.Complete || $checkConstraintsStatus === Status.Failed}
{#if $constraintsStatus === Status.Complete || $constraintsStatus === Status.Failed || $constraintsStatus === Status.PartialSuccess}
<div class="constraints-status-item">
<StatusBadge status={$constraintsViolationStatus} showTooltip={false} />
<StatusBadge status={$cachedConstraintsStatus} showTooltip={false} />
{#if numConstraintsViolated > 0}
<div style:color="var(--st-error-red)">
{numConstraintsViolated} constraint{pluralize(numConstraintsViolated)}
Expand Down
Loading
Loading