mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 10:11:03 +00:00
Make API calls with time travel timestamp (#2600)
* Node details fetching reports at proper timestamp. * Corrected all the relevant timestamps in the UI. * Renamed some state variables. * Time travel works for topologies list. * Added a whole screen overlay for time travel. * Polished the backend. * Make time travel work also with the Resource View. * Fixed the jest tests. * Fixed the empty view message for resource view. * Some naming polishing. * Addressed the comments.
This commit is contained in:
@@ -89,18 +89,20 @@ export function ipToPaddedString(value) {
|
||||
// Formats metadata values. Add a key to the `formatters` obj
|
||||
// that matches the `dataType` of the field. You must return an Object
|
||||
// with the keys `value` and `title` defined.
|
||||
export function formatDataType(field) {
|
||||
// `referenceTimestamp` is the timestamp we've time-travelled to.
|
||||
export function formatDataType(field, referenceTimestampStr = null) {
|
||||
const formatters = {
|
||||
datetime(dateString) {
|
||||
const date = moment(new Date(dateString));
|
||||
datetime(timestampString) {
|
||||
const timestamp = moment(timestampString);
|
||||
const referenceTimestamp = referenceTimestampStr ? moment(referenceTimestampStr) : moment();
|
||||
return {
|
||||
value: date.fromNow(),
|
||||
title: date.format('YYYY-MM-DD HH:mm:ss.SSS')
|
||||
value: timestamp.from(referenceTimestamp),
|
||||
title: timestamp.utc().toISOString()
|
||||
};
|
||||
}
|
||||
};
|
||||
const format = formatters[field.dataType];
|
||||
return format
|
||||
? format(field.value)
|
||||
: {value: field.value, title: field.value};
|
||||
: { value: field.value, title: field.value };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user