-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add absolute timestamp to uptime #1768
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import {DefinitionList} from '@gravity-ui/uikit'; | ||
|
||
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants'; | ||
import { | ||
formatDateTime, | ||
getDowntimeFromDateFormatted, | ||
getUptimeFromDateFormatted, | ||
} from '../../utils/dataFormatters/dataFormatters'; | ||
import {CellWithPopover} from '../CellWithPopover/CellWithPopover'; | ||
|
||
import i18n from './i18n'; | ||
|
||
interface NodeUptimeProps { | ||
StartTime?: string; | ||
DisconnectTime?: string; | ||
} | ||
|
||
export function NodeUptime({StartTime, DisconnectTime}: NodeUptimeProps) { | ||
let uptime: string | undefined; | ||
|
||
if (DisconnectTime) { | ||
uptime = getDowntimeFromDateFormatted(DisconnectTime); | ||
} else { | ||
uptime = getUptimeFromDateFormatted(StartTime); | ||
} | ||
|
||
if (!uptime) { | ||
return EMPTY_DATA_PLACEHOLDER; | ||
} | ||
return ( | ||
<CellWithPopover | ||
placement={['top', 'auto']} | ||
content={ | ||
<DefinitionList responsive> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we add Popover if nor StartTime neither DisconnectTime is provided? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uptime won't be calculated in such case ( |
||
{StartTime ? ( | ||
<DefinitionList.Item key={'StartTime'} name={i18n('start-time')}> | ||
{formatDateTime(StartTime, {withTimeZone: true})} | ||
</DefinitionList.Item> | ||
) : null} | ||
{DisconnectTime ? ( | ||
<DefinitionList.Item key={'DisconnectTime'} name={i18n('disconnect-time')}> | ||
{formatDateTime(DisconnectTime, {withTimeZone: true})} | ||
</DefinitionList.Item> | ||
) : null} | ||
</DefinitionList> | ||
} | ||
> | ||
{uptime} | ||
</CellWithPopover> | ||
); | ||
} | ||
|
||
interface TabletUptimeProps { | ||
ChangeTime?: string; | ||
} | ||
|
||
export function TabletUptime({ChangeTime}: TabletUptimeProps) { | ||
const uptime = getUptimeFromDateFormatted(ChangeTime); | ||
|
||
if (!uptime) { | ||
return EMPTY_DATA_PLACEHOLDER; | ||
} | ||
return ( | ||
<CellWithPopover | ||
placement={['top', 'auto']} | ||
content={ | ||
<DefinitionList responsive> | ||
<DefinitionList.Item key={'changeTime'} name={i18n('change-time')}> | ||
{formatDateTime(ChangeTime, {withTimeZone: true})} | ||
</DefinitionList.Item> | ||
</DefinitionList> | ||
} | ||
> | ||
{uptime} | ||
</CellWithPopover> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"start-time": "Start time", | ||
"disconnect-time": "Disconnect time", | ||
"change-time": "Change time" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {registerKeysets} from '../../../utils/i18n'; | ||
|
||
import en from './en.json'; | ||
|
||
const COMPONENT = 'ydb-uptime-viewer'; | ||
|
||
export default registerKeysets(COMPONENT, {en}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,6 @@ import type {TNodeInfo} from '../types/api/nodesList'; | |
import type {NodeHostsMap} from '../types/store/nodesList'; | ||
|
||
import {HOUR_IN_SECONDS} from './constants'; | ||
import { | ||
getDowntimeFromDateFormatted, | ||
getUptimeFromDateFormatted, | ||
} from './dataFormatters/dataFormatters'; | ||
|
||
import {valueIsDefined} from '.'; | ||
|
||
|
@@ -60,7 +56,6 @@ export interface PreparedNodeSystemState extends TSystemStateInfo { | |
Rack?: string; | ||
DC?: string; | ||
LoadAveragePercents?: number[]; | ||
Uptime: string; | ||
TenantName?: string; | ||
SharedCacheLimit?: number; | ||
SharedCacheUsed?: number; | ||
|
@@ -74,14 +69,6 @@ export function prepareNodeSystemState( | |
const DC = systemState.Location?.DataCenter || systemState.DataCenter; | ||
const TenantName = systemState?.Tenants?.[0]; | ||
|
||
let Uptime: PreparedNodeSystemState['Uptime']; | ||
|
||
if (systemState.DisconnectTime) { | ||
Uptime = getDowntimeFromDateFormatted(systemState.DisconnectTime); | ||
} else { | ||
Uptime = getUptimeFromDateFormatted(systemState.StartTime); | ||
} | ||
|
||
Comment on lines
-77
to
-84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's more about display, moved it to |
||
const LoadAveragePercents = calculateLoadAveragePercents(systemState); | ||
|
||
// 0 limit means that limit is not set, so it should be undefined | ||
|
@@ -94,7 +81,6 @@ export function prepareNodeSystemState( | |
...systemState, | ||
Rack, | ||
DC, | ||
Uptime, | ||
LoadAveragePercents, | ||
TenantName, | ||
SharedCacheLimit, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need
flex
to display progress bars correctly, for other values we needinline-flex
for proper align inside table