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 .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 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 / 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 / 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 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.
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
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.
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
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.
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.