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

View File

@ -47,7 +47,8 @@ export class AuthenticatedGuard implements CanActivate {
return that.router.navigateByUrl(that.router.parseUrl('/login?target=' + encodeURIComponent(state.url)), { skipLocationChange: true, replaceUrl: true });
}
this.profileService.get([ "locale", "darkTheme" ]).subscribe((profileFields: any) => {
this.profileService.get([ "locale", "darkTheme" ]).subscribe({
next: (profileFields: any) => {
let updateLocale = false;
let darktheme = 'false';
let updateTheme = false;
@ -70,6 +71,7 @@ export class AuthenticatedGuard implements CanActivate {
if (updateLocale || updateTheme) {
window.location.reload();
}
}
})
return true;

View File

@ -13,8 +13,10 @@ export class AccountComponent implements OnInit {
auth;
constructor(private authService: AuthService) {
this.authService.auth.subscribe(data => {
this.authService.auth.subscribe({
next: (data) => {
this.auth = data;
}
})
}

View File

@ -46,14 +46,17 @@ export class AliasesComponent implements OnInit {
create(): void {
this.working = true;
this.userAliasService.create(this.alias).subscribe(response => {
this.userAliasService.create(this.alias).subscribe(
{
next: (response) => {
this.update();
this.formDirective.resetForm();
this.alias = {
visibility: "PROTECTED"
};
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -66,27 +69,34 @@ export class AliasesComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}
updateAlias(alias) {
this.userAliasService.update(alias).subscribe((response: any) => {
this.userAliasService.update(alias).subscribe({
next: (response: any) => {
alias = response;
}
})
}
update() {
this.aliasCreation = 0;
this.quotaService.quotas().subscribe((data: any) => {
this.quotaService.quotas().subscribe({
next: (data: any) => {
for (let quota of data) {
if (quota.name == "alias_creation") {
this.aliasCreation = quota.value;
}
}
}
})
this.userAliasService.get().subscribe((data: any) => {
this.userAliasService.get().subscribe({
next: (data: any) => {
this.aliases = data;
}
})
}
@ -98,12 +108,16 @@ export class AliasesComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.userAliasService.delete(alias.id).subscribe((result: any) => {
this.userAliasService.delete(alias.id).subscribe({
next: (result: any) => {
this.update();
}
})
}
}
});
}

View File

@ -46,14 +46,16 @@ export class DomainsComponent implements OnInit {
create(): void {
this.working = true;
this.userDomainService.create(this.domain).subscribe(response => {
this.userDomainService.create(this.domain).subscribe({
next: (response) => {
this.update();
this.formDirective.resetForm();
this.domain = {
visibility: "PRIVATE"
};
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -66,18 +68,23 @@ export class DomainsComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}
updateDomain(domain) {
this.userDomainService.update(domain).subscribe((response: any) => {
this.userDomainService.update(domain).subscribe({
next: (response: any) => {
domain = response;
}
})
}
update() {
this.userDomainService.get().subscribe((data: any) => {
this.userDomainService.get().subscribe({
next: (data: any) => {
this.domains = data;
}
})
}
@ -89,12 +96,16 @@ export class DomainsComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.userDomainService.delete(domain.id).subscribe((result: any) => {
this.userDomainService.delete(domain.id).subscribe({
next: (result: any) => {
this.update();
}
})
}
}
});
}

View File

@ -15,12 +15,16 @@ export class InfoComponent implements OnInit {
constructor(private permissionService: PermissionService, private quotaService: QuotaService) { }
ngOnInit(): void {
this.permissionService.permissions().subscribe((data: any) => {
this.permissionService.permissions().subscribe({
next: (data: any) => {
this.permissions = data;
}
})
this.quotaService.quotasAll().subscribe((data: any) => {
this.quotaService.quotasAll().subscribe({
next: (data: any) => {
this.quotas = data;
}
})
}

View File

@ -46,16 +46,19 @@ export class SecurityComponent implements OnInit {
status: [ '', Validators.required ]
});
this.userService.get().subscribe((response: any) => {
this.userService.get().subscribe({
next: (response: any) => {
this.model.status = response.status;
}, error => {
}, error: (error) => { }
})
this.auth2FAService.isEnabled('totp').subscribe(response => {
this.auth2FAService.isEnabled('totp').subscribe({
next: (response) => {
this.totp = true;
}, error => {
},
error: (error) => {
this.totp = false;
}
})
}
@ -63,11 +66,13 @@ export class SecurityComponent implements OnInit {
if (this.passwordForm.valid && !this.working) {
this.working = true;
this.userService.password(this.model).subscribe((result: any) => {
this.userService.password(this.model).subscribe({
next: (result: any) => {
this.passwordFormDirective.resetForm();
this.success = true;
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -80,6 +85,7 @@ export class SecurityComponent implements OnInit {
this.passwordForm.get(code).setErrors(errors[ code ]);
}
}
}
})
}
}
@ -89,34 +95,45 @@ export class SecurityComponent implements OnInit {
if (this.statusForm.valid && !this.working) {
this.working = true;
this.userService.update({status : this.model.status}).subscribe((result: any) => {
this.userService.update({ status: this.model.status }).subscribe({
next: (result: any) => {
this.successStatus = true;
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
}
})
}
}
createTotp() {
this.auth2FAService.create('totp').subscribe((result: any) => {
this.auth2FAService.create('totp').subscribe({
next: (result: any) => {
const dialogRef = this.dialog.open(SecurityTotpDialog, {
closeOnNavigation: false,
disableClose: true,
data: result
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.auth2FAService.enable('totp', result).subscribe((result: any) => {
this.auth2FAService.enable('totp', result).subscribe({
next: (result: any) => {
this.totp = true;
}
})
} else {
this.auth2FAService.remove('totp').subscribe((result: any) => {
this.auth2FAService.remove('totp').subscribe({
next: (result: any) => {
this.totp = false;
}
})
}
}
});
}
})
}
@ -130,8 +147,10 @@ export class SecurityComponent implements OnInit {
}
removeTotp() {
this.auth2FAService.remove('totp').subscribe((result: any) => {
this.auth2FAService.remove('totp').subscribe({
next: (result: any) => {
this.totp = false;
}
})
}

View File

@ -23,8 +23,10 @@ export class VoucherComponent implements OnInit {
ngOnInit(): void {
this.voucherSource.data = this.vouchers;
this.voucherService.get().subscribe((data: any) => {
this.voucherService.get().subscribe({
next: (data: any) => {
this.available = data;
}
})
}

View File

@ -33,39 +33,55 @@ export class BorrowItemsComponent implements OnInit {
}
ngOnInit() {
this.authService.auth.subscribe((auth: any) => {
this.authService.auth.subscribe({
next: (auth: any) => {
if (auth.principal && auth.principal.userId) {
this.userId = auth.principal.userId;
}
}
});
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
this.borrowItemsService.getItems(0, this.page.size, this.page.sort, this.page.desc, value, this.ownerFormControl.value).subscribe((data: any) => {
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe({
next: (value) => {
this.borrowItemsService.getItems(0, this.page.size, this.page.sort, this.page.desc, value, this.ownerFormControl.value).subscribe(
{
next: (data: any) => {
this.borrowItems = data;
}, (error) => { })
}, error: (error) => { }
})
}
})
this.ownerFormControl.valueChanges.subscribe(value => {
this.borrowItemsService.getItems(0, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, value).subscribe((data: any) => {
this.ownerFormControl.valueChanges.subscribe({
next: (value) => {
this.borrowItemsService.getItems(0, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, value).subscribe({
next: (data: any) => {
this.borrowItems = data;
}, (error) => { })
}, error: (error) => { }
})
}
})
this.refresh();
}
refresh(): void {
this.borrowItemsService.getItems(this.page.page, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, this.ownerFormControl.value).subscribe((data: any) => {
this.borrowItemsService.getItems(this.page.page, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, this.ownerFormControl.value).subscribe({
next: (data: any) => {
this.borrowItems = data;
}
})
}
updatePages(event: PageEvent) {
this.page.page = event.pageIndex;
this.page.size = event.pageSize;
this.borrowItemsService.getItems(this.page.page, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, this.ownerFormControl.value).subscribe((data: any) => {
this.borrowItemsService.getItems(this.page.page, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, this.ownerFormControl.value).subscribe({
next: (data: any) => {
this.borrowItems = data;
}, (error) => { })
},
error: (error) => { }
})
}
updateSort(sort: Sort) {
@ -76,9 +92,13 @@ export class BorrowItemsComponent implements OnInit {
this.page.sort = sort.active;
this.page.desc = sort.direction == "desc";
}
this.borrowItemsService.getItems(this.page.page, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, this.ownerFormControl.value).subscribe((data: any) => {
this.borrowItemsService.getItems(this.page.page, this.page.size, this.page.sort, this.page.desc, this.searchFormControl.value, this.ownerFormControl.value).subscribe({
next: (data: any) => {
this.borrowItems = data;
}, (error) => { })
},
error: (error) => { }
})
}
edit(borrowItem) {
@ -87,10 +107,12 @@ export class BorrowItemsComponent implements OnInit {
minWidth: '80%'
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.refresh();
}
}
});
}
@ -100,10 +122,12 @@ export class BorrowItemsComponent implements OnInit {
minWidth: '80%'
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: result => {
if (result) {
this.refresh();
}
}
});
}
@ -115,10 +139,12 @@ export class BorrowItemsComponent implements OnInit {
}
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.refresh();
}
}
});
}
@ -130,12 +156,16 @@ export class BorrowItemsComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.borrowItemsService.deleteItem(borrowItem.id).subscribe((result: any) => {
this.borrowItemsService.deleteItem(borrowItem.id).subscribe({
next: (result: any) => {
this.refresh();
}
})
}
}
});
}
@ -172,13 +202,15 @@ export class BorrowItemEditComponent {
slots: this.formBuilder.array([])
}, { validators: [ durationValidator ] })
this.form.get('availability').valueChanges.subscribe((value) => {
this.form.get('availability').valueChanges.subscribe({
next: (value) => {
this.slots.clear();
if (value == 'MANUAL') {
this.addManualSlot('', '', '');
} else if (value == 'PERIOD') {
this.addPeriodSlot('', '', '', '', '');
}
}
})
if (data.id) {
@ -285,9 +317,11 @@ export class BorrowItemEditComponent {
save() {
this.borrowItemsService.createOrUpdateItem(this.formToBorrowItem()).subscribe((data: any) => {
this.borrowItemsService.createOrUpdateItem(this.formToBorrowItem()).subscribe({
next: (data: any) => {
this.dialogRef.close(data);
}, (error) => {
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
@ -299,6 +333,7 @@ export class BorrowItemEditComponent {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
}
@ -312,12 +347,16 @@ export class BorrowItemEditComponent {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.borrowItemsService.deleteItem(borrowItem.id).subscribe((result: any) => {
this.borrowItemsService.deleteItem(borrowItem.id).subscribe({
next: (result: any) => {
this.dialogRef.close(true);
}
})
}
}
});
}
}

View File

@ -38,8 +38,10 @@ export class BorrowProvingComponent implements AfterViewInit {
if (this.cameras.length) {
this.noCamera = false;
this.camera.setValue(this.cameras[ 0 ].id, { emitEvent: false });
this.camera.valueChanges.subscribe((value) => {
this.camera.valueChanges.subscribe({
next: (value) => {
this.qrScanner.setCamera(value);
}
})
}
})
@ -47,12 +49,14 @@ export class BorrowProvingComponent implements AfterViewInit {
this.qrScanner.hasFlash().then(hasFlash => {
if (hasFlash) {
this.toggleFlash.enable();
this.toggleFlash.valueChanges.subscribe(value => {
this.toggleFlash.valueChanges.subscribe({
next: (value) => {
if (value) {
this.qrScanner.turnFlashOn();
} else {
this.qrScanner.turnFlashOff();
}
}
});
} else {
this.toggleFlash.disable();
@ -64,10 +68,13 @@ export class BorrowProvingComponent implements AfterViewInit {
onResult(result: string) {
this.qrScanner.pause();
this.borrowRequestService.verifyRequest(result).subscribe((response) => {
this.borrowRequestService.verifyRequest(result).subscribe({
next: (response) => {
this.openResultDialog(response, true);
}, (error) => {
},
error: (error) => {
this.openResultDialog(error, false);
}
});
}
@ -80,8 +87,10 @@ export class BorrowProvingComponent implements AfterViewInit {
disableClose: true,
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
this.qrScanner.start();
}
});
}
}

View File

@ -33,34 +33,46 @@ export class BorrowRequestsComponent implements OnInit {
}
ngOnInit() {
this.authService.auth.subscribe((auth: any) => {
this.authService.auth.subscribe({
next: (auth: any) => {
if (auth.principal && auth.principal.userId) {
this.userId = auth.principal.userId;
}
}
});
this.ownerFormControl.valueChanges.subscribe(value => {
this.borrowRequestsService.getRequests(0, this.page.size, this.page.sort, this.page.desc, value).subscribe((data: any) => {
this.ownerFormControl.valueChanges.subscribe({
next: (value) => {
this.borrowRequestsService.getRequests(0, this.page.size, this.page.sort, this.page.desc, value).subscribe({
next: (data: any) => {
this.borrowRequests = data;
}, (error) => { })
},
error: (error) => { }
})
}
})
this.refresh();
}
refresh(): void {
this.borrowRequestsService.getRequests(this.page.page, this.page.size, this.page.sort, this.page.desc, this.ownerFormControl.value).subscribe((data: any) => {
this.borrowRequestsService.getRequests(this.page.page, this.page.size, this.page.sort, this.page.desc, this.ownerFormControl.value).subscribe({
next: (data: any) => {
this.borrowRequests = data;
}
})
}
updatePages(event: PageEvent) {
this.page.page = event.pageIndex;
this.page.size = event.pageSize;
this.borrowRequestsService.getRequests(this.page.page, this.page.size, this.page.sort, this.page.desc, this.ownerFormControl.value).subscribe((data: any) => {
this.borrowRequestsService.getRequests(this.page.page, this.page.size, this.page.sort, this.page.desc, this.ownerFormControl.value).subscribe({
next: (data: any) => {
this.borrowRequests = data;
}, (error) => { })
},
error: (error) => { }
})
}
updateSort(sort: Sort) {
@ -71,9 +83,12 @@ export class BorrowRequestsComponent implements OnInit {
this.page.sort = sort.active;
this.page.desc = sort.direction == "desc";
}
this.borrowRequestsService.getRequests(this.page.page, this.page.size, this.page.sort, this.page.desc, this.ownerFormControl.value).subscribe((data: any) => {
this.borrowRequestsService.getRequests(this.page.page, this.page.size, this.page.sort, this.page.desc, this.ownerFormControl.value).subscribe({
next: (data: any) => {
this.borrowRequests = data;
}, (error) => { })
},
error: (error) => { }
})
}
edit(borrowRequest) {
@ -81,10 +96,12 @@ export class BorrowRequestsComponent implements OnInit {
data: borrowRequest
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.refresh();
}
}
});
}
@ -96,12 +113,16 @@ export class BorrowRequestsComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.borrowRequestsService.deleteRequest(borrowRequest.id).subscribe((result: any) => {
this.borrowRequestsService.deleteRequest(borrowRequest.id).subscribe({
next: (result: any) => {
this.refresh();
}
})
}
}
});
}
@ -143,9 +164,11 @@ export class BorrowRequestEditComponent {
save() {
this.borrowRequestsService.createOrUpdateRequest(this.formToBorrowRequest()).subscribe((data: any) => {
this.borrowRequestsService.createOrUpdateRequest(this.formToBorrowRequest()).subscribe({
next: (data: any) => {
this.dialogRef.close(data);
}, (error) => {
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
@ -157,6 +180,7 @@ export class BorrowRequestEditComponent {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
}
@ -170,12 +194,16 @@ export class BorrowRequestEditComponent {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.borrowRequestsService.deleteRequest(borrowRequest.id).subscribe((result: any) => {
this.borrowRequestsService.deleteRequest(borrowRequest.id).subscribe({
next: (result: any) => {
this.dialogRef.close(true);
}
})
}
}
});
}
}

View File

@ -24,7 +24,8 @@ export class FormLogin2FAComponent implements OnInit {
private auth2FAService: Auth2FAService) { }
async ngOnInit() {
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params[ 'error' ] || params[ 'error' ] == '') {
this.loginInvalid = true;
this.router.navigate([], { queryParams: { error: null }, queryParamsHandling: 'merge' });
@ -33,13 +34,16 @@ export class FormLogin2FAComponent implements OnInit {
this.keep = true;
this.router.navigate([], { queryParams: { keep: null }, queryParamsHandling: 'merge' });
}
}
});
this.auth2FAService.getEnabled().subscribe((providers: any) => {
this.auth2FAService.getEnabled().subscribe({
next: (providers: any) => {
this.providers = providers;
if (this.providers[ 0 ]) {
this.selectedProvider = this.providers[ 0 ];
}
}
})
}

View File

@ -20,7 +20,8 @@ export class FormLoginComponent implements OnInit {
private route: ActivatedRoute) { }
async ngOnInit() {
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', replaceUrl: true });
@ -29,6 +30,7 @@ export class FormLoginComponent implements OnInit {
this.loginInvalid = true;
this.router.navigate([], { queryParams: { error: null }, queryParamsHandling: 'merge', replaceUrl: true });
}
}
});
}

View File

@ -35,8 +35,10 @@ export class InviteCodeComponent implements OnInit {
private i18n: I18nService,
public dialog: MatDialog,
private route: ActivatedRoute) {
this.authService.auth.subscribe(data => {
this.authService.auth.subscribe({
next: (data) => {
this.auth = data;
}
})
}
@ -53,7 +55,8 @@ export class InviteCodeComponent implements OnInit {
});
const code = this.route.snapshot.paramMap.get('code');
this.inviteService.code(code).subscribe((data) => {
this.inviteService.code(code).subscribe({
next: (data) => {
this.invite = data;
if (this.invite.redeemed) {
@ -71,19 +74,25 @@ export class InviteCodeComponent implements OnInit {
}
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 406) {
this.error = "INVALID_CODE";
}
}
})
this.inviteService.permissions(code).subscribe((data: any) => {
this.inviteService.permissions(code).subscribe({
next: (data: any) => {
this.permissions = data;
}
})
this.inviteService.quotas(code).subscribe((data: any) => {
this.inviteService.quotas(code).subscribe({
next: (data: any) => {
this.quotas = data;
}
})
}
@ -108,10 +117,12 @@ export class InviteCodeComponent implements OnInit {
model.password = this.form.get("password").value;
model.password2 = this.form.get("password2").value;
this.inviteService.register(model).subscribe((result: any) => {
this.inviteService.register(model).subscribe({
next: (result: any) => {
this.working = false;
this.success = true;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 401) {
this.error = "NO_CODE";
@ -130,6 +141,7 @@ export class InviteCodeComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}
@ -140,10 +152,12 @@ export class InviteCodeComponent implements OnInit {
this.working = true;
this.invite.message = this.form.get("message").value;
this.invite.note = this.form.get("note").value;
this.inviteService.update(this.invite).subscribe((result: any) => {
this.inviteService.update(this.invite).subscribe({
next: (result: any) => {
this.invite = result;
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 406) {
this.error = "INVALID_CODE";
@ -160,6 +174,7 @@ export class InviteCodeComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}
}

View File

@ -44,10 +44,12 @@ export class InviteEditComponent {
this.invite.message = this.form.get("message").value;
this.invite.note = this.form.get("note").value;
this.inviteService.update(this.invite).subscribe((result: any) => {
this.inviteService.update(this.invite).subscribe({
next: (result: any) => {
this.working = false;
this.dialogRef.close(result);
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 406) {
this.error = "INVALID_CODE";
@ -64,6 +66,7 @@ export class InviteEditComponent {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}

View File

@ -47,26 +47,46 @@ export class InvitesComponent implements OnInit {
this.datetimeformat = this.i18n.get('format.datetime', []);
this.quota = this.route.snapshot.paramMap.get('quota');
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
this.inviteService.getPages(this.quota, 0, this.invites.size, value, this.redeemedFormControl.value).subscribe((data: any) => {
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe({
next: (value) => {
this.inviteService.getPages(this.quota, 0, this.invites.size, value, this.redeemedFormControl.value).subscribe({
next: (data: any) => {
this.invites = data;
}, (error) => { })
},
error: (error) => { }
})
this.redeemedFormControl.valueChanges.subscribe(value => {
this.inviteService.getPages(this.quota, 0, this.invites.size, this.searchFormControl.value ? this.searchFormControl.value : "", value).subscribe((data: any) => {
}
})
this.redeemedFormControl.valueChanges.subscribe({
next: (value) => {
this.inviteService.getPages(this.quota, 0, this.invites.size, this.searchFormControl.value ? this.searchFormControl.value : "", value).subscribe({
next: (data: any) => {
this.invites = data;
}, (error) => { })
},
error: (error) => { }
})
}
})
this.searchOthersFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
this.inviteService.getOthersPages(this.quota, 0, this.others.size, value, this.redeemedOthersFormControl.value).subscribe((data: any) => {
this.searchOthersFormControl.valueChanges.pipe(debounceTime(500)).subscribe({
next: (value) => {
this.inviteService.getOthersPages(this.quota, 0, this.others.size, value, this.redeemedOthersFormControl.value).subscribe({
next: (data: any) => {
this.others = data;
}, (error) => { })
},
error: (error) => { }
})
this.redeemedOthersFormControl.valueChanges.subscribe(value => {
this.inviteService.getOthersPages(this.quota, 0, this.others.size, this.searchOthersFormControl.value ? this.searchOthersFormControl.value : "", value).subscribe((data: any) => {
}
})
this.redeemedOthersFormControl.valueChanges.subscribe({
next: (value) => {
this.inviteService.getOthersPages(this.quota, 0, this.others.size, this.searchOthersFormControl.value ? this.searchOthersFormControl.value : "", value).subscribe({
next: (data: any) => {
this.others = data;
}, (error) => { })
}, error: (error) => { }
})
}
})
this.update();
@ -75,41 +95,56 @@ export class InvitesComponent implements OnInit {
update(): void {
this.inviteQuota = 0;
this.quotaService.quotas().subscribe((data: any) => {
this.quotaService.quotas().subscribe({
next: (data: any) => {
for (let quota of data) {
if (quota.name == "invite_" + this.quota) {
this.inviteQuota = quota.value;
}
}
}
})
if (!this.invites) {
this.inviteService.get(this.quota).subscribe((data: any) => {
this.inviteService.get(this.quota).subscribe({
next: (data: any) => {
this.invites = data;
}
})
} else {
this.inviteService.getPages(this.quota, this.invites.number || 0, this.invites.size || 10, this.searchFormControl.value ? this.searchFormControl.value : "", this.redeemedFormControl.value).subscribe((data: any) => {
this.inviteService.getPages(this.quota, this.invites.number || 0, this.invites.size || 10, this.searchFormControl.value ? this.searchFormControl.value : "", this.redeemedFormControl.value).subscribe({
next: (data: any) => {
this.invites = data;
}, (error) => { })
},
error: (error) => { }
})
}
this.inviteService.getOthers(this.quota).subscribe((data: any) => {
this.inviteService.getOthers(this.quota).subscribe({
next: (data: any) => {
this.others = data;
}, (error) => { })
},
error: (error) => { }
})
}
updatePages(event: PageEvent) {
this.inviteService.getPages(this.quota, event.pageIndex, event.pageSize, this.searchFormControl.value ? this.searchFormControl.value : "", this.redeemedFormControl.value).subscribe((data: any) => {
this.inviteService.getPages(this.quota, event.pageIndex, event.pageSize, this.searchFormControl.value ? this.searchFormControl.value : "", this.redeemedFormControl.value).subscribe({
next: (data: any) => {
this.invites = data;
}, (error) => { })
},
error: (error) => { }
})
}
create(): void {
this.working = true;
this.inviteService.create(this.quota, {}).subscribe(response => {
this.inviteService.create(this.quota, {}).subscribe({
next: (response) => {
this.update();
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -118,6 +153,7 @@ export class InvitesComponent implements OnInit {
errors[ code.field ][ code.code ] = true;
}
}
}
})
}
@ -127,16 +163,21 @@ export class InvitesComponent implements OnInit {
minWidth: "400px"
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.update();
}
}
});
}
updateOthers(event: PageEvent) {
this.inviteService.getOthersPages(this.quota, event.pageIndex, event.pageSize, this.searchOthersFormControl.value ? this.searchOthersFormControl.value : "", this.redeemedOthersFormControl.value).subscribe((data: any) => {
this.inviteService.getOthersPages(this.quota, event.pageIndex, event.pageSize, this.searchOthersFormControl.value ? this.searchOthersFormControl.value : "", this.redeemedOthersFormControl.value).subscribe({
next: (data: any) => {
this.others = data;
}, (error) => { })
},
error: (error) => { }
})
}
}

View File

@ -61,12 +61,14 @@ export class JitsiComponent implements OnInit {
this.jitsiRoom.moderationStarts = null;
}
this.jitsiService.create(this.jitsiRoom).subscribe(response => {
this.jitsiService.create(this.jitsiRoom).subscribe({
next: (response) => {
this.refresh();
this.formDirective.resetForm();
this.jitsiRoom = {};
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -79,13 +81,15 @@ export class JitsiComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}
refresh() {
this.jitsiRoomsQuota = 0;
this.shortenedUrlQuota = 0;
this.quotaService.quotas().subscribe((data: any) => {
this.quotaService.quotas().subscribe({
next: (data: any) => {
for (let quota of data) {
if (quota.name == "jitsi") {
this.jitsiRoomsQuota = quota.value;
@ -93,19 +97,25 @@ export class JitsiComponent implements OnInit {
this.shortenedUrlQuota = quota.value;
}
}
}
})
this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => {
this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe({
next: (data: any) => {
this.jitsiRooms = data;
}
})
}
updatePages(event: PageEvent) {
this.page.page = event.pageIndex;
this.page.size = event.pageSize;
this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => {
this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe({
next: (data: any) => {
this.jitsiRooms = data;
}, (error) => { })
},
error: (error) => { }
})
}
updateSort(sort: Sort) {
@ -116,9 +126,12 @@ export class JitsiComponent implements OnInit {
this.page.sort = sort.active;
this.page.desc = sort.direction == "desc";
}
this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe((data: any) => {
this.jitsiService.get(this.page.page, this.page.size, this.page.sort, this.page.desc).subscribe({
next: (data: any) => {
this.jitsiRooms = data;
}, (error) => { })
},
error: (error) => { }
})
}
confirmDelete(jitsiRoom) {
@ -129,12 +142,16 @@ export class JitsiComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.jitsiService.delete(jitsiRoom.id).subscribe((result: any) => {
this.jitsiService.delete(jitsiRoom.id).subscribe({
next: (result: any) => {
this.refresh();
}
})
}
}
});
}
@ -150,10 +167,13 @@ export class JitsiComponent implements OnInit {
}
createShortenedUrl(jitsiRoom: any) {
this.jitsiService.createShortUrl(jitsiRoom.id).subscribe((result: any) => {
this.jitsiService.createShortUrl(jitsiRoom.id).subscribe({
next: (result: any) => {
this.refresh();
}, (error: any) => {
},
error: (error: any) => {
this.snackBar.open(this.i18n.get("urlshortener.noQuota", []), this.i18n.get("close", []));
}
});
}
@ -176,10 +196,12 @@ export class JitsiComponent implements OnInit {
minWidth: '400px',
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.refresh();
}
}
});
}
}
@ -222,9 +244,11 @@ export class JitsiEditDialog {
}
save() {
this.jitsiService.update(this.jitsiRoom).subscribe((result: any) => {
this.jitsiService.update(this.jitsiRoom).subscribe({
next: (result: any) => {
this.dialogRef.close(result);
}, (error) => {
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
@ -236,6 +260,7 @@ export class JitsiEditDialog {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
}

View File

@ -4,6 +4,7 @@
<mat-card-header>
<mat-card-title>{{'jukebox' | i18n}}</mat-card-title>
</mat-card-header>
<ng-container *ngIf="!checking">
<mat-card-title-group *ngIf="currentTrack">
<img *ngIf="getImageUrl(currentTrack)" mat-card-sm-image [src]="getImageUrl(currentTrack)">
<mat-card-title><small>{{'jukebox.current' | i18n}}</small></mat-card-title>
@ -22,11 +23,25 @@
</mat-form-field>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button type="submit" [disabled]="!searchFormControl.value || timeout > 0 || searchDisabled">
<button mat-raised-button type="submit"
[disabled]="!searchFormControl.value || timeout > 0 || searchDisabled">
<mat-icon inline="true">{{'jukebox.search.icon' | i18n}}</mat-icon>
{{'jukebox.search.submit' | i18n}}
</button>
</mat-card-actions>
<mat-card-footer>
<a (click)="check()" class="help-button" mat-fab color="accent">
<mat-icon>refresh</mat-icon>
</a>
</mat-card-footer>
</ng-container>
<ng-container *ngIf="checking">
<mat-card-actions>
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</mat-card-actions>
</ng-container>
</mat-card>
</form>

View File

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
@ -15,18 +15,20 @@ import { Data } from '@angular/router';
templateUrl: './jukebox.component.html',
styleUrls: [ './jukebox.component.scss' ]
})
export class JukeboxComponent implements OnInit {
export class JukeboxComponent implements OnInit, OnDestroy {
timeout: number = 0;
timer;
searchResult: any;
currentTrack: any;
checking: boolean = false;
active: boolean = false;
wait: boolean = false;
forbidden: boolean = false;
unavailable: boolean = false;
searchDisabled = true;
searchFormControl = new FormControl();
automaticCheck;
constructor(
public dialog: MatDialog,
@ -37,23 +39,38 @@ export class JukeboxComponent implements OnInit {
ngOnInit(): void {
this.check();
this.searchFormControl.valueChanges.subscribe(value => {
this.searchFormControl.valueChanges.subscribe({
next: (value) => {
this.searchDisabled = false;
}
})
this.automaticCheck = setInterval(() => {
this.check();
}, 15000);
}
ngOnDestroy(): void {
if (this.automaticCheck) {
clearInterval(this.automaticCheck);
}
}
check() {
this.timeout = 0;
this.wait = false;
this.checking = true;
this.forbidden = false;
this.unavailable = false;
this.jukeboxService.check().subscribe((response) => {
this.jukeboxService.check().subscribe({
next: (response) => {
if (response) {
this.currentTrack = response;
}
this.active = true;
}, (error) => {
this.checking = false;
},
error: (error) => {
this.active = false;
if (error.status == 403) {
this.forbidden = true;
@ -63,8 +80,10 @@ export class JukeboxComponent implements OnInit {
this.wait = true;
this.timeout = 60 - error.error;
this.jukeboxService.current().subscribe((response) => {
this.jukeboxService.current().subscribe({
next: (response) => {
this.currentTrack = response;
}
});
this.timer = setInterval(() => {
@ -75,24 +94,30 @@ export class JukeboxComponent implements OnInit {
}
}, 1000)
}
this.checking = false;
}
})
}
search() {
this.searchDisabled = true;
this.jukeboxService.search(this.searchFormControl.value).subscribe((data: any) => {
this.jukeboxService.search(this.searchFormControl.value).subscribe({
next: (data: any) => {
this.searchResult = data.tracks;
}
})
}
searchMore() {
this.searchDisabled = true;
this.jukeboxService.searchOffset(this.searchFormControl.value, this.searchResult.offset + this.searchResult.limit).subscribe((data: any) => {
this.jukeboxService.searchOffset(this.searchFormControl.value, this.searchResult.offset + this.searchResult.limit).subscribe({
next: (data: any) => {
this.searchResult.offset = data.tracks.offset;
this.searchResult.total = data.tracks.total;
for (let track of data.tracks.items) {
this.searchResult.items.push(track);
}
}
})
}
@ -117,9 +142,11 @@ export class JukeboxComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.jukeboxService.queue(track.uri).subscribe(() => {
this.jukeboxService.queue(track.uri).subscribe({
next: () => {
this.active = false;
this.wait = true;
this.timeout = 60;
@ -134,12 +161,15 @@ export class JukeboxComponent implements OnInit {
this.snackBar.open(this.i18n.get("jukebox.addToQueue.success", []), this.i18n.get("close", []), {
duration: 3000
});
}, (error) => {
},
error: (error) => {
this.snackBar.open(this.i18n.get("jukebox.addToQueue.error", []), this.i18n.get("close", []), {
duration: 3000
});
}
})
}
}
});
}

View File

@ -26,20 +26,25 @@ export class LoginTotpComponent implements OnInit {
keep: [ '' ]
});
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
}
}
});
}
async loginTotp() {
this.loginInvalid = false;
if (this.form.valid) {
this.auth2FAService.login('totp', this.form.get('code').value, this.form.get('keep').value).subscribe((response: any) => {
this.auth2FAService.login('totp', this.form.get('code').value, this.form.get('keep').value).subscribe({
next: (response: any) => {
this.router.navigate([ this.targetRoute ]);
}, error => {
},
error: (error) => {
this.loginInvalid = true;
}
});
}

View File

@ -31,11 +31,13 @@ export class LoginComponent implements OnInit {
keep: [ '' ]
});
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge' });
}
}
});
}
@ -49,14 +51,17 @@ export class LoginComponent implements OnInit {
keep: this.form.get('keep').value
};
this.authService.login(loginModel).subscribe((response: any) => {
this.authService.login(loginModel).subscribe({
next: (response: any) => {
this.router.navigate([ this.targetRoute ]);
}, error => {
},
error: (error) => {
if (error.status == 428) {
this.router.navigate([ "/login/totp" ], { queryParams: { target: this.targetRoute } });
} else {
this.loginInvalid = true;
}
}
});
}

View File

@ -41,12 +41,14 @@ export class MinetestAccountsComponent implements OnInit {
create(): void {
this.working = true;
this.minetestAccountsService.create(this.minetestAccount).subscribe(response => {
this.minetestAccountsService.create(this.minetestAccount).subscribe({
next: (response) => {
this.refresh();
this.formDirective.resetForm();
this.minetestAccount = {};
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -59,21 +61,26 @@ export class MinetestAccountsComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}
refresh() {
this.minetestAccountsQuota = 0;
this.quotaService.quotas().subscribe((data: any) => {
this.quotaService.quotas().subscribe({
next: (data: any) => {
for (let quota of data) {
if (quota.name == "minetest_accounts") {
this.minetestAccountsQuota = quota.value;
}
}
}
})
this.minetestAccountsService.get().subscribe((data: any) => {
this.minetestAccountsService.get().subscribe({
next: (data: any) => {
this.minetestAccounts = data;
}
})
}
@ -86,12 +93,16 @@ export class MinetestAccountsComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.minetestAccountsService.delete(name).subscribe((result: any) => {
this.minetestAccountsService.delete(name).subscribe({
next: (result: any) => {
this.refresh();
}
})
}
}
});
}
}

View File

@ -16,8 +16,10 @@ export class ParteyComponent implements OnInit {
}
ngOnInit(): void {
this.parteyTagsService.get().subscribe((data: any[]) => {
this.parteyTagsService.get().subscribe({
next: (data: any[]) => {
this.tags = data;
}
})
}

View File

@ -56,10 +56,12 @@ export class ParteyTimeslotsComponent implements OnInit {
ngOnInit(): void {
this.authService.auth.subscribe((auth: any) => {
this.authService.auth.subscribe({
next: (auth: any) => {
if (auth.principal && auth.principal.userId) {
this.userId = auth.principal.userId;
}
}
});
this.datetimeformat = this.i18n.get('format.datetime', []);
@ -78,29 +80,51 @@ export class ParteyTimeslotsComponent implements OnInit {
this.filter.after = moment.utc().format();
this.afterFormControl.setValue(new Date());
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe({
next: (value) => {
this.filter.search = value;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe({
next: (data: any) => {
this.timeslots = data;
}, (error) => { })
},
error: (error) => { }
})
this.ownerFormControl.valueChanges.subscribe(value => {
}
})
this.ownerFormControl.valueChanges.subscribe({
next: (value) => {
this.filter.owner = value;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe({
next: (data: any) => {
this.timeslots = data;
}, (error) => { })
},
error: (error) => { }
})
this.typeFormControl.valueChanges.subscribe(value => {
}
})
this.typeFormControl.valueChanges.subscribe({
next: (value) => {
this.filter.type = value;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe({
next: (data: any) => {
this.timeslots = data;
}, (error) => { })
},
error: (error) => { }
})
this.afterFormControl.valueChanges.subscribe((value: Date) => {
}
})
this.afterFormControl.valueChanges.subscribe({
next: (value: Date) => {
this.filter.after = value && moment.utc(value).format() || undefined;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe({
next: (data: any) => {
this.timeslots = data;
}, (error) => { })
},
error: (error) => { }
})
}
})
this.refresh();
@ -109,21 +133,28 @@ export class ParteyTimeslotsComponent implements OnInit {
refresh() {
this.timeslotsQuota = 0;
this.parteyTimeslotsService.quota().subscribe((data: number) => {
this.parteyTimeslotsService.quota().subscribe({
next: (data: number) => {
this.timeslotsQuota = data;
}
})
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe({
next: (data: any) => {
this.timeslots = data;
}
})
}
updatePages(event: PageEvent) {
this.page.page = event.pageIndex;
this.page.size = event.pageSize;
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe({
next: (data: any) => {
this.timeslots = data;
}, (error) => { })
},
error: (error) => { }
})
}
updateSort(sort: Sort) {
@ -134,9 +165,12 @@ export class ParteyTimeslotsComponent implements OnInit {
this.page.sort = sort.active;
this.page.desc = sort.direction == "desc";
}
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe({
next: (data: any) => {
this.timeslots = data;
}, (error) => { })
},
error: (error) => { }
})
}
confirmDelete(timeslot) {
@ -147,12 +181,16 @@ export class ParteyTimeslotsComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.parteyTimeslotsService.delete(timeslot.id).subscribe((result: any) => {
this.parteyTimeslotsService.delete(timeslot.id).subscribe({
next: (result: any) => {
this.refresh();
}
})
}
}
});
}
@ -162,10 +200,12 @@ export class ParteyTimeslotsComponent implements OnInit {
minWidth: '400px'
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.refresh();
}
}
});
}
@ -176,10 +216,12 @@ export class ParteyTimeslotsComponent implements OnInit {
minWidth: '400px'
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.refresh();
}
}
});
}
@ -229,9 +271,11 @@ export class ParteyTimeslotDialog {
}
create(timeslot) {
this.parteyTimeslotsService.create(timeslot).subscribe((result: any) => {
this.parteyTimeslotsService.create(timeslot).subscribe({
next: (result: any) => {
this.dialogRef.close(timeslot);
}, (error) => {
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
@ -243,13 +287,16 @@ export class ParteyTimeslotDialog {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
}
save(timeslot) {
this.parteyTimeslotsService.update(timeslot).subscribe((result: any) => {
this.parteyTimeslotsService.update(timeslot).subscribe({
next: (result: any) => {
this.dialogRef.close(timeslot);
}, (error) => {
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
@ -261,6 +308,7 @@ export class ParteyTimeslotDialog {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
}

View File

@ -32,19 +32,23 @@ export class PasswordResetComponent implements OnInit {
validator: MatchingValidator('password', 'password2')
});
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params.token) {
this.model.token = params.token;
}
}
});
}
passwordReset() {
this.working = true;
this.authService.passwordReset(this.model).subscribe(response => {
this.authService.passwordReset(this.model).subscribe({
next: (response) => {
this.success = true;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -59,6 +63,7 @@ export class PasswordResetComponent implements OnInit {
} else {
this.tokenInvalid = true;
}
}
})
}

View File

@ -33,7 +33,8 @@ export class PasswordComponent implements OnInit {
username: this.model.username
}
this.authService.passwordRequest(this.model.username).subscribe(async response => {
this.authService.passwordRequest(this.model.username).subscribe({
next: async response => {
if (privateKey) {
const message = await openpgp.message.readArmored(response);
@ -47,6 +48,7 @@ export class PasswordComponent implements OnInit {
} else {
this.working = false;
}
}
})
}

View File

@ -60,17 +60,23 @@ export class RegisterComponent implements OnInit {
validator: MatchingValidator('password', 'password2')
});
this.itemService.items().subscribe((data: any) => {
this.itemService.items().subscribe({
next: (data: any) => {
this.items = data;
}
});
this.permissionService.permissionsNew().subscribe((data: any) => {
this.permissionService.permissionsNew().subscribe({
next: (data: any) => {
this.permissions = data;
})
}
});
this.quotaService.quotasNew().subscribe((data: any) => {
this.quotaService.quotasNew().subscribe({
next: (data: any) => {
this.quotas = data;
})
}
});
}
onPrimaryChange() {
@ -119,7 +125,8 @@ export class RegisterComponent implements OnInit {
this.model.profileFields.push({ "name": "primaryEmail", "type": "BOOL", "visibility": "PRIVATE", "value": this.model.primaryEmail });
}
this.userService.register(this.model).subscribe((result: any) => {
this.userService.register(this.model).subscribe({
next: (result: any) => {
result.privateKey = privKey;
const dialogRef = this.dialog.open(RegisterDialog, {
@ -128,14 +135,17 @@ export class RegisterComponent implements OnInit {
data: result
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.success = true;
}
}
});
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 401) {
this.missingToken = true;
@ -152,6 +162,7 @@ export class RegisterComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
})

View File

@ -20,7 +20,8 @@ export class ServicesComponent implements OnInit {
this.view = localStorage.getItem("bstly.servicesView") || 'grid';
this.serviceService.services().subscribe((data: Array<any>) => {
this.serviceService.services().subscribe({
next: (data: Array<any>) => {
let that = this;
that.baseServices = [];
data.forEach(function (service) {
@ -33,6 +34,7 @@ export class ServicesComponent implements OnInit {
that.serviceCategory[ service.category ].push(service);
}
})
}
})
}

View File

@ -37,8 +37,10 @@ export class TokensComponent implements OnInit {
this.currentLocale = this.i18n.getLocale();
this.authService.auth.subscribe(data => {
this.authService.auth.subscribe({
next: (data) => {
this.auth = data;
}
})
this.update();
@ -49,19 +51,24 @@ export class TokensComponent implements OnInit {
token: [ '', Validators.required ]
});
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params.token) {
this.itemService.redeemSecret(params.token).subscribe((data: any) => {
this.itemService.redeemSecret(params.token).subscribe({
next: (data: any) => {
this.update();
}, error => {
},
error: error => {
this.form.get('token').patchValue(params.token);
if (error.status == 410) {
this.tokenRedeemed = true;
} else {
this.tokenInvalid = true;
}
}
})
}
}
});
}
@ -70,46 +77,60 @@ export class TokensComponent implements OnInit {
this.tokenRedeemed = false;
if (this.form.valid) {
const secret = this.form.get('token').value;
this.itemService.redeemSecret(secret).subscribe((data: any) => {
this.itemService.redeemSecret(secret).subscribe({
next: (data: any) => {
this.formDirective.resetForm();
this.update();
}, error => {
},
error: (error) => {
if (error.status == 410) {
this.tokenRedeemed = true;
} else {
this.tokenInvalid = true;
}
}
})
}
}
removeSecret(secret: String) {
this.itemService.removeSecret(secret).subscribe((data: any) => {
this.itemService.removeSecret(secret).subscribe({
next: (data: any) => {
this.update();
}, error => {
},
error: (error) => {
}
})
}
redeem() {
if (this.auth.authenticated) {
this.itemService.redeem().subscribe((data: any) => {
this.itemService.redeem().subscribe({
next: (data: any) => {
this.router.navigate([ "/account/info" ]);
}
})
}
}
update() {
this.authService.getAuth().then(response => {
this.itemService.items().subscribe((data: any) => {
this.itemService.items().subscribe({
next: (data: any) => {
this.items = data;
}
});
this.permissionService.permissionsNew().subscribe((data: any) => {
this.permissionService.permissionsNew().subscribe({
next: (data: any) => {
this.permissions = data;
}
})
this.quotaService.quotasNew().subscribe((data: any) => {
this.quotaService.quotasNew().subscribe({
next: (data: any) => {
this.quotas = data;
}
})
}).catch(function (error) { });;
}

View File

@ -16,11 +16,13 @@ export class UnavailableComponent implements OnInit {
private route: ActivatedRoute) { }
ngOnInit(): void {
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params[ 'target' ]) {
this.targetRoute = params[ 'target' ];
this.router.navigate([], { queryParams: { target: null }, queryParamsHandling: 'merge', skipLocationChange: true });
}
}
});
}

View File

@ -60,17 +60,23 @@ export class UrlShortenerComponent implements OnInit {
});
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe({
next: (value) => {
this.page.search = this.searchFormControl.value ? this.searchFormControl.value : "";
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe((data: any) => {
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe({
next: (data: any) => {
this.shortenedUrls = data;
}
})
}
})
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params.url) {
this.shortenedUrl.url = decodeURIComponent(params.url);
}
}
})
this.refresh();
@ -79,12 +85,14 @@ export class UrlShortenerComponent implements OnInit {
create(): void {
this.working = true;
this.urlShortenerService.create(this.shortenedUrl).subscribe(response => {
this.urlShortenerService.create(this.shortenedUrl).subscribe({
next: (response) => {
this.refresh();
this.formDirective.resetForm();
this.shortenedUrl = {};
this.working = false;
}, (error) => {
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
@ -97,40 +105,51 @@ export class UrlShortenerComponent implements OnInit {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
})
}
refresh() {
this.shortenedUrlQuota = 0;
this.quotaService.quotas().subscribe((data: any) => {
this.quotaService.quotas().subscribe({
next: (data: any) => {
for (let quota of data) {
if (quota.name == "url_shortener") {
this.shortenedUrlQuota = quota.value;
}
}
}
})
this.page.search = this.searchFormControl.value ? this.searchFormControl.value : "";
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe((data: any) => {
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe({
next: (data: any) => {
this.shortenedUrls = data;
}
})
}
updateSearch() {
this.page.search = this.searchFormControl.value ? this.searchFormControl.value : "";
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe((data: any) => {
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe({
next: (data: any) => {
this.shortenedUrls = data;
}, (error) => { })
},
error: (error) => { }
})
}
updatePages(event: PageEvent) {
this.page.page = event.pageIndex;
this.page.size = event.pageSize;
this.page.search = this.searchFormControl.value ? this.searchFormControl.value : "";
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe((data: any) => {
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe({
next: (data: any) => {
this.shortenedUrls = data;
}, (error) => { })
},
error: (error) => { }
})
}
updateSort(sort: Sort) {
@ -142,9 +161,12 @@ export class UrlShortenerComponent implements OnInit {
this.page.desc = sort.direction == "desc";
}
this.page.search = this.searchFormControl.value ? this.searchFormControl.value : "";
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe((data: any) => {
this.urlShortenerService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.page.search).subscribe({
next: (data: any) => {
this.shortenedUrls = data;
}, (error) => { })
},
error: (error) => { }
})
}
confirmDelete(shortenedUrl) {
@ -155,12 +177,16 @@ export class UrlShortenerComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.urlShortenerService.delete(shortenedUrl.code).subscribe((result: any) => {
this.urlShortenerService.delete(shortenedUrl.code).subscribe({
next: (result: any) => {
this.refresh();
}
})
}
}
});
}
@ -177,10 +203,12 @@ export class UrlShortenerComponent implements OnInit {
minWidth: '400px',
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.refresh();
}
}
});
}
}
@ -236,9 +264,11 @@ export class UrlShortenerEditDialog {
}
save() {
this.urlShortenerService.update(this.shortenedUrlModel).subscribe((result: any) => {
this.urlShortenerService.update(this.shortenedUrlModel).subscribe({
next: (result: any) => {
this.dialogRef.close(result);
}, (error) => {
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
@ -250,6 +280,7 @@ export class UrlShortenerEditDialog {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
}
@ -308,10 +339,12 @@ export class UrlShortenerPasswordComponent implements OnInit {
async ngOnInit() {
this.code = this.route.snapshot.paramMap.get('code');
this.route.queryParams.subscribe(params => {
this.route.queryParams.subscribe({
next: (params) => {
if (params[ 'error' ] || params[ 'error' ] == '') {
this.invalidPassword = true;
}
}
});
}

View File

@ -24,15 +24,20 @@ export class UserComponent implements OnInit {
async ngOnInit() {
this.username = this.route.snapshot.paramMap.get('username');
this.profileService.getForUser(this.username).subscribe((data: any) => {
this.profileService.getForUser(this.username).subscribe({
next: (data: any) => {
this.success = true;
this.model = data;
this.authService.auth.subscribe((auth: any) => {
this.authService.auth.subscribe({
next: (auth: any) => {
this.isMe = auth && auth.principal && auth.principal.username == this.model.username;
}
});
}, error => {
},
error: (error) => {
this.error = error;
}
})

View File

@ -29,31 +29,37 @@ export class DurationpickerComponent implements OnInit, ControlValueAccessor {
constructor() { }
ngOnInit(): void {
this.days.valueChanges.subscribe(value => {
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.hours.valueChanges.subscribe(value => {
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.minutes.valueChanges.subscribe(value => {
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();
}
})
}

View File

@ -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.authService.auth.subscribe({
next: (data) => {
this.auth = data;
}
})
this._adapter.setLocale(this.currentLocale);
@ -69,7 +71,8 @@ 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 = {
@ -80,9 +83,12 @@ export class MainComponent {
}
profileField.value = locale;
this.profileService.createOrUpdate(profileField).subscribe((response) => {
this.profileService.createOrUpdate(profileField).subscribe({
next: (response) => {
window.location.reload();
}
})
}
})
} else {
window.location.reload();
@ -99,7 +105,8 @@ 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 = {
@ -110,9 +117,12 @@ export class MainComponent {
}
profileField.value = this.darkTheme;
this.profileService.createOrUpdate(profileField).subscribe((response) => {
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.authService.logout().subscribe({
next: (data) => {
this.router.navigate([ "" ]).then(() => {
window.location.reload();
});
}
})
}
@ -151,20 +163,25 @@ export class MainComponent {
}
touchEvents(): void {
fromEvent(document, 'touchstart').subscribe((event: TouchEvent) => {
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, 'touchend').subscribe((event: TouchEvent) => {
fromEvent(document, 'touchmove').subscribe({
next: (event: TouchEvent) => {
if (event.touches[ 0 ]) {
this.touchX = event.touches[ 0 ].screenX;
}
}
})
fromEvent(document, 'touchend').subscribe({
next: (event: TouchEvent) => {
if (this.touchX != 0) {
const touchDiff = this.touchStartX - this.touchX;
this.touchStartX = 0;
@ -175,6 +192,7 @@ export class MainComponent {
this.opened = false;
}
}
}
})
}
}

View File

@ -29,7 +29,8 @@ export class ProfileFieldPgpBlob implements OnInit {
}
ngOnInit(): void {
this.authService.auth.subscribe((auth: any) => {
this.authService.auth.subscribe({
next: (auth: any) => {
if (!auth.authenticated) {
return;
}
@ -47,7 +48,7 @@ export class ProfileFieldPgpBlob implements OnInit {
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");
});
}
});
}

View File

@ -41,12 +41,16 @@ export class ProfileFieldsComponent implements OnInit {
update() {
if (this.username) {
this.profileService.getForUser(this.username).subscribe((data: any) => {
this.profileService.getForUser(this.username).subscribe({
next: (data: any) => {
this.profileFields = data.profileFields;
}
})
} else {
this.profileService.get().subscribe((data: any) => {
this.profileService.get().subscribe({
next: (data: any) => {
this.profileFields = data;
}
})
}
}
@ -87,9 +91,10 @@ export class ProfileFieldsComponent implements OnInit {
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.profileService.createOrUpdate(result).subscribe();
this.profileService.createOrUpdate(result);
} else {
profileField.name = resetProfileField.name;
profileField.value = resetProfileField.value;
@ -97,6 +102,7 @@ export class ProfileFieldsComponent implements OnInit {
profileField.visibility = resetProfileField.visibility;
profileField.index = resetProfileField.index;
}
}
});
}
@ -110,12 +116,16 @@ export class ProfileFieldsComponent implements OnInit {
}
})
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.profileService.delete(profileField.name).subscribe((result: any) => {
this.profileService.delete(profileField.name).subscribe({
next: (result: any) => {
this.update();
}
})
}
}
});
}
@ -125,10 +135,12 @@ export class ProfileFieldsComponent implements OnInit {
minWidth: '400px'
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
this.update();
}
}
});
}
@ -185,9 +197,11 @@ export class ProfileFieldDialog {
save(profileField) {
this.profileService.createOrUpdate(profileField).subscribe((result: any) => {
this.profileService.createOrUpdate(profileField).subscribe({
next: (result: any) => {
this.dialogRef.close(profileField);
}, (error) => {
},
error: (error) => {
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
@ -199,6 +213,7 @@ export class ProfileFieldDialog {
this.form.get(code).setErrors(errors[ code ]);
}
}
}
});
}
@ -207,10 +222,12 @@ export class ProfileFieldDialog {
minWidth: '400px'
});
dialogRef.afterClosed().subscribe(result => {
dialogRef.afterClosed().subscribe({
next: (result) => {
if (result) {
profileField.blob = result;
}
}
});
}

View File

@ -26,7 +26,9 @@ export class HtmlComponent implements OnInit {
{
headers: headers,
responseType: 'text'
}).subscribe(response => this.htmlTemplate = response);
}).subscribe({
next: (response) => this.htmlTemplate = response
});
}
}