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
+88 -47
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.invites = data;
}, (error) => { })
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) => { }
})
}
})
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.invites = data;
}, (error) => { })
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) => { }
})
}
})
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.others = data;
}, (error) => { })
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) => { }
})
}
})
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.others = data;
}, (error) => { })
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) => { }
})
}
})
this.update();
@@ -75,47 +95,63 @@ export class InvitesComponent implements OnInit {
update(): void {
this.inviteQuota = 0;
this.quotaService.quotas().subscribe((data: any) => {
for (let quota of data) {
if (quota.name == "invite_" + this.quota) {
this.inviteQuota = quota.value;
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.invites = data;
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.invites = data;
}, (error) => { })
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) => { }
})
}
this.inviteService.getOthers(this.quota).subscribe((data: any) => {
this.others = data;
}, (error) => { })
this.inviteService.getOthers(this.quota).subscribe({
next: (data: any) => {
this.others = data;
},
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.invites = data;
}, (error) => { })
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) => { }
})
}
create(): void {
this.working = true;
this.inviteService.create(this.quota, {}).subscribe(response => {
this.update();
this.working = false;
}, (error) => {
this.working = false;
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.inviteService.create(this.quota, {}).subscribe({
next: (response) => {
this.update();
this.working = false;
},
error: (error) => {
this.working = false;
if (error.status == 409) {
let errors = {};
for (let code of error.error) {
errors[ code.field ] = errors[ code.field ] || {};
errors[ code.field ][ code.code ] = true;
}
}
}
})
@@ -127,16 +163,21 @@ export class InvitesComponent implements OnInit {
minWidth: "400px"
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.update();
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.others = data;
}, (error) => { })
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) => { }
})
}
}