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

Fix/import preview loading indicator #2435

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
<div class="flex-row gap-regular align-center">
<span class="flex-grow" i18n>Review your mapped data to be imported:</span>
@if (isLoading) {
<div>
<div i18n>Preparing data for preview and import ...</div>
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
} @else {
<div class="flex-row gap-regular align-center">
<span class="flex-grow" i18n>Review your mapped data to be imported:</span>

<button (click)="startImport()" mat-raised-button color="accent" i18n>
Start Import
</button>
<button (click)="startImport()" mat-raised-button color="accent" i18n>
Start Import
</button>

<app-help-button
text="The data previewed here is mapped and transformed according to the 'Column Mapping' you defined in the previous step.
<app-help-button
text="The data previewed here is mapped and transformed according to the 'Column Mapping' you defined in the previous step.
Only columns for which you selected a field there will be imported and appears here in this preview.
If necessary, you can go back to the previous step and make changes to the mapping."
i18n-text="import - review data - help text"
>
</app-help-button>
</div>
i18n-text="import - review data - help text"
>
</app-help-button>
</div>

<app-entities-table
*ngIf="mappedEntities.length > 0"
[entityType]="entityConstructor"
[customColumns]="displayColumns"
[columnsToDisplay]="displayColumns"
[records]="mappedEntities"
clickMode="none"
[editable]="false"
/>
<app-entities-table
[entityType]="entityConstructor"
[customColumns]="displayColumns"
[columnsToDisplay]="displayColumns"
[records]="mappedEntities"
clickMode="none"
[editable]="false"
/>
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ import { ImportMetadata } from "../import-metadata";
import { AdditionalImportAction } from "../import-additional-actions/additional-import-action";
import { MatButtonModule } from "@angular/material/button";
import { HelpButtonComponent } from "../../common-components/help-button/help-button.component";
import { NgIf } from "@angular/common";
import { EntitiesTableComponent } from "../../common-components/entities-table/entities-table.component";
import { EntityRegistry } from "../../entity/database-entity.decorator";
import { MatProgressBar } from "@angular/material/progress-bar";

@Component({
selector: "app-import-review-data",
templateUrl: "./import-review-data.component.html",
styleUrls: ["./import-review-data.component.scss"],
standalone: true,
imports: [MatButtonModule, HelpButtonComponent, EntitiesTableComponent, NgIf],
imports: [
MatButtonModule,
HelpButtonComponent,
EntitiesTableComponent,
MatProgressBar,
],
})
export class ImportReviewDataComponent implements OnChanges {
@Input() rawData: any[];
Expand All @@ -39,6 +44,7 @@ export class ImportReviewDataComponent implements OnChanges {

@Output() importComplete = new EventEmitter<ImportMetadata>();

isLoading: boolean;
mappedEntities: Entity[] = [];
displayColumns: string[] = [];

Expand All @@ -56,6 +62,7 @@ export class ImportReviewDataComponent implements OnChanges {
}

private async parseRawData() {
this.isLoading = true;
this.mappedEntities = await this.importService.transformRawDataToEntities(
this.rawData,
this.entityType,
Expand All @@ -65,6 +72,8 @@ export class ImportReviewDataComponent implements OnChanges {
this.displayColumns = this.columnMapping
.filter(({ propertyName }) => !!propertyName)
.map(({ propertyName }) => propertyName);

this.isLoading = false;
}

async startImport() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ const Template: StoryFn<ImportReviewDataComponent> = (
props: args,
});

export const Basic = Template.bind({});
Basic.args = {
export const Preview = Template.bind({});
Preview.args = {
rawData: IMPORT_SAMPLE_RAW_DATA,
entityType: "Child",
columnMapping: IMPORT_SAMPLE_COLUMN_MAPPING,
};

export const Loading = Template.bind({});
Loading.args = {
isLoading: true,
};
Loading