diff --git a/web/run.py b/web/run.py index 41fd83a..8f00d72 100755 --- a/web/run.py +++ b/web/run.py @@ -103,8 +103,8 @@ PARAMETERS = { 'temp': { 'slug': 'temp', 'name': 'Temperature', - 'title': 'The absolute temperature.', - 'units': 'K', + 'title': 'The temperature.', + 'units': 'eV', 'active': False, 'position': 40, }, @@ -457,10 +457,12 @@ def get_data_for_target(target_config, started_at, stopped_at): for orbit in orbits: if 'started_at' in orbit: s0 = datetime.datetime.strptime(orbit['started_at'], FILE_DATE_FMT) + s0 = max(s0, started_at) else: s0 = started_at if 'stopped_at' in orbit: s1 = datetime.datetime.strptime(orbit['stopped_at'], FILE_DATE_FMT) + s1 = min(s1, stopped_at) else: s1 = stopped_at diff --git a/web/static/img/target/error_128.png b/web/static/img/target/error_128.png new file mode 100644 index 0000000..216df34 Binary files /dev/null and b/web/static/img/target/error_128.png differ diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index e78add5..a2c0e61 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -181,7 +181,7 @@ url = sw.buildDataUrlForTarget(target_slug, started_at, stopped_at); return d3.csv(url, function(csv){ var timeFormat, data; - console.debug("Requested CSV for " + target_slug + "...", csv); + console.debug("Requested CSV for " + target_slug + "…", csv); timeFormat = d3.timeParse('%Y-%m-%dT%H:%M:%S%Z'); data = { 'hee': [] @@ -220,41 +220,49 @@ }; SpaceWeather.prototype.loadAndCreatePlots = function(started_at, stopped_at){ "started_at: moment(.js) datetime object\nstopped_at: moment(.js) datetime object"; - var k, this$ = this; + var targets, res$, k, handleTarget, this$ = this; this.showLoader(); this.started_at = started_at; this.stopped_at = stopped_at; this.orbits = new Orbits(this.configuration.orbits_container, this.configuration); started_at = started_at.format(API_TIME_FORMAT); stopped_at = stopped_at.format(API_TIME_FORMAT); - return (function(){ - var results$ = []; - for (k in this.targets) { - results$.push(this.targets[k]); - } - return results$; - }.call(this)).forEach(function(target){ + res$ = []; + for (k in this.targets) { + res$.push(this.targets[k]); + } + targets = res$; + targets.forEach(function(target){ var targetButton; - console.info("Loading CSV data of " + target.name + "…"); targetButton = $(".targets-filters .target." + target.slug); targetButton.addClass('loading'); - targetButton.removeClass('failed empty'); + return targetButton.removeClass('failed error empty'); + }); + handleTarget = function(i){ + var target, targetButton; + if (i >= targets.length) { + return; + } + target = targets[i]; + console.info("Loading CSV data of " + target.name + "…"); + targetButton = $(".targets-filters .target." + target.slug); return this$.loadData(target.slug, started_at, stopped_at).then(function(data){ console.info("Loaded CSV data of " + target.name + ".", data); this$.createTimeSeries(target, data); this$.orbits.initOrbiter(target.slug, target.config, data['hee']); targetButton.removeClass('loading'); if (target.active) { - return this$.hideLoader(); + this$.hideLoader(); } else { - return this$.disableTarget(target.slug); + this$.disableTarget(target.slug); } + return handleTarget(i + 1); }, function(error){ var msg; switch (error) { case 'invalid': console.error("Failed loading CSV data of " + target.name + "."); - alert("There was an error with " + target.name + ".\nPlease retry in a few moments."); + targetButton.addClass('error'); this$.is_invalid = true; break; case 'empty': @@ -265,9 +273,12 @@ } targetButton.addClass('failed'); targetButton.removeClass('loading'); - return this$.hideLoader(); + this$.hideLoader(); + return handleTarget(i + 1); }); - }); + }; + handleTarget(0); + return this; }; SpaceWeather.prototype.clearPlots = function(){ this.orbits.clear(); diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index b97e053..4c26cd6 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -157,7 +157,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE new Promise((resolve, reject) -> url = sw.buildDataUrlForTarget(target_slug, started_at, stopped_at) d3.csv(url, (csv) -> - console.debug("Requested CSV for #{target_slug}...", csv) + console.debug("Requested CSV for #{target_slug}…", csv) timeFormat = d3.timeParse('%Y-%m-%dT%H:%M:%S%Z') data = { 'hee': [] } configuration['parameters'].forEach((parameter) -> @@ -191,12 +191,18 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE @orbits = new Orbits(@configuration.orbits_container, @configuration) started_at = started_at.format(API_TIME_FORMAT) stopped_at = stopped_at.format(API_TIME_FORMAT) - # active_targets = [@targets[k] for k of @targets when @targets[k].active] - [@targets[k] for k of @targets].forEach((target) ~> - console.info "Loading CSV data of #{target.name}…" + + targets = [@targets[k] for k of @targets] + targets.forEach((target) ~> targetButton = $(".targets-filters .target.#{target.slug}") targetButton.addClass('loading') - targetButton.removeClass('failed empty') + targetButton.removeClass('failed error empty') + ) + handleTarget = (i) ~> + if i >= targets.length then return + target = targets[i] + console.info "Loading CSV data of #{target.name}…" + targetButton = $(".targets-filters .target.#{target.slug}") @loadData(target.slug, started_at, stopped_at).then( (data) ~> console.info "Loaded CSV data of #{target.name}.", data @@ -204,6 +210,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE @orbits.initOrbiter(target.slug, target.config, data['hee']) targetButton.removeClass('loading') if target.active then @hideLoader() else @disableTarget(target.slug) + handleTarget(i+1) , (error) ~> switch error @@ -211,7 +218,8 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE console.error("Failed loading CSV data of #{target.name}.") # Sometimes, AMDA's API returns garbage, so the CSV sometime fails # But when we re-generate it a second time, usually it's okay. - alert("There was an error with #{target.name}.\nPlease retry in a few moments.") + # alert("There was an error with #{target.name}.\nPlease retry in a few moments.") + targetButton.addClass('error') @is_invalid = true break case 'empty' @@ -223,9 +231,12 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE targetButton.addClass('failed') targetButton.removeClass('loading') @hideLoader() - + handleTarget(i+1) ) - ) + handleTarget(0) + + + this clearPlots: -> @orbits.clear() diff --git a/web/view/home.html.jinja2 b/web/view/home.html.jinja2 index 6043466..747ef50 100755 --- a/web/view/home.html.jinja2 +++ b/web/view/home.html.jinja2 @@ -16,14 +16,14 @@ alt="{{ target.name }}"> No data for {{ target.name }} -{# Loader for {{ target.name }}#} + ERROR
@@ -361,6 +361,9 @@ .targets-filters .target.empty .decorator.empty { display: block; } + .targets-filters .target.error .decorator.error { + display: block; + } .targets-filters .target .decorator.loading { top: 19px; left: 19px; -- libgit2 0.21.2