An array of GoJS Diagrams whose model(s) will be saved to / loaded from Google Drive.
The client ID of the Google application linked with this instance of GoGoogleDrive (given in Google Developers Console after registering a Google app)
The Google Picker API key. Once obtained, it can be found in the Google Developers Console
String representation of the default model data for new diagrams. If this is null, default new diagrams will be empty. Usually a value given by calling .toJson() on a GoJS Diagram's Model.
The directory path relative to the page in which this instance of GoGoogleDrive exists, in which the storage service brand icons can be found. The default value is "../goCloudStorageIcons/".
Get the name of the class; i.e. "GoDropbox"
Get the clientId for the app using the cloud storage service. This is usually given by the cloud storage provider's dev console or similar. Set with a parameter during construction.
Get or set the currently open DiagramFile. By default, currentDiagramFile is set when a file is loaded from storage, saved to storage (if saved to a different path from the currentDiagramFile.path), or deleted from storage (if the deleted file is the currently open one). The default value is a DiagramFile with null id, name, and path values.
Get / set the defaultModel data for the app used by an instance of GoCloudStorage. defaultModel is used when creating new diagrams. See create.
Get Google API Client. The Google API Client is used in GoGoogleDrive to make many different requests to Google Drive, however, it can be used with other Google Libraries to achieve many purposes. To read more about what can be done with a Google API Client object, click here. gapiClient is set after a succesful authorization in authorize.
gapiClient is really of type Object, not type any. However, the Google libraries are all written in JavaScript and do not provide d.ts files. As such, to avoid TypeScript compilation errors, both gapiClient and gapiPicker properties are declared as type any.
Get Google Picker API Object. Used to show the Google filepicker when loading / deleting files, in the createPicker function. gapiPicker is set after a succesful authorization in authorize.
gapiPicker is really of type Object, not type any. However, the Google libraries are all written in JavaScript and do not provide d.ts files. As such, to avoid TypeScript compilation errors, both gapiClient and gapiPicker properties are declared as type any.
Get / set iconsRelativeDirectory, the directory path relative to the page in which this instance of GoCloudStorage exists, in which the storage service brand icons can be found. The default value is "../goCloudStorageIcons/".
Get or set isAutoSaving property. If true, the managedDiagrams will be saved to storage after every
Transaction (only if currentDiagramFile holds a non-null path value).
Additionally, if isAutoSaving is true, users will be prompted to save newly created diagrams when created with create.
The default value for isAutoSaving is true
.
Get / set the GoJS Diagrams associated with this instance of GoCloudStorage. Set with a parameter during construction.
Get the Google Picker API key associated with this instance of GoGoogleDrive. This is set with a parameter during construction. A Google Picker API key can be obtained by following the process detailed here, and it can be found in your Google Developers Console. The pickerApiKey is used only in createPicker.
Get the scope for the application linked to this instance of GoGoogleDrive (via clientId). Scope tells the gapiClient what permissions it has in making requests. Read more on scope here. The default value is 'https://www.googleapis.com/auth/drive', set during construction. This can only be modified by changing the source code for GoGoogleDrive. As changing scope impacts gapiClient's permissions (and could break the usability of some or all functions of GoGoogleDrive), this is not recommended.
Get the name of the cloud storage service being used; i.e. "Dropbox"
Get the UI element associated with this instance of GoCloudStorage. This is a custom filepicker window for GoDropBox and GoLocalStorage. It is a save prompt for GoOneDrive and GoGoogleDrive (both these classes use third party UI for storage navigation, provided by Microsoft and Google, respectively). The UI element is created during construction.
Check if there is a signed in user who has authorized the application connected to this instance of GoGoogleDrive (via clientId. If not, prompt user to sign into their Google Account and authorize the application. On successful authorization, set gapiClient and gapiPicker.
Whether to get a new token (change current Google User)(true) or attempt to fetch a token for the currently signed in Google User (false).
Returns a Promise that resolves with a boolean stating whether authorization was succesful (true) or failed (false)
Check whether a file exists at a given path
A valid GoogleDrive file ID -- not a path. Named 'path' only to preserve system nomenclature
Returns a Promise that resolves with a boolean stating whether a file exists at a given path
Set each of managedDiagrams' .model to defaultModel (if defaultModel is null, each model will be set to a new GraphLinksModel by default). If isAutoSaving is true and no path parameter is supplied, users will be immediately prompted to save their new diagrams to cloud storage.
If a valid filepath is supplied, save each of managedDiagrams' model data to this path. No UI of any sort appears. What is meant by "valid filepath" varies from subclass to subclass. Rules for valid filepaths by subclass:
example.diagram
/{path-to-file}/{filename}
; i.e. /Public/example.diagram
/drive/root:/{path-to-file}/{filename}
; i.e. /drive/root:/Documents/example.diagram
Returns a Promise that resolves with a DiagramFile representing the newly created file.
Launch Google Picker, a filepicker UI used to graphically select files in Google Drive to load or delete. This is accomplished with gapiPicker, which is set after succesful authorization, so this function may only be called after a successful call to authorize.
Callback function that takes the chosen file from the picker as a parameter
Get the Google Drive file reference object at a given path. Fields include:
text/plain
drive#file
.Note: Name, ID, and path values are requisite for creating valid DiagramFiles. When creating a DiagramFile for a diagram saved to Google Drive, provide the same value for name and path properties.
A valid GoogleDrive file ID -- not a path. Named 'path' only to preserve system nomenclature
Returns a Promise that resolves with a Google Drive file reference object at a given path
Get information about the currently logged in Google user. Some fields of particular note include:
Returns a Promise that resolves with information about the currently logged in Google user
Hide the ui element associated with this instance of GoCloudStorage. Used in some UI element onclicks.
If action (save, delete, load) is canceled, resolve Promise (returned previously in showUI) with a 'Canceled' notification. Default value is false.
Get the contents of a saved diagram from Google Drive using a given Google Drive file ID. No UI of any sort appears.
A valid GoogleDrive file ID -- not a path. Named 'path' only to preserve GoCloudStorage system nomenclature
Returns a Promise that resolves with a DiagramFile representing the loaded file
Load the contents of a saved diagram from Google Drive using the Google Picker (see gapiPicker and createPicker).
Returns a Promise that resolves with a DiagramFile representing the loaded file
Delete a the diagram from a user's Google Drive with the given Google Drive file ID. No UI of any sort appears.
A valid GoogleDrive file ID -- not a path. Named 'path' only to preserve system nomenclature
Returns a Promise that resolves with a DiagramFile representing the deleted file
Delete a selected diagram from a user's Google Drive using the Google Picker (see gapiPicker and createPicker).
Returns a Promise that resolves with a DiagramFile representing the deleted file
Save managedDiagrams' model data to GoGoogleDrive. If path is supplied save to that path. If no path is supplied but currentDiagramFile has non-null, valid properties, update saved diagram file content at the path in GoGoogleDrive corresponding to currentDiagramFile.path with current managedDiagrams' model data. If no path is supplied and currentDiagramFile is null or has null properties, this calls saveWithUI.
A name (not a path, not an id) to save this diagram file in Google Drive under. Named 'path' only to preserve system nomenclature
Returns a Promise that resolves with a DiagramFile representing the saved file
Save the current managedDiagrams's model data to the current Google user's Google Drive using the custom ui save prompt.
Returns a Promise that resolves with a DiagramFile representing the saved file
Show the custom GoGoogleDrive save prompt; a div with an HTML input element that accepts a file name to save the current managedDiagrams data to in Google Drive.
Returns a Promise that resolves (in save, load, or remove) with a DiagramFile representing the saved/loaded/deleted file
Class for saving / loading GoJS Diagram models to / from Google Drive. Uses the Google Drive V3 API by use of a Google Client API object. As with all GoCloudStorage subclasses (with the exception of GoLocalStorage, any page using GoDropBox must be served on a web server.
Note: Any page using GoGoogleDrive must include a script tag with src set to https://apis.google.com/js/api.js.