Commit 7994cf1a82cc7498f2248ba4b6b4f3baa9a32a7a
1 parent
243cd8a4
Exists in
master
and in
2 other branches
Hunt bugs.
Showing
2 changed files
with
22 additions
and
25 deletions
Show diff stats
web/static/js/swapp.js
@@ -36,18 +36,15 @@ | @@ -36,18 +36,15 @@ | ||
36 | this.configuration['parameters'].forEach(function(p){ | 36 | this.configuration['parameters'].forEach(function(p){ |
37 | return this$.parameters[p['id']] = p; | 37 | return this$.parameters[p['id']] = p; |
38 | }); | 38 | }); |
39 | + this.orbiter = null; | ||
39 | this.timeSeries = []; | 40 | this.timeSeries = []; |
40 | } | 41 | } |
41 | SpaceWeather.prototype.init = function(){ | 42 | SpaceWeather.prototype.init = function(){ |
42 | "This is called by the inline bootstrap javascript code.\nThis ain't in the constructor because it might return a Promise later on.\n(for the loader, for example)"; | 43 | "This is called by the inline bootstrap javascript code.\nThis ain't in the constructor because it might return a Promise later on.\n(for the loader, for example)"; |
43 | var started_at, stopped_at, this$ = this; | 44 | var started_at, stopped_at, this$ = this; |
44 | - this.orbits = new Orbits(this.configuration.orbits_container, this.configuration); | ||
45 | - this.started_at = moment().subtract(1, 'years').hours(0).minutes(0).seconds(0); | ||
46 | - this.stopped_at = moment().add(7, 'days').hours(0).minutes(0).seconds(0); | ||
47 | - started_at = this.started_at.format(API_TIME_FORMAT); | ||
48 | - stopped_at = this.stopped_at.format(API_TIME_FORMAT); | ||
49 | - console.info("Setting time interval from " + started_at + " to " + stopped_at + "…"); | ||
50 | - this.setStartAndStop(this.started_at, this.stopped_at); | 45 | + started_at = moment().subtract(1, 'years').hours(0).minutes(0).seconds(0); |
46 | + stopped_at = moment().add(7, 'days').hours(0).minutes(0).seconds(0); | ||
47 | + this.setStartAndStop(started_at, stopped_at); | ||
51 | this.loadAndCreatePlots(started_at, stopped_at); | 48 | this.loadAndCreatePlots(started_at, stopped_at); |
52 | return window.addEventListener('resize', function(){ | 49 | return window.addEventListener('resize', function(){ |
53 | return this$.resize(); | 50 | return this$.resize(); |
@@ -142,6 +139,9 @@ | @@ -142,6 +139,9 @@ | ||
142 | "started_at: moment(.js) object\nstopped_at: moment(.js) object"; | 139 | "started_at: moment(.js) object\nstopped_at: moment(.js) object"; |
143 | var active_targets, res$, k, this$ = this; | 140 | var active_targets, res$, k, this$ = this; |
144 | this.showLoader(); | 141 | this.showLoader(); |
142 | + this.started_at = started_at; | ||
143 | + this.stopped_at = stopped_at; | ||
144 | + this.orbits = new Orbits(this.configuration.orbits_container, this.configuration); | ||
145 | started_at = started_at.format(API_TIME_FORMAT); | 145 | started_at = started_at.format(API_TIME_FORMAT); |
146 | stopped_at = stopped_at.format(API_TIME_FORMAT); | 146 | stopped_at = stopped_at.format(API_TIME_FORMAT); |
147 | res$ = []; | 147 | res$ = []; |
@@ -258,11 +258,9 @@ | @@ -258,11 +258,9 @@ | ||
258 | return [this.started_at, this.stopped_at]; | 258 | return [this.started_at, this.stopped_at]; |
259 | }; | 259 | }; |
260 | SpaceWeather.prototype.resizeDomain = function(started_at, stopped_at){ | 260 | SpaceWeather.prototype.resizeDomain = function(started_at, stopped_at){ |
261 | - var tmp, formatted_started_at, formatted_stopped_at; | 261 | + var ref$, formatted_started_at, formatted_stopped_at; |
262 | if (stopped_at < started_at) { | 262 | if (stopped_at < started_at) { |
263 | - tmp = started_at; | ||
264 | - started_at = stopped_at; | ||
265 | - stopped_at = started_at; | 263 | + ref$ = [stopped_at, started_at], started_at = ref$[0], stopped_at = ref$[1]; |
266 | } | 264 | } |
267 | if (started_at === stopped_at) { | 265 | if (started_at === stopped_at) { |
268 | console.warn("Please provide distinct start and stop dates."); | 266 | console.warn("Please provide distinct start and stop dates."); |
@@ -301,6 +299,7 @@ | @@ -301,6 +299,7 @@ | ||
301 | return this; | 299 | return this; |
302 | }; | 300 | }; |
303 | SpaceWeather.prototype.setStartAndStop = function(started_at, stopped_at){ | 301 | SpaceWeather.prototype.setStartAndStop = function(started_at, stopped_at){ |
302 | + console.info("Setting time interval from " + started_at + " to " + stopped_at + "…"); | ||
304 | this.current_started_at = started_at; | 303 | this.current_started_at = started_at; |
305 | this.current_stopped_at = stopped_at; | 304 | this.current_stopped_at = stopped_at; |
306 | $("#started_at").val(started_at.format(INPUT_TIME_FORMAT)); | 305 | $("#started_at").val(started_at.format(INPUT_TIME_FORMAT)); |
@@ -561,6 +560,7 @@ | @@ -561,6 +560,7 @@ | ||
561 | }; | 560 | }; |
562 | this.data = {}; | 561 | this.data = {}; |
563 | this.orbiters = {}; | 562 | this.orbiters = {}; |
563 | + this.orbitersElements = {}; | ||
564 | this.extremum = 1; | 564 | this.extremum = 1; |
565 | this.xScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); | 565 | this.xScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); |
566 | this.yScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); | 566 | this.yScale = d3.scaleLinear().domain([-1 * this.extremum, this.extremum]); |
@@ -587,7 +587,6 @@ | @@ -587,7 +587,6 @@ | ||
587 | $(this.svg.node()).hide(); | 587 | $(this.svg.node()).hide(); |
588 | return this.resize(); | 588 | return this.resize(); |
589 | }; | 589 | }; |
590 | - Orbits.prototype.orbitersElements = {}; | ||
591 | Orbits.prototype.initOrbiter = function(slug, config, data){ | 590 | Orbits.prototype.initOrbiter = function(slug, config, data){ |
592 | var orbit_ellipse, orbiter, orbit_line, orbit_section, this$ = this; | 591 | var orbit_ellipse, orbiter, orbit_line, orbit_section, this$ = this; |
593 | console.info("Initializing orbit of " + config.name + "…"); | 592 | console.info("Initializing orbit of " + config.name + "…"); |
web/static/js/swapp.ls
@@ -63,7 +63,8 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -63,7 +63,8 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
63 | @configuration['parameters'].forEach((p) ~> | 63 | @configuration['parameters'].forEach((p) ~> |
64 | @parameters[p['id']] = p | 64 | @parameters[p['id']] = p |
65 | ) | 65 | ) |
66 | - @timeSeries = [] | 66 | + @orbiter = null # our Orbiter |
67 | + @timeSeries = [] # a List of TimeSeries objects | ||
67 | 68 | ||
68 | init: -> | 69 | init: -> |
69 | """ | 70 | """ |
@@ -71,15 +72,11 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -71,15 +72,11 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
71 | This ain't in the constructor because it might return a Promise later on. | 72 | This ain't in the constructor because it might return a Promise later on. |
72 | (for the loader, for example) | 73 | (for the loader, for example) |
73 | """ | 74 | """ |
74 | - @orbits = new Orbits(@configuration.orbits_container, @configuration) | ||
75 | # Default time interval is from one year ago to one week ahead. | 75 | # Default time interval is from one year ago to one week ahead. |
76 | # We set the h/m/s to zero to benefit from a daily cache. | 76 | # We set the h/m/s to zero to benefit from a daily cache. |
77 | - @started_at = moment().subtract(1, 'years').hours(0).minutes(0).seconds(0) | ||
78 | - @stopped_at = moment().add(7, 'days').hours(0).minutes(0).seconds(0) | ||
79 | - started_at = @started_at.format(API_TIME_FORMAT) | ||
80 | - stopped_at = @stopped_at.format(API_TIME_FORMAT) | ||
81 | - console.info "Setting time interval from #{started_at} to #{stopped_at}…" | ||
82 | - @setStartAndStop(@started_at, @stopped_at) | 77 | + started_at = moment().subtract(1, 'years').hours(0).minutes(0).seconds(0) |
78 | + stopped_at = moment().add(7, 'days').hours(0).minutes(0).seconds(0) | ||
79 | + @setStartAndStop(started_at, stopped_at) | ||
83 | @loadAndCreatePlots(started_at, stopped_at) | 80 | @loadAndCreatePlots(started_at, stopped_at) |
84 | 81 | ||
85 | window.addEventListener 'resize', ~> @resize() | 82 | window.addEventListener 'resize', ~> @resize() |
@@ -154,6 +151,9 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -154,6 +151,9 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
154 | stopped_at: moment(.js) object | 151 | stopped_at: moment(.js) object |
155 | """ | 152 | """ |
156 | @showLoader() | 153 | @showLoader() |
154 | + @started_at = started_at | ||
155 | + @stopped_at = stopped_at | ||
156 | + @orbits = new Orbits(@configuration.orbits_container, @configuration) | ||
157 | started_at = started_at.format(API_TIME_FORMAT) | 157 | started_at = started_at.format(API_TIME_FORMAT) |
158 | stopped_at = stopped_at.format(API_TIME_FORMAT) | 158 | stopped_at = stopped_at.format(API_TIME_FORMAT) |
159 | active_targets = [@targets[k] for k of @targets when @targets[k].active] | 159 | active_targets = [@targets[k] for k of @targets when @targets[k].active] |
@@ -223,10 +223,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -223,10 +223,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
223 | 223 | ||
224 | resizeDomain: (started_at, stopped_at) -> | 224 | resizeDomain: (started_at, stopped_at) -> |
225 | if stopped_at < started_at | 225 | if stopped_at < started_at |
226 | - tmp = started_at | ||
227 | - started_at = stopped_at | ||
228 | - stopped_at = started_at | ||
229 | - | 226 | + [started_at, stopped_at] = [stopped_at, started_at] |
230 | if started_at == stopped_at | 227 | if started_at == stopped_at |
231 | console.warn "Please provide distinct start and stop dates." | 228 | console.warn "Please provide distinct start and stop dates." |
232 | return | 229 | return |
@@ -259,6 +256,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -259,6 +256,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
259 | this | 256 | this |
260 | 257 | ||
261 | setStartAndStop: (started_at, stopped_at) -> | 258 | setStartAndStop: (started_at, stopped_at) -> |
259 | + console.info "Setting time interval from #{started_at} to #{stopped_at}…" | ||
262 | @current_started_at = started_at | 260 | @current_started_at = started_at |
263 | @current_stopped_at = stopped_at | 261 | @current_stopped_at = stopped_at |
264 | $("\#started_at").val(started_at.format(INPUT_TIME_FORMAT)) | 262 | $("\#started_at").val(started_at.format(INPUT_TIME_FORMAT)) |
@@ -574,6 +572,7 @@ export class Orbits | @@ -574,6 +572,7 @@ export class Orbits | ||
574 | 572 | ||
575 | @data = {} # slug => HCI array | 573 | @data = {} # slug => HCI array |
576 | @orbiters = {} # slug => config | 574 | @orbiters = {} # slug => config |
575 | + @orbitersElements = {} | ||
577 | @extremum = 1 | 576 | @extremum = 1 |
578 | @xScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) | 577 | @xScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) |
579 | @yScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) | 578 | @yScale = d3.scaleLinear().domain([-1 * @extremum, @extremum]) |
@@ -613,7 +612,6 @@ export class Orbits | @@ -613,7 +612,6 @@ export class Orbits | ||
613 | $(@svg.node()).hide(); # we'll show it later when there'll be data | 612 | $(@svg.node()).hide(); # we'll show it later when there'll be data |
614 | @resize() | 613 | @resize() |
615 | 614 | ||
616 | - orbitersElements: {} | ||
617 | initOrbiter: (slug, config, data) -> | 615 | initOrbiter: (slug, config, data) -> |
618 | console.info "Initializing orbit of #{config.name}…" | 616 | console.info "Initializing orbit of #{config.name}…" |
619 | if slug of @orbitersElements then throw new Error("Second init of #{slug}") | 617 | if slug of @orbitersElements then throw new Error("Second init of #{slug}") |