Skip to content

Commit

Permalink
reinstate test
Browse files Browse the repository at this point in the history
  • Loading branch information
lastminutediorama committed Dec 20, 2024
1 parent aebb77e commit 126d7d3
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
class="create-scenarios-panel mat-elevation-z2"
[ngClass]="{ hidden: scenarioNotFound }">
<div
*ngIf="scenarioOrigin === 'USER'; else tabContent"
*ngIf="scenarioOrigin === 'USER'"
class="uploaded-scenario-panel-content">
<app-treatments-tab
class="uploaded-treatments-tab"
*ngIf="scenarioId"
[scenarioId]="scenarioId!"
[planningArea]="plan$ | async"></app-treatments-tab>
<!-- TODO: make this a separate component? -->
<section class="treatment-footer" *ngIf="showTreatmentFooter()">
<mat-spinner diameter="24" *ngIf="creatingTreatment"></mat-spinner>
<button
Expand All @@ -28,118 +27,116 @@
</section>
</div>

<ng-template #tabContent>
<div class="create-scenarios-panel-content">
<div class="scenario-name">
<form [formGroup]="forms!">
<mat-form-field class="scenario-name-input">
<input
formControlName="scenarioName"
matInput
placeholder="Scenario Name:" />
</mat-form-field>
</form>
<div
*ngIf="
scenarioNameFormField?.invalid &&
scenarioNameFormField?.touched &&
scenarioNameFormField?.errors?.['required']
"
class="error">
Please enter scenario name above
</div>
<div *ngIf="scenarioNameFormField?.errors?.['duplicate']" class="error">
This name is already used by another scenario.
</div>
<div
[hidden]="!scenarioOrigin || scenarioOrigin === 'SYSTEM'"
class="create-scenarios-panel-content">
<div class="scenario-name">
<form [formGroup]="forms!">
<mat-form-field class="scenario-name-input">
<input
formControlName="scenarioName"
matInput
placeholder="Scenario Name:" />
</mat-form-field>
</form>
<div
*ngIf="
scenarioNameFormField?.invalid &&
scenarioNameFormField?.touched &&
scenarioNameFormField?.errors?.['required']
"
class="error">
Please enter scenario name above
</div>
<div class="tab-container">
<mat-tab-group
[selectedIndex]="selectedTab"
[animationDuration]="tabAnimation">
<mat-tab label="Configuration">
<div class="create-scenarios-inner-wrapper">
<app-set-priorities></app-set-priorities>
<app-identify-project-areas
*ngIf="project_area_upload_enabled"
[formGroup]="projectAreasForm"></app-identify-project-areas>
<app-constraints-panel
[planningAreaAcres]="(acres$ | async) || 0"
[showWarning]="
scenarioState !== 'SUCCESS'
"></app-constraints-panel>
<div class="flex-row gap-12" *ngIf="!scenarioResults">
<button
mat-raised-button
color="primary"
type="submit"
[disabled]="
scenarioNameFormField?.invalid ||
prioritiesForm?.invalid ||
constrainsForm?.invalid ||
generatingScenario
"
(click)="createScenario()">
{{
generatingScenario ? 'GENERATING SCENARIO...' : 'GENERATE'
}}
</button>
<div *ngIf="project_area_upload_enabled">
Estimated time ??????
</div>
</div>
</div>
</mat-tab>
<mat-tab label="Results">
<div class="results-container">
<ng-container *ngIf="scenarioState === 'LOADING'"></ng-container>
<app-scenario-not-started
*ngIf="
scenarioState === 'NOT_STARTED'
"></app-scenario-not-started>
<app-scenario-pending
*ngIf="scenarioState === 'PENDING'"></app-scenario-pending>
<app-scenario-pending
*ngIf="scenarioState === 'RUNNING'"></app-scenario-pending>
<app-scenario-results
*ngIf="scenarioState === 'SUCCESS'"
[results]="scenarioResults"
[scenarioChartData]="scenarioChartData"
[priorities]="priorities"
[scenarioName]="scenarioNameFormField?.value"
[scenarioId]="scenarioId!">
</app-scenario-results>
<app-scenario-failure
*ngIf="
scenarioState === 'FAILURE' ||
scenarioState === 'PANIC' ||
scenarioState === 'TIMED_OUT'
<div *ngIf="scenarioNameFormField?.errors?.['duplicate']" class="error">
This name is already used by another scenario.
</div>
</div>
<div class="tab-container">
<mat-tab-group
[selectedIndex]="selectedTab"
[animationDuration]="tabAnimation">
<mat-tab label="Configuration">
<div class="create-scenarios-inner-wrapper">
<app-set-priorities></app-set-priorities>
<app-identify-project-areas
*ngIf="project_area_upload_enabled"
[formGroup]="projectAreasForm"></app-identify-project-areas>
<app-constraints-panel
[planningAreaAcres]="(acres$ | async) || 0"
[showWarning]="
scenarioState !== 'SUCCESS'
"></app-constraints-panel>
<div class="flex-row gap-12" *ngIf="!scenarioResults">
<button
mat-raised-button
color="primary"
type="submit"
[disabled]="
scenarioNameFormField?.invalid ||
prioritiesForm?.invalid ||
constrainsForm?.invalid ||
generatingScenario
"
(tryAgain)="goToConfig()"
[scenarioName]="scenarioNameFormField?.value"
[scenarioId]="scenarioId!"
[scenarioState]="scenarioState"></app-scenario-failure>
(click)="createScenario()">
{{ generatingScenario ? 'GENERATING SCENARIO...' : 'GENERATE' }}
</button>
<div *ngIf="project_area_upload_enabled">
Estimated time ??????
</div>
</div>
</mat-tab>
<mat-tab label="Treatments" *ngIf="showTreatmentsTab && scenarioId">
<app-treatments-tab
[scenarioId]="scenarioId"
[planningArea]="plan$ | async"></app-treatments-tab>
</mat-tab>
</mat-tab-group>
</div>

