mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-25 16:52:17 +00:00
* chore(deps-dev): bump eslint from 8.46.0 to 8.50.0 in /console (#6618) Bumps [eslint](https://github.com/eslint/eslint) from 8.46.0 to 8.50.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.46.0...v8.50.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump @types/node from 18.16.10 to 20.6.5 in /console (#6617) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.16.10 to 20.6.5. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump protobufjs from 7.2.3 to 7.2.5 in /console (#6584) Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 7.2.3 to 7.2.5. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](https://github.com/protobufjs/protobuf.js/compare/protobufjs-v7.2.3...protobufjs-v7.2.5) --- updated-dependencies: - dependency-name: protobufjs dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Max Peintner <[email protected]> * chore(deps-dev): bump @types/jasmine from 4.3.5 to 4.3.6 in /console (#6581) Bumps [@types/jasmine](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jasmine) from 4.3.5 to 4.3.6. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jasmine) --- updated-dependencies: - dependency-name: "@types/jasmine" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump @grpc/grpc-js from 1.8.14 to 1.9.3 in /console (#6578) Bumps [@grpc/grpc-js](https://github.com/grpc/grpc-node) from 1.8.14 to 1.9.3. - [Release notes](https://github.com/grpc/grpc-node/releases) - [Commits](https://github.com/grpc/grpc-node/compare/@grpc/[email protected]...@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]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump @types/qrcode from 1.5.0 to 1.5.2 in /console (#6477) Bumps [@types/qrcode](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/qrcode) from 1.5.0 to 1.5.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/qrcode) --- updated-dependencies: - dependency-name: "@types/qrcode" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump prettier from 2.8.8 to 3.0.3 in /console (#6476) Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.3. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.3) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump socket.io-parser from 4.2.2 to 4.2.4 in /console (#6376) Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.2.2 to 4.2.4. - [Release notes](https://github.com/socketio/socket.io-parser/releases) - [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md) - [Commits](https://github.com/socketio/socket.io-parser/compare/4.2.2...4.2.4) --- updated-dependencies: - dependency-name: socket.io-parser dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump semver from 5.7.1 to 5.7.2 in /console (#6375) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * lint * node types * use node 20 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
182 lines
6.3 KiB
TypeScript
182 lines
6.3 KiB
TypeScript
import { Component, Injector, Input, OnInit, Type } from '@angular/core';
|
|
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
|
|
import {
|
|
AddNotificationPolicyRequest,
|
|
GetNotificationPolicyResponse as AdminGetNotificationPolicyResponse,
|
|
UpdateNotificationPolicyRequest,
|
|
} from 'src/app/proto/generated/zitadel/admin_pb';
|
|
import {
|
|
AddCustomNotificationPolicyRequest,
|
|
GetNotificationPolicyResponse as MgmtGetNotificationPolicyResponse,
|
|
} from 'src/app/proto/generated/zitadel/management_pb';
|
|
import { NotificationPolicy } from 'src/app/proto/generated/zitadel/policy_pb';
|
|
import { AdminService } from 'src/app/services/admin.service';
|
|
import { ManagementService } from 'src/app/services/mgmt.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import { InfoSectionType } from '../../info-section/info-section.component';
|
|
import { WarnDialogComponent } from '../../warn-dialog/warn-dialog.component';
|
|
import { PolicyComponentServiceType } from '../policy-component-types.enum';
|
|
|
|
@Component({
|
|
selector: 'cnsl-notification-policy',
|
|
templateUrl: './notification-policy.component.html',
|
|
styleUrls: ['./notification-policy.component.scss'],
|
|
})
|
|
export class NotificationPolicyComponent implements OnInit {
|
|
@Input() public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
|
|
public service!: ManagementService | AdminService;
|
|
|
|
public notificationData?: NotificationPolicy.AsObject = { isDefault: false, passwordChange: false };
|
|
|
|
public PolicyComponentServiceType: any = PolicyComponentServiceType;
|
|
|
|
public loading: boolean = false;
|
|
public InfoSectionType: any = InfoSectionType;
|
|
|
|
public isDefault: boolean = false;
|
|
private hasNotificationPolicy: boolean = false;
|
|
constructor(
|
|
private toast: ToastService,
|
|
private injector: Injector,
|
|
private dialog: MatDialog,
|
|
) {}
|
|
|
|
public ngOnInit(): void {
|
|
switch (this.serviceType) {
|
|
case PolicyComponentServiceType.MGMT:
|
|
this.service = this.injector.get(ManagementService as Type<ManagementService>);
|
|
break;
|
|
case PolicyComponentServiceType.ADMIN:
|
|
this.service = this.injector.get(AdminService as Type<AdminService>);
|
|
break;
|
|
}
|
|
this.fetchData();
|
|
}
|
|
|
|
public fetchData(): void {
|
|
this.loading = true;
|
|
|
|
this.getData()
|
|
.then((data) => {
|
|
if (data.policy) {
|
|
this.hasNotificationPolicy = true;
|
|
this.notificationData = data.policy;
|
|
this.isDefault = data.policy.isDefault;
|
|
this.loading = false;
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
this.loading = false;
|
|
if (error && error.code === 5) {
|
|
console.log(error);
|
|
this.hasNotificationPolicy = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
private async getData(): Promise<
|
|
MgmtGetNotificationPolicyResponse.AsObject | AdminGetNotificationPolicyResponse.AsObject
|
|
> {
|
|
switch (this.serviceType) {
|
|
case PolicyComponentServiceType.MGMT:
|
|
return (this.service as ManagementService).getNotificationPolicy();
|
|
case PolicyComponentServiceType.ADMIN:
|
|
return (this.service as AdminService).getNotificationPolicy();
|
|
}
|
|
}
|
|
|
|
public removePolicy(): void {
|
|
if (this.service instanceof ManagementService) {
|
|
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
|
data: {
|
|
confirmKey: 'ACTIONS.RESET',
|
|
cancelKey: 'ACTIONS.CANCEL',
|
|
titleKey: 'SETTING.DIALOG.RESET.DEFAULTTITLE',
|
|
descriptionKey: 'SETTING.DIALOG.RESET.DEFAULTDESCRIPTION',
|
|
},
|
|
width: '400px',
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe((resp) => {
|
|
if (resp) {
|
|
(this.service as ManagementService)
|
|
.resetNotificationPolicyToDefault()
|
|
.then(() => {
|
|
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
|
|
this.isDefault = true;
|
|
setTimeout(() => {
|
|
this.fetchData();
|
|
}, 1000);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public savePolicy(): void {
|
|
if (this.notificationData) {
|
|
switch (this.serviceType) {
|
|
case PolicyComponentServiceType.MGMT:
|
|
if ((this.notificationData as NotificationPolicy.AsObject).isDefault) {
|
|
const req = new AddCustomNotificationPolicyRequest();
|
|
req.setPasswordChange(this.notificationData.passwordChange);
|
|
(this.service as ManagementService)
|
|
.addCustomNotificationPolicy(req)
|
|
.then(() => {
|
|
this.isDefault = false;
|
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
} else {
|
|
const req = new UpdateNotificationPolicyRequest();
|
|
req.setPasswordChange(this.notificationData.passwordChange);
|
|
(this.service as ManagementService)
|
|
.updateCustomNotificationPolicy(req)
|
|
.then(() => {
|
|
this.isDefault = false;
|
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
break;
|
|
case PolicyComponentServiceType.ADMIN:
|
|
if (this.hasNotificationPolicy) {
|
|
const req = new UpdateNotificationPolicyRequest();
|
|
req.setPasswordChange(this.notificationData.passwordChange);
|
|
(this.service as AdminService)
|
|
.updateNotificationPolicy(req)
|
|
.then(() => {
|
|
this.isDefault = false;
|
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
} else {
|
|
const req = new AddNotificationPolicyRequest();
|
|
req.setPasswordChange(this.notificationData.passwordChange);
|
|
(this.service as AdminService)
|
|
.addNotificationPolicy(req)
|
|
.then(() => {
|
|
this.isDefault = false;
|
|
this.hasNotificationPolicy = true;
|
|
this.toast.showInfo('POLICY.TOAST.SET', true);
|
|
})
|
|
.catch((error) => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|