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
@@ -29,31 +29,37 @@ export class DurationpickerComponent implements OnInit, ControlValueAccessor {
constructor() { }
ngOnInit(): void {
this.days.valueChanges.subscribe(value => {
if (value < this.model.days()) {
this.model.subtract((this.model.days() - value), "days");
} else {
this.model.add((value - this.model.days()), "days");
this.days.valueChanges.subscribe({
next: (value) => {
if (value < this.model.days()) {
this.model.subtract((this.model.days() - value), "days");
} else {
this.model.add((value - this.model.days()), "days");
}
this.checkValue();
}
this.checkValue();
})
this.hours.valueChanges.subscribe(value => {
if (value < this.model.hours()) {
this.model.subtract((this.model.hours() - value), "hours");
} else {
this.model.add((value - this.model.hours()), "hours");
this.hours.valueChanges.subscribe({
next: (value) => {
if (value < this.model.hours()) {
this.model.subtract((this.model.hours() - value), "hours");
} else {
this.model.add((value - this.model.hours()), "hours");
}
this.checkValue();
}
this.checkValue();
})
this.minutes.valueChanges.subscribe(value => {
if (value < this.model.minutes()) {
this.model.subtract((this.model.minutes() - value), "minutes");
} else {
this.model.add((value - this.model.minutes()), "minutes");
this.minutes.valueChanges.subscribe({
next: (value) => {
if (value < this.model.minutes()) {
this.model.subtract((this.model.minutes() - value), "minutes");
} else {
this.model.add((value - this.model.minutes()), "minutes");
}
this.checkValue();
}
this.checkValue();
})
}
+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;
}
}
}
})
@@ -29,25 +29,26 @@ export class ProfileFieldPgpBlob implements OnInit {
}
ngOnInit(): void {
this.authService.auth.subscribe((auth: any) => {
if (!auth.authenticated) {
return;
this.authService.auth.subscribe({
next: (auth: any) => {
if (!auth.authenticated) {
return;
}
let pgpOption = {
userIds: [ { name: auth.principal.username, email: auth.principal.username + "@we.bstly.de" } ],
curve: "ed25519",
}
openpgp.generateKey(pgpOption).then((key) => {
this.data = {};
this.data.privateKey = key.privateKeyArmored;
this.data.publicKey = key.publicKeyArmored;
this.downloadKey.nativeElement.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.data.privateKey));
this.downloadKey.nativeElement.setAttribute('download', auth.principal.username + ".private.key");
});
}
let pgpOption = {
userIds: [ { name: auth.principal.username, email: auth.principal.username + "@we.bstly.de" } ],
curve: "ed25519",
}
openpgp.generateKey(pgpOption).then((key) => {
this.data = {};
this.data.privateKey = key.privateKeyArmored;
this.data.publicKey = key.publicKeyArmored;
this.downloadKey.nativeElement.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(this.data.privateKey));
this.downloadKey.nativeElement.setAttribute('download', auth.principal.username + ".private.key");
});
});
}
@@ -41,12 +41,16 @@ export class ProfileFieldsComponent implements OnInit {
update() {
if (this.username) {
this.profileService.getForUser(this.username).subscribe((data: any) => {
this.profileFields = data.profileFields;
this.profileService.getForUser(this.username).subscribe({
next: (data: any) => {
this.profileFields = data.profileFields;
}
})
} else {
this.profileService.get().subscribe((data: any) => {
this.profileFields = data;
this.profileService.get().subscribe({
next: (data: any) => {
this.profileFields = data;
}
})
}
}
@@ -87,15 +91,17 @@ export class ProfileFieldsComponent implements OnInit {
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.profileService.createOrUpdate(result).subscribe();
} else {
profileField.name = resetProfileField.name;
profileField.value = resetProfileField.value;
profileField.type = resetProfileField.type;
profileField.visibility = resetProfileField.visibility;
profileField.index = resetProfileField.index;
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.profileService.createOrUpdate(result);
} else {
profileField.name = resetProfileField.name;
profileField.value = resetProfileField.value;
profileField.type = resetProfileField.type;
profileField.visibility = resetProfileField.visibility;
profileField.index = resetProfileField.index;
}
}
});
@@ -110,11 +116,15 @@ export class ProfileFieldsComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.profileService.delete(profileField.name).subscribe((result: any) => {
this.update();
})
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.profileService.delete(profileField.name).subscribe({
next: (result: any) => {
this.update();
}
})
}
}
});
}
@@ -125,9 +135,11 @@ export class ProfileFieldsComponent implements OnInit {
minWidth: '400px'
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.update();
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.update();
}
}
});
@@ -185,18 +197,21 @@ export class ProfileFieldDialog {
save(profileField) {
this.profileService.createOrUpdate(profileField).subscribe((result: any) => {
this.dialogRef.close(profileField);
}, (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
errors[ code.field ] = errors[ code.field ] || {};
errors[ code.field ][ code.code ] = true;
}
this.profileService.createOrUpdate(profileField).subscribe({
next: (result: any) => {
this.dialogRef.close(profileField);
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
errors[ code.field ] = errors[ code.field ] || {};
errors[ code.field ][ code.code ] = true;
}
for (let code in errors) {
this.form.get(code).setErrors(errors[ code ]);
for (let code in errors) {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
@@ -207,9 +222,11 @@ export class ProfileFieldDialog {
minWidth: '400px'
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
profileField.blob = result;
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
profileField.blob = result;
}
}
});