@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
90 lines (89 loc) • 3.45 kB
TypeScript
import { EventEmitter, OnDestroy } from '@angular/core';
import { AppContextService } from '../../service/app-context.service';
import { DataTableComponent } from './data-table.component';
import * as i0 from "@angular/core";
export declare enum DataTableDownloadDataType {
CSV = "text/csv",
JSON = "application/json"
}
export declare class DataTableDownloadService implements OnDestroy {
private appContextService;
/**
* The localization strings object for master view.
*/
resourceStrings: any;
/**
* The download finished event emitter.
*/
downloadDataFinished: EventEmitter<void>;
/**
* The notification instance.
*/
private notificationInstance;
/**
* The download worker.
*/
private worker;
/**
* The current extension/module fileName.
*/
private moduleName;
/**
* Determines if one download service is ongoing.
*/
private isBusy;
/**
* Adding a force delay time can help with general performance of the downloading function when dataset grows big.
* It can also help with improve granularity for notification state changes.
*/
private readonly minDownloadDelayTime;
/**
* Force timeout 2mins.
*/
private readonly maxDownloadTimeAllowed;
constructor(appContextService: AppContextService);
ngOnDestroy(): void;
downloadData(dataTable: DataTableComponent, downloadType: DataTableDownloadDataType, contextParameters?: any): void;
/**
* It guarantees the valid DataTableDownloadDataType is passed in to the worker.
* @param downloadType the downloadType passed in from client side that needs validation.
* @returns a valid downloadType that comes from DataTableDownloadDataType
*/
private validateMimeType;
/**
* The actual implementation core function for download data.
* @param dataTable the data table component reference.
* @param downloadType the downloadType passed in from client.
* @returns parsed error in string.
*/
private downloadDataCore;
private downloadAction;
private convertToCsv;
/**
* It converts any type to string.
* @param input any type of input.
* @returns the string representation for input.
*/
private castToString;
/**
* Prevents space to be recognized as different columns.
* The solution is to wrap the string with double quote and still forms a valid string.
* @param value The input string that needs to wrap with double quote.
* @returns the string wrapped with double quotes and is still a valid string.
*/
private preventTextContentAsSeparatedColumns;
/**
* It gets the rendered string from the rendered table row and cell.
* @param rowIndex the row index from the data table.
* @param columnIndex the column index from the data table.
* @param dataTable the data table component reference.
* @returns the string representing the rendered data from DOM.
*/
private getTableCellRenderedString;
/**
* The initialization for the worker to be used for downloading data table text content.
*/
private initWorker;
static ɵfac: i0.ɵɵFactoryDeclaration<DataTableDownloadService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DataTableDownloadService>;
}