Skip to content

Commit

Permalink
Add separate layouts for calibrations
Browse files Browse the repository at this point in the history
  • Loading branch information
cquiroz committed Dec 28, 2024
1 parent 08c4c73 commit 9582f88
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 80 deletions.
41 changes: 32 additions & 9 deletions common/src/main/scala/explore/model/ExploreGridLayouts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ import scala.collection.immutable.SortedMap
object ExploreGridLayouts:

def sectionLayout: GridLayoutSection => LayoutsMap = _ match {
case GridLayoutSection.ProgramsLayout => programs.defaultProgramsLayouts
case GridLayoutSection.ConstraintsLayout => constraints.defaultConstraintsLayouts
case GridLayoutSection.SchedulingLayout => scheduling.defaultSchedulingLayouts
case GridLayoutSection.TargetLayout => targets.defaultTargetLayouts
case GridLayoutSection.ObservationsLayout => observations.defaultObsLayouts
case GridLayoutSection.ObservationListLayout => observationList.defaultObsListLayouts
case GridLayoutSection.OverviewLayout => overview.defaultOverviewLayouts
case GridLayoutSection.ProposalLayout => proposal.defaultProposalLayouts
case GridLayoutSection.GroupEditLayout => groupEdit.defaultGroupEditLayouts
case GridLayoutSection.ProgramsLayout => programs.defaultProgramsLayouts
case GridLayoutSection.ConstraintsLayout => constraints.defaultConstraintsLayouts
case GridLayoutSection.SchedulingLayout => scheduling.defaultSchedulingLayouts
case GridLayoutSection.TargetLayout => targets.defaultTargetLayouts
case GridLayoutSection.ObservationsLayout => observations.defaultObsLayouts
case GridLayoutSection.ObservationsSpecPhotoLayout => observations.specPhotoObsLayouts
case GridLayoutSection.ObservationsTwilightLayout => observations.twilightObsLayouts
case GridLayoutSection.ObservationListLayout => observationList.defaultObsListLayouts
case GridLayoutSection.OverviewLayout => overview.defaultOverviewLayouts
case GridLayoutSection.ProposalLayout => proposal.defaultProposalLayouts
case GridLayoutSection.GroupEditLayout => groupEdit.defaultGroupEditLayouts
}

extension (l: LayoutsMap)
Expand Down Expand Up @@ -261,13 +263,34 @@ object ExploreGridLayouts:
)
)

lazy val specPhotoMedium = layoutMedium
lazy val twilightRemovedIds =
List(ObsTabTileIds.FinderChartsId, ObsTabTileIds.ItcId, ObsTabTileIds.NotesId).map(_.id.value)
lazy val twilightMedium = layoutMedium.asList.filterNot(l => twilightRemovedIds.contains(l.i))

lazy val defaultObsLayouts: LayoutsMap =
defineStdLayouts(
Map(
(BreakpointName.lg, layoutMedium),
(BreakpointName.md, layoutMedium)
)
).withMinWidth

lazy val specPhotoObsLayouts: LayoutsMap =
defineStdLayouts(
Map(
(BreakpointName.lg, specPhotoMedium),
(BreakpointName.md, specPhotoMedium)
)
).withMinWidth

lazy val twilightObsLayouts: LayoutsMap =
defineStdLayouts(
Map(
(BreakpointName.lg, Layout(twilightMedium)),
(BreakpointName.md, Layout(twilightMedium))
)
).withMinWidth
end observations

