Skip to content

GoogleDriveProvider - #832

Open
ibgreen wants to merge 2 commits into
cloud-provider-refactorfrom
google-drive
Open

GoogleDriveProvider#832
ibgreen wants to merge 2 commits into
cloud-provider-refactorfrom
google-drive

Conversation

@ibgreen

@ibgreen ibgreen commented Nov 15, 2019

Copy link
Copy Markdown
Collaborator

(Note: This is currently a stacked diff on top of the cloud-provider-refactor branch #831. Should be rebased to master before landing.)

Screen Shot 2019-11-17 at 9 40 03 AM

To test/integrate a Google client id and app keyneeds to be registered for kepler.gl. Optionally, I can provide the client id for the integration I have set up (which could make some sense as I may keep working on the Google integration for a while).

SOME HIGHLIGHTS:

  • GoogleProvider dynamically loads the gapi (Google API) library with a new loadScript util, partly to help avoid bundle size impact from linking in multiple cloud provider SDKs.
  • GoogleProvider implements OAUTH2 login via gapi.

REMAINING:

  • Currently uses both CLIENT_ID and APPKEY, investigate if this is required.
  • The GoogleProvider should correctly implement file upload (currently lists google drive files instead of uploads them).
  • The Google Drive SVG icon is a major hack, we need a proper icon.

Signed-off-by: Ib Green <ibgreen@Ibs-MacBook-Pro.local>
Signed-off-by: Ib Green <ibgreen@Ibs-MacBook-Pro.local>
@ibgreen
ibgreen marked this pull request as ready for review November 17, 2019 17:38
@ibgreen

ibgreen commented Nov 17, 2019

Copy link
Copy Markdown
Collaborator Author

@macrigiuseppe This PR is now ready for review.

It would be good to get some initial feedback on the way additional tokens are being managed, with new environment variables etc.

@ibgreen

ibgreen commented Nov 17, 2019

Copy link
Copy Markdown
Collaborator Author

@macrigiuseppe Added screenshot

@ibgreen ibgreen changed the title GoogleDriveProvider (WIP: For exposition only) GoogleDriveProvider Nov 17, 2019
* To access Google Drive, specify it in scopes
* param scopes = ['https://www.googleapis.com/auth/drive.file'];
*/
constructor(appName, clientId, appKey, scopes = SCOPES) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should try to make to make this consistent across all cloud providers.
Right now Dropbox provider accepts an icon where here we have different parameters.

I think we can follow a more flexible pattern:

constructor(appName, clientId, options = {})

options can handle all different requirement for each cloud provider

* param scopes = ['https://www.googleapis.com/auth/drive.file'];
*/
constructor(appName, clientId, appKey, scopes = SCOPES) {
super({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For default parameters I would create a constant and merge it with constructor’s postmasters

* @returns {Promise<void>}
*/
async uploadFile({blob, name, isPublic = true}) {
const mimeType = 'application/json';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This can be defined outside the scope of this method.

Actually it could be defined in a cloud provider constant file since other providers may take advantage of it

const metadata = {
name, // Filename on Google Drive
mimeType, // mimeType on Google Drive
parents: ['root'] // Folder ID at Google Drive

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Constant

};

// The body of the post request will be this form
const form = new FormData();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would encapsulate the logic to generate the body into an helper method

// To access Google Drive, specify it in scopes
// @param scopes = ['https://www.googleapis.com/auth/drive'];
constructor({clientId, appKey, name, appName, icon, discoveryDocs, scopes = []}) {
// All cloud-providers providers must implement the following properties

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I’m not clear what the hierarchy is here. My understanding is the following:
GoogleDroveProvider and DropboxProvider are peers and GoogleProvider and DropboxSdk are their respective parents.

But constructors don’t reflect such hierarchy, why google provider have an icon given it is an api layer?

If my first assumptions is wrong, can you clarify in the PR description the role of GoolgeProvider and GoogleCloudProvider?

I only see google provider in it

this._getUserData(googleUser);
this._onLoginStatusChange();
onCloudLoginSuccess(this.name);
}).catch (error => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you call onCloudLoginFailure?

@macrigiuseppe

Copy link
Copy Markdown
Collaborator

@ibgreen the UI is not correct. There should be some margin space between the two tiles.

You can look at the UI here: #746

@VictorVelarde

Copy link
Copy Markdown
Contributor

Hi @macrigiuseppe and @ibgreen. Regarding to the UI of the 'tiles', we have this WIP here: https://github.com/keplergl/kepler.gl/blob/660bc42a53383f276f1f8b4c2b2ec1200db52fae/examples/demo-app/src/components/sharing/cloud-tile.js that might be useful.

Apart from the space between the tiles, we also added the 'username', with a new getUserName method in the provider, as @heshan0131 suggested in her feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants