-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from rashidkpc/master
Time picker. Closes #57
- Loading branch information
Showing
9 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
define(function (require) { | ||
var module = require('modules').get('kibana/directives'); | ||
var $ = require('jquery'); | ||
var _ = require('lodash'); | ||
var moment = require('moment'); | ||
|
||
module.directive('inputDatetime', function () { | ||
return { | ||
restrict: 'A', | ||
require: 'ngModel', | ||
link: function ($scope, $elem, attrs, ngModel) { | ||
|
||
var format = 'YYYY-MM-DD HH:mm:ss.SSS'; | ||
|
||
$elem.after('<div class="input-datetime-format">' + format + '</div>'); | ||
|
||
// What should I make with the input from the user? | ||
var fromUser = function (text) { | ||
var parsed = moment(text, format); | ||
return parsed.isValid() ? parsed : undefined; | ||
}; | ||
|
||
// How should I present the data back to the user in the input field? | ||
var toUser = function (datetime) { | ||
return moment(datetime).format(format); | ||
}; | ||
|
||
ngModel.$parsers.push(fromUser); | ||
ngModel.$formatters.push(toUser); | ||
|
||
} | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
define(function (require) { | ||
var moment = require('moment'); | ||
var _ = require('lodash'); | ||
var datemath = require('utils/datemath'); | ||
|
||
require('modules') | ||
.get('kibana/filters') | ||
.filter('moment', function () { | ||
return function (datetime) { | ||
return function (datetime, roundUp) { | ||
var format = 'MMMM Do YYYY, HH:mm:ss.SSS'; | ||
return moment.isMoment(datetime) ? datetime.format(format) : undefined; | ||
var parsed = datemath.parse(datetime, roundUp); | ||
if (parsed) return parsed.format(format); | ||
return undefined; | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters