set default for "Newer than" option

This commit is contained in:
Alexander Zobnin
2017-12-14 12:54:30 +03:00
parent 11ad51d5dc
commit f728d50a9f
5 changed files with 21 additions and 11 deletions

View File

@@ -110,8 +110,8 @@
<label class="gf-form-label width-10">Newer than</label> <label class="gf-form-label width-10">Newer than</label>
<input class="gf-form-input width-8" <input class="gf-form-input width-8"
ng-model="ctrl.panel.highlightNewerThan" ng-model="ctrl.panel.highlightNewerThan"
ng-model-onblur placeholder="1h"
ng-change="ctrl.render()"> ng-model-onblur ng-change="ctrl.render()">
</div> </div>
<gf-form-switch class="gf-form" <gf-form-switch class="gf-form"
label-class="width-16" label-class="width-16"

View File

@@ -602,9 +602,14 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap
}, { }, {
key: 'isNewTrigger', key: 'isNewTrigger',
value: function isNewTrigger(trigger) { value: function isNewTrigger(trigger) {
var highlightIntervalMs = utils.parseInterval(this.panel.highlightNewerThan); try {
var highlightNewerThanDefault = '1h';
var highlightIntervalMs = utils.parseInterval(this.panel.highlightNewerThan || highlightNewerThanDefault);
var durationSec = Date.now() - trigger.lastchangeUnix * 1000; var durationSec = Date.now() - trigger.lastchangeUnix * 1000;
return durationSec < highlightIntervalMs; return durationSec < highlightIntervalMs;
} catch (e) {
return false;
}
} }
}, { }, {
key: 'link', key: 'link',

File diff suppressed because one or more lines are too long

View File

@@ -110,8 +110,8 @@
<label class="gf-form-label width-10">Newer than</label> <label class="gf-form-label width-10">Newer than</label>
<input class="gf-form-input width-8" <input class="gf-form-input width-8"
ng-model="ctrl.panel.highlightNewerThan" ng-model="ctrl.panel.highlightNewerThan"
ng-model-onblur placeholder="1h"
ng-change="ctrl.render()"> ng-model-onblur ng-change="ctrl.render()">
</div> </div>
<gf-form-switch class="gf-form" <gf-form-switch class="gf-form"
label-class="width-16" label-class="width-16"

View File

@@ -458,9 +458,14 @@ export class TriggerPanelCtrl extends PanelCtrl {
} }
isNewTrigger(trigger) { isNewTrigger(trigger) {
const highlightIntervalMs = utils.parseInterval(this.panel.highlightNewerThan); try {
const highlightNewerThanDefault = '1h';
const highlightIntervalMs = utils.parseInterval(this.panel.highlightNewerThan || highlightNewerThanDefault);
const durationSec = (Date.now() - trigger.lastchangeUnix * 1000); const durationSec = (Date.now() - trigger.lastchangeUnix * 1000);
return durationSec < highlightIntervalMs; return durationSec < highlightIntervalMs;
} catch (e) {
return false;
}
} }
link(scope, elem, attrs, ctrl) { link(scope, elem, attrs, ctrl) {