Skip to content
Merged
154 changes: 5 additions & 149 deletions meteor_packages/mats-common/lib/plot_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import moment from "moment";
// eslint-disable-next-line import/no-unresolved
import hexRgb from "hex-rgb";

/* global $, Session, _ */
/* global $, Session */

const getBaseURL = function () {
const urlComponents = document.location.href.split("/");
Expand Down Expand Up @@ -176,7 +176,7 @@ const enableActionButtons = function () {
};

const restoreSettings = function (p) {
Session.set("Curves", p.data.curves);
matsCurveUtils.clearAllUsed();
// reset the plotType - have to do this first because the event will remove all the possibly existing curves
// get the plot-type elements checked state
let plotTypeSaved = false;
Expand All @@ -186,63 +186,8 @@ const restoreSettings = function (p) {
if (p.data.plotTypes && p.data.plotTypes[ptElem.value] === true) {
plotTypeSaved = true;
ptElem.checked = true;
// We have to set up the display without using click events because that would cause
// the restored curves to be removed
switch (ptElem.value) {
case matsTypes.PlotTypes.profile:
matsCurveUtils.showProfileFace();
break;
case matsTypes.PlotTypes.dieoff:
matsCurveUtils.showDieoffFace();
break;
case matsTypes.PlotTypes.threshold:
matsCurveUtils.showThresholdFace();
break;
case matsTypes.PlotTypes.validtime:
matsCurveUtils.showValidTimeFace();
break;
case matsTypes.PlotTypes.gridscale:
matsCurveUtils.showGridScaleFace();
break;
case matsTypes.PlotTypes.dailyModelCycle:
matsCurveUtils.showDailyModelCycleFace();
break;
case matsTypes.PlotTypes.yearToYear:
matsCurveUtils.showYearToYearFace();
break;
case matsTypes.PlotTypes.reliability:
matsCurveUtils.showReliabilityFace();
break;
case matsTypes.PlotTypes.roc:
matsCurveUtils.showROCFace();
break;
case matsTypes.PlotTypes.performanceDiagram:
matsCurveUtils.showPerformanceDiagramFace();
break;
case matsTypes.PlotTypes.gridscaleProb:
matsCurveUtils.showGridScaleProbFace();
break;
case matsTypes.PlotTypes.map:
matsCurveUtils.showMapFace();
break;
case matsTypes.PlotTypes.histogram:
matsCurveUtils.showHistogramFace();
break;
case matsTypes.PlotTypes.ensembleHistogram:
matsCurveUtils.showEnsembleHistogramFace();
break;
case matsTypes.PlotTypes.contour:
case matsTypes.PlotTypes.contourDiff:
matsCurveUtils.showContourFace();
break;
case matsTypes.PlotTypes.simpleScatter:
matsCurveUtils.showSimpleScatterFace();
break;
case matsTypes.PlotTypes.timeSeries:
default:
matsCurveUtils.showTimeseriesFace();
break;
}
document.getElementById("plotTypes-selector").value = ptElem.value;
$("#plotTypes-selector").trigger("change");
} else {
ptElem.checked = false;
}
Expand All @@ -253,95 +198,6 @@ const restoreSettings = function (p) {
matsCollections.PlotGraphFunctions.findOne({ checked: true }).plotType;
}

// now set the PlotParams
let params = matsCollections.PlotParams.find({}).fetch();
params.forEach(function (plotParam) {
const val =
p.data.paramData.plotParams[plotParam.name] === null ||
p.data.paramData.plotParams[plotParam.name] === undefined
? matsTypes.InputTypes.unused
: p.data.paramData.plotParams[plotParam.name];
matsParamUtils.setInputForParamName(plotParam.name, val);
});

const paramNames = matsCollections.CurveParamsInfo.findOne({
curve_params: { $exists: true },
}).curve_params;
params = [];
const superiors = [];
const dependents = [];
// get all of the curve param collections in one place
for (let pidx = 0; pidx < paramNames.length; pidx += 1) {
const param = matsCollections[paramNames[pidx]].findOne({});
// superiors
if (param.dependentNames !== undefined) {
superiors.push(param);
// dependents
} else if (param.superiorNames !== undefined) {
dependents.push(param);
// everything else
} else {
params.push(param);
}
}

// reset the form parameters for the superiors first
superiors.forEach(function (plotParam) {
if (plotParam.type === matsTypes.InputTypes.dateRange) {
if (p.data.paramData.curveParams[plotParam.name] === undefined) {
return; // just like continue
}
const dateArr = p.data.paramData.curveParams[plotParam.name].split(" - ");
const from = dateArr[0];
const to = dateArr[1];
const idref = `#${plotParam.name}-${plotParam.type}`;
$(idref)
.data("daterangepicker")
.setStartDate(moment.utc(from, "MM-DD-YYYY HH:mm"));
$(idref).data("daterangepicker").setEndDate(moment.utc(to, "MM-DD-YYYY HH:mm"));
matsParamUtils.setValueTextForParamName(
plotParam.name,
p.data.paramData.curveParams[plotParam.name]
);
} else {
const val =
p.data.paramData.curveParams[plotParam.name] === null ||
p.data.paramData.curveParams[plotParam.name] === undefined
? matsTypes.InputTypes.unused
: p.data.paramData.curveParams[plotParam.name];
matsParamUtils.setInputForParamName(plotParam.name, val);
}
});

// now reset the form parameters for the dependents
params = _.union(dependents, params);
params.forEach(function (plotParam) {
if (plotParam.type === matsTypes.InputTypes.dateRange) {
if (p.data.paramData.curveParams[plotParam.name] === undefined) {
return; // just like continue
}
const dateArr = p.data.paramData.curveParams[plotParam.name].split(" - ");
const from = dateArr[0];
const to = dateArr[1];
const idref = `#${plotParam.name}-${plotParam.type}`;
$(idref)
.data("daterangepicker")
.setStartDate(moment.utc(from, "MM-DD-YYYY HH:mm"));
$(idref).data("daterangepicker").setEndDate(moment.utc(to, "MM-DD-YYYY HH:mm"));
matsParamUtils.setValueTextForParamName(
plotParam.name,
p.data.paramData.curveParams[plotParam.name]
);
} else {
const val =
p.data.paramData.curveParams[plotParam.name] === null ||
p.data.paramData.curveParams[plotParam.name] === undefined
? matsTypes.InputTypes.unused
: p.data.paramData.curveParams[plotParam.name];
matsParamUtils.setInputForParamName(plotParam.name, val);
}
});

// reset the dates
if (p.data.dates !== undefined) {
const dateArr = p.data.dates.split(" - ");
Expand All @@ -356,8 +212,8 @@ const restoreSettings = function (p) {
matsParamUtils.setValueTextForParamName("dates", p.data.dates);
}

// reset the plotFormat
// reset the plotParams
Session.set("Curves", p.data.curves);
Session.set("PlotParams", p);
// set the used defaults so that subsequent adds get a core default
matsCurveUtils.setUsedColorsAndLabels();
Expand Down
21 changes: 21 additions & 0 deletions meteor_packages/mats-common/public/MATSReleaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ <h4>All apps v6.2.6</h4>
<p style="margin: 25px 0"></p>
<p>Changes:</p>
<p>* Fixed npm security vulnerability.</p>
<p>* Added documentation link to top navigation bar.</p>
<p>
* Fixed bug where the upper air app erroneously displayed the "Region Mode" selector
when "Truth" was set to some sort of AMDAR. Users should not be offered a choice of
region mode for AMDAR, as AMDAR is predefined region only.
</p>
<p>
* Clicking Restore Settings no longer removes all added curves unless the user then
clicks confirm.
</p>
<p>
* Clicking Restore Settings no longer changes the values on the blue curve selector
buttons (although it may by necessity change plot type).
</p>
<p>
* Fixed bug where the default legend text wouldn't appear on the Edit Legend modal.
</p>
<p>
* Reordered curve legends to be more concise and display forecast lead time earlier.
</p>
<p>* Made modals larger.</p>
</div>
<div>
<hr
Expand Down
13 changes: 6 additions & 7 deletions meteor_packages/mats-common/templates/about/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
tabindex="-1"
aria-labelledby="aboutModalLabel"
>
<div class="modal-dialog modal-style">
<div class="modal-dialog modal-lg modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="aboutModalLabel" class="modal-title text-dark-blue">About</h2>
<h2 id="aboutModalLabel" class="modal-title text-dark-blue">
{{#if isMetexpress}} METexpress {{else}} Model Analysis Tool Suite (MATS)
{{/if}}
</h2>
<button
type="button"
class="btn-close"
Expand All @@ -19,11 +22,7 @@ <h2 id="aboutModalLabel" class="modal-title text-dark-blue">About</h2>
></button>
</div>
<div class="text-center mt-4 mb-3">
{{#if isMetexpress}}
<h3>METexpress</h3>
{{else}}
<h3>Model Analysis Tool Suite (MATS)</h3>
{{/if}} {{{version}}}
<h4>{{{version}}}</h4>
</div>
<div
id="hideNotesUpper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tabindex="-1"
aria-labelledby="changePlotTypeModalLabel"
>
<div class="modal-dialog modal-style">
<div class="modal-dialog modal-lg modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="changePlotTypeModalLabel" class="modal-title text-dark-blue">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tabindex="-1"
aria-labelledby="removeCurveModalLabel"
>
<div class="modal-dialog modal-style">
<div class="modal-dialog modal-lg modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="removeCurveModalLabel" class="modal-title text-dark-blue">
Expand Down
5 changes: 3 additions & 2 deletions meteor_packages/mats-common/templates/curves/curve_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Template.curveItem.helpers({
const confirmRemoveCurve = Session.get("confirmRemoveCurve");
return confirmRemoveCurve ? confirmRemoveCurve.label : null;
},
text() {
async text() {
if (this.diffFrom === undefined) {
let plotType = Session.get("plotType");
if (plotType === undefined) {
Expand All @@ -41,7 +41,8 @@ Template.curveItem.helpers({
if (this.region) {
[this.regionName] = this.region.split(" ");
}
return matsPlotUtils.getCurveText(plotType, this).then();
const text = await matsPlotUtils.getCurveText(plotType, this);
return text;
}
return `${this.label}: Difference`;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tabindex="-1"
aria-labelledby="removeAllModalLabel"
>
<div class="modal-dialog modal-style">
<div class="modal-dialog modal-lg modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="removeAllModalLabel" class="modal-title text-dark-blue">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
tabindex="-1"
aria-labelledby="confirmLostEditsModalLabel"
>
<div class="modal-dialog modal-style">
<div class="modal-dialog modal-lg modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="confirmLostEditsModalLabel" class="modal-title text-dark-blue">
Expand Down
2 changes: 1 addition & 1 deletion meteor_packages/mats-common/templates/error/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tabindex="-1"
aria-labelledby="errorModalLabel"
>
<div class="modal-dialog modal-style">
<div class="modal-dialog modal-lg modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="errorModalLabel" class="modal-title text-dark-blue">
Expand Down
12 changes: 6 additions & 6 deletions meteor_packages/mats-common/templates/graph/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
tabindex="-1"
aria-labelledby="axisLimitModalLabel"
>
<div class="modal-dialog modal-lg modal-style">
<div class="modal-dialog modal-xl modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="axisLimitModalLabel" class="modal-title text-dark-blue">Axes</h2>
Expand Down Expand Up @@ -706,7 +706,7 @@ <h4>
tabindex="-1"
aria-labelledby="lineTypeModalLabel"
>
<div class="modal-dialog modal-lg modal-style">
<div class="modal-dialog modal-xl modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="lineTypeModalLabel" class="modal-title text-dark-blue">
Expand Down Expand Up @@ -857,7 +857,7 @@ <h4>* Leave a field blank to preserve its original value.</h4>
tabindex="-1"
aria-labelledby="showHideModalLabel"
>
<div class="modal-dialog modal-lg modal-style">
<div class="modal-dialog modal-xl modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="showHideModalLabel" class="modal-title text-dark-blue">
Expand Down Expand Up @@ -969,7 +969,7 @@ <h3>Show/hide curve elements</h3>
tabindex="-1"
aria-labelledby="legendTextModalLabel"
>
<div class="modal-dialog modal-lg modal-style">
<div class="modal-dialog modal-xl modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="legendTextModalLabel" class="modal-title text-dark-blue">
Expand Down Expand Up @@ -1051,7 +1051,7 @@ <h4>* Leave a field blank to preserve its original value.</h4>
tabindex="-1"
aria-labelledby="filterPointsModalLabel"
>
<div class="modal-dialog modal-lg modal-style">
<div class="modal-dialog modal-xl modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="filterPointsModalLabel" class="modal-title text-dark-blue">
Expand Down Expand Up @@ -1121,7 +1121,7 @@ <h3>Uncheck points to exclude from graph</h3>
tabindex="-1"
aria-labelledby="colorbarModalLabel"
>
<div class="modal-dialog modal-lg modal-style">
<div class="modal-dialog modal-xl modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="colorbarModalLabel" class="modal-title text-dark-blue">
Expand Down
9 changes: 6 additions & 3 deletions meteor_packages/mats-common/templates/graph/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,9 @@ Template.graph.helpers({
? " (in log10)"
: "";
},
curveText() {
async curveText() {
Session.get("PlotResultsUpDated");
let text;
if (this.diffFrom === undefined) {
let plotType = Session.get("plotType");
if (plotType === undefined) {
Expand All @@ -568,9 +570,10 @@ Template.graph.helpers({
plotType = Session.get("plotType");
}
if (plotType === matsTypes.PlotTypes.profile) {
return matsPlotUtils.getCurveTextWrapping(plotType, this).then();
text = await matsPlotUtils.getCurveTextWrapping(plotType, this);
}
return matsPlotUtils.getCurveText(plotType, this).then();
text = await matsPlotUtils.getCurveText(plotType, this);
return text;
}
return `${this.label}: Difference`;
},
Expand Down
2 changes: 1 addition & 1 deletion meteor_packages/mats-common/templates/help/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tabindex="-1"
aria-labelledby="helpModalLabel"
>
<div class="modal-dialog modal-style">
<div class="modal-dialog modal-lg modal-style">
<div class="modal-content bg-white pt-3">
<div class="modal-header border-bottom-0">
<h2 id="helpModalLabel" class="modal-title text-dark-blue">
Expand Down
Loading
Loading