From 91958dc3ff8617471684eb9df9115864c147e94e Mon Sep 17 00:00:00 2001 From: _Bastler Date: Mon, 4 Oct 2021 10:35:57 +0200 Subject: [PATCH] improvements+fixes --- src/app/pages/entry/entry.page.html | 18 +++++++------ src/app/pages/entry/entry.page.scss | 5 ++++ src/app/pages/entry/entry.page.ts | 3 ++- src/app/pages/login/login.page.html | 11 +++++--- src/app/pages/login/login.page.ts | 17 ++++++++++++ src/app/pages/settings/settings.page.html | 6 ++--- src/app/pages/settings/settings.page.ts | 9 +++---- src/app/pages/submission/submission.page.html | 2 +- src/app/ui/comment/comment.ui.html | 2 +- src/app/ui/comment/comment.ui.scss | 8 +++++- src/app/ui/commentform/commentform.ui.html | 2 +- src/app/ui/entries/entries.ui.html | 6 +++-- src/app/ui/main/main.ui.html | 12 +++------ src/app/ui/main/main.ui.ts | 17 +++++------- src/styles.scss | 26 ++----------------- 15 files changed, 72 insertions(+), 72 deletions(-) create mode 100644 src/app/pages/entry/entry.page.scss diff --git a/src/app/pages/entry/entry.page.html b/src/app/pages/entry/entry.page.html index c4389c5..b3e8185 100644 --- a/src/app/pages/entry/entry.page.html +++ b/src/app/pages/entry/entry.page.html @@ -1,12 +1,14 @@ - - - +
+ + + -

{{entry.text}}

+

{{entry.text}}

