Batch add data from csv to API server

UI modules: MatProgressBarModule, MatCheckboxModule

```html

<h2 mat-dialog-title align="center">Batch add <b class="text-info">Product</b> records from csv file</h2>
<div style="padding-left: 10px;">
  <input type="file" #csvReader name="Upload CSV" id="txtFileUpload" (change)="uploadListener($event)" accept=".csv" />
</div>

<div class="controls" *ngIf="isLoading">
  <mat-progress-bar mode="indeterminate" color="primary" aria-label="Loading content"> </mat-progress-bar>
</div>
<hr>
<mat-dialog-content>
  <table class="table table-bordered table-striped table-hover" >
    <thead class="table-dark">
      <tr align="center" class="align-middle center">
        <th *ngFor="let title of headerTitle">
          {{title}}
        </th>
        <th class="text-info">Result</th>
      </tr>
    </thead>
    <tbody>
      <tr *ngFor="let record of records" scope="row">
        <td>{{record.Id}}</td>
        <td>{{record.Description}}</td>
        <td>
          <span class="text-success" *ngIf="record.Result; else failed">
            Success
          </span>
          <ng-template #failed>
            <span *ngIf="record.Result == false" class="text-danger">
              Failed
            </span>
          </ng-template>
        </td>
      </tr>
    </tbody>
  </table>
</mat-dialog-content>

<div mat-dialog-actions align="center">
  <button class="btn btn-block btn-outline-secondary btn-sm" mat-button mat-dialog-close>Cancel</button>
  <span>&nbsp; &nbsp; </span> <span>&nbsp; &nbsp; </span>
  <button class="btn btn-block btn-outline-warning btn-sm" [disabled]="!submitClicked" mat-button
    (click)="onImportClick()">Import</button>

</div>

```

Preview batch data, and display result (success/failed) after connecting to API

Convert to JSON and post to API

API add record, return failed record

Last updated

Was this helpful?