(core) Update export CSV and Excel endpoints

Summary:
The endpoints for exporting CSV and Excel are now under
/api/docs/:docId/ and are forwarded to a doc worker for export.

The Share Menu has been updated to use the new endpoints.

Test Plan: No new tests. Existing tests that verify endpoints work correctly.

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3007
This commit is contained in:
George Gevoian
2021-08-30 13:06:40 -07:00
parent 5258fa649d
commit ef5da42378
7 changed files with 25 additions and 36 deletions

View File

@@ -347,6 +347,8 @@ export interface DocAPI {
// is HEAD, the result will contain a copy of any rows added or updated.
compareVersion(leftHash: string, rightHash: string): Promise<DocStateComparison>;
getDownloadUrl(template?: boolean): string;
getGenerateXlsxUrl(): string;
getGenerateCsvUrl(): string;
/**
* Exports current document to the Google Drive as a spreadsheet file. To invoke this method, first
* acquire "code" via Google Auth Endpoint (see ShareMenu.ts for an example).
@@ -790,6 +792,14 @@ export class DocAPIImpl extends BaseAPI implements DocAPI {
return this._url + `/download?template=${Number(template)}`;
}
public getGenerateXlsxUrl() {
return this._url + '/gen-xlsx';
}
public getGenerateCsvUrl() {
return this._url + '/gen-csv';
}
public async sendToDrive(code: string, title: string): Promise<{url: string}> {
const url = new URL(`${this._url}/send-to-drive`);
url.searchParams.append('title', title);