From 525ba4aa61b154326db9fd05a6ec80c536ce1fb2 Mon Sep 17 00:00:00 2001 From: lastminutediorama Date: Sun, 22 Dec 2024 17:31:53 -0500 Subject: [PATCH] rm changes to create-scenarios component --- .../create-scenarios.component.scss | 24 +---------- .../create-scenarios.component.spec.ts | 2 +- .../create-scenarios.component.ts | 22 +++------- .../src/app/plan/plan-routing.module.ts | 2 +- .../uploaded-scenario-view.component.scss | 43 ++++++++++++++++++- .../uploaded-scenario-view.component.ts | 4 ++ 6 files changed, 55 insertions(+), 42 deletions(-) diff --git a/src/interface/src/app/plan/create-scenarios/create-scenarios.component.scss b/src/interface/src/app/plan/create-scenarios/create-scenarios.component.scss index a714395d2..571670c99 100644 --- a/src/interface/src/app/plan/create-scenarios/create-scenarios.component.scss +++ b/src/interface/src/app/plan/create-scenarios/create-scenarios.component.scss @@ -1,4 +1,4 @@ -@import "colors"; +@import 'colors'; .create-scenarios-panel { box-sizing: border-box; @@ -19,23 +19,6 @@ } } -.uploaded-scenario-panel-content { - display: flex; - flex-direction: column; - align-items: center; - height: 100%; - width: 100%; - // z-index: 5; - top: 0; - left: 0; -} - -.uploaded-treatments-tab { - flex-grow: 1; - width: 100%; - background-color: $color-soft-purple; -} - .create-scenarios-panel-content { box-sizing: border-box; display: flex; @@ -93,7 +76,6 @@ :host { ::ng-deep .mat-tab-body-wrapper { - background-color: #e6e9f4; flex-grow: 1; } @@ -107,7 +89,6 @@ } } - .flex-row { align-items: center; display: flex; @@ -129,7 +110,6 @@ top: 0; z-index: 10; background: white; - } .scenario-name-input { @@ -142,7 +122,6 @@ color: #f44336; } - .hidden { display: none; } @@ -151,7 +130,6 @@ padding: 0 20px 10px; } - .treatment-footer { background-color: $color-white; padding: 16px 0; diff --git a/src/interface/src/app/plan/create-scenarios/create-scenarios.component.spec.ts b/src/interface/src/app/plan/create-scenarios/create-scenarios.component.spec.ts index b078aa1f3..2074f4e3f 100644 --- a/src/interface/src/app/plan/create-scenarios/create-scenarios.component.spec.ts +++ b/src/interface/src/app/plan/create-scenarios/create-scenarios.component.spec.ts @@ -18,7 +18,7 @@ import { } from '@types'; import { PlanModule } from '../plan.module'; -// import { CreateScenariosComponent } from './create-scenarios.component'; +import { CreateScenariosComponent } from './create-scenarios.component'; import { HarnessLoader } from '@angular/cdk/testing'; import { MatLegacyButtonHarness as MatButtonHarness } from '@angular/material/legacy-button/testing'; import { RouterTestingModule } from '@angular/router/testing'; diff --git a/src/interface/src/app/plan/create-scenarios/create-scenarios.component.ts b/src/interface/src/app/plan/create-scenarios/create-scenarios.component.ts index c22d4c61f..70c4f3235 100644 --- a/src/interface/src/app/plan/create-scenarios/create-scenarios.component.ts +++ b/src/interface/src/app/plan/create-scenarios/create-scenarios.component.ts @@ -8,13 +8,7 @@ import { } from '@angular/forms'; import { MatStepper } from '@angular/material/stepper'; import { BehaviorSubject, catchError, interval, map, NEVER, take } from 'rxjs'; -import { - ORIGIN_TYPE, - Plan, - Scenario, - ScenarioResult, - ScenarioResultStatus, -} from '@types'; +import { Plan, Scenario, ScenarioResult, ScenarioResultStatus } from '@types'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { POLLING_INTERVAL } from '../plan-helpers'; import { ActivatedRoute, Router } from '@angular/router'; @@ -48,7 +42,6 @@ export class CreateScenariosComponent implements OnInit { generatingScenario: boolean = false; scenarioId: string | null = null; scenarioName: string | null = null; - scenarioOrigin?: ORIGIN_TYPE = 'SYSTEM'; planId?: number | null; plan$ = new BehaviorSubject(null); acres$ = this.plan$.pipe(map((plan) => (plan ? plan.area_acres : 0))); @@ -60,7 +53,6 @@ export class CreateScenariosComponent implements OnInit { ); // this value gets updated once we load the scenario result. - scenarioState: ScenarioResultStatus = 'NOT_STARTED'; scenarioResults: ScenarioResult | null = null; priorities: string[] = []; @@ -102,8 +94,8 @@ export class CreateScenariosComponent implements OnInit { (control: AbstractControl) => scenarioNameMustBeNew(control, this.existingScenarioNames), ]), - priorities: this.prioritiesComponent?.createForm() || '', - constrains: this.constraintsPanelComponent?.createForm() || '', + priorities: this.prioritiesComponent.createForm(), + constrains: this.constraintsPanelComponent.createForm(), projectAreas: this.fb.group({ generateAreas: [''], uploadedArea: [''], @@ -188,7 +180,6 @@ export class CreateScenariosComponent implements OnInit { // Updating breadcrumbs this.scenarioName = scenario.name; this.scenarioId = scenario.id; - this.scenarioOrigin = scenario.origin; this.planStateService.updateStateWithScenario( this.scenarioId, this.scenarioName @@ -216,12 +207,12 @@ export class CreateScenariosComponent implements OnInit { } // setting treatment question if (scenario.configuration.treatment_question) { - this.prioritiesComponent?.setFormData( + this.prioritiesComponent.setFormData( scenario.configuration.treatment_question ); } // setting constraints - this.constraintsPanelComponent?.setFormData(scenario.configuration); + this.constraintsPanelComponent.setFormData(scenario.configuration); }, error: () => { this.scenarioNotFound = true; @@ -245,7 +236,7 @@ export class CreateScenariosComponent implements OnInit { /** Creates the scenario */ // TODO Add support for uploaded Project Area shapefiles createScenario(): void { - this.forms?.markAllAsTouched(); + this.forms.markAllAsTouched(); if (this.forms.invalid) { return; } @@ -264,7 +255,6 @@ export class CreateScenariosComponent implements OnInit { // Setting the new scenario id this.scenarioId = newScenario.id; this.scenarioName = newScenario.name; - this.scenarioOrigin = newScenario.origin; this.matSnackBar.dismiss(); this.scenarioState = 'PENDING'; this.disableForms(); diff --git a/src/interface/src/app/plan/plan-routing.module.ts b/src/interface/src/app/plan/plan-routing.module.ts index 83511185e..754cb8478 100644 --- a/src/interface/src/app/plan/plan-routing.module.ts +++ b/src/interface/src/app/plan/plan-routing.module.ts @@ -14,7 +14,7 @@ const routes: Routes = [ canActivate: [AuthGuard], children: [ { - path: 'config', + path: 'config/', title: 'Scenario Configuration', component: CreateScenariosComponent, }, diff --git a/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.scss b/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.scss index 8eb2654b0..be54a029b 100644 --- a/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.scss +++ b/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.scss @@ -1,7 +1,48 @@ +@import 'colors'; + :host { flex: 1; display: flex; flex-direction: column; height: 100%; - background-color: purple; + width: 100%; + background-color: $color-soft-purple; + display: flex; + align-items: center; + z-index: 5; + top: 0; + left: 0; +} + +.uploaded-scenario-panel-content { + display: flex; + flex-direction: column; + align-items: center; + height: 100%; + width: 100%; + z-index: 5; + top: 0; + left: 0; +} + +.uploaded-treatments-tab { + flex-grow: 1; + width: 100%; + background-color: $color-soft-purple; +} + +.treatment-footer { + background-color: $color-white; + padding: 16px 8px; + box-sizing: border-box; + bottom: 0; + width: 100%; + text-align: right; + display: flex; + justify-content: flex-end; + align-items: center; + flex-grow: 0; + position: sticky; + z-index: 500; + border-top: 1px solid $color-soft-gray; } diff --git a/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.ts b/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.ts index 22a4b6ed1..79aa304b0 100644 --- a/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.ts +++ b/src/interface/src/app/plan/uploaded-scenario-view/uploaded-scenario-view.component.ts @@ -34,6 +34,10 @@ export class UploadedScenarioViewComponent implements OnInit { .pipe(untilDestroyed(this), take(1)) .subscribe((planState) => { this.plan$.next(planState.all[planState.currentPlanId!]); + this.planStateService.updateStateWithScenario( + this.scenario?.id ?? null, + this.scenario?.name ?? null + ); }); }