mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Add more meta information when line limit is hit (#33069)
* WIP: Add more info ro log line limit, remove redundant info * Refactor * Clean up * Adjust tests * Adjust spacing * Add test for new functionality * Update snapshot * Change solution, simplify * Remove redundant variables, makees it more clear * Update public/app/core/logs_model.ts Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
@@ -261,6 +261,23 @@ export function secondsToHms(seconds: number): string {
|
||||
return 'less than a millisecond'; //'just now' //or other string you like;
|
||||
}
|
||||
|
||||
// Format timeSpan (in sec) to string used in log's meta info
|
||||
export function msRangeToTimeString(rangeMs: number): string {
|
||||
const rangeSec = Number((rangeMs / 1000).toFixed());
|
||||
|
||||
const h = Math.floor(rangeSec / 60 / 60);
|
||||
const m = Math.floor(rangeSec / 60) - h * 60;
|
||||
const s = Number((rangeSec % 60).toFixed());
|
||||
let formattedH = h ? h + 'h' : '';
|
||||
let formattedM = m ? m + 'min' : '';
|
||||
let formattedS = s ? s + 'sec' : '';
|
||||
|
||||
formattedH && formattedM ? (formattedH = formattedH + ' ') : (formattedH = formattedH);
|
||||
(formattedM || formattedH) && formattedS ? (formattedM = formattedM + ' ') : (formattedM = formattedM);
|
||||
|
||||
return formattedH + formattedM + formattedS || 'less than 1sec';
|
||||
}
|
||||
|
||||
export function calculateInterval(range: TimeRange, resolution: number, lowLimitInterval?: string): IntervalValues {
|
||||
let lowLimitMs = 1; // 1 millisecond default low limit
|
||||
if (lowLimitInterval) {
|
||||
|
||||
Reference in New Issue
Block a user