Trigger panel: able to set custom last change time format (based
on moment.js).
This commit is contained in:
@@ -81,7 +81,7 @@ function (angular, app, _, $, moment, config, PanelMeta) {
|
||||
sortTriggersBy: { text: 'last change', value: 'lastchange' },
|
||||
showEvents: { text: 'Problem events', value: '1' },
|
||||
triggerSeverity: grafanaDefaultSeverity,
|
||||
okEventColor: '#890F02'
|
||||
okEventColor: '#890F02',
|
||||
};
|
||||
|
||||
_.defaults($scope.panel, panelDefaults);
|
||||
@@ -97,7 +97,8 @@ function (angular, app, _, $, moment, config, PanelMeta) {
|
||||
var scopeDefaults = {
|
||||
metric: {},
|
||||
inputStyles: {},
|
||||
oldTarget: _.cloneDeep($scope.panel.triggers)
|
||||
oldTarget: _.cloneDeep($scope.panel.triggers),
|
||||
defaultTimeFormat: "DD MMM YYYY HH:mm:ss"
|
||||
};
|
||||
_.defaults($scope, scopeDefaults);
|
||||
|
||||
@@ -141,7 +142,12 @@ function (angular, app, _, $, moment, config, PanelMeta) {
|
||||
// Format last change and age
|
||||
trigger.lastchangeUnix = Number(trigger.lastchange);
|
||||
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);
|
||||
|
||||
// Set color
|
||||
|
||||
Reference in New Issue
Block a user