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

feat(grid): added export progress visualization in toolbar #8000

Merged
merged 15 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
Expand Up @@ -23,6 +23,10 @@
@extend %igx-grid-toolbar__actions !optional;
}

@include e(export-progress){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name this something more generic. I think it might be used for other purposes as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about e(progress-bar)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think that's fine 👍

@extend %igx-grid-toolbar__export-progress !optional;
}

@include e(adv-filter, $m: 'filtered') {
@extend %igx-grid-toolbar__adv-filter--filtered !optional;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@

%igx-grid-toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
grid-row: 1;
Expand Down Expand Up @@ -253,6 +254,10 @@
}
}

%igx-grid-toolbar__export-progress {
flex-basis: 100%;
}

%igx-grid-toolbar__adv-filter--filtered {
border-color: igx-color(map-get($theme, 'palette'), 'secondary') !important;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
</igx-column-actions>
</igx-drop-down>
</div>

<div *ngIf="grid.columnPinning">
<button igxButton="outlined" [displayDensity]="grid.displayDensity" #columnPinningButton name="btnColumnPinning" igxRipple
(click)="toggleColumnPinningUI()">
Expand All @@ -65,7 +66,7 @@

<div class="igx-grid-toolbar__dropdown" *ngIf="shouldShowExportButton" id="btnExport">
<button igxButton="outlined" [displayDensity]="grid.displayDensity" igxRipple #btnExport
(click)="exportClicked()">
(click)="exportClicked()" [disabled]="isExporting">
<span class="igx-grid-toolbar__button-space">
<igx-icon fontSet="material">import_export</igx-icon>
<span>{{ getExportText() }}</span>
Expand All @@ -83,3 +84,7 @@
</igx-drop-down>
</div>
</div>

<div class="igx-grid-toolbar__export-progress" *ngIf="isExporting">
<igx-linear-bar [indeterminate]="true"></igx-linear-bar>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class IgxGridToolbarComponent extends DisplayDensityBase implements After
}

private _filterColumnsPrompt = this.grid.resourceStrings.igx_grid_toolbar_actions_filter_prompt;
private _isExporting = false;

/**
* @hidden
Expand Down Expand Up @@ -186,6 +187,13 @@ export class IgxGridToolbarComponent extends DisplayDensityBase implements After
return (this.grid != null && (this.grid.exportExcel || this.grid.exportCsv));
}

/**
* @hidden @internal
*/
public get isExporting(): boolean {
return this._isExporting;
}

/**
* Returns whether the `IgxGridComponent` renders an Excel export button.
* ```typescript
Expand Down Expand Up @@ -315,6 +323,16 @@ export class IgxGridToolbarComponent extends DisplayDensityBase implements After
* ```
*/
public exportToExcelClicked() {
let exportEnded = false;
this.excelExporter.onExportEnded.subscribe((args: any) => {
exportEnded = true;
this.setIsExporting(false);
});
setTimeout(() => {
if (!exportEnded) {
this.setIsExporting(true);
}
}, 500);
this.performExport(this.excelExporter, 'excel');
}

Expand All @@ -325,9 +343,24 @@ export class IgxGridToolbarComponent extends DisplayDensityBase implements After
* ```
*/
public exportToCsvClicked() {
let exportEnded = false;
this.csvExporter.onExportEnded.subscribe((args: any) => {
exportEnded = true;
this.setIsExporting(false);
});
setTimeout(() => {
if (!exportEnded) {
this.setIsExporting(true);
}
}, 500);
igdmdimitrov marked this conversation as resolved.
Show resolved Hide resolved
this.performExport(this.csvExporter, 'csv');
}

private setIsExporting(isExporting: boolean) {
this._isExporting = isExporting;
this.cdr.detectChanges();
}

private performExport(exp: IgxBaseExporter, exportType: string) {
this.exportClicked();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export abstract class IgxBaseExporter {
const dataToExport = new Array<any>();
const isSpecialData = ExportUtilities.isSpecialData(data);

yieldingLoop(data.length, 1000, (i) => {
yieldingLoop(data.length, 100, (i) => {
const row = data[i];
this.exportRow(dataToExport, row, i, isSpecialData);
}, () => {
Expand Down