This is part of GoCloudStorage and not part of the main GoJS library. Storage can be found in the GoJS kit under the projects
folder. See the Storage intro page for more information.
An array of GoJS Diagrams whose model(s) will be saved to / loaded from Google Drive. Can also be a single Diagram.
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 Model.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 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 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.
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
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
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 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.