Merge pull request #6759 from bevacqua/feature/config-switch-dow

Added advanced setting to tweak starting day of week
This commit is contained in:
Spencer 2016-04-20 19:57:52 -05:00
commit 40b2645db9
5 changed files with 34 additions and 25 deletions

View file

@ -11,6 +11,7 @@ compatible with other configuration settings. Deleting a custom setting removes
`dateFormat`:: The format to use for displaying pretty-formatted dates.
`dateFormat:tz`:: The timezone that Kibana uses. The default value of `Browser` uses the timezone detected by the browser.
`dateFormat:scaled`:: These values define the format used to render ordered time-based data. Formatted timestamps must
`dateFormat:dow`:: This property defines what day weeks should start on.
adapt to the interval between measurements. Keys are http://en.wikipedia.org/wiki/ISO_8601#Time_intervals[ISO8601 intervals].
`defaultIndex`:: Default is `null`. This property specifies the default index.
`metaFields`:: An array of fields outside of `_source`. Kibana merges these fields into the document when displaying the

View file

@ -2,8 +2,10 @@ import moment from 'moment-timezone';
import _ from 'lodash';
export default function configDefaultsProvider() {
// wrapped in provider so that a new instance is given to each app/test
const weekdays = moment.weekdays().slice();
const [defaultWeekday] = weekdays;
// wrapped in provider so that a new instance is given to each app/test
return {
'buildNum': {
readonly: true
@ -46,6 +48,12 @@ export default function configDefaultsProvider() {
' <a href="http://en.wikipedia.org/wiki/ISO_8601#Time_intervals" target="_blank">' +
'ISO8601 intervals.</a>'
},
'dateFormat:dow': {
value: defaultWeekday,
description: 'What day should weeks start on?',
type: 'select',
options: weekdays
},
'defaultIndex': {
value: null,
description: 'The index to access if no index is set',

View file

@ -19,11 +19,9 @@ uiRoutes
uiModules
.get('kibana')
.service('timefilter', function (Private, globalState, $rootScope, config) {
let Events = Private(EventsProvider);
let diff = Private(UtilsDiffTimePickerValsProvider);
function convertISO8601(stringTime) {
let obj = moment(stringTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ', true);
return obj.isValid() ? obj : stringTime;

View file

@ -1,3 +1,4 @@
import moment from 'moment';
import UiModules from 'ui/modules';
import chromeNavControlsRegistry from 'ui/registry/chrome_nav_controls';
import { once, clone } from 'lodash';
@ -6,7 +7,7 @@ import toggleHtml from './kbn_global_timepicker.html';
UiModules
.get('kibana')
.directive('kbnGlobalTimepicker', (timefilter, globalState, $rootScope) => {
.directive('kbnGlobalTimepicker', (timefilter, globalState, $rootScope, config) => {
const listenForUpdates = once($scope => {
$scope.$listen(timefilter, 'update', (newVal, oldVal) => {
globalState.time = clone(timefilter.time);
@ -18,6 +19,12 @@ UiModules
return {
template: toggleHtml,
link: ($scope, $el, attrs) => {
config.$bind($scope, 'dateFormat:dow', 'dateFormat_dow');
$scope.$watch('dateFormat_dow', function (day) {
const dow = moment.weekdays().indexOf(day);
moment.locale(moment.locale(), { week: { dow } });
});
listenForUpdates($rootScope);
$rootScope.timefilter = timefilter;

View file

@ -15,7 +15,6 @@ let notify = new Notifier({
location: 'timepicker',
});
module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshIntervals) {
return {
restrict: 'E',
@ -28,10 +27,6 @@ module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshInter
},
template: html,
controller: function ($scope) {
let init = function () {
$scope.setMode($scope.mode);
};
$scope.format = 'MMMM Do YYYY, HH:mm:ss.SSS';
$scope.modes = ['quick', 'relative', 'absolute'];
$scope.activeTab = $scope.activeTab || 'filter';
@ -115,7 +110,7 @@ module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshInter
$scope.mode = thisMode;
};
$scope.setQuick = function (from, to, description) {
$scope.setQuick = function (from, to) {
$scope.from = from;
$scope.to = to;
};
@ -154,7 +149,7 @@ module.directive('kbnTimepicker', function (quickRanges, timeUnits, refreshInter
$scope.interval = interval;
};
init();
$scope.setMode($scope.mode);
}
};
});