Skip to content

Commit 8b94f8f

Browse files
authored
Merge pull request #79 from LCOGT/feature/remove-test-sites-from-map
Feature/remove test sites from map
2 parents c35babb + 35969dd commit 8b94f8f

File tree

11 files changed

+109
-97
lines changed

11 files changed

+109
-97
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ build/
3333
dist/
3434
node_modules/
3535
aws-exports.js
36-
awsconfiguration.json
36+
awsconfiguration.json

package-lock.json

Lines changed: 23 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<template>
22
<div id="app">
3-
<router-view
4-
v-if="$store.state.site_config.did_config_load_yet"
5-
class="router-view"
6-
/>
3+
<router-view class="router-view" />
74

85
<!-- This is the home for the JS9 DOM elements. They are hidden here and only
96
visible when moved into the js9 component. This avoid js9-reloading issues.-->
@@ -30,18 +27,8 @@
3027
</div>
3128
</template>
3229

33-
<script>
34-
export default {
35-
beforeCreate () {
36-
// Initial load of the config. This is the only time it needs to happen unless the user reloads the site.
37-
this.$store.dispatch('site_config/update_config')
38-
}
39-
}
40-
</script>
41-
4230
<style scoped lang="scss">
4331
.router-view {
44-
//height: calc(100vh - 75px);
4532
overflow-x: hidden;
4633
}
4734
</style>

src/components/AdminTools/SiteConfigViewer.vue

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
<template>
2-
<json-viewer :value="displayed_config" theme="jv-dark" expanded sort />
2+
<json-viewer
3+
:value="displayed_config"
4+
theme="jv-dark"
5+
expanded
6+
sort
7+
/>
38
</template>
49

510
<script>
6-
import SiteSelectField from "@/components/FormElements/SiteSelectField";
711
812
export default {
9-
name: "SiteConfigViewer",
10-
components: { SiteSelectField },
13+
name: 'SiteConfigViewer',
1114
props: {
1215
// Specify a site to load when the component loads
1316
init_site: {
1417
type: String,
15-
default: () => "all"
16-
},
18+
default: () => 'all'
19+
}
1720
},
18-
data() {
21+
data () {
1922
return {
2023
loading: false,
21-
selected_site: this.init_site,
22-
};
23-
},
24-
mounted() {
25-
this.$store.dispatch("site_config/update_config");
24+
selected_site: this.init_site
25+
}
2626
},
2727
computed: {
28-
displayed_config() {
29-
let global_config = this.$store.state.site_config.global_config;
30-
if (this.init_site == "all") {
31-
return global_config
32-
} else if (Object.keys(global_config).includes(this.init_site)) {
33-
return global_config[this.init_site]
34-
} else {
35-
return {}
36-
}
37-
},
38-
},
39-
};
28+
displayed_config () {
29+
const global_config = this.$store.state.site_config.global_config
30+
if (this.init_site == 'all') {
31+
return global_config
32+
} else if (Object.keys(global_config).includes(this.init_site)) {
33+
return global_config[this.init_site]
34+
} else {
35+
return {}
36+
}
37+
}
38+
}
39+
}
4040
</script>
4141

4242
<style scoped>

src/components/SitesOverviewCards.vue

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<template>
22
<div class="card-row">
3-
<template v-for="s in all_sites_real">
3+
<template v-for="s in sites">
44
<div
5-
v-if="!site_blacklist.includes(s.site)"
65
:key="s.site"
76
:val="s.site"
87
class="card"
@@ -86,20 +85,10 @@ export default {
8685
this.site_images = response.data
8786
})
8887
}
89-
9088
},
9189
9290
computed: {
93-
...mapGetters('site_config', [
94-
'all_sites_real',
95-
'all_sites_simulated'
96-
]),
97-
98-
// We want to add enough empty (invisible) test sites so that the cards are sized the same as real sites.
99-
// Compute the difference in number. If there are more test sites than real sites, don't add any empty sites.
100-
empty_test_sites_needed () {
101-
return Math.max(0, Object.keys(this.all_sites_real).length - Object.keys(this.all_sites_simulated).length)
102-
}
91+
...mapGetters('site_config', ['all_sites_real'])
10392
}
10493
10594
}

