feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
import { Component, Inject } from '@angular/core';
|
2023-01-11 14:23:16 +01:00
|
|
|
import {
|
|
|
|
|
MAT_LEGACY_DIALOG_DATA as MAT_DIALOG_DATA,
|
|
|
|
|
MatLegacyDialog as MatDialog,
|
|
|
|
|
MatLegacyDialogRef as MatDialogRef,
|
|
|
|
|
} from '@angular/material/legacy-dialog';
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
import { Duration } from 'google-protobuf/google/protobuf/duration_pb';
|
2021-12-08 10:48:23 +01:00
|
|
|
import { mapTo } from 'rxjs';
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
import { WarnDialogComponent } from 'src/app/modules/warn-dialog/warn-dialog.component';
|
|
|
|
|
import { Action } from 'src/app/proto/generated/zitadel/action_pb';
|
|
|
|
|
import { CreateActionRequest, UpdateActionRequest } from 'src/app/proto/generated/zitadel/management_pb';
|
|
|
|
|
import { ManagementService } from 'src/app/services/mgmt.service';
|
|
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
|
|
|
|
|
|
@Component({
|
2021-12-08 10:48:23 +01:00
|
|
|
selector: 'cnsl-add-action-dialog',
|
|
|
|
|
templateUrl: './add-action-dialog.component.html',
|
|
|
|
|
styleUrls: ['./add-action-dialog.component.scss'],
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
})
|
|
|
|
|
export class AddActionDialogComponent {
|
2021-12-08 10:48:23 +01:00
|
|
|
public name: string = '';
|
|
|
|
|
public script: string = '';
|
|
|
|
|
public durationInSec: number = 10;
|
|
|
|
|
public allowedToFail: boolean = false;
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
public id: string = '';
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
public opened$ = this.dialogRef.afterOpened().pipe(mapTo(true));
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private toast: ToastService,
|
|
|
|
|
private mgmtService: ManagementService,
|
|
|
|
|
private dialog: MatDialog,
|
|
|
|
|
public dialogRef: MatDialogRef<AddActionDialogComponent>,
|
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data: any,
|
|
|
|
|
) {
|
|
|
|
|
if (data && data.action) {
|
|
|
|
|
const action: Action.AsObject = data.action;
|
|
|
|
|
this.name = action.name;
|
|
|
|
|
this.script = action.script;
|
|
|
|
|
if (action.timeout?.seconds) {
|
|
|
|
|
this.durationInSec = action.timeout?.seconds;
|
|
|
|
|
}
|
|
|
|
|
this.allowedToFail = action.allowedToFail;
|
|
|
|
|
this.id = action.id;
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
}
|
2021-12-08 10:48:23 +01:00
|
|
|
}
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
public closeDialog(): void {
|
|
|
|
|
this.dialogRef.close(false);
|
|
|
|
|
}
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
public closeDialogWithSuccess(): void {
|
|
|
|
|
if (this.id) {
|
|
|
|
|
const req = new UpdateActionRequest();
|
|
|
|
|
req.setId(this.id);
|
|
|
|
|
req.setName(this.name);
|
|
|
|
|
req.setScript(this.script);
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
const duration = new Duration();
|
|
|
|
|
duration.setNanos(0);
|
|
|
|
|
duration.setSeconds(this.durationInSec);
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
req.setAllowedToFail(this.allowedToFail);
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
req.setTimeout(duration);
|
|
|
|
|
this.dialogRef.close(req);
|
|
|
|
|
} else {
|
|
|
|
|
const req = new CreateActionRequest();
|
|
|
|
|
req.setName(this.name);
|
|
|
|
|
req.setScript(this.script);
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
const duration = new Duration();
|
|
|
|
|
duration.setNanos(0);
|
|
|
|
|
duration.setSeconds(this.durationInSec);
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
req.setAllowedToFail(this.allowedToFail);
|
|
|
|
|
|
|
|
|
|
req.setTimeout(duration);
|
|
|
|
|
this.dialogRef.close(req);
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
}
|
2021-12-08 10:48:23 +01:00
|
|
|
}
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
public deleteAndCloseDialog(): void {
|
|
|
|
|
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
|
|
|
|
data: {
|
|
|
|
|
confirmKey: 'ACTIONS.DELETE',
|
|
|
|
|
cancelKey: 'ACTIONS.CANCEL',
|
|
|
|
|
titleKey: 'FLOWS.DIALOG.DELETEACTION.TITLE',
|
|
|
|
|
descriptionKey: 'FLOWS.DIALOG.DELETEACTION.DESCRIPTION',
|
|
|
|
|
},
|
|
|
|
|
width: '400px',
|
|
|
|
|
});
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
|
2021-12-08 10:48:23 +01:00
|
|
|
dialogRef.afterClosed().subscribe((resp) => {
|
|
|
|
|
if (resp) {
|
|
|
|
|
this.mgmtService
|
|
|
|
|
.deleteAction(this.id)
|
|
|
|
|
.then((resp) => {
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
this.dialogRef.close();
|
2021-12-08 10:48:23 +01:00
|
|
|
})
|
|
|
|
|
.catch((error: any) => {
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
this.toast.showError(error);
|
|
|
|
|
});
|
2021-12-08 10:48:23 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
feat(console): actions and flows (#2559)
* features, page, table, create dialog, i18n
* trigger actions service, add action dialog
* display flows, add flow dialog, duration pipe, i18n
* optim flow layout, action presets
* delete actions, flows, layout
* drag drop list, fix update
* lint
* stylelint
* fix template rest
* actions, drag, fix hasrole
* stylelint
* toast, i18n
* missing italian translations
* it
* fix ActionSearchQueries
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-11-16 08:18:03 +01:00
|
|
|
}
|