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 OneDrive. Can also be a single Diagram.
The client ID of the application in use (given by Microsoft in Microsoft Dev Center)
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 GoOneDrive exists, in which the storage service brand icons can be found. The default value is "../goCloudStorageIcons/".
Get / set the global oauthToken. Only used to authorize requests in load, save, and remove when the oneDriveFilepicker property is not used. Not needed when the oneDriveFilePicker is used, as action-specific tokens (issued by the Microsoft-provided OneDrive Filepicker) are issued then. oauthToken is null after construction, but can be set or refreshed with calls to authorize.
Get OneDrive Filepicker object. Used to display a Microsoft user's OneDrive files.
Get OAuth 2.0 token for Microsoft OneDrive API requests with a specific Microsoft account. Sets oauthToken.
Whether to get a new access token (triggers a page redirect) (true) or try to find / use the one in the browser window URI (no redirect) (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 MS OneDrive filepath to save current diagram model to
Path must be of the form: /drive/root:/{item-path}
Returns a Promise that resolves with a boolean stating whether a file exists at a given path
Generate and return a Microsoft Graph URL for a target item
The item to generate the URL for
Indicates whether to target the parent folder + filename instead of the item itself
Indicates whether to append /content to the item URL
Returns a Microsoft Graph URL for a target item
Get the OneDrive file reference object at a given path. Properties of particular note include:
Note: Name, ID, and path are requisite for creating valid DiagramFiles. A path can be constructed by concatenating the parentReference.path with name. DiagramFiles optionally also contain parentReference and token values (both used exclusively by GoOneDrive and its methods).
A valid MS OneDrive filepath to save current diagram model to
Path must be of the form: /drive/root:/{item-path}
Optional: A token received by OneDrive filepicker (loadDiagramWithUI) to allow for its file to be loaded. If no token is given, use global oauthToken
Returns a Promise that resolves with a OneDrive file reference object at a given path
Get information about the currently logged in Microsoft user. Some fields of particular note include:
Note: If oauthToken is not valid or has expired, a page redirect to the Microsoft Account sign in will occur.
Returns a Promise that resolves with information about the currently logged in Microsoft user
Load the contents of a saved diagram from MS OneDrive to diagram model.
A valid Microsoft OneDrive filepath to load diagram model data from. Path syntax is
/drive/root:/{path-to-file}/{filename}
; i.e. /drive/root:/Documents/example.diagram
A token received by OneDrive Filepicker (passed from loadWithUI) to allow for its file to be loaded. If no token is given, use global oauthToken
Returns a Promise that resolves with a DiagramFile representing the loaded file
Load diagram model data from a given OneDrive-specific file path into managedDiagrams using the MS OneDrive filepicker.
Returns a Promise that resolves with a DiagramFile representing the loaded file
Delete a diagram from a user's OneDrive at a given path.
A valid Microsoft OneDrive filepath to delete. Path syntax is
/drive/root:/{path-to-file}/{filename}
; i.e. /drive/root:/Documents/example.diagram
A token received by OneDrive filepicker (passed from removeWithUI) to allow for its file to be deleted. If no token is given, use global oauthToken
Returns a Promise that resolves with a DiagramFile representing the deleted file
Delete a diagram from a user's OneDrive using the OneDrive Filepicker.
Returns a Promise that resolves with a DiagramFile representing the deleted file
Save managedDiagrams' model data to Microsoft OneDrive. 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 OneDrive corresponding to currentDiagramFile.path with current managedDiagrams' model data.
A valid MS OneDrive filepath to save current diagram model to. Path syntax is
/drive/root:/{path-to-file}/{filename}
; i.e. /drive/root:/Documents/example.diagram
Returns a Promise that resolves with a DiagramFile representing the saved file.
Save the each managedDiagrams' model data to a user's One Drive account, using One Drive FilePicker.
Returns a Promise that resolves with a DiagramFile representing the saved file.
Show the custom GoOneDrive save prompt ui.
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 Microsoft One Drive. As with all GoCloudStorage subclasses (with the exception of GoLocalStorage, any page using GoDropBox must be served on a web server.
Note: Makes use of OneDrive FilePicker for JavaScript v7.2. Any page using GoOneDrive must include a script tag with src set to https://js.live.net/v7.2/OneDrive.js.