Added login/logout button to topbar.
This commit is contained in:
parent
3e9a9f9dc5
commit
b8a92534d9
6
src/app/auth/login-button/login-button.component.html
Normal file
6
src/app/auth/login-button/login-button.component.html
Normal file
@ -0,0 +1,6 @@
|
||||
<button mat-icon-button
|
||||
class="neutral"
|
||||
matTooltip="Navigate to the log in page"
|
||||
(click)="login()">
|
||||
<mat-icon>login</mat-icon>
|
||||
</button>
|
23
src/app/auth/login-button/login-button.component.spec.ts
Normal file
23
src/app/auth/login-button/login-button.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoginButtonComponent } from './login-button.component';
|
||||
|
||||
describe('LoginButtonComponent', () => {
|
||||
let component: LoginButtonComponent;
|
||||
let fixture: ComponentFixture<LoginButtonComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [LoginButtonComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(LoginButtonComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
28
src/app/auth/login-button/login-button.component.ts
Normal file
28
src/app/auth/login-button/login-button.component.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'login-button',
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatFormFieldModule,
|
||||
MatTooltipModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './login-button.component.html',
|
||||
styleUrl: './login-button.component.scss'
|
||||
})
|
||||
export class LoginButtonComponent {
|
||||
private readonly router = inject(Router);
|
||||
|
||||
login() {
|
||||
this.router.navigate(['login']);
|
||||
}
|
||||
}
|
6
src/app/auth/logoff-button/logoff-button.component.html
Normal file
6
src/app/auth/logoff-button/logoff-button.component.html
Normal file
@ -0,0 +1,6 @@
|
||||
<button mat-icon-button
|
||||
class="danger"
|
||||
matTooltip="Log off"
|
||||
(click)="logoff()">
|
||||
<mat-icon>logout</mat-icon>
|
||||
</button>
|
23
src/app/auth/logoff-button/logoff-button.component.spec.ts
Normal file
23
src/app/auth/logoff-button/logoff-button.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LogoffButtonComponent } from './logoff-button.component';
|
||||
|
||||
describe('LogoffButtonComponent', () => {
|
||||
let component: LogoffButtonComponent;
|
||||
let fixture: ComponentFixture<LogoffButtonComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [LogoffButtonComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(LogoffButtonComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
28
src/app/auth/logoff-button/logoff-button.component.ts
Normal file
28
src/app/auth/logoff-button/logoff-button.component.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { ApiAuthenticationService } from '../../shared/services/api/api-authentication.service';
|
||||
|
||||
@Component({
|
||||
selector: 'logoff-button',
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatFormFieldModule,
|
||||
MatTooltipModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './logoff-button.component.html',
|
||||
styleUrl: './logoff-button.component.scss'
|
||||
})
|
||||
export class LogoffButtonComponent {
|
||||
private readonly auth = inject(ApiAuthenticationService);
|
||||
|
||||
logoff() {
|
||||
this.auth.logout();
|
||||
}
|
||||
}
|
@ -31,10 +31,6 @@ export class ConnectionItemComponent {
|
||||
|
||||
constructor(@Inject(DOCUMENT) private document: Document) { }
|
||||
|
||||
ngOnInit() {
|
||||
console.log('coonnn', this.connection())
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.client.deleteConnection(this.connection().name);
|
||||
}
|
||||
|
@ -28,4 +28,10 @@
|
||||
</div>
|
||||
}
|
||||
<theme />
|
||||
|
||||
@if (isLoggedIn) {
|
||||
<logoff-button />
|
||||
} @else {
|
||||
<login-button />
|
||||
}
|
||||
</mat-toolbar>
|
@ -10,6 +10,8 @@ import { HermesClientService } from '../../hermes-client.service';
|
||||
import EventService from '../../shared/services/EventService';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ThemeComponent } from "../../theme/theme.component";
|
||||
import { LogoffButtonComponent } from "../../auth/logoff-button/logoff-button.component";
|
||||
import { LoginButtonComponent } from "../../auth/login-button/login-button.component";
|
||||
|
||||
@Component({
|
||||
selector: 'topbar',
|
||||
@ -21,6 +23,8 @@ import { ThemeComponent } from "../../theme/theme.component";
|
||||
MatIconModule,
|
||||
MatToolbarModule,
|
||||
ThemeComponent,
|
||||
LoginButtonComponent,
|
||||
LogoffButtonComponent,
|
||||
],
|
||||
providers: [AuthVisitorGuard],
|
||||
templateUrl: './topbar.component.html',
|
||||
|
Loading…
x
Reference in New Issue
Block a user