File

libs/acl/angular/src/lib/policy-editor/presets/presets.component.ts

Index

Properties

Properties

content
Type string
name
Type string
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { UntypedFormControl } from '@angular/forms';

export interface PolicyPreset {
  name: string;
  content: string;
}

const PRESETS: PolicyPreset[] = [
  {
    name: 'Allow All',
    content: `
      *,,view,allow
      *,,edit,allow
    `
  },
  {
    name: 'Read Only',
    content: `
      *,,view,allow
      *,,edit,deny
    `
  },
  {
    name: 'Deny All',
    content: `
      *,,view,deny
      *,,edit,deny
    `
  }
];
@Component({
  // eslint-disable-next-line @angular-eslint/component-selector
  selector: 'presets',
  templateUrl: './presets.component.html',
  styleUrls: ['./presets.component.scss']
})
export class PresetsComponent {
  @Input() presets: PolicyPreset[] = PRESETS;
  @Output() presetSelected = new EventEmitter();
  selectControl = new UntypedFormControl('DEFAULT');

  handleSelection(event: Event) {
    event.preventDefault();
    event.stopPropagation();

    const content = (event.target as HTMLSelectElement).value;
    (event.target as HTMLSelectElement).selectedIndex = 0;

    if (content !== 'DEFAULT') {
      this.presetSelected.emit(content);
    }
  }
}

results matching ""

    No results matching ""