(core) Export to Excel and Send to drive

Summary:
Implementing export to excel and send to Google Drive feature.

As part of this feature few things were implemented:
- Server side google authentication exposed on url: (docs, docs-s, or localhost:8080)/auth/google
- Exporting grist documents as an excel file (xlsx)
- Storing exported grist document (in excel format) in Google Drive as a spreadsheet document.

Server side google authentication requires one new environmental variables
- GOOGLE_CLIENT_SECRET (required) used by authentication handler

Test Plan: Browser tests for exporting to excel.

Reviewers: paulfitz, dsagal

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2924
This commit is contained in:
Jarosław Sadziński
2021-07-21 10:46:03 +02:00
parent 9cc034f606
commit 08295a696b
20 changed files with 1182 additions and 187 deletions

View File

@@ -46,6 +46,22 @@ export function makeGristConfig(homeUrl: string|null, extra: Partial<GristLoadCo
};
}
/**
* Creates a method that will send html page that will immediately post a message to a parent window.
* Primary used for Google Auth Grist's endpoint, but can be used in future in any other server side
* authentication flow.
*/
export function makeMessagePage(server: GristServer, staticDir: string) {
return async (req: express.Request, resp: express.Response, message: any) => {
const config = server.getGristConfig();
const fileContent = await fse.readFile(path.join(staticDir, "message.html"), 'utf8');
const content = fileContent
.replace("<!-- INSERT CONFIG -->", `<script>window.gristConfig = ${JSON.stringify(config)};</script>`)
.replace("<!-- INSERT MESSAGE -->", `<script>window.message = ${JSON.stringify(message)};</script>`);
resp.status(200).type('html').send(content);
};
}
/**
* Send a simple template page, read from file at pagePath (relative to static/), with certain
* placeholders replaced.