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:
Filip Barl
2017-06-20 12:31:22 +02:00
committed by GitHub
parent 5d6c965c47
commit eb64d3f09b
24 changed files with 292 additions and 187 deletions

View File

@@ -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 };
}