-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from damienbod/dev
Update UI
- Loading branch information
Showing
11 changed files
with
165 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import { Route } from '@angular/router'; | ||
import { CallApiComponent } from './call-api/call-api.component'; | ||
|
||
export const appRoutes: Route[] = []; | ||
export const appRoutes: Route[] = [ | ||
{ | ||
path: 'call-api', | ||
component: CallApiComponent | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h2>Data from API:</h2> | ||
|
||
<div> | ||
<button class="btn btn-link" (click)="getDirectApiData()">Get data from API direct</button> | ||
</div> | ||
|
||
<hr /> | ||
|
||
<pre>{{ dataFromAzureProtectedApi$ | async | json }}</pre> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { CallApiComponent } from './call-api.component'; | ||
|
||
describe('CallApiComponent', () => { | ||
let component: CallApiComponent; | ||
let fixture: ComponentFixture<CallApiComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [CallApiComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(CallApiComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Component, OnInit, inject } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-call-api', | ||
standalone: true, | ||
imports: [CommonModule], | ||
templateUrl: './call-api.component.html', | ||
styleUrl: './call-api.component.scss', | ||
}) | ||
|
||
export class CallApiComponent { | ||
|
||
private readonly httpClient = inject(HttpClient); | ||
dataFromAzureProtectedApi$: Observable<string[]>; | ||
|
||
getDirectApiData() { | ||
this.dataFromAzureProtectedApi$ = this.httpClient.get<string[]>( | ||
`${this.getCurrentHost()}/api/DirectApi` | ||
); | ||
} | ||
|
||
private getCurrentHost() { | ||
const host = window.location.host; | ||
const url = `${window.location.protocol}//${host}`; | ||
|
||
return url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
<h2>BFF OpenIddict Security architecture with Angular nx</h2> | ||
|
||
<ng-container | ||
*ngIf="userProfileClaims$ | async as userProfileClaims; else noAuth" | ||
> | ||
<ng-container *ngIf="userProfileClaims$ | async as userProfileClaims; else noAuth"> | ||
<div *ngIf="userProfileClaims?.isAuthenticated; else noAuth"> | ||
<button (click)="getDirectApiData()">get data from API direct</button> | ||
<form method="post" action="api/Account/Logout"> | ||
<button class="btn btn-link" type="submit">Sign out</button> | ||
</form> | ||
<nav class="navbar navbar-expand-lg navbar-light bg-light"> | ||
<a class="btn btn-link" href="./call-api">Call API</a> | ||
|
||
<form method="post" action="api/Account/Logout"> | ||
<button class="btn btn-link" type="submit">Sign out</button> | ||
</form> | ||
</nav> | ||
</div> | ||
|
||
<hr /> | ||
|
||
<h2>User profile:</h2> | ||
<pre>{{ userProfileClaims | json }}</pre> | ||
|
||
<hr /> | ||
|
||
<h2>get direct data using API:</h2> | ||
<pre>{{ dataFromAzureProtectedApi$ | async | json }}</pre> | ||
</ng-container> | ||
|
||
<ng-template #noAuth> | ||
<a class="btn btn-link" href="api/Account/Login">Log in</a> | ||
<nav class="navbar navbar-expand-lg navbar-light bg-light"> | ||
<a class="btn btn-link" href="api/Account/Login">Log in</a> | ||
</nav> | ||
</ng-template> | ||
|
||
<hr /> |