Skip to content

Commit

Permalink
rm changes to create-scenarios component
Browse files Browse the repository at this point in the history
  • Loading branch information
lastminutediorama committed Dec 22, 2024
1 parent 2e9128b commit 525ba4a
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "colors";
@import 'colors';

.create-scenarios-panel {
box-sizing: border-box;
Expand All @@ -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;
Expand Down Expand Up @@ -93,7 +76,6 @@

:host {
::ng-deep .mat-tab-body-wrapper {

background-color: #e6e9f4;
flex-grow: 1;
}
Expand All @@ -107,7 +89,6 @@
}
}


.flex-row {
align-items: center;
display: flex;
Expand All @@ -129,7 +110,6 @@
top: 0;
z-index: 10;
background: white;

}

.scenario-name-input {
Expand All @@ -142,7 +122,6 @@
color: #f44336;
}


.hidden {
display: none;
}
Expand All @@ -151,7 +130,6 @@
padding: 0 20px 10px;
}


.treatment-footer {
background-color: $color-white;
padding: 16px 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<Plan | null>(null);
acres$ = this.plan$.pipe(map((plan) => (plan ? plan.area_acres : 0)));
Expand All @@ -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[] = [];
Expand Down Expand Up @@ -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: [''],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/interface/src/app/plan/plan-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const routes: Routes = [
canActivate: [AuthGuard],
children: [
{
path: 'config',
path: 'config/',
title: 'Scenario Configuration',
component: CreateScenariosComponent,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});
}

Expand Down

0 comments on commit 525ba4a

Please sign in to comment.