@WidgetComponent

nm-data-list-export-dialog

File

src/app/shared/widgets/data-list/data-list-dialog-component/data-list-export.component.ts

Implements

OnInit

Metadata

selector nm-data-list-export-dialog
styleUrls data-list-export.component.scss
templateUrl ./data-list-export.component.html

Index

Widget inputs
Widget outputs
Properties
Methods

Constructor

constructor(dialogRef: MatDialogRef, httpClient: HttpClient)
Parameters :
Name Type Optional
dialogRef MatDialogRef<DataListExportComponent> no
httpClient HttpClient no

Methods

cancel
cancel()
Returns : void
Private close
close(download: boolean)
Parameters :
Name Type Optional
download boolean no
Returns : void
download
download()
Returns : void
export
export()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

Public assetFormat
assetFormat: string
Type : string
Public assetFormats
assetFormats: any[]
Type : any[]
Public csvEncoding
csvEncoding: string
Type : string
Public csvHeaders
csvHeaders: boolean
Type : boolean
Public csvSeparator
csvSeparator: string
Type : string
Public dialogRef
dialogRef: MatDialogRef<DataListExportComponent>
Type : MatDialogRef<DataListExportComponent>
Public exportFormat
exportFormat: string
Type : string
Public httpClient
httpClient: HttpClient
Type : HttpClient
Public onlySelectedRows
onlySelectedRows: boolean
Type : boolean
Public showCsvHeaders
showCsvHeaders: boolean
Type : boolean
Public showDownload
showDownload: boolean
Type : boolean
Default value : true
Public showExport
showExport: boolean
Type : boolean
Default value : true
Public showExportAssetFormats
showExportAssetFormats: boolean
Type : boolean
import { Component, OnInit } from "@angular/core";
import { MatDialogRef } from "@angular/material/dialog";
import { HttpClient } from "@angular/common/http";

@Component({
  selector: "nm-data-list-export-dialog",
  styleUrls: ["./data-list-export.component.scss"],
  templateUrl: "./data-list-export.component.html",
})
export class DataListExportComponent implements OnInit {
  public showDownload: boolean = true;
  public showExport: boolean = true;

  public assetFormats: any[];
  public assetFormat: string;
  public exportFormat: string;
  public csvSeparator: string;
  public csvEncoding: string;
  public csvHeaders: boolean;
  public onlySelectedRows: boolean;
  public showExportAssetFormats: boolean;
  public showCsvHeaders: boolean;

  constructor(
    public dialogRef: MatDialogRef<DataListExportComponent>,
    public httpClient: HttpClient
  ) {}

  export() {
    this.close(false);
  }

  download() {
    this.close(true);
  }

  private close(download: boolean) {
    this.dialogRef.close({
      assetFormat: this.assetFormat,
      exportFormat: this.exportFormat,
      csvSeparator: this.csvSeparator,
      csvEncoding: this.csvEncoding,
      csvHeaders: this.csvHeaders,
      onlySelectedRows: this.onlySelectedRows,
      download,
    });
  }

  ngOnInit(): void {
    if (this.showExportAssetFormats) {
      this.httpClient
        .get("/api/core/assets/formats")
        .subscribe((resp: any[]) => {
          this.assetFormats = resp;
        });
    }
  }

  cancel() {
    this.dialogRef.close();
  }
}
<nm-dialog [dialogRef]="dialogRef" class="nm-dialog nm-dataListExport">
  <ng-container slot="title">
    {{ "dialog.data.list.export.settings" | translate }}
  </ng-container>
  <ng-container slot="content">
    <mat-form-field class="nm-dataListExport__selection">
      <mat-select
        [(ngModel)]="exportFormat"
        [placeholder]="'placeholder.export.format' | translate"
      >
        <mat-option value="CSV"> CSV </mat-option>
        <mat-option value="Excel"> Excel </mat-option>
      </mat-select>
    </mat-form-field>
    <br />

    <mat-form-field
      *ngIf="showExportAssetFormats"
      class="nm-dataListExport__selection"
    >
      <mat-select
        [(ngModel)]="assetFormat"
        [placeholder]="'placeholder.export.asset.format' | translate"
      >
        <mat-option *ngFor="let format of assetFormats" [value]="format.format"
          >{{ format.ipimFormat }}
        </mat-option>
      </mat-select>
    </mat-form-field>
    <br />
    <mat-form-field *ngIf="exportFormat == 'CSV'">
      <input
        [(ngModel)]="csvSeparator"
        matInput
        [placeholder]="'placeholder.export.csv.separator' | translate"
      />
    </mat-form-field>

    <mat-form-field *ngIf="exportFormat == 'CSV'">
      <mat-select
        [(ngModel)]="csvEncoding"
        [placeholder]="'placeholder.export.csv.encoding' | translate"
      >
        <mat-option value="ISO-8859-15">ISO-8859-15</mat-option>
        <mat-option value="UTF-8">UTF-8</mat-option>
      </mat-select>
    </mat-form-field>
    <br /><br />
    <mat-checkbox
      color="primary"
      *ngIf="showCsvHeaders && exportFormat == 'CSV'"
      [(ngModel)]="csvHeaders"
    >
      {{ "placeholder.export.csv.headers" | translate }}
    </mat-checkbox>
    <br />
    <mat-checkbox color="primary" [(ngModel)]="onlySelectedRows"
      >{{ "placeholder.export.only.selected" | translate }}
    </mat-checkbox>
  </ng-container>
  <ng-container slot="actions">
    <button mat-button type="button" (click)="cancel()">
      {{ "button.cancel" | translate }}
    </button>

    <button
      *ngIf="showExport"
      mat-raised-button
      color="primary"
      type="button"
      [pTooltip]="'button.export.description' | translate"
      [showDelay]="150"
      (click)="export()"
    >
      {{ "button.export" | translate }}
    </button>

    <button
      *ngIf="showDownload"
      mat-raised-button
      color="primary"
      type="button"
      [pTooltip]="'button.download.description' | translate"
      [showDelay]="150"
      (click)="download()"
    >
      {{ "button.download" | translate }}
    </button>
  </ng-container>
</nm-dialog>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""