CritasWang opened a new pull request, #27:
URL: https://github.com/apache/tsfile-viewer/pull/27

   ## Summary
   
   Fixes two defects in the Data Preview of table-model TsFiles, plus a related 
`atob` regression.
   
   ### 1. Header/body column misalignment
   On table-model files, `measurements` also contains the tag columns (e.g. 
`plant`, `device`). The fixed **device** column used `key`/`dataIndex = 
"device"`, colliding with a tag column also named `device`. Since antdv `Table` 
distinguishes columns by `key`, the header desynced from the body, and 
`flatRow.device` was 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.NaN`
   Source timestamps can be nanoseconds (19 digits, e.g. 
`1692611833503000000`), which overflow JS `Date` → `Invalid Date` → `NaN`.
   
   **Fix**:
   - Added `normalizeToMs()` (in `utils/timestamp.ts`) to auto-scale seconds / 
milliseconds / microseconds / nanoseconds to milliseconds.
   - Display stays at millisecond precision. The **exact** original value is 
preserved without a backend change via a scoped `transformResponse` hook that 
captures the raw timestamp digit string **before** `JSON.parse` (avoiding lossy 
`double` conversion), exposed on hover, with an info banner explaining the 
behavior.
   - CSV export timestamps now use `normalizeToMs` too.
   
   ### 3. `atob` regression fix
   After fileIds became URL-safe base64, `atob()` failed on `-`/`_` characters 
(and never handled UTF-8 for non-ASCII paths). Extracted 
`encodeFileId`/`decodeFileId` into `utils/fileId.ts` and replaced all six call 
sites (file tree, data-preview, chart, metadata).
   
   ## Testing
   - `pnpm build` (vue-tsc + vite) passes.
   - Verified end-to-end in the browser on a real nanosecond table-model file: 
columns align, timestamp displays as `2023-08-21 17:57:13.503`, hover shows the 
exact raw value, and sub-millisecond precision is preserved losslessly (raw 
string `...123456` kept exact, vs `...123500` under naive `String(double)`).
   
   ## Notes
   `timestampRaw` is currently preserved only on the data-preview endpoint. The 
chart endpoint could get the same treatment if full nanosecond fidelity is 
needed there.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to