- + - - + + + -
\ No newline at end of file +
\ No newline at end of file diff --git a/src/app/pages/entry/entry.page.scss b/src/app/pages/entry/entry.page.scss new file mode 100644 index 0000000..f96bb4e --- /dev/null +++ b/src/app/pages/entry/entry.page.scss @@ -0,0 +1,5 @@ +.text { + max-width: 100%; + white-space: break-spaces; + word-break: break-all; +} diff --git a/src/app/pages/entry/entry.page.ts b/src/app/pages/entry/entry.page.ts index 71a35ee..71744dc 100644 --- a/src/app/pages/entry/entry.page.ts +++ b/src/app/pages/entry/entry.page.ts @@ -7,7 +7,8 @@ import { CommentService } from '../../services/comment.service'; @Component({ selector: 'page-entry', - templateUrl: './entry.page.html' + templateUrl: './entry.page.html', + styleUrls: [ './entry.page.scss' ] }) export class PageEntry implements OnInit { diff --git a/src/app/pages/login/login.page.html b/src/app/pages/login/login.page.html index 4fdaa81..7952947 100644 --- a/src/app/pages/login/login.page.html +++ b/src/app/pages/login/login.page.html @@ -6,13 +6,16 @@ - + + + {{'login.autologin' | i18n}} + -
- + +

{{'login.internal' | i18n}}

diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index 1c16059..5cf3edf 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -13,6 +13,7 @@ import { AuthService } from '../../services/auth.service'; export class PageLogin implements OnInit { @ViewChild('loginForm') loginForm: ElementRef; + autologin: boolean = false; internalLogin: boolean; loginInvalid: boolean; externalLoginInvalid: boolean; @@ -46,6 +47,12 @@ export class PageLogin implements OnInit { this.authService.getExternal().subscribe((data: any[]) => { this.externals = data; + const autologinClient = localStorage.getItem("bstlboard.autologin"); + for (let client of this.externals) { + if (client.id == autologinClient) { + window.location.href = this.apiUrl + "/" + client.loginUrl; + } + } }) } @@ -56,5 +63,15 @@ export class PageLogin implements OnInit { } } + externalLogin(client: any): void { + console.log(this.autologin); + if (this.autologin) { + localStorage.setItem("bstlboard.autologin", client.id); + } else { + localStorage.removeItem("bstlboard.autologin"); + } + + window.location.href = this.apiUrl + "/" + client.loginUrl; + } } diff --git a/src/app/pages/settings/settings.page.html b/src/app/pages/settings/settings.page.html index 190615a..3ba2b6f 100644 --- a/src/app/pages/settings/settings.page.html +++ b/src/app/pages/settings/settings.page.html @@ -11,19 +11,17 @@ - + {{'settings.about.error' | i18n}} - - {{'settings.darkTheme' | i18n}} -
+ {{'settings.success' | i18n}}
diff --git a/src/app/pages/settings/settings.page.ts b/src/app/pages/settings/settings.page.ts index 23c5db8..352e6d7 100644 --- a/src/app/pages/settings/settings.page.ts +++ b/src/app/pages/settings/settings.page.ts @@ -13,6 +13,7 @@ export class PageSettings implements OnInit { auth: any; user: any; working: boolean = false; + success: boolean = false; form: FormGroup; @ViewChild('formDirective') private formDirective: NgForm; @@ -25,7 +26,6 @@ export class PageSettings implements OnInit { username: [ { disabled: true }, Validators.nullValidator ], email: [ '', Validators.nullValidator ], about: [ '', Validators.nullValidator ], - darkTheme: [ '', Validators.nullValidator ], }); this.form.get('username').disable(); @@ -35,14 +35,9 @@ 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('darkTheme').setValue(this.user.darkTheme); }) } - darkThemeChange($event) { - this.user.darkTheme = $event.checked; - } - hasError(controlName: string): boolean { return this.form.controls[ controlName ].errors != null; } @@ -53,6 +48,7 @@ export class PageSettings implements OnInit { } this.working = true; + this.success = false; this.user.about = this.form.get('about').value; this.user.email = this.form.get('email').value; @@ -60,6 +56,7 @@ export class PageSettings implements OnInit { this.userService.update(this.user).subscribe((data) => { this.user = data; this.working = false; + this.success = true; }, (error) => { this.working = false; if (error.status == 422) { diff --git a/src/app/pages/submission/submission.page.html b/src/app/pages/submission/submission.page.html index da2252d..9eb6224 100644 --- a/src/app/pages/submission/submission.page.html +++ b/src/app/pages/submission/submission.page.html @@ -28,7 +28,7 @@ - + {{'submission.text.error' | i18n}} diff --git a/src/app/ui/comment/comment.ui.html b/src/app/ui/comment/comment.ui.html index e38c65d..d1deb87 100644 --- a/src/app/ui/comment/comment.ui.html +++ b/src/app/ui/comment/comment.ui.html @@ -15,7 +15,7 @@ -
+
{{comment.text}}
diff --git a/src/app/ui/comment/comment.ui.scss b/src/app/ui/comment/comment.ui.scss index e784604..7632c49 100644 --- a/src/app/ui/comment/comment.ui.scss +++ b/src/app/ui/comment/comment.ui.scss @@ -6,4 +6,10 @@ small a { small a:hover { color: inherit !important; text-decoration: underline; -} \ No newline at end of file +} + +.text { + max-width: 100%; + white-space: break-spaces; + word-break: break-all; +} diff --git a/src/app/ui/commentform/commentform.ui.html b/src/app/ui/commentform/commentform.ui.html index 3cc5372..b28bdc3 100644 --- a/src/app/ui/commentform/commentform.ui.html +++ b/src/app/ui/commentform/commentform.ui.html @@ -1,7 +1,7 @@ - + {{'comment.text.error' | i18n}} diff --git a/src/app/ui/entries/entries.ui.html b/src/app/ui/entries/entries.ui.html index 8c78002..e06801a 100644 --- a/src/app/ui/entries/entries.ui.html +++ b/src/app/ui/entries/entries.ui.html @@ -1,7 +1,7 @@
- + @@ -13,7 +13,9 @@

{{'entries.nothing' | i18n}}

-
+ + +
diff --git a/src/app/ui/main/main.ui.html b/src/app/ui/main/main.ui.html index a92595c..7afbcfb 100644 --- a/src/app/ui/main/main.ui.html +++ b/src/app/ui/main/main.ui.html @@ -36,21 +36,17 @@ exit_to_app {{'logout' | i18n}} - - login {{'login' | i18n}} - - done{{'locale.' + locale + '.long' | i18n}} - - + + {{'darkTheme' | i18n}} @@ -60,8 +56,6 @@ -
- -
+
\ No newline at end of file diff --git a/src/app/ui/main/main.ui.ts b/src/app/ui/main/main.ui.ts index 0ce856e..f870aa4 100644 --- a/src/app/ui/main/main.ui.ts +++ b/src/app/ui/main/main.ui.ts @@ -15,7 +15,7 @@ import { DateAdapter } from '@angular/material/core'; export class UiMain { opened = true; - darkTheme = "false"; + darkTheme: boolean = false; title = 'bstlboard'; currentLocale: String; datetimeformat: String; @@ -51,7 +51,7 @@ export class UiMain { } if (localStorage.getItem("bstlboard.darkTheme") == "true") { - this.darkTheme = "true"; + this.darkTheme = true; window.document.body.classList.add("dark-theme"); } } @@ -72,18 +72,14 @@ export class UiMain { } } - darkThemeChange($event) { - if ($event.checked) { - this.darkTheme = "true"; - } else { - this.darkTheme = "false"; - } + toggleDarkTheme() { + this.darkTheme = !this.darkTheme; - localStorage.setItem("bstlboard.darkTheme", this.darkTheme); + localStorage.setItem("bstlboard.darkTheme", this.darkTheme ? "true" : "false"); if (this.auth && this.auth.authenticated) { this.userService.get().subscribe((user: any) => { - user.darkTheme = $event.checked; + user.darkTheme = this.darkTheme; this.userService.update(user).subscribe(() => { window.location.reload(); }) @@ -95,6 +91,7 @@ export class UiMain { } logout() { + localStorage.removeItem("bstlboard.autologin"); this.authService.logout().subscribe(data => { this.router.navigate([ "" ]).then(() => { window.location.reload(); diff --git a/src/styles.scss b/src/styles.scss index cd45a28..f1a1b19 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -174,34 +174,12 @@ mat-sidenav-container { .container { width: 100%; max-width: 100%; - padding-right: 2px; - padding-left: 2px; + padding-right: 15px; + padding-left: 15px; margin-right: auto; margin-left: auto; margin-top: 15px; margin-bottom: 15px; - overflow-x: none; - overflow-y: auto; - - @media screen and (min-width: 576px) { - padding-right: 3px; - padding-left: 3px; - } - - @media screen and (min-width: 768px) { - padding-right: 15px; - padding-left: 15px; - } - - @media screen and (min-width: 992px) { - padding-right: 25px; - padding-left: 25px; - } - - @media screen and (min-width: 1200px) { - padding-right: 45px; - padding-left: 45px; - } } .text-center {