Skip to content

Commit

Permalink
improve no latest backup support
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Sep 1, 2024
1 parent c5dcb75 commit ef08e1e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
6 changes: 3 additions & 3 deletions client/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
}
</ul>
</div>
@if (time) {

<h3 bt>
Last backup
<span
bt-badge
[attr.bt-green]="!olderThenOneDay(time) ? '' : null"
[attr.bt-red]="olderThenOneDay(time) ? '' : null"
>{{ time | relativeTime }}</span
>@if (time) {{{ time | relativeTime }}} @else { — }</span
>
</h3>
} }
}
</div>
</nav>
</header>
Expand Down
8 changes: 3 additions & 5 deletions client/src/app/databases/databases.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ <h2 bt>
<td bt-no-wrap bt-center-align>{{ database.tablesCount }}</td>
<td bt-no-wrap bt-center-align>{{ database.totalRowCount }}</td>
<td bt-no-wrap bt-center-align>{{ database.backupsCount }}</td>
@if (database.lastBackupTime) {

<td
bt-no-wrap
bt-right-align
bt-text
[attr.bt-green]="!olderThenOneDay(database.lastBackupTime) ? '' : null"
[attr.bt-red]="olderThenOneDay(database.lastBackupTime) ? '' : null"
>
{{ database.lastBackupTime | relativeTime }}
@if (database.lastBackupTime)
{{{ database.lastBackupTime | relativeTime }}}@else { — }
</td>
} @else {
<td bt-no-wrap></td>
}
</tr>
}
</tbody>
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/databases/databases.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export class DatabasesService {
map((databases) =>
databases.map((db) => ({
...db,
lastBackupTime: new Date(db.lastBackupTime),
lastBackupTime:
db.lastBackupTime && new Date(db.lastBackupTime),
}))
),
tap(() => this.loading.set(false))
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/utils/dateUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function olderThenOneDay(date?: Date): boolean {
export function olderThenOneDay(date?: Date | null): boolean {
return !date || Date.now() - date.getTime() > 24 * 60 * 60 * 1000;
}
7 changes: 7 additions & 0 deletions client/src/mocks/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ const databases: Database[] = [
backupsCount: 3,
lastBackupTime: new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 0.5),
},
{
name: 'db3',
tablesCount: 1,
totalRowCount: 3,
backupsCount: 1,
lastBackupTime: null,
},
];

function getDatabase(name: string): Database {
Expand Down
2 changes: 1 addition & 1 deletion client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type Database = {
tablesCount: number;
totalRowCount: number;
backupsCount: number;
lastBackupTime: Date;
lastBackupTime: Date | null;
};

export type Table = {
Expand Down

0 comments on commit ef08e1e

Please sign in to comment.