<section class="treatment-footer" *ngIf="showTreatmentFooter()">
<mat-spinner diameter="24" *ngIf="creatingTreatment"></mat-spinner>
<button
sg-button
variant="primary"
icon="add"
class="new-treatment"
[disabled]="creatingTreatment"
(click)="createTreatment()">
New Treatment Plan
</button>
</section>
</div>
</mat-tab>
<mat-tab label="Results">
<div class="results-container">
<ng-container *ngIf="scenarioState === 'LOADING'"></ng-container>
<app-scenario-not-started
*ngIf="
scenarioState === 'NOT_STARTED'
"></app-scenario-not-started>
<app-scenario-pending
*ngIf="scenarioState === 'PENDING'"></app-scenario-pending>
<app-scenario-pending
*ngIf="scenarioState === 'RUNNING'"></app-scenario-pending>
<app-scenario-results
*ngIf="scenarioState === 'SUCCESS'"
[results]="scenarioResults"
[scenarioChartData]="scenarioChartData"
[priorities]="priorities"
[scenarioName]="scenarioNameFormField?.value"
[scenarioId]="scenarioId!">
</app-scenario-results>
<app-scenario-failure
*ngIf="
scenarioState === 'FAILURE' ||
scenarioState === 'PANIC' ||
scenarioState === 'TIMED_OUT'
"
(tryAgain)="goToConfig()"
[scenarioName]="scenarioNameFormField?.value"
[scenarioId]="scenarioId!"
[scenarioState]="scenarioState"></app-scenario-failure>
</div>
</mat-tab>
<mat-tab label="Treatments" *ngIf="showTreatmentsTab && scenarioId">
<app-treatments-tab
[scenarioId]="scenarioId"
[planningArea]="plan$ | async"></app-treatments-tab>
</mat-tab>
</mat-tab-group>
</div>
</ng-template>

<section class="treatment-footer" *ngIf="showTreatmentFooter()">
<mat-spinner diameter="24" *ngIf="creatingTreatment"></mat-spinner>
<button
sg-button
variant="primary"
icon="add"
class="new-treatment"
[disabled]="creatingTreatment"
(click)="createTreatment()">
New Treatment Plan
</button>
</section>
</div>
</div>
Loading

0 comments on commit 126d7d3

Please sign in to comment.