Trigger panel: able to set custom last change time format (based
on moment.js).
This commit is contained in:
@@ -61,7 +61,7 @@
|
|||||||
placeholder="trigger name"
|
placeholder="trigger name"
|
||||||
class="input-large tight-form-input last"
|
class="input-large tight-form-input last"
|
||||||
ng-style="panel.triggers.trigger.style"
|
ng-style="panel.triggers.trigger.style"
|
||||||
empty-to-null">
|
empty-to-null>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
@@ -192,6 +192,38 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tight-form">
|
||||||
|
<ul class="tight-form-list">
|
||||||
|
<li class="tight-form-item">
|
||||||
|
<strong>Custom Last change format</strong>
|
||||||
|
<label class="checkbox-label" for="panel.customLastChangeFormat"> </label>
|
||||||
|
<input class="cr1"
|
||||||
|
id="panel.customLastChangeFormat"
|
||||||
|
type="checkbox"
|
||||||
|
ng-change="get_data()"
|
||||||
|
ng-model="panel.customLastChangeFormat"
|
||||||
|
ng-checked="panel.customLastChangeFormat">
|
||||||
|
<label for="panel.customLastChangeFormat" class="cr1"></label>
|
||||||
|
</li>
|
||||||
|
<li ng-if="panel.customLastChangeFormat">
|
||||||
|
<input type="text"
|
||||||
|
ng-model="panel.lastChangeFormat"
|
||||||
|
ng-blur="get_data()"
|
||||||
|
placeholder="dddd, MMMM Do YYYY, h:mm:ss a"
|
||||||
|
class="tight-form-input"
|
||||||
|
style="width: 300px"
|
||||||
|
empty-to-null>
|
||||||
|
</li>
|
||||||
|
<li class="tight-form-item last" ng-if="panel.customLastChangeFormat">
|
||||||
|
<a href="http://momentjs.com/docs/#/displaying/format/" target="_blank">
|
||||||
|
<i class="fa fa-question-circle"
|
||||||
|
bs-tooltip="'See moment.js dosc for time format.'">
|
||||||
|
</i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section">
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ function (angular, app, _, $, moment, config, PanelMeta) {
|
|||||||
sortTriggersBy: { text: 'last change', value: 'lastchange' },
|
sortTriggersBy: { text: 'last change', value: 'lastchange' },
|
||||||
showEvents: { text: 'Problem events', value: '1' },
|
showEvents: { text: 'Problem events', value: '1' },
|
||||||
triggerSeverity: grafanaDefaultSeverity,
|
triggerSeverity: grafanaDefaultSeverity,
|
||||||
okEventColor: '#890F02'
|
okEventColor: '#890F02',
|
||||||
};
|
};
|
||||||
|
|
||||||
_.defaults($scope.panel, panelDefaults);
|
_.defaults($scope.panel, panelDefaults);
|
||||||
@@ -97,7 +97,8 @@ function (angular, app, _, $, moment, config, PanelMeta) {
|
|||||||
var scopeDefaults = {
|
var scopeDefaults = {
|
||||||
metric: {},
|
metric: {},
|
||||||
inputStyles: {},
|
inputStyles: {},
|
||||||
oldTarget: _.cloneDeep($scope.panel.triggers)
|
oldTarget: _.cloneDeep($scope.panel.triggers),
|
||||||
|
defaultTimeFormat: "DD MMM YYYY HH:mm:ss"
|
||||||
};
|
};
|
||||||
_.defaults($scope, scopeDefaults);
|
_.defaults($scope, scopeDefaults);
|
||||||
|
|
||||||
@@ -141,7 +142,12 @@ function (angular, app, _, $, moment, config, PanelMeta) {
|
|||||||
// Format last change and age
|
// Format last change and age
|
||||||
trigger.lastchangeUnix = Number(trigger.lastchange);
|
trigger.lastchangeUnix = Number(trigger.lastchange);
|
||||||
var timestamp = moment.unix(trigger.lastchangeUnix);
|
var timestamp = moment.unix(trigger.lastchangeUnix);
|
||||||
triggerObj.lastchange = timestamp.format("DD MMM YYYY, HH:mm:ss");
|
if ($scope.panel.customLastChangeFormat) {
|
||||||
|
// User defined format
|
||||||
|
triggerObj.lastchange = timestamp.format($scope.panel.lastChangeFormat);
|
||||||
|
} else {
|
||||||
|
triggerObj.lastchange = timestamp.format($scope.defaultTimeFormat);
|
||||||
|
}
|
||||||
triggerObj.age = timestamp.fromNow(true);
|
triggerObj.age = timestamp.fromNow(true);
|
||||||
|
|
||||||
// Set color
|
// Set color
|
||||||
|
|||||||
Reference in New Issue
Block a user