Added login UI

- Added empty adminui component
- Added authStore
This commit is contained in:
2024-05-30 13:44:38 +02:00
parent 414d152655
commit 95c9b2082a
11 changed files with 208 additions and 1 deletions

View File

@ -0,0 +1,40 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { map } from 'rxjs/operators';
interface AuthStoreState {
username: string;
token: string;
}
@Injectable({
providedIn: 'root'
})
export class AuthStore {
private state: BehaviorSubject<AuthStoreState> = new BehaviorSubject<AuthStoreState>({
username: "",
token: "",
});
// Getter for username
get username$() {
return this.state.asObservable().pipe(map(state => state.username));
}
// Getter for token
get token$() {
return this.state.asObservable().pipe(map(state => state.token));
}
// Mutation for username
setUsername(username: string) {
const currentState = this.state.getValue();
this.state.next({ ...currentState, username });
}
// Mutation for token
setToken(token: string) {
const currentState = this.state.getValue();
this.state.next({ ...currentState, token });
}
}