MakerLabs ACM
ImageFileUploader Class Reference

WebComponent which displays an image, and also supports uploading a new image to Google Drive via drag n' drop, or a file picker window. More...

Inheritance diagram for ImageFileUploader:

Detailed Description

WebComponent which displays an image, and also supports uploading a new image to Google Drive via drag n' drop, or a file picker window.

Public Member Functions

 constructor ()
 
 render ()
 LitElement lifecycle hook. Re-rendered after any update(). More...
 
 firstUpdated (changedProperties)
 LitElement lifecycle hook. Called after the element's DOM has been updated the first time, immediately before updated() is called. More...
 
get accessToken ()
 Check if Google Auth user is currently logged-in, and extract the OAuth accessToken for Google Drive access. More...
 
 uploadFiles (files)
 Uploads the content to Drive & displays the results when complete. More...
 
 clearUploadedFiles ()
 Clear the temporary data storage of the uploaded file. More...
 
 handleDraggedFileUpload (evt)
 Called when files are uploaded via drag n' drop. More...
 
 handleSelectedFileUpload (evt)
 Called when files are uploaded via the OS file picker dialog. More...
 
 handleDragOver (evt)
 dragover handler to set the drop effect. More...
 
 handleDragLeave (evt)
 dragleave handler to clear the drop effect. More...
 

Static Public Member Functions

static get properties ()
 WebComponent properties that can be used as HTML attributes. More...
 

Member Function Documentation

◆ accessToken()

get ImageFileUploader::accessToken ( )
inline

Check if Google Auth user is currently logged-in, and extract the OAuth accessToken for Google Drive access.

Returns
OAuth accessToken

◆ clearUploadedFiles()

ImageFileUploader::clearUploadedFiles ( )
inline

Clear the temporary data storage of the uploaded file.

◆ constructor()

ImageFileUploader::constructor ( )
inline
Here is the call graph for this function:

◆ firstUpdated()

ImageFileUploader::firstUpdated (   changedProperties)
inline

LitElement lifecycle hook. Called after the element's DOM has been updated the first time, immediately before updated() is called.

Parameters
changedPropertiesJS Map containing properties which have changed

Setup event listeners:

  • On dragover, draw a border around the drop zone.
  • On dragleave, cancel the border when no longer dragged over.
  • On drop, begin the file upload immediately.
  • On change, begin the file upload after selecting a file with the chooser dialog
Here is the call graph for this function:

◆ handleDraggedFileUpload()

ImageFileUploader::handleDraggedFileUpload (   evt)
inline

Called when files are uploaded via drag n' drop.

Here is the call graph for this function:

◆ handleDragLeave()

ImageFileUploader::handleDragLeave (   evt)
inline

dragleave handler to clear the drop effect.

◆ handleDragOver()

ImageFileUploader::handleDragOver (   evt)
inline

dragover handler to set the drop effect.

◆ handleSelectedFileUpload()

ImageFileUploader::handleSelectedFileUpload (   evt)
inline

Called when files are uploaded via the OS file picker dialog.

Here is the call graph for this function:

◆ properties()

static get ImageFileUploader::properties ( )
inlinestatic

WebComponent properties that can be used as HTML attributes.

Parameters
srcArray of User/Machine info for searching and displaying a popup window
nameArray of User/Machine info for searching and displaying a popup window
emptyImageDataDefault image data to display if no image data is provided (a blank PNG)
parentFolderIdGoogle Drive Folder ID to be used as the parent for uploaded images (defaults to "root")

◆ render()

ImageFileUploader::render ( )
inline

LitElement lifecycle hook. Re-rendered after any update().

Returns
LitElement html`` literal, containing desired DOM state.

◆ uploadFiles()

ImageFileUploader::uploadFiles (   files)
inline

Uploads the content to Drive & displays the results when complete.

Trigger a file upload via Google Drive MediaUploader, then:

  • Parse the uploaded file response metadata
  • Check if a valid web content link was created/found
  • Determine the URL for a 300px thumbnail image
  • Update displayed image
Here is the call graph for this function:

The documentation for this class was generated from the following file: