Skip to content

Commit adb96de

Browse files
committed
DI issue Fixed
1 parent beb3f41 commit adb96de

File tree

14 files changed

+112
-20
lines changed

14 files changed

+112
-20
lines changed

web/package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
},
1111
"private": true,
1212
"dependencies": {
13-
"@angular/cdk": "^20.0.2",
13+
"@angular/cdk": "^20.0.4",
1414
"@angular/common": "^20.0.5",
1515
"@angular/compiler": "^20.0.5",
1616
"@angular/core": "^20.0.5",
1717
"@angular/forms": "^20.0.5",
18-
"@angular/material": "^20.0.2",
18+
"@angular/material": "^20.0.4",
1919
"@angular/platform-browser": "^20.0.5",
2020
"@angular/router": "^20.0.5",
2121
"ngx-infinite-scroll": "^20.0.0",

web/src/app/_components/layout/toolbar/toolbar.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<button routerLink="/" mat-button>Home</button>
88
<button routerLink="/images" mat-button>Images</button>
99
<button routerLink="/dashboard" mat-button>Dashboard</button>
10+
<button routerLink="/admindashboard" mat-button>Admin Dashboard</button>
1011
<span class="spacer"></span>
1112

1213
@if (isAuthenticated() && profile()) {

web/src/app/_components/picture/picture-dialog/picture-dialog.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
.dialog-container {
2-
position: relative;
3-
background: black;
2+
position: fixed;
3+
top: 50%;
4+
left: 50%;
5+
transform: translate(-50%, -50%);
6+
//background: black;
47
display: flex;
58
align-items: center;
69
justify-content: center;
710
padding: 2rem;
8-
height: 100%;
11+
width: 800px; /* fixed width for dialog */
12+
max-height: 90vh; /* limit height */
13+
border-radius: 12px;
914
}
1015

11-
img {
12-
max-width: 100%;
13-
max-height: 100vh;
16+
.dialog-container img {
17+
width: 100%; /* image fills dialog width */
18+
height: auto; /* maintain aspect ratio */
19+
max-height: 90vh; /* prevent image from overflowing viewport height */
1420
object-fit: contain;
1521
border-radius: 12px;
1622
}
1723

24+
1825
.close-btn {
1926
position: absolute;
2027
top: 1rem;

web/src/app/_components/unauthorized/unauthorized.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
.unauthorized-container {
2-
height: 100vh;
2+
height: calc(100vh - 128px);
33
display: flex;
4+
position: relative;
45
align-items: center;
56
justify-content: center;
6-
background: linear-gradient(135deg, #ff6b6b, #f06595);
7+
//background: linear-gradient(135deg, #ff6b6b, #f06595);
78
color: white;
89
text-align: center;
910
font-family: 'Segoe UI', sans-serif;
1011
}
1112

1213
.content {
13-
background-color: rgba(0, 0, 0, 0.25);
14+
background-color: rgba(0, 0, 0, 0.45);
1415
padding: 2rem 3rem;
1516
border-radius: 1.5rem;
1617
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { TestBed } from '@angular/core/testing';
2+
import { CanActivateFn } from '@angular/router';
3+
4+
import { adminGuard } from './admin-guard';
5+
6+
describe('adminGuard', () => {
7+
const executeGuard: CanActivateFn = (...guardParameters) =>
8+
TestBed.runInInjectionContext(() => adminGuard(...guardParameters));
9+
10+
beforeEach(() => {
11+
TestBed.configureTestingModule({});
12+
});
13+
14+
it('should be created', () => {
15+
expect(executeGuard).toBeTruthy();
16+
});
17+
});

web/src/app/_guards/admin-guard.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { inject } from '@angular/core';
2+
import { CanActivateFn, Router } from '@angular/router';
3+
//import { AuthService } from '../_services/auth-service';
4+
import { map } from 'rxjs';
5+
import { hasRole } from '../_services/shared/auth-roles';
6+
import { UserService } from '../_services/user-service';
7+
8+
export const adminGuard: CanActivateFn = () => {
9+
const router = inject(Router);
10+
const userService = inject(UserService);
11+
12+
if (!userService || typeof userService.getProfile !== 'function') {
13+
return router.createUrlTree(['/unauthorized']);
14+
}
15+
16+
return userService.getProfile().pipe(
17+
map(profile => hasRole(profile, 'admin') ? true : router.createUrlTree(['/unauthorized']))
18+
);
19+
20+
21+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>admin-dashboard works!</p>

web/src/app/_pages/admin/admin-dashboard/admin-dashboard.scss

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { AdminDashboard } from './admin-dashboard';
4+
5+
describe('AdminDashboard', () => {
6+
let component: AdminDashboard;
7+
let fixture: ComponentFixture<AdminDashboard>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [AdminDashboard]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(AdminDashboard);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});

0 commit comments

Comments
 (0)