Skip to content

Commit

Permalink
add UTC timestamps to discovery list
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Apr 4, 2024
1 parent b62929e commit d3fcf5a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { Discovery } from "@/app/store/discovery/types";
import { DiscoveryMeta } from "@/app/store/discovery/types";
import type { RootState } from "@/app/store/root/types";
import { generateEmptyStateMsg, getTableStatus } from "@/app/utils";
import { formatUtcTimestamp } from "@/app/utils/time";

export enum Labels {
DiscoveriesList = "Discoveries list",
Expand Down Expand Up @@ -78,7 +79,11 @@ const generateRows = (
content: discovery.observer_hostname,
},
{
content: <div className="u-truncate">{discovery.last_seen}</div>,
content: (
<div className="u-truncate">
{formatUtcTimestamp(discovery.last_seen)}
</div>
),
},
{
content: (
Expand Down
4 changes: 2 additions & 2 deletions src/app/store/discovery/types/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { APIError } from "@/app/base/types";
import type { Model } from "@/app/store/types/model";
import type { Model, UtcTimestamp } from "@/app/store/types/model";
import type { GenericState } from "@/app/store/types/state";

export type Discovery = Model & {
Expand All @@ -10,7 +10,7 @@ export type Discovery = Model & {
hostname: string | null;
ip: string | null;
is_external_dhcp: boolean | null;
last_seen: string;
last_seen: UtcTimestamp;
mac_address: string | null;
mac_organization: string;
mdns: number | null;
Expand Down
3 changes: 2 additions & 1 deletion src/testing/factories/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { model } from "./model";

import type { Discovery } from "@/app/store/discovery/types";
import type { Model } from "@/app/store/types/model";

Check failure on line 6 in src/testing/factories/discovery.ts

View workflow job for this annotation

GitHub Actions / Lint

There should be at least one empty line between import groups
import { timestamp } from "./general";

Check failure on line 7 in src/testing/factories/discovery.ts

View workflow job for this annotation

GitHub Actions / Lint

`./general` import should occur before import of `./model`

export const discovery = extend<Model, Discovery>(model, {
discovery_id: () => `discovery-${random()}`,
Expand All @@ -13,7 +14,7 @@ export const discovery = extend<Model, Discovery>(model, {
hostname: "discovery-hostname",
ip: "192.168.1.1",
is_external_dhcp: false,
last_seen: "Wed, 08 Jul. 2020 05:35:4",
last_seen: () => timestamp("Wed, 08 Jul. 2020 05:35:4"),
mac_address: "00:00:00:00:00:00",
mac_organization: "Business Corp, Inc.",
mdns: 2,
Expand Down

0 comments on commit d3fcf5a

Please sign in to comment.