fix: correct table column alignment and non-millisecond timestamp formatting#27
Merged
HTHou merged 1 commit intoJul 2, 2026
Conversation
…matting
Data preview had two defects on table-model TsFiles:
1. Header/body column misalignment: the fixed "device" column shared the
same key/dataIndex ("device") with a tag column also named "device",
which collided in antdv Table and desynced header from body. The fixed
identity column now uses a reserved key "__device__" isolated from tag
columns.
2. Timestamps rendered as "NaN-NaN-NaN": nanosecond (19-digit) timestamps
overflow JS Date. Added normalizeToMs() to auto-scale sec/ms/us/ns to
milliseconds. Display stays at millisecond precision; the exact original
value is preserved via a transformResponse hook that captures the raw
digit string before JSON.parse (avoiding lossy double conversion) and is
shown on hover, with an info banner explaining the precision behavior.
Also fixes an atob() regression: after fileIds became URL-safe base64,
atob() failed on "_"/"-" chars. Extracted encode/decodeFileId into
utils/fileId.ts and replaced all six call sites (file tree, data-preview,
chart, metadata). CSV export timestamps now use normalizeToMs too.
HTHou
pushed a commit
that referenced
this pull request
Jul 2, 2026
The data preview table hardcoded the virtual-scroll viewport height (scroll.y = 480). After #27 added the timestamp-precision info banner above the table, the fixed height no longer matched the actual space left in the flex layout, so the table body overflowed onto the bottom pagination bar. Replace the hardcoded height with a measured one: wrap the table in a flex-1 container and use a ResizeObserver to compute scroll.y from the container's real client height, subtracting the measured header height plus a scrollbar/border reserve. Re-measure after loading/data changes (nextTick) since the column toolbar, info banner and pagination toggle visibility. This adapts automatically to any future elements added above or below the table instead of relying on a magic constant. Also make .ant-card-body a flex column so the wrapper's flex-1 receives the real remaining height, and drop an unused Spin import.
HTHou
pushed a commit
that referenced
this pull request
Jul 2, 2026
The data preview table hardcoded the virtual-scroll viewport height (scroll.y = 480). After #27 added the timestamp-precision info banner above the table, the fixed height no longer matched the actual space left in the flex layout, so the table body overflowed onto the bottom pagination bar. Replace the hardcoded height with a measured one: wrap the table in a flex-1 container and use a ResizeObserver to compute scroll.y from the container's real client height, subtracting the measured header height plus a scrollbar/border reserve. Re-measure after loading/data changes (nextTick) since the column toolbar, info banner and pagination toggle visibility. This adapts automatically to any future elements added above or below the table instead of relying on a magic constant. Also make .ant-card-body a flex column so the wrapper's flex-1 receives the real remaining height, and drop an unused Spin import.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two defects in the Data Preview of table-model TsFiles, plus a related
atobregression.1. Header/body column misalignment
On table-model files,
measurementsalso contains the tag columns (e.g.plant,device). The fixed device column usedkey/dataIndex = "device", colliding with a tag column also nameddevice. Since antdvTabledistinguishes columns bykey, the header desynced from the body, andflatRow.devicewas overwritten by the measurement value.Fix: the fixed identity column now uses a reserved key
__device__, fully isolated from tag columns. Tree-model files are unaffected.2. Timestamps rendered as
NaN-NaN-NaN NaN:NaN:NaN.NaNSource timestamps can be nanoseconds (19 digits, e.g.
1692611833503000000), which overflow JSDate→Invalid Date→NaN.Fix:
normalizeToMs()(inutils/timestamp.ts) to auto-scale seconds / milliseconds / microseconds / nanoseconds to milliseconds.transformResponsehook that captures the raw timestamp digit string beforeJSON.parse(avoiding lossydoubleconversion), exposed on hover, with an info banner explaining the behavior.normalizeToMstoo.3.
atobregression fixAfter fileIds became URL-safe base64,
atob()failed on-/_characters (and never handled UTF-8 for non-ASCII paths). ExtractedencodeFileId/decodeFileIdintoutils/fileId.tsand replaced all six call sites (file tree, data-preview, chart, metadata).Testing
pnpm build(vue-tsc + vite) passes.2023-08-21 17:57:13.503, hover shows the exact raw value, and sub-millisecond precision is preserved losslessly (raw string...123456kept exact, vs...123500under naiveString(double)).Notes
timestampRawis currently preserved only on the data-preview endpoint. The chart endpoint could get the same treatment if full nanosecond fidelity is needed there.