src/components/maps/TheWorldMap.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default {
3636
}
3737
},
3838
async mounted () {
39-
this.global_config = await this.get_global_config()
39+
this.global_config = this.$store.state.site_config.global_config
4040
this.initMap()
4141
},
4242
beforeDestroy () {
@@ -46,7 +46,7 @@ export default {
4646
},
4747
4848
watch: {
49-
all_sites () {
49+
all_sites_real () {
5050
this.redrawMapSites()
5151
},
5252
site_open_status () {
@@ -96,7 +96,7 @@ export default {
9696
},
9797
9898
async initMap () {
99-
await this.$store.dispatch('sitestatus/getSiteOpenStatus')
99+
await this.getSiteOpenStatus
100100
const sun_pos = { lat: nite.calculatePositionOfSun().lat(), lng: nite.calculatePositionOfSun().lng() }
101101
const map_center_latitude = 15 // puts sites at a more visibly comfortable location
102102
this.map = new google.maps.Map(document.getElementById(this.mapName), {
@@ -128,11 +128,14 @@ export default {
128128
function iwClose () { iw.close() }
129129
google.maps.event.addListener(this.map, 'click', iwClose)
130130
131-
let sites = this.all_sites
131+
let sites = this.all_sites_real
132+
133+
// First, remove sites that don't have an available status
132134
sites = sites.filter(site => {
133-
// First, remove sites that don't have an available status
134135
return Object.keys(this.site_open_status).includes(site.site)
135136
})
137+
138+
// Consolidate additional data used to render sites to the map
136139
sites.forEach(site => {
137140
const markerData = {
138141
lat: site.latitude,
@@ -304,7 +307,7 @@ export default {
304307
305308
async redrawMapSites () {
306309
// Fetch the list of sites to display on the map
307-
const sites = this.all_sites.reverse()
310+
const sites = this.all_sites_real.reverse()
308311
309312
// For each site, draw a marker with a popup (on click) to visit the site.
310313
sites.forEach(site => {
@@ -335,7 +338,8 @@ export default {
335338
},
336339
337340
computed: {
338-
...mapGetters('site_config', ['all_sites']),
341+
...mapState('site_config', ['test_sites']),
342+
...mapGetters('site_config', ['all_sites_real']),
339343
...mapState('sitestatus', ['site_open_status']),
340344
...mapActions('sitestatus', ['getSiteOpenStatus'])
341345
}
@@ -344,8 +348,6 @@ export default {
344348
345349
<style lang="scss" scoped>
346350
.google-map {
347-
//width: 100vw;
348-
//height: 50vh;
349351
min-width: 50px;
350352
min-height: 50px;
351353
width: 100%;

src/components/sitepages/SiteTargets.vue

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@
8484
@click="set_coordinates_from_aladin"
8585
/>
8686
</div>
87+
<div class="search-slew-container">
88+
<command-button
89+
:data="mount_slew_radec_command"
90+
style="margin-bottom: 1em"
91+
class="command-slew-button is-small is-success is-outlined"
92+
/>
93+
<TargetSearchField
94+
v-model="mount_object"
95+
label="Search for objects..."
96+
size="is-small"
97+
@results="handle_object_name_search"
98+
/>
99+
</div>
87100

88101
<div class="sidebar-tabs">
89102
<div
@@ -111,11 +124,6 @@
111124

112125
<div class="sidebar-tab-content">
113126
<div v-if="active_target_tab=='telescope controls'">
114-
<TargetSearchField
115-
v-model="mount_object"
116-
label="Search for objects..."
117-
@results="handle_object_name_search"
118-
/>
119127
<command-tabs-accordion
120128
:controls="['Telescope', 'Camera']"
121129
:init-instrument-open-view="0"
@@ -567,6 +575,7 @@ import TheSkyChart from '@/components/celestialmap/TheSkyChart'
567575
import DateTimeLocationPicker from '@/components/celestialmap/DateTimeLocationPicker'
568576
import TargetSearchField from '@/components/FormElements/TargetSearchField'
569577
import CommandTabsAccordion from '@/components/CommandTabsAccordion'
578+
import CommandButton from '@/components/FormElements/CommandButton'
570579
// import Celestial from '@/components/celestialmap/celestial'
571580
import celestial from 'd3-celestial'
572581
@@ -586,6 +595,7 @@ export default {
586595
TargetSearchField,
587596
TheSkyChart,
588597
CommandTabsAccordion,
598+
CommandButton,
589599
DateTimeLocationPicker,
590600
TargetCard
591601
},
@@ -1208,7 +1218,19 @@ $toggle-button-height: 32px;
12081218
width: 100%;
12091219
height: 300px;
12101220
background-color:grey;
1211-
margin-bottom: 3em;
1221+
}
1222+
1223+
.search-slew-container {
1224+
position: relative;
1225+
height: 6em;
1226+
margin-top: 10px;
1227+
display:flex;
1228+
flex-direction: row-reverse;
1229+
gap: 1em;
1230+
padding-right: 1em;
1231+
}
1232+
.command-slew-button {
1233+
margin-top: 30px;
12121234
}
12131235
12141236
.command-tab-accordion {

src/main.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ Vue.use(Auth0Plugin, {
3838
// Hide the 'you are running in development mode!' warning in the console.
3939
Vue.config.productionTip = false
4040

41-
new Vue({
42-
el: '#app',
43-
router,
44-
store,
45-
render: h => h(App)
46-
}).$mount('#app')
41+
// Load the config for all sites
42+
store.dispatch('site_config/update_config').then(() => {
43+
new Vue({
44+
el: '#app',
45+
router,
46+
store,
47+
render: h => h(App)
48+
}).$mount('#app')
49+
})

src/store/modules/site_config.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import _ from 'lodash'
77
import axios from 'axios'
88

99
const state = {
10-
11-
test_sites: ['tst', 'tst001', 'dht', 'sintezsim'],
10+
test_sites: ['tst', 'tst001', 'dht'],
1211

1312
global_config: {},
1413
is_site_selected: false,
@@ -236,13 +235,11 @@ const actions = {
236235
* This action gets the most recent config from AWS, which applies to all
237236
* observatories in the network.
238237
*/
239-
update_config ({ commit, dispatch, rootState }) {
238+
async update_config ({ commit, rootState }) {
240239
const url = `${rootState.api_endpoints.active_api}/all/config`
241-
axios.get(url).then(response => {
242-
commit('setGlobalConfig', response.data)
243-
}).catch(error => {
244-
console.warn(error)
245-
})
240+
const response = await axios.get(url)
241+
commit('setGlobalConfig', response.data)
242+
return response.data
246243
},
247244

248245
set_default_filter_option ({ commit, getters }) {

0 commit comments

Comments
 (0)