migration

This commit is contained in:
_Bastler
2022-01-21 22:38:31 +01:00
parent 5cf6230005
commit 578e6e6981
36 changed files with 1473 additions and 1012 deletions
+62 -44
View File
@@ -17,7 +17,7 @@ import { MatSidenav } from '@angular/material/sidenav';
})
export class MainComponent {
opened : boolean = true;
opened: boolean = true;
darkTheme = "false";
title = 'we.bstly';
currentLocale: String;
@@ -44,8 +44,10 @@ export class MainComponent {
this.datetimeformat = this.i18n.get('format.datetime', []);
this.currentLocale = this.i18n.getLocale();
this.locales = this.i18n.getLocales();
this.authService.auth.subscribe(data => {
this.auth = data;
this.authService.auth.subscribe({
next: (data) => {
this.auth = data;
}
})
this._adapter.setLocale(this.currentLocale);
@@ -69,20 +71,24 @@ export class MainComponent {
localStorage.setItem("bstly.locale", locale);
if (this.auth && this.auth.authenticated) {
this.profileService.getField("locale").subscribe((profileField: any) => {
this.profileService.getField("locale").subscribe({
next: (profileField: any) => {
if (profileField == null) {
profileField = {
"name": "locale",
"type": "TEXT",
"visibility": "PRIVATE"
if (profileField == null) {
profileField = {
"name": "locale",
"type": "TEXT",
"visibility": "PRIVATE"
}
}
}
profileField.value = locale;
this.profileService.createOrUpdate(profileField).subscribe((response) => {
window.location.reload();
})
profileField.value = locale;
this.profileService.createOrUpdate(profileField).subscribe({
next: (response) => {
window.location.reload();
}
})
}
})
} else {
window.location.reload();
@@ -99,20 +105,24 @@ export class MainComponent {
localStorage.setItem("bstly.darkTheme", this.darkTheme);
if (this.auth && this.auth.authenticated) {
this.profileService.getField("darkTheme").subscribe((profileField: any) => {
this.profileService.getField("darkTheme").subscribe({
next: (profileField: any) => {
if (profileField == null) {
profileField = {
"name": "darkTheme",
"type": "BOOL",
"visibility": "PRIVATE"
if (profileField == null) {
profileField = {
"name": "darkTheme",
"type": "BOOL",
"visibility": "PRIVATE"
}
}
}
profileField.value = this.darkTheme;
this.profileService.createOrUpdate(profileField).subscribe((response) => {
window.location.reload();
})
profileField.value = this.darkTheme;
this.profileService.createOrUpdate(profileField).subscribe({
next: (response) => {
window.location.reload();
}
})
}
})
} else {
window.location.reload();
@@ -121,10 +131,12 @@ export class MainComponent {
}
logout() {
this.authService.logout().subscribe(data => {
this.router.navigate([ "" ]).then(() => {
window.location.reload();
});
this.authService.logout().subscribe({
next: (data) => {
this.router.navigate([ "" ]).then(() => {
window.location.reload();
});
}
})
}
@@ -151,28 +163,34 @@ export class MainComponent {
}
touchEvents(): void {
fromEvent(document, 'touchstart').subscribe((event: TouchEvent) => {
if (event.touches[ 0 ]) {
this.touchStartX = event.touches[ 0 ].screenX;
fromEvent(document, 'touchstart').subscribe({
next: (event: TouchEvent) => {
if (event.touches[ 0 ]) {
this.touchStartX = event.touches[ 0 ].screenX;
}
}
})
fromEvent(document, 'touchmove').subscribe((event: TouchEvent) => {
if (event.touches[ 0 ]) {
this.touchX = event.touches[ 0 ].screenX;
fromEvent(document, 'touchmove').subscribe({
next: (event: TouchEvent) => {
if (event.touches[ 0 ]) {
this.touchX = event.touches[ 0 ].screenX;
}
}
})
fromEvent(document, 'touchend').subscribe((event: TouchEvent) => {
if (this.touchX != 0) {
const touchDiff = this.touchStartX - this.touchX;
this.touchStartX = 0;
this.touchX = 0;
if (touchDiff < 0 && touchDiff < (this.touchThresh * -1) && !this.opened) {
this.opened = true;
} else if (touchDiff > 0 && touchDiff > this.touchThresh && this.opened) {
this.opened = false;
fromEvent(document, 'touchend').subscribe({
next: (event: TouchEvent) => {
if (this.touchX != 0) {
const touchDiff = this.touchStartX - this.touchX;
this.touchStartX = 0;
this.touchX = 0;
if (touchDiff < 0 && touchDiff < (this.touchThresh * -1) && !this.opened) {
this.opened = true;
} else if (touchDiff > 0 && touchDiff > this.touchThresh && this.opened) {
this.opened = false;
}
}
}
})