mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-07 06:42:15 +00:00
* cli core * update material * imports * schematics * lint * rm ng-qrcode, ngx-quicklink * replace qr code lib * rm shared module as quicklink is removed * lazy loading imports * rm public * chore(deps): bump @grpc/grpc-js from 1.7.1 to 1.8.0 in /console (#4857) Bumps [@grpc/grpc-js](https://github.com/grpc/grpc-node) from 1.7.1 to 1.8.0. - [Release notes](https://github.com/grpc/grpc-node/releases) - [Commits](https://github.com/grpc/grpc-node/compare/v1.7.1...@grpc/[email protected]) --- updated-dependencies: - dependency-name: "@grpc/grpc-js" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump libphonenumber-js from 1.10.13 to 1.10.15 in /console (#4861) Bumps [libphonenumber-js](https://gitlab.com/catamphetamine/libphonenumber-js) from 1.10.13 to 1.10.15. - [Release notes](https://gitlab.com/catamphetamine/libphonenumber-js/tags) - [Changelog](https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/CHANGELOG.md) - [Commits](https://gitlab.com/catamphetamine/libphonenumber-js/compare/v1.10.13...v1.10.15) --- updated-dependencies: - dependency-name: libphonenumber-js dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * rxjs * chore(deps): bump engine.io from 6.2.0 to 6.2.1 in /console (#4734) Bumps [engine.io](https://github.com/socketio/engine.io) from 6.2.0 to 6.2.1. - [Release notes](https://github.com/socketio/engine.io/releases) - [Changelog](https://github.com/socketio/engine.io/blob/main/CHANGELOG.md) - [Commits](https://github.com/socketio/engine.io/compare/6.2.0...6.2.1) --- updated-dependencies: - dependency-name: engine.io dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * lock * lint * rm comments * tsconfig ES2022 * get rid of polyfills file * use node 18 * rm age policy, legacy components * packages * build beta prerelease * remove pre-release build Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Livio Spring <[email protected]>
77 lines
2.2 KiB
TypeScript
77 lines
2.2 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import {
|
|
MatLegacySnackBar as MatSnackBar,
|
|
MatLegacySnackBarHorizontalPosition as MatSnackBarHorizontalPosition,
|
|
MatLegacySnackBarVerticalPosition as MatSnackBarVerticalPosition,
|
|
} from '@angular/material/legacy-snack-bar';
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
import { Observable } from 'rxjs';
|
|
import { take } from 'rxjs/operators';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ToastService {
|
|
horizontalPosition: MatSnackBarHorizontalPosition = 'end';
|
|
verticalPosition: MatSnackBarVerticalPosition = 'top';
|
|
|
|
constructor(private snackBar: MatSnackBar, private translate: TranslateService) {}
|
|
|
|
public showInfo(message: string, i18nkey: boolean = false): void {
|
|
if (i18nkey) {
|
|
this.translate.get(message).subscribe((data) => {
|
|
this.translate
|
|
.get('ACTIONS.CLOSE')
|
|
.pipe(take(1))
|
|
.subscribe((value) => {
|
|
this.showMessage(data, value, true);
|
|
});
|
|
});
|
|
} else {
|
|
this.translate
|
|
.get('ACTIONS.CLOSE')
|
|
.pipe(take(1))
|
|
.subscribe((value) => {
|
|
this.showMessage(message, value, true);
|
|
});
|
|
}
|
|
}
|
|
|
|
public showError(error: any | string, isGrpc: boolean = true, i18nKey: boolean = false): void {
|
|
if (isGrpc) {
|
|
const { message, code, metadata } = error;
|
|
if (code !== 16) {
|
|
this.translate
|
|
.get('ACTIONS.CLOSE')
|
|
.pipe(take(1))
|
|
.subscribe((value) => {
|
|
this.showMessage(decodeURI(message), value, false);
|
|
});
|
|
}
|
|
} else if (i18nKey) {
|
|
this.translate
|
|
.get(error)
|
|
.pipe(take(1))
|
|
.subscribe((value) => {
|
|
this.showMessage(value, '', false);
|
|
});
|
|
} else {
|
|
this.showMessage(error as string, '', false);
|
|
}
|
|
}
|
|
|
|
private showMessage(message: string, action: string, success: boolean): Observable<void> {
|
|
const ref = this.snackBar.open(message, action, {
|
|
data: {
|
|
message,
|
|
},
|
|
duration: success ? 4000 : 5000,
|
|
panelClass: ['data-e2e-message', success ? 'data-e2e-success' : 'data-e2e-failure'],
|
|
horizontalPosition: this.horizontalPosition,
|
|
verticalPosition: this.verticalPosition,
|
|
});
|
|
|
|
return ref.onAction();
|
|
}
|
|
}
|