Skip to content

Commit

Permalink
add backup status colors
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Aug 25, 2024
1 parent 37bd394 commit 1a0d350
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 9 deletions.
8 changes: 4 additions & 4 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@angular/platform-browser": "^18.1.0",
"@angular/platform-browser-dynamic": "^18.1.0",
"@angular/router": "^18.1.0",
"@mucsi96/ui-elements": "^59.0.0",
"@mucsi96/ui-elements": "^60.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3"
Expand Down
12 changes: 10 additions & 2 deletions client/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@
<ul bt-dropdown-menu>
@for(database of databases(); track database.name) {
<li>
<a routerLink="/database/{{ database.name }}">{{ database.name }}</a>
<a routerLink="/database/{{ database.name }}">{{
database.name
}}</a>
</li>
}
</ul>
</div>
@if (time) {
<h3 bt>
Last backup <span bt-badge>{{ time | relativeTime }}</span>
Last backup
<span
bt-badge
[attr.bt-green]="!olderThenOneDay(time) ? '' : null"
[attr.bt-red]="olderThenOneDay(time) ? '' : null"
>{{ time | relativeTime }}</span
>
</h3>
} }
</div>
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BackupsService } from './backups/backups.service';
import { RelativeTimePipe } from './utils/relativeTime.pipe';
import { DatabasesService } from './databases/databases.service';
import { Database } from '../types';
import { olderThenOneDay } from './utils/dateUtils';

@Component({
selector: 'app-root',
Expand All @@ -16,6 +17,7 @@ export class AppComponent {
databaseName = signal<string | undefined>(undefined);
databases: Signal<Database[] | undefined>;
lastBackupTime: Signal<Date | undefined>;
olderThenOneDay = olderThenOneDay

constructor(
private readonly route: ActivatedRoute,
Expand Down
10 changes: 9 additions & 1 deletion client/src/app/databases/databases.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ <h2 bt>
<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>{{ database.lastBackupTime | relativeTime }}</td>
<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 }}
</td>
} @else {
<td bt-no-wrap></td>
}
Expand Down
3 changes: 3 additions & 0 deletions client/src/app/databases/databases.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Router } from '@angular/router';
import { DatabasesService } from './databases.service';
import { Database } from '../../types';
import { RelativeTimePipe } from '../utils/relativeTime.pipe';
import { olderThenOneDay } from '../utils/dateUtils';

@Component({
selector: 'app-databases',
Expand All @@ -14,6 +15,7 @@ import { RelativeTimePipe } from '../utils/relativeTime.pipe';
export class DatabasesComponent {
databases: Signal<Database[] | undefined>;
loading: Signal<boolean>;
olderThenOneDay = olderThenOneDay;

constructor(
private readonly databasesService: DatabasesService,
Expand All @@ -26,4 +28,5 @@ export class DatabasesComponent {
selectDatabase(database: Database) {
this.router.navigate(['/database', database.name]);
}

}
3 changes: 3 additions & 0 deletions client/src/app/utils/dateUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function olderThenOneDay(date?: Date): boolean {
return !date || Date.now() - date.getTime() > 24 * 60 * 60 * 1000;
}
2 changes: 1 addition & 1 deletion client/src/mocks/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const databases: Database[] = [
tablesCount: 3,
totalRowCount: 12,
backupsCount: 3,
lastBackupTime: new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 3),
lastBackupTime: new Date(new Date().getTime() - 24 * 60 * 60 * 1000 * 0.5),
},
];

Expand Down

0 comments on commit 1a0d350

Please sign in to comment.