diff --git a/web/skins/classic/views/js/montagereview.js b/web/skins/classic/views/js/montagereview.js index 92ffb9849..a02e11d69 100644 --- a/web/skins/classic/views/js/montagereview.js +++ b/web/skins/classic/views/js/montagereview.js @@ -1316,23 +1316,29 @@ function loadEventData(e) { const op_name = 'filter[Query][terms]['+found[1]+'][op]'; const op = this.form.elements[op_name]; if (attr) { - if (attr.value==='Monitor') attr.value='MonitorId'; - // DateTime is a filter-engine pseudo-attribute, not an Events - // column: Filter.php resolves 'DateTime' and 'StartDateTime' to the - // same E.StartDateTime. The API takes column names, and silently - // ignores a term it cannot resolve rather than erroring, so leaving - // it as DateTime returns every event ever instead of the window. - if (attr.value==='DateTime') attr.value='StartDateTime'; + // Translate to the column names the API expects, in a local rather + // than by writing back to attr.value. The form is submitted when a + // filter changes, and montagereview.php decides whether the range + // terms are already present by looking for 'DateTime'; a form left + // holding 'StartDateTime' came back with a second, duplicate pair. + // Filter.php resolves 'DateTime' and 'StartDateTime' to the same + // E.StartDateTime, so only the query needs the column name. The + // API silently ignores a term it cannot resolve rather than + // erroring, which is why an untranslated DateTime returned every + // event ever instead of the requested window. + let apiAttr = attr.value; + if (apiAttr === 'Monitor') apiAttr = 'MonitorId'; + if (apiAttr === 'DateTime') apiAttr = 'StartDateTime'; let urlVal = val; // Normalize date/time values to YYYY-MM-DD HH:mm:ss for the API URL. // Locale formats using / as separator break the URL path. - if (/Date|Time/.test(attr.value)) { + if (/Date|Time/.test(apiAttr)) { const m = moment(val); if (m.isValid()) { urlVal = m.format('YYYY-MM-DD HH:mm:ss'); } } - url += '/'+attr.value+' '+op.value+':'+encodeURIComponent(urlVal); + url += '/'+apiAttr+' '+op.value+':'+encodeURIComponent(urlVal); } else { console.warn('No attr for '+attr_name); }