From ca8284236571a42cf128f6749c76771199482a2b Mon Sep 17 00:00:00 2001 From: Reid Givens <rgivens@nrao.edu> Date: Tue, 20 Feb 2024 10:28:01 -0700 Subject: [PATCH] STT-1767 added OSDs to the FE and migrated the prototypes to use them instead of ObsSpecs --- .../app/data/dto/allocation-disposition.ts | 32 ++++++++++-- .../src/app/data/dto/allocation-version.ts | 4 +- .../repos/allocation_request_repo.service.ts | 4 +- .../src/app/model/allocation-disposition.ts | 51 ++++++++++++++++++- ...fication-disposition-overview.component.ts | 2 +- .../allocation-disposition.service.ts | 25 +++++++-- .../src/app/services/selection.service.ts | 15 ++++-- 7 files changed, 118 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/data/dto/allocation-disposition.ts b/frontend/src/app/data/dto/allocation-disposition.ts index 091758ed3..d008c331c 100644 --- a/frontend/src/app/data/dto/allocation-disposition.ts +++ b/frontend/src/app/data/dto/allocation-disposition.ts @@ -18,6 +18,7 @@ * */ + /** * Allocatable resources based on the Proposals Allocation Requests. * @@ -40,8 +41,33 @@ export interface AllocationDispositionDTO { } /** - * Allocatable observation details based on the Proposals Observation Specifications + * the specification for a schedulable observation based on Observation Specifications * - * @category Allocation + * @category Allocate */ -export interface ObservationSpecificationDispositionDTO {} +export interface ObservationSpecificationDispositionDTO { + /** id generated from the backend for identification */ + observationSpecificationDispositionId: number; + observationSpecificationId: number; + allocationRequestId: number; + allocationDispositionId: number; + //scans: Array<ScanDTO>; + observationConfiguration: string; + modified: boolean; + schedulingPriorityName: string; + proprietaryPeriodStart: string; + proprietaryPeriodEnd: string; + needsManualConstruction: boolean; + approvedTime: string; + + /** A bunch of statistics summarizing this.scans + * They won't be populated until this.scans is + * + scienceTargetIntegrationTimes: Array<ObservingTargetWithIntegrationTimeDTO>; + totalScienceTargetIntegrationTime: number; + observingTargetIntegrationTimes: Array<ObservingTargetWithIntegrationTimeDTO>; + totalObservingTargetIntegrationTime: number; + totalDurationOfObservationSpecification: number; + totalOverhead: number; + */ +} diff --git a/frontend/src/app/data/dto/allocation-version.ts b/frontend/src/app/data/dto/allocation-version.ts index f9c8e3c33..fbf3a7568 100644 --- a/frontend/src/app/data/dto/allocation-version.ts +++ b/frontend/src/app/data/dto/allocation-version.ts @@ -19,9 +19,9 @@ */ /** - * The astronomical sub-field of science related to a Proposal. + * A version of a solicitations/facilities allocation * - * @category Solicitation + * @category Allocate */ export interface AllocationVersionDTO { /** Unique identifier from backend - integer */ diff --git a/frontend/src/app/data/repos/allocation_request_repo.service.ts b/frontend/src/app/data/repos/allocation_request_repo.service.ts index 9fdc4662c..ebba2ce4f 100644 --- a/frontend/src/app/data/repos/allocation_request_repo.service.ts +++ b/frontend/src/app/data/repos/allocation_request_repo.service.ts @@ -46,7 +46,9 @@ export class AllocationRequestRepo extends BaseRepo<AllocationRequestDTO> { this.loadingSignal.set(true); this.continueProcessing( this.http.get<Array<AllocationRequestDTO>>(`${environment.apiUrl}${this.endpoint}`), - (ars: Array<AllocationRequestDTO>) => (ars.forEach((ar: AllocationRequestDTO) => this._replaceInCache(ar))) + (ars: Array<AllocationRequestDTO>) => ars.forEach((ar: AllocationRequestDTO) => { + this._replaceInCache(ar); + }) ); } diff --git a/frontend/src/app/model/allocation-disposition.ts b/frontend/src/app/model/allocation-disposition.ts index 59b634d83..248c9e72c 100644 --- a/frontend/src/app/model/allocation-disposition.ts +++ b/frontend/src/app/model/allocation-disposition.ts @@ -19,6 +19,7 @@ */ import {AllocationRequest} from "./allocation-request"; +import {ObservationSpecification} from "./observation-specification"; /** * Allocatable resources based on the Proposals Allocation Requests. @@ -69,4 +70,52 @@ export class AllocationDisposition { * * @category Allocation */ -export class ObservationSpecificationDisposition {} +export class ObservationSpecificationDisposition { + /** id generated from the backend for identification */ + observationSpecificationDispositionId: number; + observationSpecification: ObservationSpecification; + allocationDispositionId: number; + //scans: Array<ScanDTO>; + observationConfiguration: string; + modified: boolean; + schedulingPriorityName: string; + proprietaryPeriodStart: string; + proprietaryPeriodEnd: string; + needsManualConstruction: boolean; + approvedTime: string; + + /** A bunch of statistics summarizing this.scans + * They won't be populated until this.scans is + * + scienceTargetIntegrationTimes: Array<ObservingTargetWithIntegrationTimeDTO>; + totalScienceTargetIntegrationTime: number; + observingTargetIntegrationTimes: Array<ObservingTargetWithIntegrationTimeDTO>; + totalObservingTargetIntegrationTime: number; + totalDurationOfObservationSpecification: number; + totalOverhead: number; + */ + + constructor( + observationSpecificationDispositionId: number, + observationSpecification: ObservationSpecification, + allocationDispositionId: number, + observationConfiguration: string, + modified: boolean, + schedulingPriorityName: string, + proprietaryPeriodStart: string, + proprietaryPeriodEnd: string, + needsManualConstruction: boolean, + approvedTime: string + ) { + this.observationSpecificationDispositionId = observationSpecificationDispositionId; + this.observationSpecification = observationSpecification; + this.allocationDispositionId = allocationDispositionId; + this.observationConfiguration = observationConfiguration; + this.modified = modified; + this.schedulingPriorityName = schedulingPriorityName; + this.proprietaryPeriodStart = proprietaryPeriodStart; + this.proprietaryPeriodEnd = proprietaryPeriodEnd; + this.needsManualConstruction = needsManualConstruction; + this.approvedTime = approvedTime; + } +} diff --git a/frontend/src/app/reviews/review-solicitation/ppr-review/scheduling-tools/observation-specification-disposition-overview/observation-specification-disposition-overview.component.ts b/frontend/src/app/reviews/review-solicitation/ppr-review/scheduling-tools/observation-specification-disposition-overview/observation-specification-disposition-overview.component.ts index 0f554b4d7..fcc4559c9 100644 --- a/frontend/src/app/reviews/review-solicitation/ppr-review/scheduling-tools/observation-specification-disposition-overview/observation-specification-disposition-overview.component.ts +++ b/frontend/src/app/reviews/review-solicitation/ppr-review/scheduling-tools/observation-specification-disposition-overview/observation-specification-disposition-overview.component.ts @@ -55,7 +55,7 @@ export class ObservationSpecificationDispositionOverviewComponent { effect(async () => { const osd: ObservationSpecificationDisposition | undefined = this.selectedObservationSpecificationDisposition(); if (osd) { - // await this.router.navigate([osd.observationSpecificationId], {relativeTo: this.route}); + await this.router.navigate([osd.observationSpecificationDispositionId], {relativeTo: this.route}); } }, {allowSignalWrites: true}); } diff --git a/frontend/src/app/services/allocation-disposition.service.ts b/frontend/src/app/services/allocation-disposition.service.ts index 4dd899bb8..a076ce432 100644 --- a/frontend/src/app/services/allocation-disposition.service.ts +++ b/frontend/src/app/services/allocation-disposition.service.ts @@ -25,6 +25,8 @@ import {AlertService} from "./alert.service"; import {AuthService} from "./auth.service"; import {AllocationRequest} from "../model/allocation-request"; import {AllocationRequestService} from "./allocation-request.service"; +import {ObservationSpecification} from "../model/observation-specification"; +import {ObservationSpecificationService} from "./observation-specification.service"; @Injectable({ providedIn: 'root' @@ -50,10 +52,24 @@ export class AllocationDispositionService { adDTO.schedulerInternalCommentsToTac ); ad.effectiveScienceTargetList = adDTO.effectiveScienceTargetList; - if(adDTO.observationSpecificationDispositions) { - for (var osdDto of adDTO.observationSpecificationDispositions) { - const osd = new ObservationSpecificationDisposition(); - ad.observationSpecificationDispositions.push(osd); + if (adDTO.observationSpecificationDispositions && adDTO.observationSpecificationDispositions.length > 0) { + for (const osdDto of adDTO.observationSpecificationDispositions) { + const observationSpecification = ar.observationSpecifications.find((os: ObservationSpecification) => os.observationSpecificationId == osdDto.observationSpecificationId); + if (observationSpecification) { + const osd = new ObservationSpecificationDisposition( + osdDto.observationSpecificationDispositionId, + observationSpecification, + osdDto.allocationDispositionId, + osdDto.observationConfiguration, + osdDto.modified, + osdDto.schedulingPriorityName, + osdDto.proprietaryPeriodStart, + osdDto.proprietaryPeriodEnd, + osdDto.needsManualConstruction, + osdDto.approvedTime + ); + ad.observationSpecificationDispositions.push(osd); + } } } @@ -91,6 +107,7 @@ export class AllocationDispositionService { constructor( private allocationDispositionRepo: AllocationDispositionRepo, private allocationRequestService: AllocationRequestService, + private observationSpecificationService: ObservationSpecificationService, private alertService: AlertService, private authService: AuthService, ) { diff --git a/frontend/src/app/services/selection.service.ts b/frontend/src/app/services/selection.service.ts index 83343bfec..601f8486f 100644 --- a/frontend/src/app/services/selection.service.ts +++ b/frontend/src/app/services/selection.service.ts @@ -100,14 +100,14 @@ export class SelectionService { selectedAllocationDisposition: Signal<AllocationDisposition | undefined> = computed(() => { const versionAllocationDispositions: Array<AllocationDisposition> = this.versionAllocationDispositions(); return versionAllocationDispositions.find((ad: AllocationDisposition) => - ad.allocationRequestId == this._selectedAllocationDispositionId()); + ad.allocationDispositionId == this._selectedAllocationDispositionId()); }); /** compute the ObservationSpecificationDisposition if one exists */ selectedObservationSpecificationDisposition: Signal<ObservationSpecificationDisposition | undefined> = computed(() => { const ad: AllocationDisposition | undefined = this.selectedAllocationDisposition(); - return undefined; //ad?.observationSpecificationDispositions!.find((osd: ObservationSpecificationDisposition) => - // osd.observationSpecificationDispositionId == this._selectedObservationSpecificationDispositionId()); + return ad?.observationSpecificationDispositions!.find((osd: ObservationSpecificationDisposition) => + osd.observationSpecificationDispositionId == this._selectedObservationSpecificationDispositionId()); }); /** compute the proposalCopy if one is selected */ @@ -668,6 +668,15 @@ export class SelectionService { } }, {allowSignalWrites: true}); + + /** ensure we have our ObsSpecs when an AllocationDisposition is selected */ + effect(() => { + const ad: AllocationDisposition | undefined = this.selectedAllocationDisposition(); + if (ad && !this.ObsSpecFetchRequests.includes(ad.allocationRequestId)) { + this.ObsSpecFetchRequests.push(ad.allocationRequestId); + this.observationSpecificationService.fetchAllByAllocationRequestId(ad.allocationRequestId); + } + }, {allowSignalWrites: true}); } /** select a new Solicitation id, clear out reliant children for reselection */ -- GitLab