update angular

This commit is contained in:
2025-01-02 15:01:59 +01:00
parent 73d3ecfd42
commit 802c309679
199 changed files with 13745 additions and 11691 deletions

View File

@@ -7,7 +7,8 @@ import {Config} from './config';
providedIn: 'root',
})
export class ConfigService {
public constructor(private db: DbService) {}
public constructor(private db: DbService) {
}
public get$ = (): Observable<Config | null> => this.db.doc$<Config>('global/config');
public get = (): Promise<Config | null> => firstValueFrom(this.get$());

View File

@@ -11,7 +11,8 @@ type DocumentPredicate<T> = string | AngularFirestoreDocument<T>;
providedIn: 'root',
})
export class DbService {
public constructor(private afs: AngularFirestore) {}
public constructor(private afs: AngularFirestore) {
}
public col<T>(ref: CollectionPredicate<T>, queryFn?: QueryFn): AngularFirestoreCollection<T> {
return typeof ref === 'string' ? this.afs.collection<T>(ref, queryFn) : ref;

View File

@@ -4,7 +4,7 @@ import {filterSong} from './filter.helper';
describe('Filter Helper', () => {
const song: Song = {
title: 'Song Title',
text: "This is a songtext, aa?bb!cc,dd.ee'ff",
text: 'This is a songtext, aa?bb!cc,dd.ee\'ff',
legalOwner: '',
label: '',
id: '',

View File

@@ -22,7 +22,7 @@ export function dynamicSort(property: string) {
sortOrder = -1;
property = property.substr(1);
}
return function (a: unknown, b: unknown) {
return function(a: unknown, b: unknown) {
/* next line works with strings and numbers,
* and you may want to customize it to your needs
*/

View File

@@ -7,7 +7,8 @@ import {Observable} from 'rxjs';
providedIn: 'root',
})
export class GlobalSettingsService {
public constructor(private db: DbService) {}
public constructor(private db: DbService) {
}
public get get$(): Observable<GlobalSettings | null> {
return this.db.doc$<GlobalSettings>('global/static');

View File

@@ -3,12 +3,14 @@ import {UserService} from './user.service';
@Directive({
selector: '[appOwner]',
standalone: false,
})
export class OwnerDirective implements OnInit {
private currentUserId: string | null = null;
private iAppOwner: string | null = null;
public constructor(private element: ElementRef, private templateRef: TemplateRef<unknown>, private viewContainer: ViewContainerRef, private userService: UserService) {}
public constructor(private element: ElementRef, private templateRef: TemplateRef<unknown>, private viewContainer: ViewContainerRef, private userService: UserService) {
}
@Input()
public set appOwner(value: string) {

View File

@@ -7,4 +7,5 @@ import {CommonModule} from '@angular/common';
exports: [OwnerDirective],
imports: [CommonModule],
})
export class OwnerModule {}
export class OwnerModule {
}

View File

@@ -6,19 +6,22 @@ import {combineLatest} from 'rxjs';
@Directive({
selector: '[appRole]',
standalone: false,
})
export class RoleDirective implements OnInit {
@Input() public appRole: roles[] = [];
private currentUser: User | null = null;
private loggedIn = false;
private currentViewState = false;
public constructor(
private element: ElementRef,
private templateRef: TemplateRef<unknown>,
private viewContainer: ViewContainerRef,
private userService: UserService,
private changeDetection: ChangeDetectorRef
) {}
private changeDetection: ChangeDetectorRef,
) {
}
public ngOnInit(): void {
combineLatest([this.userService.user$, this.userService.loggedIn$()]).subscribe(_ => {
@@ -28,7 +31,6 @@ export class RoleDirective implements OnInit {
});
}
private currentViewState = false;
private updateView() {
const viewState = this.loggedIn && this.checkPermission();
if (this.currentViewState !== viewState) {

View File

@@ -7,4 +7,5 @@ import {RoleDirective} from './role.directive';
exports: [RoleDirective],
imports: [CommonModule],
})
export class RoleModule {}
export class RoleModule {
}

View File

@@ -11,7 +11,7 @@ describe('UserNameComponent', () => {
void TestBed.configureTestingModule({
declarations: [UserNameComponent],
}).compileComponents();
})
}),
);
beforeEach(() => {

View File

@@ -7,11 +7,13 @@ import {Observable} from 'rxjs';
selector: 'app-user-name',
templateUrl: './user-name.component.html',
styleUrls: ['./user-name.component.less'],
standalone: false,
})
export class UserNameComponent {
public name$: Observable<string | null> | null = null;
public constructor(private userService: UserService) {}
public constructor(private userService: UserService) {
}
@Input()
public set userId(id: string) {

View File

@@ -7,4 +7,5 @@ import {UserNameComponent} from './user-name.component';
exports: [UserNameComponent],
imports: [CommonModule],
})
export class UserNameModule {}
export class UserNameModule {
}

View File

@@ -13,10 +13,28 @@ import {ShowSongDataService} from '../../modules/shows/services/show-song-data.s
providedIn: 'root',
})
export class UserService {
public users$ = new BehaviorSubject<User[]>([]);
private iUserId$ = new BehaviorSubject<string | null>(null);
private iUser$ = new BehaviorSubject<User | null>(null);
public users$ = new BehaviorSubject<User[]>([]);
public constructor(
private afAuth: AngularFireAuth,
private db: DbService,
private router: Router,
private showDataService: ShowDataService,
private showSongDataService: ShowSongDataService,
) {
this.afAuth.authState
.pipe(
filter(auth => !!auth),
map(auth => auth?.uid ?? ''),
tap(uid => this.iUserId$.next(uid)),
switchMap(uid => this.readUser$(uid)),
)
.subscribe(_ => this.iUser$.next(_));
this.db.col$<User>('users/').subscribe(_ => this.users$.next(_));
}
public get userId$(): Observable<string | null> {
return this.iUserId$.asObservable();
@@ -28,24 +46,6 @@ export class UserService {
public currentUser = async (): Promise<User | null> => firstValueFrom(this.user$);
public constructor(
private afAuth: AngularFireAuth,
private db: DbService,
private router: Router,
private showDataService: ShowDataService,
private showSongDataService: ShowSongDataService
) {
this.afAuth.authState
.pipe(
filter(auth => !!auth),
map(auth => auth?.uid ?? ''),
tap(uid => this.iUserId$.next(uid)),
switchMap(uid => this.readUser$(uid))
)
.subscribe(_ => this.iUser$.next(_));
this.db.col$<User>('users/').subscribe(_ => this.users$.next(_));
}
public getUserbyId = (userId: string): Promise<User | null> => firstValueFrom(this.getUserbyId$(userId));
public getUserbyId$ = (userId: string): Observable<User | null> => this.users$.pipe(map(_ => _.find(f => f.id === userId) || null));