Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GoDropBox

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.

Hierarchy

Class for saving / loading GoJS Models to / from Dropbox. 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 GoDropBox must include a script tag with a reference to the Dropbox JS SDK.

Index

Constructors

constructor

  • new GoDropBox(managedDiagrams: Diagram | Diagram[], clientId: string, defaultModel?: string, iconsRelativeDirectory?: string): GoDropBox
  • Parameters

    • managedDiagrams: Diagram | Diagram[]

      An array of GoJS Diagrams whose model(s) will be saved to / loaded from Dropbox. Can also be a single Diagram.

    • clientId: string

      The client ID of the application in use (given in Dropbox Developer's Console)

    • Optional defaultModel: string

      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.

    • Optional iconsRelativeDirectory: string

      The directory path relative to the page in which this instance of GoDropBox exists, in which the storage service brand icons can be found. The default value is "../goCloudStorageIcons/".

    Returns GoDropBox

Properties

Read-only dropbox : any

menuPath : string

  • Get / set currently open Dropnpx path in custom filepicker ui. Default value is the empty string, which corresponds to the currently signed in user's Drobox account's root path. Set when a user clicks on a folder in the custom ui menu by invoking anchor onclick values. These onclick values are set when the Dropbox directory at the current menuPath is displayed with showUI.

Methods

Override authorize

  • authorize(refreshToken?: boolean): Promise<unknown>
  • Check if there is a signed in Dropbox user who has authorized the application linked to this instance of GoDropBox (via clientId). If not, prompt user to sign in / authenticate their Dropbox account.

    Parameters

    • refreshToken: boolean = false

      Whether to get a new acess token (triggers a page redirect) (true) or try to find / use the one in the browser window URI (no redirect) (false)

    Returns Promise<unknown>

    Returns a Promise that resolves with a boolean stating whether authorization was succesful (true) or failed (false)

Override checkFileExists

  • checkFileExists(path: string): Promise<unknown>
  • Check whether a file exists in user's Dropbox at a given path.

    Parameters

    • path: string

      A valid Dropbox filepath. Path syntax is /{path-to-file}/{filename}; i.e. /Public/example.diagram. Alternatively, this may be a valid Dropbox file ID.

    Returns Promise<unknown>

    Returns a Promise that resolves with a boolean stating whether a file exists in user's Dropbox at a given path

Override getFile

  • getFile(path: string): any
  • Get the Dropbox file reference object at a given path. Properties of particular note include:

    • name: The name of the file in DropBox
    • id: The DropBox-given file ID
    • path_diplay: A lower-case version of the path this file is stored at in DropBox
    • .tag: A tag denoting the type of this file. Common values are "file" and "folder".

    Note: The first three elements in the above list are requisite for creating valid DiagramFiles.

    Parameters

    • path: string

      A valid Dropbox filepath. Path syntax is /{path-to-file}/{filename}; i.e. /Public/example.diagram. Alternatively, this may be a valid Dropbox file ID.

    Returns any

    Returns a Promise that resolves with a Dropbox file reference object at a given path

Override getUserInfo

  • getUserInfo(): Promise<unknown>
  • Get information about the currently logged in Dropbox user. Some properties of particular note include:

    • country
    • email
    • account_id
    • name
      • abbreviated_name
      • display_name
      • given_name
      • surname

    Returns Promise<unknown>

    Returns a Promise that resolves with information about the currently logged in Dropbox user

Override hideUI

  • hideUI(isActionCanceled?: boolean): void
  • Hide the custom GoDropBox filepicker ui; nullify menuPath.

    Parameters

    • Optional isActionCanceled: boolean

      If action (Save, Delete, Load) is cancelled, resolve the Promise returned in showUI with a 'Canceled' notification.

    Returns void

Override load

  • load(path: string): Promise<unknown>
  • Load the contents of a saved diagram from Dropbox.

    Parameters

    • path: string

      A valid Dropbox filepath to load diagram model data from. Path syntax is /{path-to-file}/{filename}; i.e. /Public/example.diagram. Alternatively, this may be a valid Dropbox file ID.

    Returns Promise<unknown>

    Returns a Promise that resolves with a DiagramFile representing the loaded file

Override loadWithUI

  • loadWithUI(): any
  • Load the contents of a saved diagram from Dropbox using the custom filepicker ui.

    Returns any

    Returns a Promise that resolves with a DiagramFile representing the loaded file.

Override remove

  • remove(path: string): Promise<unknown>
  • Delete a given diagram file from Dropbox.

    Parameters

    • path: string

      A valid Dropbox filepath to delete diagram model data from. Path syntax is /{path-to-file}/{filename}; i.e. /Public/example.diagram. Alternatively, this may be a valid Dropbox file ID.

    Returns Promise<unknown>

    Returns a Promise that resolves with a DiagramFile representing the deleted file.

Override removeWithUI

  • removeWithUI(): any
  • Delete a chosen diagram file from Dropbox using the custom filepicker ui.

    Returns any

    Returns a Promise that resolves with a DiagramFile representing the deleted file.

Override save

  • save(path?: string): Promise<unknown>
  • Save managedDiagrams' model data to Dropbox. 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 Dropbox 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.

    Parameters

    • Optional path: string

      A valid Dropbox filepath to save current diagram model to. Path syntax is /{path-to-file}/{filename}; i.e. /Public/example.diagram. Alternatively, this may be a valid Dropbox file ID.

    Returns Promise<unknown>

    Returns a Promise that resolves with a DiagramFile representing the saved file.

Override saveWithUI

  • saveWithUI(filename?: string): Promise<unknown>
  • Save the current managedDiagrams model data to Dropbox with the filepicker ui. Returns a Promise that resolves with a DiagramFile representing the saved file.

    Parameters

    • Optional filename: string

      Optional: The name to save data to Dropbox under. If this is not provided, you will be prompted for a filename

    Returns Promise<unknown>

Override showUI

  • showUI(): any
  • Returns any

signOut

  • signOut(): void
  • Sign out the currently signed in Dropbox user Note: Since this redirects the app page, unsaved diagram model data will be lost after calling this

    Returns void