diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index e56e9b5..0000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ - RouterTestingModule - ], - declarations: [ - AppComponent - ], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have as title 'bstlboard-angular'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('bstlboard-angular'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement; - expect(compiled.querySelector('.content span').textContent).toContain('bstlboard-angular app is running!'); - }); -}); diff --git a/src/app/auth/auth.guard.ts b/src/app/auth/auth.guard.ts index a430908..ec5aa29 100644 --- a/src/app/auth/auth.guard.ts +++ b/src/app/auth/auth.guard.ts @@ -1,7 +1,8 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { AuthService, RequestError } from '../services/auth.service'; +import { AuthService } from '../services/auth.service'; +import { RequestError } from '../services/requesterror'; import { UserService } from '../services/user.service'; import { I18nService } from '../services/i18n.service'; diff --git a/src/app/pages/entries/entries.page.ts b/src/app/pages/entries/entries.page.ts index e1c6d6f..d340a0f 100644 --- a/src/app/pages/entries/entries.page.ts +++ b/src/app/pages/entries/entries.page.ts @@ -1,22 +1,24 @@ import { Component, OnInit, Input } from '@angular/core'; - import { Router, ActivatedRoute } from '@angular/router'; - import { PageEvent } from '@angular/material/paginator'; +import { SettingsService } from '../../services/settings.service'; + @Component({ selector: 'page-entries', templateUrl: './entries.page.html' }) export class PageEntries implements OnInit { + settings: any; @Input() fetch: Function; entries: any; boundRefresh: Function; boundUpdate: Function; init: boolean = true; - constructor(private router: Router, private route: ActivatedRoute) { } + constructor( + private settingsService: SettingsService, private router: Router, private route: ActivatedRoute) { } ngOnInit(): void { this.boundRefresh = this.refresh.bind(this); @@ -35,8 +37,11 @@ export class PageEntries implements OnInit { this.entries.size = +params[ 's' ]; } - this.refresh(); - this.init = false; + this.settingsService.settings.subscribe((settings) => { + this.settings = settings; + this.refresh(); + this.init = false; + }) } }); } @@ -47,7 +52,7 @@ export class PageEntries implements OnInit { } this.entries.content = null; - this.fetch(this.entries.number || 0, this.entries.size || 30).subscribe((data: any) => { + this.fetch(this.entries.number || 0, this.entries.size || this.settings.pageSize).subscribe((data: any) => { this.entries = data; }, (error) => { }) @@ -61,7 +66,7 @@ export class PageEntries implements OnInit { params.p = event.pageIndex + 1; } - if (event.pageSize != 30) { + if (event.pageSize != this.settings.pageSize) { params.s = event.pageSize; } diff --git a/src/app/pages/settings/settings.page.html b/src/app/pages/settings/settings.page.html index 88ddb6a..fc95e39 100644 --- a/src/app/pages/settings/settings.page.html +++ b/src/app/pages/settings/settings.page.html @@ -19,18 +19,33 @@

{{'settings.pagesettings' | i18n}}

- - - {{'settings.gravity.hint' | i18n}} - - - {{'settings.gravity.zero' | i18n}} - + + {{'settings.gravity.hint' | i18n}} + + + {{'settings.gravity.zero' | i18n}} + + + + + + + {{'settings.commentDelay.hint' | i18n}} + + + {{'settings.commentDelay.zero' | i18n}} + diff --git a/src/app/pages/settings/settings.page.ts b/src/app/pages/settings/settings.page.ts index fb754f8..48cfdee 100644 --- a/src/app/pages/settings/settings.page.ts +++ b/src/app/pages/settings/settings.page.ts @@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators, NgForm } from '@angular/forms'; import { UserService } from '../../services/user.service'; +import { SettingsService } from 'src/app/services/settings.service'; @Component({ selector: 'page-settings', @@ -15,10 +16,12 @@ export class PageSettings implements OnInit { working: boolean = false; success: boolean = false; form: FormGroup; + settings: any; @ViewChild('formDirective') private formDirective: NgForm; constructor( private userService: UserService, + private settingsService: SettingsService, private formBuilder: FormBuilder) { } ngOnInit(): void { @@ -27,6 +30,7 @@ export class PageSettings implements OnInit { email: [ '', Validators.nullValidator ], about: [ '', Validators.nullValidator ], gravity: [ '', Validators.nullValidator ], + commentDelay: [ '', Validators.nullValidator ], }); this.form.get('username').disable(); @@ -39,8 +43,15 @@ export class PageSettings implements OnInit { this.form.get('username').setValue(this.user.username); this.form.get('email').setValue(this.user.email); this.form.get('about').setValue(this.user.about); - this.form.get('gravity').setValue(this.user.settings.gravity || this.user.metadata.defaultGravity); + + this.settingsService.settings.subscribe((settings) => { + this.settings = settings; + this.form.get('gravity').setValue(this.user.settings.gravity || this.settings.defaultGravity); + this.form.get('commentDelay').setValue(this.user.settings.commentDelay || this.settings.defaultCommentDelay); + }); }) + + } hasError(controlName: string): boolean { @@ -49,7 +60,12 @@ export class PageSettings implements OnInit { resetGravity(): void { this.user.settings.gravity = null; - this.form.get('gravity').setValue(this.user.metadata.defaultGravity); + this.form.get('gravity').setValue(this.settings.defaultGravity); + } + + resetCommentDelay(): void { + this.user.settings.commentDelay = null; + this.form.get('commentDelay').setValue(this.settings.defaultCommentDelay); } save(): void { @@ -67,12 +83,18 @@ export class PageSettings implements OnInit { this.user.settings = {}; } - if (this.form.get('gravity').value != this.user.metadata.defaultGravity && !this.user.settings.gravity) { + if (this.form.get('gravity').value != this.settings.defaultGravity && !this.user.settings.gravity) { this.user.settings.gravity = this.form.get('gravity').value; } else if (this.user.settings.gravity) { this.user.settings.gravity = this.form.get('gravity').value; } + if (this.form.get('commentDelay').value != this.settings.defaultCommentDelay && !this.user.settings.commentDelay) { + this.user.settings.commentDelay = this.form.get('commentDelay').value; + } else if (this.user.settings.commentDelay) { + this.user.settings.commentDelay = this.form.get('gravity').value; + } + this.userService.update(this.user).subscribe((data) => { this.user = data; if (!this.user.settings) { diff --git a/src/app/pages/user/usercomments/usercomments.page.ts b/src/app/pages/user/usercomments/usercomments.page.ts index 7b9bdfa..33de81d 100644 --- a/src/app/pages/user/usercomments/usercomments.page.ts +++ b/src/app/pages/user/usercomments/usercomments.page.ts @@ -3,6 +3,7 @@ import { Component, OnInit, Input } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { CommentService } from '../../../services/comment.service'; +import { SettingsService } from '../../../services/settings.service'; @Component({ selector: 'page-usercomments', @@ -11,18 +12,22 @@ import { CommentService } from '../../../services/comment.service'; }) export class PageUserComments implements OnInit { + settings: any; username: string; comments: any = {}; init: boolean = true; - ignore : string[] = ["author"]; + ignore: string[] = [ "author" ]; - constructor(private commentService: CommentService, private router: Router, private route: ActivatedRoute) { } + constructor(private settingsService: SettingsService, private commentService: CommentService, private router: Router, private route: ActivatedRoute) { } ngOnInit(): void { this.username = this.route.snapshot.paramMap.get('username'); - this.commentService.getByUser(this.username, this.comments.number || 0, this.comments.size || 30, this.ignore).subscribe((data: any) => { - this.comments = data; - }, (error) => { }) + this.settingsService.settings.subscribe((settings) => { + this.settings = settings; + this.commentService.getByUser(this.username, this.comments.number || 0, this.comments.size || this.settings.pageSize, this.ignore).subscribe((data: any) => { + this.comments = data; + }, (error) => { }) + }) } showMore() { diff --git a/src/app/pages/user/userentries/userentries.page.html b/src/app/pages/user/userentries/userentries.page.html index 4440802..ea40ddc 100644 --- a/src/app/pages/user/userentries/userentries.page.html +++ b/src/app/pages/user/userentries/userentries.page.html @@ -2,5 +2,5 @@

{{'user.entriesBy' | i18n}}{{username}}

- + \ No newline at end of file diff --git a/src/app/pages/user/userentries/userentries.page.ts b/src/app/pages/user/userentries/userentries.page.ts index bc33488..f7c106f 100644 --- a/src/app/pages/user/userentries/userentries.page.ts +++ b/src/app/pages/user/userentries/userentries.page.ts @@ -1,9 +1,8 @@ import { Component, OnInit } from '@angular/core'; -import { Router, ActivatedRoute } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; import { EntriesService } from '../../../services/entries.service'; -import { PageEvent } from '@angular/material/paginator'; @Component({ selector: 'page-userentries', @@ -11,73 +10,18 @@ import { PageEvent } from '@angular/material/paginator'; }) export class PageUserEntries implements OnInit { - username : string; - entries: any; - boundRefresh: Function; - boundUpdate: Function; - init: boolean = true; + username: string; + boundFetch: Function; - constructor(private entriesService: EntriesService, private router: Router, private route: ActivatedRoute) { } + constructor(private entriesService: EntriesService, private route: ActivatedRoute) { } ngOnInit(): void { this.username = this.route.snapshot.paramMap.get('username'); - this.boundRefresh = this.refresh.bind(this); - this.boundUpdate = this.update.bind(this); - this.route.queryParams.subscribe(params => { - if (this.init) { - this.entries = {}; - if (params[ 'p' ]) { - this.entries.number = +params[ 'p' ] - 1; - if (this.entries.number < 0) { - this.entries.number = 0; - } - } - - if (params[ 's' ]) { - this.entries.size = +params[ 's' ]; - } - - this.refresh(); - this.init = false; - } - }); + this.boundFetch = this.fetch.bind(this); } - refresh(): void { - if (!this.entries) { - this.entries = {}; - } - - this.entries.content = null; - this.entriesService.getByUser(this.username, this.entries.number || 0, this.entries.size || 30).subscribe((data: any) => { - this.entries = data; - }, (error) => { }) - - } - - update(event: PageEvent) { - this.entries.content = null; - const params: any = { p: null, s: null }; - - if (event.pageIndex != 0) { - params.p = event.pageIndex + 1; - } - - if (event.pageSize != 30) { - params.s = event.pageSize; - } - - this.router.navigate( - [], - { - relativeTo: this.route, - queryParams: params, - queryParamsHandling: 'merge' - }); - - this.entriesService.getByUser(this.username,event.pageIndex, event.pageSize).subscribe((data: any) => { - this.entries = data; - }, (error) => { }) + fetch(page: number, size: number) { + return this.entriesService.getByUser(this.username, page, size); } } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 23ac7c3..a8c02c1 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -1,6 +1,8 @@ import { Injectable } from '@angular/core'; import { ReplaySubject, of } from 'rxjs'; -import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; + +import { RequestError } from './requesterror'; import { environment } from './../../environments/environment'; @@ -36,19 +38,3 @@ export class AuthService { } } - -export class RequestError extends Error { - - response : any; - - constructor(response : any) { - super(response.message); - this.response = response; - // Set the prototype explicitly. - Object.setPrototypeOf(this, RequestError.prototype); - } - - getResponse() : any { - return this.response; - } -} \ No newline at end of file diff --git a/src/app/services/comment.service.ts b/src/app/services/comment.service.ts index e6483a9..b6fd196 100644 --- a/src/app/services/comment.service.ts +++ b/src/app/services/comment.service.ts @@ -10,24 +10,24 @@ export class CommentService { constructor(private http: HttpClient) { } - getRanked(target: number, page: number, size: number, ignore : string[] = []) { + getRanked(target: number, page: number, size: number, ignore: string[] = []) { return this.http.get(environment.apiUrl + "/comments/" + target + "?page=" + page + "&size=" + size + "&ignore=" + ignore); } - getRankedByParent(target: number, parent: number, page: number, size: number, ignore : string[] = []) { - return this.http.get(environment.apiUrl + "/comments/" + target + "/" + parent + "?page=" + page + "&size=" + size+ "&ignore=" + ignore); + getRankedByParent(target: number, parent: number, page: number, size: number, ignore: string[] = []) { + return this.http.get(environment.apiUrl + "/comments/" + target + "/" + parent + "?page=" + page + "&size=" + size + "&ignore=" + ignore); } - getNew(target: number, page: number, size: number, ignore : string[] = []) { - return this.http.get(environment.apiUrl + "/comments/new/" + target + "?page=" + page + "&size=" + size+ "&ignore=" + ignore); + getNew(target: number, page: number, size: number, ignore: string[] = []) { + return this.http.get(environment.apiUrl + "/comments/new/" + target + "?page=" + page + "&size=" + size + "&ignore=" + ignore); } - getNewByParent(target: number, parent: number, page: number, size: number, ignore : string[] = []) { - return this.http.get(environment.apiUrl + "/comments/new/" + target + "/" + parent + "?page=" + page + "&size=" + size+ "&ignore=" + ignore); + getNewByParent(target: number, parent: number, page: number, size: number, ignore: string[] = []) { + return this.http.get(environment.apiUrl + "/comments/new/" + target + "/" + parent + "?page=" + page + "&size=" + size + "&ignore=" + ignore); } - getByUser(username: string, page: number, size: number, ignore : string[] = []) { - return this.http.get(environment.apiUrl + "/comments/byuser/" + username + "?page=" + page + "&size=" + size+ "&ignore=" + ignore); + getByUser(username: string, page: number, size: number, ignore: string[] = []) { + return this.http.get(environment.apiUrl + "/comments/byuser/" + username + "?page=" + page + "&size=" + size + "&ignore=" + ignore); } count(target: number) { @@ -38,13 +38,20 @@ export class CommentService { return this.http.get(environment.apiUrl + "/comments/count/" + target + "/" + parent); } - getComment(id: number, ignore : string[] = []) { - return this.http.get(environment.apiUrl + "/comments/comment/" + id + "?ignore=" + ignore); + getComment(id: number, ignore: string[] = []) { + return this.http.get(environment.apiUrl + "/comments/comment/" + id + "?ignore=" + ignore); } - create(comment: any, ignore : string[] = []) { - comment.type = 'COMMENT'; + create(comment: any, ignore: string[] = []) { return this.http.post(environment.apiUrl + "/comments?ignore=" + ignore, comment); } + update(comment: any, ignore: string[] = []) { + return this.http.patch(environment.apiUrl + "/comments?ignore=" + ignore, comment); + } + + delete(id: number) { + return this.http.delete(environment.apiUrl + "/comments/" + id); + } + } \ No newline at end of file diff --git a/src/app/services/requesterror.ts b/src/app/services/requesterror.ts new file mode 100644 index 0000000..621bb93 --- /dev/null +++ b/src/app/services/requesterror.ts @@ -0,0 +1,16 @@ + +export class RequestError extends Error { + + response: any; + + constructor(response: any) { + super(response.message); + this.response = response; + // Set the prototype explicitly. + Object.setPrototypeOf(this, RequestError.prototype); + } + + getResponse(): any { + return this.response; + } +} \ No newline at end of file diff --git a/src/app/services/settings.service.ts b/src/app/services/settings.service.ts new file mode 100644 index 0000000..a497e6a --- /dev/null +++ b/src/app/services/settings.service.ts @@ -0,0 +1,28 @@ +import { Injectable } from '@angular/core'; +import { ReplaySubject, of } from 'rxjs'; +import { HttpClient } from '@angular/common/http'; + +import { RequestError } from './requesterror'; + +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class SettingsService { + + settings: ReplaySubject = new ReplaySubject(undefined); + + constructor(private http: HttpClient) { + } + + getSettings() { + return this.http.get(environment.apiUrl + "/settings").toPromise().then((data: any) => { + this.settings.next(data); + return data; + }, error => { + throw new RequestError(error); + }); + } + +} \ No newline at end of file diff --git a/src/app/ui/comment/comment.ui.html b/src/app/ui/comment/comment.ui.html index ed5e3f8..63b39f7 100644 --- a/src/app/ui/comment/comment.ui.html +++ b/src/app/ui/comment/comment.ui.html @@ -16,29 +16,58 @@ thumb_down   - {{comment.created + {{ (comment.modified || + comment.created) | datef}} {{'comment.author' | i18n}}{{comment.author}} {{'comment.to' | i18n}} {{'comment' | i18n}} + routerLink="/c/{{comment.parent}}">{{'comment' | i18n}} {{'comment.on' | i18n}} {{comment.metadata.entry || 'entry'}} | {{'comment.unvote' | i18n}} -
-
- - {{(comment.metadata.reply ? - 'comment.replyHide' : 'comment.reply') | i18n}} - | - {{'comment.delete' | i18n}} - -
+ +
+
+ + {{(comment.metadata.reply ? + 'comment.replyHide' : 'comment.reply') | i18n}} + | + {{'comment.edit' | i18n}} + | + {{'moderation.comment.delete' | i18n}} + +
+
+ + +
+ + + + {{'comment.text.error' | i18n}} + + + +
+ +
+ + {{'cancel' | i18n}} + | + {{'comment.delete' | i18n}} + +
+ +
{ if (auth && auth.authorities) { + this.author = auth.username == this.comment.author; for (let role of auth.authorities) { if (role.authority == 'ROLE_ADMIN' || role.authority == 'ROLE_MOD') { this.moderator = true; @@ -36,6 +40,12 @@ export class UiComment implements OnInit { } } }) + + this.form = this.formBuilder.group({ + text: [ '', Validators.required ], + }); + + this.form.get('text').setValue(this.comment.text); } voteUp() { @@ -62,10 +72,6 @@ export class UiComment implements OnInit { }); } - author(author: string) { - return '' + author + ''; - } - replyCallback(comment): void { if (this.subcomments) { this.comments.addComment(comment); @@ -74,17 +80,66 @@ export class UiComment implements OnInit { this.comment.metadata.comments = (this.comment.metadata.comments || 0) + 1; } - deleteComment(comment: any) { + + + canEdit(): boolean { + const canEdit = this.author && (new Date(this.comment.created).getTime() > new Date().getTime()); + + if (this.comment.metadata && this.comment.metadata.edit && !canEdit) { + this.comment.metadata.edit = false; + } + + return canEdit; + } + + edit(): void { + this.comment.metadata.edit = true; + this.form.get('text').enable(); + } + + hasError(controlName: string): boolean { + return this.form.controls[ controlName ].errors != null; + } + + update(): void { + if (this.canEdit()) { + this.comment.text = this.form.get('text').value; + this.form.get('text').disable(); + this.commentService.update(this.comment).subscribe((data) => { + this.comment = data; + this.comment.metadata.edit = false; + }) + } + } + + deleteComment() { const dialogRef = this.dialog.open(ConfirmDialog, { data: { 'label': 'comment.confirmDelete', - 'args': [ comment.text, comment.author ] + 'args': [ this.comment.text, this.comment.author ] } }) dialogRef.afterClosed().subscribe(result => { if (result) { - this.moderationService.deleteComment(comment.id).subscribe((result: any) => { + this.commentService.delete(this.comment.id).subscribe((result: any) => { + this.change && this.change() + }) + } + }); + } + + modDeleteComment() { + const dialogRef = this.dialog.open(ConfirmDialog, { + data: { + 'label': 'moderation.comment.confirmDelete', + 'args': [ this.comment.text, this.comment.author ] + } + }) + + dialogRef.afterClosed().subscribe(result => { + if (result) { + this.moderationService.deleteComment(this.comment.id).subscribe((result: any) => { this.change && this.change() }) } diff --git a/src/app/ui/comments/comments.ui.ts b/src/app/ui/comments/comments.ui.ts index 19304ce..7e388cc 100644 --- a/src/app/ui/comments/comments.ui.ts +++ b/src/app/ui/comments/comments.ui.ts @@ -2,6 +2,7 @@ import { Component, OnInit, Input } from '@angular/core'; import { PageEvent } from '@angular/material/paginator'; import { CommentService } from '../../services/comment.service'; +import { SettingsService } from '../../services/settings.service'; @Component({ selector: 'ui-comments', @@ -10,6 +11,7 @@ import { CommentService } from '../../services/comment.service'; }) export class UiComments implements OnInit { + settings: any; comments: any; @Input() target: number; @Input() parent: number; @@ -18,20 +20,23 @@ export class UiComments implements OnInit { @Input() parentLink: boolean = false; boundRefresh: Function; - constructor(private commentService: CommentService) { } + constructor(private settingsService: SettingsService, private commentService: CommentService) { } ngOnInit(): void { this.boundRefresh = this.refresh.bind(this); - this.refresh(); + this.settingsService.settings.subscribe((settings) => { + this.settings = settings; + this.refresh(); + }) } refresh(): void { if (this.parent) { - this.commentService.getNewByParent(this.target, this.parent, 0, 30, this.ignore).subscribe((data) => { + this.commentService.getNewByParent(this.target, this.parent, 0, this.settings.pageSize, this.ignore).subscribe((data) => { this.comments = data; }) } else { - this.commentService.getNew(this.target, 0, 30, this.ignore).subscribe((data) => { + this.commentService.getNew(this.target, 0, this.settings.pageSize, this.ignore).subscribe((data) => { this.comments = data; }) } diff --git a/src/app/ui/entry/entry.ui.html b/src/app/ui/entry/entry.ui.html index 779b6dc..bf7a71e 100644 --- a/src/app/ui/entry/entry.ui.html +++ b/src/app/ui/entry/entry.ui.html @@ -43,6 +43,6 @@ {{'entry.unvote' | i18n}} | - {{'entry.delete' | i18n}} + {{'moderation.entry.delete' | i18n}}
\ No newline at end of file diff --git a/src/app/ui/entry/entry.ui.ts b/src/app/ui/entry/entry.ui.ts index 6a19440..8544a23 100644 --- a/src/app/ui/entry/entry.ui.ts +++ b/src/app/ui/entry/entry.ui.ts @@ -67,7 +67,7 @@ export class UiEntry implements OnInit { deleteEntry(entry: any) { const dialogRef = this.dialog.open(ConfirmDialog, { data: { - 'label': 'entry.confirmDelete', + 'label': 'moderation.entry.confirmDelete', 'args': [ entry.title, entry.author ] } }) diff --git a/src/app/ui/main/main.ui.ts b/src/app/ui/main/main.ui.ts index d2f20f8..cac84fa 100644 --- a/src/app/ui/main/main.ui.ts +++ b/src/app/ui/main/main.ui.ts @@ -1,17 +1,18 @@ import { Component, HostListener } from '@angular/core'; - -import { AuthService } from '../../services/auth.service'; -import { UserService } from '../../services/user.service'; -import { I18nService } from '../../services/i18n.service'; import { Router } from '@angular/router'; import { DomSanitizer } from '@angular/platform-browser'; import { MatIconRegistry } from '@angular/material/icon'; import { DateAdapter } from '@angular/material/core'; +import { AuthService } from '../../services/auth.service'; +import { UserService } from '../../services/user.service'; +import { I18nService } from '../../services/i18n.service'; +import { SettingsService } from '../../services/settings.service'; + @Component({ selector: 'ui-main', templateUrl: './main.ui.html', - styleUrls : ['./main.ui.scss'] + styleUrls: [ './main.ui.scss' ] }) export class UiMain { @@ -21,12 +22,13 @@ export class UiMain { currentLocale: String; datetimeformat: String; locales; - authenticated : boolean = false; + authenticated: boolean = false; constructor( private i18n: I18nService, private authService: AuthService, private userService: UserService, + private settingsService: SettingsService, private router: Router, private iconRegistry: MatIconRegistry, private sanitizer: DomSanitizer, @@ -34,7 +36,7 @@ export class UiMain { iconRegistry.addSvgIcon('logo', sanitizer.bypassSecurityTrustResourceUrl('assets/icons/logo.svg')); } - ngOnInit() { + async ngOnInit() { this.datetimeformat = this.i18n.get('format.datetime', []); this.currentLocale = this.i18n.getLocale(); this.locales = this.i18n.getLocales(); @@ -57,6 +59,8 @@ export class UiMain { this.darkTheme = true; window.document.body.classList.add("dark-theme"); } + + await this.settingsService.getSettings(); } setLocale(locale) {