Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GoCloudStorageManager

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

  • GoCloudStorageManager

Class for easily saving / loading GoJS Models to / from a user-defined set of Cloud Storage Services with a pre-defined UI.

GoCloudStorageManager holds a set of GoCloudStorage subclass instances (storages) to manage. When one is selected from the storage selection menu, it becomes the currentStorage property, which is used to save / load / delete / create files.

Index

Constructors

constructor

  • Parameters

    • storages: Set<GoCloudStorage> | GoCloudStorage[]

      Contains valid instances of GoCloudStorage subclasses. Use at most one instance of each subclass.

    • Optional iconsRelativeDirectory: string

      The directory path relative to the page in which this instance of GoCloudStorageManager exists, in which the storage service brand icons can be found. The default value is "../goCloudStorageIcons/". Note: If this parameter is supplied, it is used as for the "iconsRelativeDirectory" constructor parameter for each instance this instance of GoCloudStorageManager manages in storages.

    Returns GoCloudStorageManager

Properties

currentStorage : GoCloudStorage

  • Get / set the GoCloudStorage subclass this instance of GoCloudStorageManager is actively managing.

iconsRelativeDirectory : string

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

Read-only menu : HTMLElement

  • Get GoCloudStorageManager menu, from which a user chooses which storage service for this instance of GoCloudStorageManager to actively manage (see currentStorage). This is created (as a blank div) during construction. Its contents are populated during selectStorageService.

Read-only storages : Set<GoCloudStorage>

  • Get storages (GoCloudStorage subclass instances) managed by an instance of GoCloudStorageManager. At most, there should be only one instance of each subclass. This is set with a parameter during construction.

Methods

create

  • create(saveBeforeCreate?: boolean): Promise<unknown>
  • Creates a new diagram with currentStorage's default model data (see GoCloudStorage.defaultModel. If currentStorage.isAutoSaving is true, prompt to save it to to currentStorage's storage service. if currentStorage's GoCloudStorage.isAutoSaving is true).

    Parameters

    • saveBeforeCreate: boolean = false

      Whether or not to prompt the user to save their current work before creating a new diagram. See more at GoCloudStorage.create. Default value is false.

    Returns Promise<unknown>

    Returns a Promise that resolves a DiagramFile representing the newly created file (if file was saved).

getStorageIconPath

  • getStorageIconPath(className: string): string

handleAction

  • handleAction(action: string, saveBeforeCreate?: boolean): Promise<unknown>
  • Handle an action with the current currentStorage. Possible values for action can be:

    • Load
    • Save
    • Save As
    • Create
    • Remove

    Parameters

    • action: string
    • saveBeforeCreate: boolean = false

      Whether or not to prompt the user to save their current work before creating a new file. Default value is false. See more at GoCloudStorage.create

    Returns Promise<unknown>

hideMenu

  • hideMenu(): void
  • Hide the storage selection menu

    Returns void

load

  • load(): Promise<unknown>
  • Launches the load interface for currentStorage.

    Returns Promise<unknown>

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

remove

  • remove(): Promise<unknown>
  • Launches the remove interface for currentStorage.

    Returns Promise<unknown>

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

save

  • save(isSaveAs?: boolean): Promise<unknown>
  • Either launches the save interface for currentStorage or just saves the GoCloudStorage.managedDiagrams' model data to storage at the path supplied in currentStorage's GoCloudStorage.currentDiagramFile.path value, depending on a parameter.

    Parameters

    • isSaveAs: boolean = true

      If true, show the save interface for currentStorage. If false, save currentStorage's managedDiagrams' model data to storage. Default value is true.

    Returns Promise<unknown>

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

selectStorageService

  • selectStorageService(): Promise<unknown>
  • Display options (storages) supported by this instance of GoCloudStorageManager. Sets currentStorage to user's choice.

    Returns Promise<unknown>

    Returns a Promise that resolves with the new currentStorage instance

showMessage

  • showMessage(msg: string, seconds?: number): void
  • Display a message on the screen for a given number of seconds. Can be used for a variety of purposes, but a common one is to notify users when a file has been loaded / saved / deleted / created by handling the DiagramFile argument in the "then" function of returned Promises (from functions load, create, save, remove) by displaying it as a message.

    Parameters

    • msg: string

      Message to display

    • Optional seconds: number

      Number of seconds to display the message for. If no value is provided, the message will display for two seconds.

    Returns void