Commit a2a08db21db789a59cb9aa99b84527ab6e303284
1 parent
b4abddb7
Exists in
master
and in
2 other branches
Make sure targets are hidden from the orbits plots when there is no orbit data f…
…or the observed interval.
Showing
3 changed files
with
62 additions
and
35 deletions
Show diff stats
config.yml
@@ -89,7 +89,11 @@ inputs: | @@ -89,7 +89,11 @@ inputs: | ||
89 | #Exomars exomars_cruise_all | 89 | #Exomars exomars_cruise_all |
90 | #Rosetta ros_orb_cruise | 90 | #Rosetta ros_orb_cruise |
91 | 91 | ||
92 | -# `slug` is used internally, and should match \[a-z0-9]+\ (NO dashes !) | 92 | +# To add a new target, you must : |
93 | +# 1. Configure it here | ||
94 | +# 2. Create the two related images in `web/static/img/target/` | ||
95 | +# | ||
96 | +# `slug` is used internally, and should match \[a-z0-9]+\ (NO dashes /!\) | ||
93 | # `name` is displayed in the time series (should be short) | 97 | # `name` is displayed in the time series (should be short) |
94 | # `title` appears on mouse hover, and can be longer | 98 | # `title` appears on mouse hover, and can be longer |
95 | # `locked` is for sources that are "coming soon" | 99 | # `locked` is for sources that are "coming soon" |
@@ -303,10 +307,3 @@ targets: | @@ -303,10 +307,3 @@ targets: | ||
303 | #Mars tao_mars_sw 1990-01-01T01:00 2017-02-19T00:00 | 307 | #Mars tao_mars_sw 1990-01-01T01:00 2017-02-19T00:00 |
304 | #Jupiter tao_jup_sw 1990-01-01T01:00 2017-02-19T00:00 | 308 | #Jupiter tao_jup_sw 1990-01-01T01:00 2017-02-19T00:00 |
305 | #Saturn tao_sat_sw 1990-01-01T01:30 2017-02-19T00:00 | 309 | #Saturn tao_sat_sw 1990-01-01T01:30 2017-02-19T00:00 |
306 | - | ||
307 | -#models: | ||
308 | -# jupiter: | ||
309 | -# name: Jupiter | ||
310 | -# model: tao_jup_sw | ||
311 | -# started_at: "1990-01-01T01:30:00" | ||
312 | -# stopped_at: "2017-02-19T00:00:00" |
web/static/js/swapp.js
@@ -141,7 +141,7 @@ | @@ -141,7 +141,7 @@ | ||
141 | }); | 141 | }); |
142 | this.targets[target_slug].active = true; | 142 | this.targets[target_slug].active = true; |
143 | if ((ref$ = this.orbits) != null) { | 143 | if ((ref$ = this.orbits) != null) { |
144 | - ref$.showOrbiter(target_slug); | 144 | + ref$.enableTarget(target_slug); |
145 | } | 145 | } |
146 | return this; | 146 | return this; |
147 | }; | 147 | }; |
@@ -154,7 +154,7 @@ | @@ -154,7 +154,7 @@ | ||
154 | }); | 154 | }); |
155 | this.targets[target_slug].active = false; | 155 | this.targets[target_slug].active = false; |
156 | if ((ref$ = this.orbits) != null) { | 156 | if ((ref$ = this.orbits) != null) { |
157 | - ref$.hideOrbiter(target_slug); | 157 | + ref$.disableTarget(target_slug); |
158 | } | 158 | } |
159 | return this; | 159 | return this; |
160 | }; | 160 | }; |
@@ -267,7 +267,6 @@ | @@ -267,7 +267,6 @@ | ||
267 | case 'invalid': | 267 | case 'invalid': |
268 | console.error("Failed loading CSV data of " + target.name + "."); | 268 | console.error("Failed loading CSV data of " + target.name + "."); |
269 | targetButton.addClass('error'); | 269 | targetButton.addClass('error'); |
270 | - this$.is_invalid = true; | ||
271 | break; | 270 | break; |
272 | case 'empty': | 271 | case 'empty': |
273 | msg = "No data for " + target.name + "\n during interval from \n" + started_at + " to " + stopped_at + "."; | 272 | msg = "No data for " + target.name + "\n during interval from \n" + started_at + " to " + stopped_at + "."; |
@@ -419,9 +418,8 @@ | @@ -419,9 +418,8 @@ | ||
419 | }); | 418 | }); |
420 | this.orbits.resizeDomain(started_at, stopped_at); | 419 | this.orbits.resizeDomain(started_at, stopped_at); |
421 | } else { | 420 | } else { |
422 | - this.is_invalid = false; | ||
423 | console.info("Resizing the temporal domain from " + formatted_started_at + " to " + formatted_stopped_at + " and fetching new data…"); | 421 | console.info("Resizing the temporal domain from " + formatted_started_at + " to " + formatted_stopped_at + " and fetching new data…"); |
424 | - console.warn("This might take a while… Why not see what else we're up to on http://cdpp.eu while you're waiting?"); | 422 | + console.warn("This might take a good while… Why not see what else we're up to on http://cdpp.eu while you're waiting?"); |
425 | this.clearPlots(); | 423 | this.clearPlots(); |
426 | this.loadAndCreatePlots(started_at, stopped_at); | 424 | this.loadAndCreatePlots(started_at, stopped_at); |
427 | } | 425 | } |
@@ -761,9 +759,6 @@ | @@ -761,9 +759,6 @@ | ||
761 | this.options = options != null | 759 | this.options = options != null |
762 | ? options | 760 | ? options |
763 | : {}; | 761 | : {}; |
764 | - this.init(); | ||
765 | - } | ||
766 | - Orbits.prototype.init = function(){ | ||
767 | console.log("Initializing plot of orbits…"); | 762 | console.log("Initializing plot of orbits…"); |
768 | this.margin = { | 763 | this.margin = { |
769 | top: 30, | 764 | top: 30, |
@@ -799,8 +794,8 @@ | @@ -799,8 +794,8 @@ | ||
799 | this.sun = this.plotWrapper.append("svg:image").attr('xlink:href', this.options.sun.img).attr('width', '32px').attr('height', '32px'); | 794 | this.sun = this.plotWrapper.append("svg:image").attr('xlink:href', this.options.sun.img).attr('width', '32px').attr('height', '32px'); |
800 | this.sun.append('svg:title').text("Sun"); | 795 | this.sun.append('svg:title').text("Sun"); |
801 | $(this.svg.node()).hide(); | 796 | $(this.svg.node()).hide(); |
802 | - return this.resize(); | ||
803 | - }; | 797 | + this.resize(); |
798 | + } | ||
804 | Orbits.prototype.initOrbiter = function(slug, config, data){ | 799 | Orbits.prototype.initOrbiter = function(slug, config, data){ |
805 | var orbit_ellipse, orbiter, orbit_line, orbit_section, this$ = this; | 800 | var orbit_ellipse, orbiter, orbit_line, orbit_section, this$ = this; |
806 | this.data[slug] = data; | 801 | this.data[slug] = data; |
@@ -833,13 +828,28 @@ | @@ -833,13 +828,28 @@ | ||
833 | return Math.max(Math.abs(d.x), Math.abs(d.y)); | 828 | return Math.max(Math.abs(d.x), Math.abs(d.y)); |
834 | }); | 829 | }); |
835 | $(this.svg.node()).show(); | 830 | $(this.svg.node()).show(); |
836 | - this.resize(true); | 831 | + if (config.active) { |
832 | + this.enableTarget(slug); | ||
833 | + } else { | ||
834 | + this.disableTarget(slug); | ||
835 | + } | ||
837 | return this; | 836 | return this; |
838 | }; | 837 | }; |
838 | + Orbits.prototype.enableTarget = function(slug){ | ||
839 | + this.orbiters[slug].enabled = true; | ||
840 | + return this.showOrbiter(slug); | ||
841 | + }; | ||
842 | + Orbits.prototype.disableTarget = function(slug){ | ||
843 | + this.orbiters[slug].enabled = false; | ||
844 | + return this.hideOrbiter(slug); | ||
845 | + }; | ||
839 | Orbits.prototype.showOrbiter = function(slug){ | 846 | Orbits.prototype.showOrbiter = function(slug){ |
840 | if (!this.data[slug].length) { | 847 | if (!this.data[slug].length) { |
841 | return; | 848 | return; |
842 | } | 849 | } |
850 | + if (!this.orbiters[slug].enabled) { | ||
851 | + return; | ||
852 | + } | ||
843 | this.orbiters[slug].hidden = false; | 853 | this.orbiters[slug].hidden = false; |
844 | this.orbitersElements[slug].orbiter.style("display", null); | 854 | this.orbitersElements[slug].orbiter.style("display", null); |
845 | this.orbitersElements[slug].orbit_ellipse.style("display", null); | 855 | this.orbitersElements[slug].orbit_ellipse.style("display", null); |
@@ -979,33 +989,39 @@ | @@ -979,33 +989,39 @@ | ||
979 | return this; | 989 | return this; |
980 | }; | 990 | }; |
981 | Orbits.prototype.resizeDomain = function(started_at, stopped_at){ | 991 | Orbits.prototype.resizeDomain = function(started_at, stopped_at){ |
982 | - var slug, ref$, config, el, data; | 992 | + var slug, ref$, config, el, data, results$ = []; |
983 | for (slug in ref$ = this.orbiters) { | 993 | for (slug in ref$ = this.orbiters) { |
984 | config = ref$[slug]; | 994 | config = ref$[slug]; |
985 | el = this.orbitersElements[slug]; | 995 | el = this.orbitersElements[slug]; |
986 | data = this.data[slug].filter(fn$); | 996 | data = this.data[slug].filter(fn$); |
987 | if (!data.length) { | 997 | if (!data.length) { |
988 | - return; | 998 | + this.hideOrbiter(slug); |
999 | + continue; | ||
989 | } | 1000 | } |
990 | el['orbit_section'].datum(data); | 1001 | el['orbit_section'].datum(data); |
991 | el['orbit_section'].attr('d', el['orbit_line']); | 1002 | el['orbit_section'].attr('d', el['orbit_line']); |
1003 | + results$.push(this.showOrbiter(slug)); | ||
992 | } | 1004 | } |
1005 | + return results$; | ||
993 | function fn$(d){ | 1006 | function fn$(d){ |
994 | var ref$; | 1007 | var ref$; |
995 | return started_at <= (ref$ = d.t) && ref$ <= stopped_at; | 1008 | return started_at <= (ref$ = d.t) && ref$ <= stopped_at; |
996 | } | 1009 | } |
997 | }; | 1010 | }; |
998 | Orbits.prototype.resetZoom = function(){ | 1011 | Orbits.prototype.resetZoom = function(){ |
999 | - var slug, ref$, config, el; | 1012 | + var slug, ref$, config, el, results$ = []; |
1000 | for (slug in ref$ = this.orbiters) { | 1013 | for (slug in ref$ = this.orbiters) { |
1001 | config = ref$[slug]; | 1014 | config = ref$[slug]; |
1002 | el = this.orbitersElements[slug]; | 1015 | el = this.orbitersElements[slug]; |
1003 | if (!this.data[slug].length) { | 1016 | if (!this.data[slug].length) { |
1004 | - return; | 1017 | + this.hideOrbiter(slug); |
1018 | + continue; | ||
1005 | } | 1019 | } |
1006 | el['orbit_section'].datum(this.data[slug]); | 1020 | el['orbit_section'].datum(this.data[slug]); |
1007 | el['orbit_section'].attr('d', el['orbit_line']); | 1021 | el['orbit_section'].attr('d', el['orbit_line']); |
1022 | + results$.push(this.showOrbiter(slug)); | ||
1008 | } | 1023 | } |
1024 | + return results$; | ||
1009 | }; | 1025 | }; |
1010 | return Orbits; | 1026 | return Orbits; |
1011 | }()); | 1027 | }()); |
web/static/js/swapp.ls
@@ -129,13 +129,13 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -129,13 +129,13 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
129 | enableTarget: (target_slug) -> | 129 | enableTarget: (target_slug) -> |
130 | @time_series.forEach((ts) ~> ts.show() if ts.target.slug == target_slug && @parameters[ts.parameter].active) | 130 | @time_series.forEach((ts) ~> ts.show() if ts.target.slug == target_slug && @parameters[ts.parameter].active) |
131 | @targets[target_slug].active = true | 131 | @targets[target_slug].active = true |
132 | - @orbits?.showOrbiter target_slug | 132 | + @orbits?.enableTarget target_slug |
133 | this | 133 | this |
134 | 134 | ||
135 | disableTarget: (target_slug) -> | 135 | disableTarget: (target_slug) -> |
136 | @time_series.forEach((ts) -> ts.hide() if ts.target.slug == target_slug) | 136 | @time_series.forEach((ts) -> ts.hide() if ts.target.slug == target_slug) |
137 | @targets[target_slug].active = false | 137 | @targets[target_slug].active = false |
138 | - @orbits?.hideOrbiter target_slug | 138 | + @orbits?.disableTarget target_slug |
139 | this | 139 | this |
140 | 140 | ||
141 | resize: -> | 141 | resize: -> |
@@ -223,7 +223,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -223,7 +223,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
223 | # But when we re-generate it a second time, usually it's okay. | 223 | # But when we re-generate it a second time, usually it's okay. |
224 | # alert("There was an error with #{target.name}.\nPlease retry in a few moments.") | 224 | # alert("There was an error with #{target.name}.\nPlease retry in a few moments.") |
225 | targetButton.addClass('error') | 225 | targetButton.addClass('error') |
226 | - @is_invalid = true | 226 | +# @is_invalid = true |
227 | break | 227 | break |
228 | case 'empty' | 228 | case 'empty' |
229 | msg = "No data for #{target.name}\n during interval from \n#{started_at} to #{stopped_at}." | 229 | msg = "No data for #{target.name}\n during interval from \n#{started_at} to #{stopped_at}." |
@@ -321,10 +321,9 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -321,10 +321,9 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
321 | @time_series.forEach((ts) -> if ts.visible then ts.zoomIn(started_at, stopped_at)) | 321 | @time_series.forEach((ts) -> if ts.visible then ts.zoomIn(started_at, stopped_at)) |
322 | @orbits.resizeDomain started_at, stopped_at | 322 | @orbits.resizeDomain started_at, stopped_at |
323 | else | 323 | else |
324 | - @is_invalid = false | 324 | +# @is_invalid = false |
325 | console.info "Resizing the temporal domain from #{formatted_started_at} to #{formatted_stopped_at} and fetching new data…" | 325 | console.info "Resizing the temporal domain from #{formatted_started_at} to #{formatted_stopped_at} and fetching new data…" |
326 | - console.warn "This might take a while… Why not see what else we're up to on http://cdpp.eu while you're waiting?" | ||
327 | - # fetch new data and remake the plots | 326 | + console.warn "This might take a good while… Why not see what else we're up to on http://cdpp.eu while you're waiting?" |
328 | @clearPlots() | 327 | @clearPlots() |
329 | @loadAndCreatePlots(started_at, stopped_at) | 328 | @loadAndCreatePlots(started_at, stopped_at) |
330 | 329 | ||
@@ -694,9 +693,7 @@ export class Orbits | @@ -694,9 +693,7 @@ export class Orbits | ||
694 | """ | 693 | """ |
695 | 694 | ||
696 | (@container, @options = {}) -> | 695 | (@container, @options = {}) -> |
697 | - @init() | ||
698 | 696 | ||
699 | - init: -> | ||
700 | console.log "Initializing plot of orbits…" | 697 | console.log "Initializing plot of orbits…" |
701 | 698 | ||
702 | # In the variable names below, x and y are the usual ones. | 699 | # In the variable names below, x and y are the usual ones. |
@@ -791,12 +788,24 @@ export class Orbits | @@ -791,12 +788,24 @@ export class Orbits | ||
791 | 788 | ||
792 | $(@svg.node()).show(); | 789 | $(@svg.node()).show(); |
793 | 790 | ||
794 | - @resize(true) | 791 | + if config.active |
792 | + @enableTarget slug | ||
793 | + else | ||
794 | + @disableTarget slug | ||
795 | 795 | ||
796 | this | 796 | this |
797 | 797 | ||
798 | + enableTarget: (slug) -> | ||
799 | + @orbiters[slug].enabled = true | ||
800 | + @showOrbiter slug | ||
801 | + | ||
802 | + disableTarget: (slug) -> | ||
803 | + @orbiters[slug].enabled = false | ||
804 | + @hideOrbiter slug | ||
805 | + | ||
798 | showOrbiter: (slug) -> | 806 | showOrbiter: (slug) -> |
799 | if not @data[slug].length then return | 807 | if not @data[slug].length then return |
808 | + if not @orbiters[slug].enabled then return | ||
800 | @orbiters[slug].hidden = false | 809 | @orbiters[slug].hidden = false |
801 | @orbitersElements[slug].orbiter.style("display", null) | 810 | @orbitersElements[slug].orbiter.style("display", null) |
802 | @orbitersElements[slug].orbit_ellipse.style("display", null) | 811 | @orbitersElements[slug].orbit_ellipse.style("display", null) |
@@ -930,14 +939,19 @@ export class Orbits | @@ -930,14 +939,19 @@ export class Orbits | ||
930 | for slug, config of @orbiters | 939 | for slug, config of @orbiters |
931 | el = @orbitersElements[slug] | 940 | el = @orbitersElements[slug] |
932 | data = @data[slug].filter (d) -> started_at <= d.t <= stopped_at | 941 | data = @data[slug].filter (d) -> started_at <= d.t <= stopped_at |
933 | - if not data.length then return | 942 | + if not data.length |
943 | + @hideOrbiter(slug) | ||
944 | + continue | ||
934 | el['orbit_section'].datum(data) | 945 | el['orbit_section'].datum(data) |
935 | el['orbit_section'].attr('d', el['orbit_line']) | 946 | el['orbit_section'].attr('d', el['orbit_line']) |
947 | + @showOrbiter(slug) | ||
936 | 948 | ||
937 | resetZoom: -> | 949 | resetZoom: -> |
938 | for slug, config of @orbiters | 950 | for slug, config of @orbiters |
939 | el = @orbitersElements[slug] | 951 | el = @orbitersElements[slug] |
940 | - if not @data[slug].length then return | 952 | + if not @data[slug].length |
953 | + @hideOrbiter(slug) | ||
954 | + continue | ||
941 | el['orbit_section'].datum(@data[slug]) | 955 | el['orbit_section'].datum(@data[slug]) |
942 | el['orbit_section'].attr('d', el['orbit_line']) | 956 | el['orbit_section'].attr('d', el['orbit_line']) |
943 | - | 957 | + @showOrbiter(slug) |