MCPcopy Create free account
hub / github.com/datapane/datapane / DataTableBlock

Class DataTableBlock

web-components/report/src/data-model/blocks/datatable.ts:70–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68};
69
70export class DataTableBlock extends AssetBlock {
71 public component = markRaw(VDataTableBlock);
72 public static captionType: CaptionType = "Table";
73 public rows: number;
74 public columns: number;
75 public size: number;
76 public casRef: string;
77
78 private webUrl: string;
79 private _revogridExportPlugin: any;
80
81 public get cells(): number {
82 return this.rows * this.columns;
83 }
84
85 public get deferLoad(): boolean {
86 return this.cells > AUTO_LOAD_CELLS_LIMIT;
87 }
88
89 public get exportUrl(): string {
90 return this.buildExtensionUrl("export");
91 }
92
93 public constructor(elem: Elem, figure: BlockFigure, opts?: any) {
94 super(elem, figure);
95 const { attributes } = elem;
96 this.rows = attributes.rows;
97 this.columns = attributes.columns;
98 this.size = attributes.size;
99 this.casRef = attributes.cas_ref;
100 this.webUrl = opts.webUrl;
101
102 this.componentProps = {
103 ...this.componentProps,
104 streamContents: this.streamContents,
105 getCsvText: this.getCsvText,
106 downloadLocal: this.downloadLocal,
107 downloadRemote: this.downloadRemote,
108 deferLoad: this.deferLoad,
109 cells: this.cells,
110 refId: this.refId,
111 };
112 }
113
114 private fetchDataset(opts: Record<string, string>): Promise<any> {
115 return axios.get(this.src, opts).then((r: AxiosResponse) => {
116 return r.data;
117 });
118 }
119
120 public streamContents = async (): Promise<DatasetResponse> => {
121 /**
122 * Fetch dataset and convert to arrow format
123 */
124 const opts = {
125 responseType: "arraybuffer",
126 };
127 const { apiResponseToArrow } = await import("../datatable/arrow-utils");

Callers

nothing calls this directly

Calls 6

fetchDatasetMethod · 0.95
getExportPluginMethod · 0.95
apiResponseToArrowFunction · 0.85
addQueryParamFunction · 0.85
downloadObjectFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected