Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOGL-8115: Add Control Entry-points API Flow #332

Merged
merged 9 commits into from
Oct 3, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="dropdown-content">
<ng-container *ngIf="rolesService.hasEditPermissions()">
<a class="dropdown-item" id="create-backup" (click)="requestBackup()">
<i class="bi bi-plus-circle plus-icon" aria-hidden="true"></i>
<i class="bi bi-plus-circle plus-icon bi-icon" aria-hidden="true"></i>
<span> Create New</span>
</a>
<a class="dropdown-item" id="upload-backup" (click)="uploadBackup()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ span.is-small {
[hidden] {
display: none !important;
}

.allow-list-text {
font-size: 0.7em;
color: gray;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
<div class="field-body">
<div class="field">
<div class="control">
<input #name=ngModel name="af.name" class="input" type="text" placeholder="Name" required
[(ngModel)]="af.name" title="No single quotes and double quotes!" [ngModelOptions]="{standalone: true}"
<input formControlName="name" class="input" type="text" placeholder="Name" required title="No single quotes and double quotes!"
[pattern]="QUOTATION_VALIDATION_PATTERN" autocomplete="off"
[ngClass]="{'is-small':rolesService.hasControlAccess(), 'is-static static-field pb-4':!rolesService.hasControlAccess()}"
[readonly]="!rolesService.hasControlAccess()">
</div>
<div *ngIf="name.invalid && (name.dirty || name.touched)" class="help is-danger">
<div *ngIf="name.errors?.['required']">
<div *ngIf="apiFlowForm.controls['name'].invalid" class="help is-danger">
<div *ngIf=" apiFlowForm.controls['name'].touched && apiFlowForm.controls['name'].errors?.['required']">
*required
</div>
</div>
Expand Down Expand Up @@ -77,15 +76,13 @@
<div class="field">
<ngContainer *ngIf="selectedType === 'operation' && rolesService.hasControlAccess()">
<div class="control">
<input #operation_name=ngModel name="af.operation_name" class="input is-small" type="text" placeholder="Operation name" required
[(ngModel)]="af.operation_name" title="No single quotes and double quotes!" [ngModelOptions]="{standalone: true}"
<input formControlName="operation_name" class="input is-small" type="text" placeholder="Operation name"
title="No single quotes and double quotes!"
[pattern]="QUOTATION_VALIDATION_PATTERN" autocomplete="off">
</div>
<div *ngIf="operation_name.invalid && (operation_name.dirty || operation_name.touched)" class="help is-danger">
<div *ngIf="operation_name.errors?.['required']">
<div *ngIf="selectedType === 'operation' && apiFlowForm.controls.operation_name.value === ''" class="help is-danger">
*required
</div>
</div>
</ngContainer>
</div>

Expand Down Expand Up @@ -197,7 +194,7 @@
<label class="label is-small has-text-left">Variables</label>
</div>
<div class="field-body">
<button class="button px-0 pt-0 is-small is-link is-light has-background-white" (click)="addValueControl('variables')">
<button class="button px-0 pt-1 is-small is-link is-light has-background-white" (click)="addValueControl('variables')">
<span class="icon is-small pt-1 mr-0">
<i class="fa fa-xs fa-plus" aria-hidden="true"></i>
</span>
Expand Down Expand Up @@ -240,7 +237,7 @@
<div class="columns">
<div class="column is-one-fifth"></div>
<div class="btn-column pt-2 pb-0 pl-2">
<button class="button px-0 pt-0 is-small is-link is-light has-background-white" (click)="addValueControl('variables')">
<button class="button px-0 pt-2 is-small is-link is-light has-background-white" (click)="addValueControl('variables')">
<span class="icon is-small pt-1 mr-0">
<i class="fa fa-xs fa-plus" aria-hidden="true"></i>
</span>
Expand All @@ -257,7 +254,7 @@
<label class="label is-small has-text-left">Constants</label>
</div>
<div class="field-body">
<button class="button px-0 pt-0 is-small is-link is-light has-background-white" (click)="addValueControl('constants')">
<button class="button px-0 pt-1 is-small is-link is-light has-background-white" (click)="addValueControl('constants')">
<span class="icon is-small pt-1 mr-0">
<i class="fa fa-xs fa-plus" aria-hidden="true"></i>
</span>
Expand Down Expand Up @@ -300,7 +297,7 @@
<div class="columns">
<div class="column is-one-fifth"></div>
<div class="btn-column pt-2 pb-0 pl-2">
<button class="button px-0 pt-0 is-small is-link is-light has-background-white"
<button class="button px-0 pt-2 is-small is-link is-light has-background-white"
(click)="addValueControl('constants')">
<span class="icon is-small pt-1 mr-0">
<i class="fa fa-xs fa-plus" aria-hidden="true"></i>
Expand Down Expand Up @@ -371,7 +368,7 @@
[ngClass]="{'is-static pb-4':!rolesService.hasControlAccess()}"
[readonly]="!rolesService.hasControlAccess()">
</ng-template>
<p class="help">*Allow list will only be applicable when the anonymous access is disabled.</p>
<p class="help allow-list-text">*Allow list will only be applicable when the anonymous access is disabled.</p>
</div>
</div>
</div>
Expand All @@ -394,11 +391,11 @@
<div class="field">
<ng-container *ngIf="rolesService.hasControlAccess(); else staticDescription">
<div class="control">
<textarea rows="2" type="text" class="textarea is-small" placeholder="description" name="af.description" required
[(ngModel)]="af.description" trim="blur" #description="ngModel" [ngModelOptions]="{standalone: true}"></textarea>
<textarea rows="2" type="text" formControlName="description" class="textarea is-small" placeholder="description" required
trim="blur"></textarea>
</div>
<div *ngIf="description.invalid && (description.dirty || description.touched)" class="help is-danger">
<div *ngIf="description.errors?.['required']">
<div *ngIf="apiFlowForm.controls['description'].invalid" class="help is-danger">
<div *ngIf="apiFlowForm.controls['description'].touched && apiFlowForm.controls['description'].errors?.['required']">
*required
</div>
</div>
Expand All @@ -419,7 +416,7 @@
<div class="field">
<div class="columns">
<div class="column is-2">
<div *ngIf="editMode && allowExecute" class="field has-addons is-fullwidth">
<div *ngIf="editMode && af.permitted" class="field has-addons is-fullwidth">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All conditionals stuff with edit mode for permitted needs proper testing; for each role based user; and not auth mode.

<p class="control is-expanded">
<a class="button is-small is-fullwidth" (click)="checkAndRequestAPIFlow()">Execute</a>
</p>
Expand All @@ -439,7 +436,7 @@
</div>
</div>
</div>
<p *ngIf="editMode && !allowExecute && rolesService.hasControlAccess()" class="control">
<p *ngIf="editMode && !af.permitted && rolesService.hasControlAccess()" class="control">
<button class="button is-small is-danger is-outlined" type="button" (click)="openModal('confirmation-delete-dialog')">Delete</button>
</p>
</div>
Expand All @@ -450,7 +447,7 @@
</p>
<p class="control">
<button (click)="saveAPIFlow(apiFlowForm.value)" type="submit" class="button is-small is-link"
[disabled]="apiFlowForm?.invalid">Save</button>
[disabled]="apiFlowForm?.invalid || (selectedType === 'operation' && apiFlowForm.controls.operation_name.value === '')">Save</button>
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export class AddEditAPIFlowComponent implements OnInit {
destinationNames = [];

editMode = false;
allowExecute = false;

apiFlowName: string;
af: APIFlow;

apiFlowForm: FormGroup;

allUsers: User[];
Expand All @@ -73,6 +73,9 @@ export class AddEditAPIFlowComponent implements OnInit {
private controlUtilsService: ControlUtilsService,
private router: Router) {
this.apiFlowForm = this.fb.group({
name: ['', Validators.required],
description: ['', Validators.required],
operation_name: [''],
variables: this.fb.array([]),
constants: this.fb.array([])
});
Expand All @@ -89,6 +92,7 @@ export class AddEditAPIFlowComponent implements OnInit {
type: 'write',
description: '',
operation_name: '',
permitted: false,
destination: 'broadcast',
constants: {},
variables: {},
Expand Down Expand Up @@ -170,17 +174,18 @@ export class AddEditAPIFlowComponent implements OnInit {
this.editMode = true;
this.ngProgress.done();
this.af = data;

this.apiFlowForm.get('name').setValue(data.name);
this.apiFlowForm.get('description').setValue(data.description);
this.apiFlowForm.get('operation_name').setValue(data.operation_name);

if (this.af.destination !== 'broadcast') {
this.selectedDestinationName = this.af[this.af.destination];
}
this.selectedType = data.type;

// TODO: FOGL-8070
this.af.anonymous = data.anonymous === 't' || data.anonymous === true ? true : false;

this.fillParameters(data.variables, 'variables');
this.fillParameters(data.constants, 'constants');
this.allowExecute = data.anonymous === true || (data.anonymous === false && data.allow.includes(this.loggedInUsername));
}, error => {
/** request completed */
this.ngProgress.done();
Expand All @@ -194,8 +199,11 @@ export class AddEditAPIFlowComponent implements OnInit {

saveAPIFlow(data) {
let payload = this.af;


payload.name = data.name;
payload.description = data.description;
payload.type = this.selectedType;
payload.operation_name = data.operation_name;

const destination = this.af.destination.toLowerCase();
payload.destination = destination;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<ng-container *ngFor="let ep of apiFlows; let i = index">
<tr id="select{{i}}">
<td class="align-content">
<!-- TODO: 8070, this requires check the same way, we have in details page for this.allowExecute; Here we need to check for each record while rendering -->
<a *ngIf="ep.permitted" class="button is-ghost ep-name mx-0 px-0"
(click)="getAndExecuteAPIFlow(ep.name);">
{{ep.name}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<header class="modal-card-head">
<span *ngIf="task" class="modal-card-title title-name">{{task.name}} <span *ngIf="isAddFilterWizard">- Add
Filter</span>
<span *ngIf="!isAddFilterWizard"><i class="bi bi-info-circle plugin-info" aria-hidden="true" [title]="task?.plugin.name"></i></span>
<span *ngIf="!isAddFilterWizard"><i class="bi bi-info-circle plugin-info bi-icon" aria-hidden="true" [title]="task?.plugin.name"></i></span>
<ng-container *ngIf="task?.processName === 'north_C'; else nTask">
<p class="help has-text-grey ctrl-pipeline">North Service</p>
</ng-container>
Expand Down Expand Up @@ -86,7 +86,7 @@
<span class="label is-size-6 add-application" *ngIf="rolesService.hasEditPermissions(); else staticLabel">
<a (click)="openAddFilterModal(true)">Applications
<span class="icon has-tooltip-right has-tooltip-arrow tooltip" data-tooltip="Add Filters">
<i class="bi bi-plus-circle plus-icon" aria-hidden="true"></i>
<i class="bi bi-plus-circle plus-icon bi-icon" aria-hidden="true"></i>
</span>
</a>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="modal-card">
<header class="modal-card-head">
<span *ngIf="notification" class="modal-card-title title-name">{{notification.name}}
<span><i class="bi bi-info-circle plugin-info" aria-hidden="true" [title]="'Rule Plugin: ' + notification.rule + '&#013;Action Plugin: ' + notification.channel"></i></span>
<span><i class="bi bi-info-circle plugin-info bi-icon" aria-hidden="true" [title]="'Rule Plugin: ' + notification.rule + '&#013;Action Plugin: ' + notification.channel"></i></span>
<p class="help has-text-grey ctrl-pipeline">Notification Instance</p>
</span>
<button class="delete" aria-label="close" (click)="toggleModal(false)"></button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<span *ngIf="service" class="modal-card-title title-name">{{service.name}} <span *ngIf="isAddFilterWizard">- Add
Filter</span>
<span *ngIf="!isAddFilterWizard">
<i class="bi bi-info-circle plugin-info" aria-hidden="true" [title]="service?.plugin?.name"></i>
<i class="bi bi-info-circle plugin-info bi-icon" aria-hidden="true" [title]="service?.plugin?.name"></i>
</span>
<p class="help has-text-grey ctrl-pipeline">South Service</p>
</span>
Expand Down Expand Up @@ -40,7 +40,7 @@
<span class="label is-size-6 add-application" *ngIf="rolesService.hasEditPermissions(); else staticLabel">
<a (click)="openAddFilterModal(true)">Applications
<span class="icon has-tooltip-right has-tooltip-arrow tooltip" data-tooltip="Add Filters">
<i class="bi bi-plus-circle plus-icon" aria-hidden="true"></i>
<i class="bi bi-plus-circle plus-icon bi-icon" aria-hidden="true"></i>
</span>
</a>
</span>
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/layout/side-menu/side-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
ACLs
</a>
</li>
<!-- <li>
<li>
<a id="entry-point" routerLinkActive="is-active" routerLink='control-dispatcher/entry-points'>
API Entry Points
</a>
</li> -->
</li>
<li>
<a id="pipelines" routerLinkActive="is-active" routerLink='control-dispatcher/pipelines'>Pipelines</a>
</li>
Expand Down
1 change: 1 addition & 0 deletions src/app/models/control/api-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export class APIFlow {
name: string;
description: string;
permitted: boolean;
type: string;
operation_name?: string;
destination: string;
Expand Down
4 changes: 4 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ a.dropdown-item:hover {
font-size: 0.70rem;
}

.bi-icon:hover {
color: rgb(91, 89, 89);
}

.desc-text{
font-size: 0.95rem;
}
Expand Down