Skip to content
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: Don't show seconds on last seen and make creation time relative #2031

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { DateArg } from 'date-fns/types';
export class RelativeTimeComponent {
@Input() date?: DateArg<Date>;
@Input() suffix = true;
@Input() showSeconds = true;

get relativeTime(): string {
if (!this.date) return '';
Expand All @@ -24,6 +25,7 @@ export class RelativeTimeComponent {

get absoluteTime(): string {
if (!this.date) return '';
return format(this.date, 'PPpp');
if (this.showSeconds) return format(this.date, 'PPpp');
return format(this.date, 'PPp');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<ng-container matColumnDef="created_at">
<th mat-header-cell *matHeaderCellDef>Creation date</th>
<td mat-cell *matCellDef="let element">
{{ element.created_at | date: "EE, dd MMM y HH:mm:ss" }}
<app-relative-time [date]="element.created_at" />
</td>
</ng-container>

Expand All @@ -62,6 +62,7 @@
[date]="
subMinutes(Date.now(), element.idle_state.idle_for_minutes!)
"
[showSeconds]="false"
/>
}
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
import { Meta, moduleMetadata, StoryObj } from '@storybook/angular';
import { userEvent, within } from '@storybook/test';
import MockDate from 'mockdate';
import { of } from 'rxjs';
import {
Session,
Expand All @@ -22,6 +23,9 @@ import { SessionOverviewComponent } from './session-overview.component';
const meta: Meta<SessionOverviewComponent> = {
title: 'Session Components/Session Overview',
component: SessionOverviewComponent,
beforeEach: () => {
MockDate.set(new Date('2024-05-01'));
},
};

export default meta;
Expand Down
Loading