Skip to content

Commit

Permalink
separated stores -> updated files where old store was used. removed h…
Browse files Browse the repository at this point in the history
…eaders from a lot of files. more pr fixes
  • Loading branch information
capetillo committed Nov 1, 2024
1 parent 2ddd2eb commit 0c4f292
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 146 deletions.
14 changes: 8 additions & 6 deletions src/components/Dashboard/UpcomingBookings.vue
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
<script setup>
import { useRouter } from 'vue-router'
import { ref, computed, onMounted } from 'vue'
import { useObsPortalDataStore } from '../../stores/sessions'
import { useRealTimeSessionsStore } from '../../stores/sessions'
import { useObsPortalDataStore } from '../../stores/obsPortalData'
import { useUserDataStore } from '../../stores/userData'
import { useConfigurationStore } from '../../stores/configuration'
import { formatDate, formatTime } from '../../utils/formatTime.js'
import { fetchApiCall } from '../../utils/api.js'
const router = useRouter()
const obsPortalDataStore = useObsPortalDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const userDataStore = useUserDataStore()
const configurationStore = useConfigurationStore()
const obsPortalDataStore = useObsPortalDataStore()
const requestGroups = ref([])
// change to bookings and add an icon to show completion
const sortedSessions = computed(() => {
const now = new Date().getTime()
// TODO: Show past sessions for a certain amount of time in a separate section
const twoHoursAgo = now - 120 * 60 * 1000
const sessions = obsPortalDataStore.upcomingRealTimeSessions || []
const sessions = Object.values(obsPortalDataStore.upcomingRealTimeSessions)
return sessions.filter(session => new Date(session.start).getTime() >= twoHoursAgo)
.slice()
.sort((a, b) => new Date(a.start) - new Date(b.start))
})
const selectSession = (sessionId) => {
obsPortalDataStore.currentSessionId = sessionId
realTimeSessionsStore.currentSessionId = sessionId
router.push(`/realtime/${sessionId}`)
}
async function deleteSession (sessionId) {
obsPortalDataStore.currentSessionId = sessionId
realTimeSessionsStore.currentSessionId = sessionId
const token = userDataStore.authToken
await fetchApiCall({
url: configurationStore.observationPortalUrl + `realtime/${sessionId}/`,
Expand All @@ -42,7 +44,7 @@ async function deleteSession (sessionId) {
}
onMounted(() => {
obsPortalDataStore.fetchObservations()
obsPortalDataStore.fetchCompleteObservationsAndUpcomingRTSessions()
obsPortalDataStore.fetchPendingRequestGroups()
requestGroups.value = obsPortalDataStore.pendingRequestGroups
})
Expand Down
19 changes: 5 additions & 14 deletions src/components/Images/MyGallery.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<script setup>
import { computed, ref, onMounted } from 'vue'
import { useObsPortalDataStore } from '../../stores/sessions'
import { useUserDataStore } from '../../stores/userData'
import { useObsPortalDataStore } from '../../stores/obsPortalData'
import { useConfigurationStore } from '../../stores/configuration'
import { formatDate } from '../../utils/formatTime.js'
import { fetchApiCall } from '../../utils/api.js'
const obsPortalDataStore = useObsPortalDataStore()
const userDataStore = useUserDataStore()
const configurationStore = useConfigurationStore()
const obsPortalDataStore = useObsPortalDataStore()
const thumbnailsMap = ref({})
const loading = ref(true)
const filteredSessions = computed(() => {
const now = new Date()
const cutoffTime = new Date(now.getTime() - 16 * 60 * 1000)
const sixteenMinutes = 16 * 60 * 1000
const cutoffTime = new Date(now.getTime() - sixteenMinutes)
// Object.values returns an array of all the values of the object
const sessions = Object.values(obsPortalDataStore.completedObservations)
const filtered = sessions
Expand All @@ -25,17 +24,9 @@ const filteredSessions = computed(() => {
})
const getThumbnails = async (observationId) => {
const token = userDataStore.authToken
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Token ${token}`
}
await fetchApiCall({
url: configurationStore.thumbnailArchiveUrl + `thumbnails/?observation_id=${observationId}&size=small`,
url: configurationStore.thumbnailArchiveUrl + `thumbnails/?observation_id=${observationId}&size=large`,
method: 'GET',
header: headers,
successCallback: (data) => {
if (data.results.length > 0) {
thumbnailsMap.value[observationId] = data.results.map(result => result.url)
Expand Down
8 changes: 4 additions & 4 deletions src/components/RealTimeInterface/CelestialMap/SkyChart.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup>
import { ref, onMounted, watch } from 'vue'
import { useObsPortalDataStore } from '../../../stores/sessions'
import { ref, onMounted } from 'vue'
import { useRealTimeSessionsStore } from '../../../stores/sessions'
import sites from '../../../utils/sites.JSON'
import celestial from 'd3-celestial'
const Celestial = celestial.Celestial ? celestial.Celestial() : celestial
const obsPortalDataStore = useObsPortalDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const lat = ref(35)
const lng = ref(-105)
Expand Down Expand Up @@ -146,7 +146,7 @@ function initializeCelestial () {
}
onMounted(() => {
const currentSession = obsPortalDataStore.currentSession
const currentSession = realTimeSessionsStore.currentSession
if (currentSession && currentSession.site) {
const siteInfo = sites[currentSession.site]
if (siteInfo && Celestial) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/RealTimeInterface/GlobeMap/WindyMap.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup>
import { computed } from 'vue'
import { useObsPortalDataStore } from '../../../stores/sessions'
import { useRealTimeSessionsStore } from '../../../stores/sessions'
import sites from '../../../utils/sites.JSON'
const obsPortalDataStore = useObsPortalDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const selectedSession = obsPortalDataStore.currentSession
const selectedSession = realTimeSessionsStore.currentSession
const siteInfo = computed(() => {
if (selectedSession && selectedSession.site) {
Expand Down
15 changes: 3 additions & 12 deletions src/components/RealTimeInterface/PolledThumbnails.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<script setup>
import { ref, onMounted, defineEmits } from 'vue'
import { useObsPortalDataStore } from '../../stores/sessions'
import { useRealTimeSessionsStore } from '../../stores/sessions'
import { fetchApiCall } from '../../utils/api'
import { useConfigurationStore } from '../../stores/configuration'
import { useUserDataStore } from '../../stores/userData'
const obsPortalDataStore = useObsPortalDataStore()
const currentSession = obsPortalDataStore.currentSession
const userDataStore = useUserDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const currentSession = realTimeSessionsStore.currentSession
const configurationStore = useConfigurationStore()
const sessionId = currentSession.id
Expand All @@ -19,16 +17,9 @@ const thumbnails = ref([])
let pollingInterval = null
const getThumbnails = async () => {
const token = userDataStore.authToken
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Token ${token}`
}
await fetchApiCall({
url: configurationStore.thumbnailArchiveUrl + `thumbnails/?observation_id=${sessionId}&size=large`,
method: 'GET',
header: headers,
successCallback: (data) => {
thumbnails.value = data.results.map(result => result.url)
if (thumbnails.value.length > 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/RealTimeInterface/SessionImageCapture.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import PolledThumbnails from './PolledThumbnails.vue'
import { fetchApiCall } from '../../utils/api.js'
import { useConfigurationStore } from '../../stores/configuration'
import { useObsPortalDataStore } from '../../stores/sessions'
import { useRealTimeSessionsStore } from '../../stores/sessions'
import { LottieAnimation } from 'lottie-web-vue'
import BlocksJSON from '@/assets/progress-blocks-bodymovin.json'
import GalaxyJSON from '@/assets/galaxy_loading_pixels.json'
const configurationStore = useConfigurationStore()
const obsPortalDataStore = useObsPortalDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const status = ref(null)
let pollingInterval = null
Expand Down Expand Up @@ -40,7 +40,7 @@ const fetchTelescopeStatus = async () => {
imagesDone.value = false
return
}
const token = obsPortalDataStore.getTokenForCurrentSession
const token = realTimeSessionsStore.getTokenForCurrentSession
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
Expand Down Expand Up @@ -71,7 +71,7 @@ const goBackToSessionStarted = () => {
}
const sendStopCommand = async () => {
const token = obsPortalDataStore.getTokenForCurrentSession
const token = realTimeSessionsStore.getTokenForCurrentSession
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions src/components/RealTimeInterface/SessionPending.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup>
import { computed } from 'vue'
import { useObsPortalDataStore } from '../../stores/sessions'
import { useRealTimeSessionsStore } from '../../stores/sessions'
import sites from '../../utils/sites.JSON'
import WindyMap from './GlobeMap/WindyMap.vue'
const obsPortalDataStore = useObsPortalDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const selectedSession = obsPortalDataStore.currentSession
const selectedSession = realTimeSessionsStore.currentSession
const lat = computed(() => sites[selectedSession.site]?.lat)
const lon = computed(() => sites[selectedSession.site]?.lon)
Expand Down
20 changes: 10 additions & 10 deletions src/components/RealTimeInterface/SessionStarted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import AladinSkyMap from '../RealTimeInterface/AladinSkyMap.vue'
import SkyChart from '../RealTimeInterface/CelestialMap/SkyChart.vue'
import SessionImageCapture from '../RealTimeInterface/SessionImageCapture.vue'
import { calcAltAz } from '../../utils/visibility.js'
import { useObsPortalDataStore } from '../../stores/sessions'
import { useRealTimeSessionsStore } from '../../stores/sessions'
import sites from '../../utils/sites.JSON'
import { fetchApiCall } from '../../utils/api'
import { useConfigurationStore } from '../../stores/configuration'
import { useUserDataStore } from '../../stores/userData'
const obsPortalDataStore = useObsPortalDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const configurationStore = useConfigurationStore()
const userDataStore = useUserDataStore()
Expand All @@ -20,7 +20,7 @@ const isCapturingImages = computed(() => {
// Change this to true to test the image capture component and false for target select
return true
} else {
return obsPortalDataStore.isCapturingImagesForCurrentSession
return realTimeSessionsStore.isCapturingImagesForCurrentSession
}
})
Expand All @@ -39,7 +39,7 @@ const loading = ref(false)
const exposureError = ref('')
const isExposureTimeValid = ref(true)
const currentSession = obsPortalDataStore.currentSession
const currentSession = realTimeSessionsStore.currentSession
const siteInfo = sites[currentSession.site]
function getRaDecFromTargetName () {
Expand Down Expand Up @@ -87,7 +87,7 @@ function changeFov (fov) {
}
const resetValues = () => {
obsPortalDataStore.updateImageCaptureState(true)
realTimeSessionsStore.updateImageCaptureState(true)
ra.value = ''
dec.value = ''
targetName.value = ''
Expand All @@ -103,7 +103,7 @@ const sendGoCommand = async () => {
exposureError.value = ''
isExposureTimeValid.value = true
const token = obsPortalDataStore.getTokenForCurrentSession
const token = realTimeSessionsStore.getTokenForCurrentSession
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
Expand All @@ -117,9 +117,9 @@ const sendGoCommand = async () => {
expTime: exposTime,
name: targetName.value,
ra: Number(ra.value) / 15,
proposalId: obsPortalDataStore.currentSession.proposal,
requestGroupId: obsPortalDataStore.currentSession.request_group_id,
requestId: obsPortalDataStore.currentSession.request.id
proposalId: realTimeSessionsStore.currentSession.proposal,
requestGroupId: realTimeSessionsStore.currentSession.request_group_id,
requestId: realTimeSessionsStore.currentSession.request.id
}
if (configurationStore.demo == true) {
loading.value = false
Expand Down Expand Up @@ -163,7 +163,7 @@ const getFilterList = async () => {
function updateRenderGallery (value) {
if (!value) {
obsPortalDataStore.updateImageCaptureState(false)
realTimeSessionsStore.updateImageCaptureState(false)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/RealTimeInterface/TimePicker.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script setup>
import { ref, watch, defineEmits, onMounted, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useObsPortalDataStore } from '../../stores/sessions'
import { useRealTimeSessionsStore } from '../../stores/sessions'
import { useUserDataStore } from '../../stores/userData'
import { fetchApiCall } from '../../utils/api'
import { formatToUTC, formatDate } from '../../utils/formatTime.js'
import { useConfigurationStore } from '../../stores/configuration'
import LeafletMap from './GlobeMap/LeafletMap.vue'
const router = useRouter()
const obsPortalDataStore = useObsPortalDataStore()
const realTimeSessionsStore = useRealTimeSessionsStore()
const configurationStore = useConfigurationStore()
const userDataStore = useUserDataStore()
Expand Down Expand Up @@ -126,7 +126,7 @@ const refreshTimes = () => {
const resetSession = () => {
errorMessage.value = null
selectedSite.value = null
obsPortalDataStore.currentSessionId = null
realTimeSessionsStore.currentSessionId = null
}
const blockRti = async () => {
Expand Down
3 changes: 0 additions & 3 deletions src/components/Scheduling/SchedulingSettings.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup>
import { ref, reactive, computed, defineProps, defineEmits, onMounted } from 'vue'
import { useConfigurationStore } from '../../stores/configuration.js'
import { useUserDataStore } from '../../stores/userData.js'
import { fetchApiCall } from '../../utils/api.js'
const props = defineProps({
Expand All @@ -22,7 +21,6 @@ const props = defineProps({
const emits = defineEmits(['exposuresUpdated', 'targetUpdated'])
const configurationStore = useConfigurationStore()
const userDataStore = useUserDataStore()
const projectName = ref('')
const targetList = ref([{ name: '', exposures: [], ra: '', dec: '' }])
Expand Down Expand Up @@ -116,7 +114,6 @@ const addExposure = () => {
settings.exposureTime = ''
settings.count = ''
emits('exposuresUpdated', targetList.value[activeTargetIndex.value].exposures)
console.log('Exposures updated:', targetList.value[activeTargetIndex.value].exposures)
}
}
Expand Down
Loading

0 comments on commit 0c4f292

Please sign in to comment.