Skip to content
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
7 changes: 6 additions & 1 deletion src/app/adf-api-docs/df-api-docs/df-api-docs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import { TranslocoModule } from '@ngneat/transloco';
import { saveRawAsFile } from 'src/app/shared/utilities/file';
import { UntilDestroy } from '@ngneat/until-destroy';
import { DfUserDataService } from 'src/app/shared/services/df-user-data.service';
import { SESSION_TOKEN_HEADER } from 'src/app/shared/constants/http-headers';
import {
SESSION_TOKEN_HEADER,
API_KEY_HEADER,
} from 'src/app/shared/constants/http-headers';
import {
mapCamelToSnake,
mapSnakeToCamel,
} from 'src/app/shared/utilities/case';
import { DfThemeService } from 'src/app/shared/services/df-theme.service';
import { AsyncPipe } from '@angular/common';
import { environment } from '../../../../environments/environment';

@UntilDestroy({ checkProperties: true })
@Component({
Expand Down Expand Up @@ -64,6 +68,7 @@ export class DfApiDocsComponent implements OnInit, AfterContentInit {
domNode: this.apiDocElement?.nativeElement,
requestInterceptor: (req: SwaggerUI.Request) => {
req['headers'][SESSION_TOKEN_HEADER] = this.userDataService.token;
req['headers'][API_KEY_HEADER] = environment.dfApiKey;
// Parse the request URL
const url = new URL(req['url']);
const params = new URLSearchParams(url.search);
Expand Down
2 changes: 1 addition & 1 deletion src/app/debug/debug.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-debug',
selector: 'df-app-debug',
template: `
<div *ngIf="debugInfo.length > 0">
<h3>Debug Information:</h3>
Expand Down
6 changes: 3 additions & 3 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Component } from '@angular/core';
import { TranslocoModule } from '@ngneat/transloco';

@Component({
selector: 'app-home',
selector: 'df-app-home',
template: '<h1>{{ "home.welcome" | transloco }}</h1>',
standalone: true,
imports: [TranslocoModule]
imports: [TranslocoModule],
})
export class HomeComponent {}
export class HomeComponent {}
16 changes: 13 additions & 3 deletions src/app/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ <h2>{{ 'login.title' | transloco }}</h2>
<form (ngSubmit)="onSubmit()">
<div>
<label for="username">{{ 'login.username' | transloco }}:</label>
<input type="text" id="username" name="username" [(ngModel)]="username" required>
<input
type="text"
id="username"
name="username"
[(ngModel)]="username"
required />
</div>
<div>
<label for="password">{{ 'login.password' | transloco }}:</label>
<input type="password" id="password" name="password" [(ngModel)]="password" required>
<input
type="password"
id="password"
name="password"
[(ngModel)]="password"
required />
</div>
<button type="submit">{{ 'login.submit' | transloco }}</button>
</form>
</div>
</div>
2 changes: 1 addition & 1 deletion src/app/login/login.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ button {
color: white;
border: none;
cursor: pointer;
}
}
2 changes: 1 addition & 1 deletion src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { UserService } from '../shared/services/user.service';
import { NotificationService } from '../shared/services/notification.service';

@Component({
selector: 'app-login',
selector: 'df-app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
})
Expand Down
4 changes: 2 additions & 2 deletions src/app/saml-callback/saml-callback.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SamlCallbackComponent implements OnInit {

private handleSamlLogin(jwt: string) {
this.authService.loginWithJwt(jwt).subscribe(
(result) => {
result => {
if (result && result.session_token) {
this.loggingService.log('SAML login successful');
this.router.navigate(['/home']);
Expand All @@ -43,4 +43,4 @@ export class SamlCallbackComponent implements OnInit {
}
);
}
}
}
19 changes: 15 additions & 4 deletions src/app/shared/guards/auth.guard.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import {
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
Router,
} from '@angular/router';
import { AuthService } from '../services/auth.service';

@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) {}
constructor(
private authService: AuthService,
private router: Router
) {}

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): boolean {
if (this.authService.isAuthenticated()) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/modules/side-nav.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { RouterModule } from '@angular/router';

@NgModule({
imports: [CommonModule, RouterModule, DfSideNavComponent],
exports: [DfSideNavComponent, RouterModule]
exports: [DfSideNavComponent, RouterModule],
})
export class SideNavModule { }
export class SideNavModule {}
8 changes: 4 additions & 4 deletions src/app/shared/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DfAuthService } from '../../adf-user-management/services/df-auth.servic
import { DfUserDataService } from './df-user-data.service';

@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class AuthService {
constructor(
Expand All @@ -14,9 +14,9 @@ export class AuthService {
) {}

loginWithJwt(jwt: string): Observable<any> {
return this.dfAuthService.loginWithToken(jwt).pipe(
tap(user => this.dfUserDataService.userData = user)
);
return this.dfAuthService
.loginWithToken(jwt)
.pipe(tap(user => (this.dfUserDataService.userData = user)));
}

setCurrentUser(user: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Injectable } from '@angular/core';
providedIn: 'root',
})
export class NotificationService {
constructor() {}
// constructor() {}

success(title: string, message: string) {
console.log('Success:', title, message);
Expand Down
2 changes: 1 addition & 1 deletion src/app/transloco-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export class TranslocoHttpLoader implements TranslocoLoader {
getTranslation(lang: string) {
return this.http.get<Translation>(`/assets/i18n/${lang}.json`);
}
}
}