object observationList:
Expand Down
6 changes: 6 additions & 0 deletions common/src/main/scala/explore/model/UserPreferences.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ case class UserPreferences(
val observationsTabLayout =
tabLayout(GridLayoutSection.ObservationsLayout)

val specPhotoTabLayout =
tabLayout(GridLayoutSection.ObservationsSpecPhotoLayout)

val twilightTabLayout =
tabLayout(GridLayoutSection.ObservationsTwilightLayout)

val observationListTabLayout =
tabLayout(GridLayoutSection.ObservationListLayout)

Expand Down
6 changes: 6 additions & 0 deletions explore/src/clue/resources/UserPreferencesDB.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,9 @@ enum LucumaGridLayoutIdEnum {
CONSTRAINTS
GROUPEDIT
OBSERVATIONS
OBSERVATIONS_SPECPHOTO
OBSERVATIONS_TWILIGHT
OBSERVATION_LIST
OVERVIEW
PROGRAMS
PROPOSAL
Expand Down Expand Up @@ -2629,8 +2632,11 @@ enum LucumaTableIdsEnum {
ASTERISM_TARGETS
CONSTRAINTS_SUMMARY
OBSERVATIONS_SUMMARY
OBSERVATION_VALIDATIONS
REQUESTED_CONFIGS
SPECTROSCOPY_MODES
TARGETS_SUMMARY
UNREQUESTED_CONFIGS
}

"""
Expand Down
3 changes: 1 addition & 2 deletions explore/src/main/scala/explore/tabs/ObsTabContents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,8 @@ object ObsTabContents extends TwoPanels:
props.searching,
// We need this as a separate view so it doesn't get in the way of undo and can be easily updated by AGS
obsView.zoom(Observation.selectedGSName),
ExploreGridLayouts.sectionLayout(GridLayoutSection.ObservationsLayout),
props.userPreferences.get.observationsTabLayout,
resize,
props.userPreferences.get,
props.globalPreferences,
props.readonly || addingObservation.get.value
).withKey(s"${obsId.show}")
Expand Down
87 changes: 70 additions & 17 deletions explore/src/main/scala/explore/tabs/ObsTabTiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import queries.schemas.odb.ObsQueries
import java.time.Instant
import scala.collection.immutable.SortedMap
import scala.collection.immutable.SortedSet
import lucuma.core.enums.CalibrationRole

case class ObsTabTiles(
vault: Option[UserVault],
Expand All @@ -99,9 +100,8 @@ case class ObsTabTiles(
focusedTarget: Option[Target.Id],
searching: View[Set[Target.Id]],
selectedGSName: View[Option[NonEmptyString]],
defaultLayouts: LayoutsMap,
layouts: LayoutsMap,
resize: UseResizeDetectorReturn,
userPreferences: UserPreferences,
globalPreferences: View[GlobalPreferences],
readonly: Boolean
) extends ReactFnProps(ObsTabTiles.component):
Expand All @@ -117,6 +117,7 @@ case class ObsTabTiles(
val asterismTracking: Option[ObjectTracking] =
observation.get.asterismTracking(obsTargets)
val posAngleConstraint: PosAngleConstraint = observation.get.posAngleConstraint
val calibrationRole: Option[CalibrationRole] = observation.zoom(Observation.calibrationRole).get

object ObsTabTiles:
private type Props = ObsTabTiles
Expand Down Expand Up @@ -147,6 +148,27 @@ object ObsTabTiles:
acquisition: Option[NonEmptyList[Offset]]
)

def roleLayout(
userPreferences: UserPreferences,
calibrationRole: Option[CalibrationRole]
): (GridLayoutSection, LayoutsMap, LayoutsMap) =
def result(section: GridLayoutSection) =
(section,
ExploreGridLayouts.sectionLayout(section),
UserPreferences.gridLayouts
.index(section)
.getOption(userPreferences)
.getOrElse(ExploreGridLayouts.sectionLayout(section))
)

calibrationRole match
case Some(CalibrationRole.SpectroPhotometric) =>
result(GridLayoutSection.ObservationsSpecPhotoLayout)
case Some(CalibrationRole.Twilight) =>
result(GridLayoutSection.ObservationsTwilightLayout)
case _ =>
result(GridLayoutSection.ObservationsLayout)

// TODO Move to core
extension (om: ObservingMode)
def centralWavelength: Option[CentralWavelength] =
Expand Down Expand Up @@ -235,6 +257,12 @@ object ObsTabTiles:
Callback.empty
}
}
.useStateBy((p, _, _, _, _, _, _, _, _, _, _) =>
roleLayout(p.userPreferences, p.calibrationRole)
)
.useEffectWithDepsBy((p, _, _, _, _, _, _, _, _, _, _, _) => p.calibrationRole):
(p, _, _, _, _, _, _, _, _, _, _, l) =>
role => l.setState(roleLayout(p.userPreferences, role))
.render:
(
props,
Expand All @@ -247,9 +275,11 @@ object ObsTabTiles:
sequenceChanged,
vizTimeOrNowPot,
_,
guideStarSelection
guideStarSelection,
roleLayouts
) =>
import ctx.given
val (section, defaultLayout, layout) = roleLayouts.value

vizTimeOrNowPot.renderPot: vizTimeOrNow =>

Expand Down Expand Up @@ -522,22 +552,45 @@ object ObsTabTiles:
props.globalPreferences.get.wavelengthUnits
)

val tiles =
props.observation.zoom(Observation.calibrationRole).get match {
case Some(CalibrationRole.SpectroPhotometric) =>
List(
targetTile.some,
skyPlotTile,
constraintsTile.some,
configurationTile.some,
sequenceTile.some,
itcTile.some
).flattenOption
case Some(CalibrationRole.Twilight) =>
List(
targetTile.some,
skyPlotTile,
constraintsTile.some,
configurationTile.some,
sequenceTile.some
).flattenOption
case _ =>
List(
notesTile.some,
targetTile.some,
if (!props.vault.isGuest) finderChartsTile.some else none,
skyPlotTile,
constraintsTile.some,
schedulingWindowsTile.some,
configurationTile.some,
sequenceTile.some,
itcTile.some
).flattenOption
}

TileController(
props.vault.userId,
props.resize.width.getOrElse(0),
props.defaultLayouts,
props.layouts,
List(
notesTile.some,
targetTile.some,
if (!props.vault.isGuest) finderChartsTile.some else none,
skyPlotTile,
constraintsTile.some,
schedulingWindowsTile.some,
configurationTile.some,
sequenceTile.some,
itcTile.some
).flattenOption,
GridLayoutSection.ObservationsLayout,
defaultLayout,
layout,
tiles,
section,
props.backButton.some
)
2 changes: 1 addition & 1 deletion hasura/user-prefs/metadata/databases/databases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
max_connections: 15
retries: 1
use_prepared_statements: true
tables: '!include default/tables/tables.yaml'
tables: "!include default/tables/tables.yaml"
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ table:
name: exploreAsterismPreferences
schema: public
object_relationships:
- name: lucumaUser
using:
foreign_key_constraint_on: userId
- name: lucumaUser
using:
foreign_key_constraint_on: userId
array_relationships:
- name: lucumaAsterisms
using:
foreign_key_constraint_on:
column: prefId
table:
name: lucumaAsterism
schema: public
- name: lucumaAsterisms
using:
foreign_key_constraint_on:
column: prefId
table:
name: lucumaAsterism
schema: public
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ table:
name: exploreFinderChart
schema: public
object_relationships:
- name: lucumaObservation
using:
foreign_key_constraint_on: observationId
- name: lucumaObservation
using:
foreign_key_constraint_on: observationId
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ table:
name: lucumaAsterism
schema: public
object_relationships:
- name: exploreAsterismPreference
using:
foreign_key_constraint_on: prefId
- name: exploreAsterismPreference
using:
foreign_key_constraint_on: prefId
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ table:
name: lucumaObservation
schema: public
array_relationships:
- name: exploreFinderCharts
using:
foreign_key_constraint_on:
column: observationId
table:
name: exploreFinderChart
schema: public
- name: exploreFinderCharts
using:
foreign_key_constraint_on:
column: observationId
table:
name: exploreFinderChart
schema: public
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ table:
name: lucumaUserPreferences
schema: public
object_relationships:
- name: lucuma_user
using:
foreign_key_constraint_on: userId
- name: lucuma_user
using:
foreign_key_constraint_on: userId
32 changes: 16 additions & 16 deletions hasura/user-prefs/metadata/databases/default/tables/tables.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
- '!include public_ItcChartType.yaml'
- '!include public_exploreAsterismPreferences.yaml'
- '!include public_exploreFinderChart.yaml'
- '!include public_explorePlotRange.yaml'
- '!include public_explorePlotTime.yaml'
- '!include public_lucumaAsterism.yaml'
- '!include public_lucumaGridBreakpointName.yaml'
- '!include public_lucumaGridLayoutId.yaml'
- '!include public_lucumaGridLayoutPositions.yaml'
- '!include public_lucumaObservation.yaml'
- '!include public_lucumaSortDirection.yaml'
- '!include public_lucumaTableColumnPreferences.yaml'
- '!include public_lucumaTableIds.yaml'
- '!include public_lucumaUser.yaml'
- '!include public_lucumaUserPreferences.yaml'
- '!include public_lucumaWavelengthUnits.yaml'
- "!include public_ItcChartType.yaml"
- "!include public_exploreAsterismPreferences.yaml"
- "!include public_exploreFinderChart.yaml"
- "!include public_explorePlotRange.yaml"
- "!include public_explorePlotTime.yaml"
- "!include public_lucumaAsterism.yaml"
- "!include public_lucumaGridBreakpointName.yaml"
- "!include public_lucumaGridLayoutId.yaml"
- "!include public_lucumaGridLayoutPositions.yaml"
- "!include public_lucumaObservation.yaml"
- "!include public_lucumaSortDirection.yaml"
- "!include public_lucumaTableColumnPreferences.yaml"
- "!include public_lucumaTableIds.yaml"
- "!include public_lucumaUser.yaml"
- "!include public_lucumaUserPreferences.yaml"
- "!include public_lucumaWavelengthUnits.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM "public"."lucumaGridLayoutId" WHERE "id" = 'observations_specphoto';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "public"."lucumaGridLayoutId"("id") VALUES (E'observations_specphoto');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM "public"."lucumaGridLayoutId" WHERE "id" = 'observations_twilight';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
INSERT INTO "public"."lucumaGridLayoutId"("id") VALUES (E'observations_twilight');
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ package explore.model.enums
import lucuma.core.util.Enumerated

enum GridLayoutSection(val value: String) derives Enumerated:
case ProgramsLayout extends GridLayoutSection("programs")
case ObservationsLayout extends GridLayoutSection("observations")
case ObservationListLayout extends GridLayoutSection("observation_list")
case TargetLayout extends GridLayoutSection("targets")
case ConstraintsLayout extends GridLayoutSection("constraints")
case SchedulingLayout extends GridLayoutSection("scheduling")
case OverviewLayout extends GridLayoutSection("overview")
case ProposalLayout extends GridLayoutSection("proposal")
case GroupEditLayout extends GridLayoutSection("groupedit")
case ProgramsLayout extends GridLayoutSection("programs")
case ObservationsLayout extends GridLayoutSection("observations")
case ObservationsSpecPhotoLayout extends GridLayoutSection("observations_specphoto")
case ObservationsTwilightLayout extends GridLayoutSection("observations_twilight")
case ObservationListLayout extends GridLayoutSection("observation_list")
case TargetLayout extends GridLayoutSection("targets")
case ConstraintsLayout extends GridLayoutSection("constraints")
case SchedulingLayout extends GridLayoutSection("scheduling")
case OverviewLayout extends GridLayoutSection("overview")
case ProposalLayout extends GridLayoutSection("proposal")
case GroupEditLayout extends GridLayoutSection("groupedit")

private val tag = value

0 comments on commit 9582f88

Please sign in to comment.