update: default query
This commit is contained in:
parent
9425fb2454
commit
74aa5c8376
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@
|
|||
|
||||
<div>
|
||||
<label class="block text-sm text-gray-400 mb-1.5"><%= isEdit ? 'Conditions' : 'Query Conditions' %> <span class="text-gray-600">(optional)</span></label>
|
||||
<p class="text-xs text-gray-600 mb-3">Define <% if (isEdit) { %>up/down conditions<% } else { %>when this monitor should be considered "up"<% } %>. Defaults to status < 400.</p>
|
||||
<p class="text-xs text-gray-600 mb-3">Define <% if (isEdit) { %>up/down conditions<% } else { %>when this monitor should be considered "up"<% } %>. Defaults to a 2xx status (shown below — edit to customise).</p>
|
||||
<div id="<%= prefix %>query-builder"></div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue