diff --git a/apps/web/src/dashboard/query-builder.js b/apps/web/src/dashboard/query-builder.js index 3b8705d..6972555 100644 --- a/apps/web/src/dashboard/query-builder.js +++ b/apps/web/src/dashboard/query-builder.js @@ -20,7 +20,7 @@ class QueryBuilder { this.onChange = onChange; this.logic = '$and'; this.consider = 'up'; // 'up' | 'down' - this.rules = [this._emptyRule()]; + this.rules = this._defaultRules(); this.render(); } @@ -28,6 +28,16 @@ class QueryBuilder { return { field: 'status', operator: '$eq', value: '', headerName: '', selectorValue: '', jsonPath: '' }; } + // The runtime default when no query is set: status is 2xx. Pre-populate the + // builder with this so users see what "default" actually means and can edit + // it instead of guessing. + _defaultRules() { + return [ + { field: 'status', operator: '$gte', value: '200', headerName: '', selectorValue: '', jsonPath: '' }, + { field: 'status', operator: '$lt', value: '300', headerName: '', selectorValue: '', jsonPath: '' }, + ]; + } + getQuery() { const conditions = this.rules .map(r => this._ruleToQuery(r)) @@ -83,7 +93,7 @@ class QueryBuilder { setQuery(query) { if (!query || typeof query !== 'object') { - this.rules = [this._emptyRule()]; + this.rules = this._defaultRules(); this.logic = '$and'; this.consider = 'up'; this.render(); diff --git a/apps/web/src/views/partials/monitor-form.ejs b/apps/web/src/views/partials/monitor-form.ejs index 0a5d206..6429937 100644 --- a/apps/web/src/views/partials/monitor-form.ejs +++ b/apps/web/src/views/partials/monitor-form.ejs @@ -174,7 +174,7 @@
Define <% if (isEdit) { %>up/down conditions<% } else { %>when this monitor should be considered "up"<% } %>. Defaults to status < 400.
+Define <% if (isEdit) { %>up/down conditions<% } else { %>when this monitor should be considered "up"<% } %>. Defaults to a 2xx status (shown below — edit to customise).