mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-04 18:08:50 +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]>
138 lines
4.2 KiB
TypeScript
138 lines
4.2 KiB
TypeScript
import { Component, Inject } from '@angular/core';
|
|
import { AbstractControl, FormControl, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
|
|
import {
|
|
MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA,
|
|
MatLegacyDialog as MatDialog,
|
|
MatLegacyDialogRef as MatDialogRef,
|
|
} from '@angular/material/legacy-dialog';
|
|
import {
|
|
AddSMSProviderTwilioRequest,
|
|
UpdateSMSProviderTwilioRequest,
|
|
UpdateSMSProviderTwilioTokenRequest,
|
|
} from 'src/app/proto/generated/zitadel/admin_pb';
|
|
import { SMSProvider, TwilioConfig } from 'src/app/proto/generated/zitadel/settings_pb';
|
|
import { AdminService } from 'src/app/services/admin.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import { PasswordDialogComponent } from '../password-dialog/password-dialog.component';
|
|
|
|
enum SMSProviderType {
|
|
Twilio = 1,
|
|
}
|
|
|
|
@Component({
|
|
selector: 'cnsl-dialog-add-sms-provider',
|
|
templateUrl: './dialog-add-sms-provider.component.html',
|
|
styleUrls: ['./dialog-add-sms-provider.component.scss'],
|
|
})
|
|
export class DialogAddSMSProviderComponent {
|
|
public SMSProviderType: any = SMSProviderType;
|
|
public availableSMSProviders: SMSProviderType[] = [SMSProviderType.Twilio];
|
|
public provider: SMSProviderType = SMSProviderType.Twilio;
|
|
public req!: AddSMSProviderTwilioRequest | UpdateSMSProviderTwilioRequest;
|
|
|
|
public twilioForm!: UntypedFormGroup;
|
|
|
|
private smsProviders: SMSProvider.AsObject[] = [];
|
|
|
|
constructor(
|
|
private fb: UntypedFormBuilder,
|
|
private service: AdminService,
|
|
public dialogRef: MatDialogRef<DialogAddSMSProviderComponent>,
|
|
private toast: ToastService,
|
|
private dialog: MatDialog,
|
|
@Inject(MAT_DIALOG_DATA) public data: any,
|
|
) {
|
|
this.twilioForm = this.fb.group({
|
|
sid: ['', [Validators.required]],
|
|
senderNumber: ['', [Validators.required]],
|
|
});
|
|
|
|
this.smsProviders = data.smsProviders;
|
|
if (!!this.twilio) {
|
|
this.twilioForm.patchValue(this.twilio);
|
|
} else {
|
|
this.twilioForm.addControl('token', new FormControl('', Validators.required));
|
|
}
|
|
}
|
|
|
|
public closeDialog(): void {
|
|
this.dialogRef.close();
|
|
}
|
|
|
|
public closeDialogWithRequest(): void {
|
|
if (!!this.twilio) {
|
|
this.req = new UpdateSMSProviderTwilioRequest();
|
|
|
|
this.req.setSid(this.sid?.value);
|
|
this.req.setSenderNumber(this.senderNumber?.value);
|
|
this.dialogRef.close(this.req);
|
|
} else {
|
|
this.req = new AddSMSProviderTwilioRequest();
|
|
|
|
this.req.setSid(this.sid?.value);
|
|
this.req.setToken(this.token?.value);
|
|
this.req.setSenderNumber(this.senderNumber?.value);
|
|
this.dialogRef.close(this.req);
|
|
}
|
|
}
|
|
|
|
public changeToken(): void {
|
|
const dialogRef = this.dialog.open(PasswordDialogComponent, {
|
|
width: '400px',
|
|
data: {
|
|
i18nTitle: 'SETTING.SMS.TWILIO.SETTOKEN',
|
|
i18nLabel: 'SETTING.SMS.TWILIO.TOKEN',
|
|
},
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe((token: string) => {
|
|
if (token && this.twilioProvider?.id) {
|
|
const tokenReq = new UpdateSMSProviderTwilioTokenRequest();
|
|
tokenReq.setToken(token);
|
|
tokenReq.setId(this.twilioProvider.id);
|
|
|
|
this.service
|
|
.updateSMSProviderTwilioToken(tokenReq)
|
|
.then(() => {
|
|
this.toast.showInfo('SETTING.SMS.TWILIO.TOKENSET', true);
|
|
this.dialogRef.close();
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
public get senderNumber(): AbstractControl | null {
|
|
return this.twilioForm.get('senderNumber');
|
|
}
|
|
|
|
public get token(): AbstractControl | null {
|
|
return this.twilioForm.get('token');
|
|
}
|
|
|
|
public get sid(): AbstractControl | null {
|
|
return this.twilioForm.get('sid');
|
|
}
|
|
|
|
public get twilioProvider(): SMSProvider.AsObject | undefined {
|
|
const twilioProvider: SMSProvider.AsObject | undefined = this.smsProviders.find((p) => p.twilio);
|
|
if (twilioProvider) {
|
|
return twilioProvider;
|
|
} else {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
public get twilio(): TwilioConfig.AsObject | undefined {
|
|
const twilioProvider: SMSProvider.AsObject | undefined = this.smsProviders.find((p) => p.twilio);
|
|
if (twilioProvider && !!twilioProvider.twilio) {
|
|
return twilioProvider.twilio;
|
|
} else {
|
|
return undefined;
|
|
}
|
|
}
|
|
}
|