Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FileBrowserModel

An implementation of a file browser view model.

Notes

All paths parameters without a leading '/' are interpreted as relative to the current directory. Supports '../' syntax.

Hierarchy

  • FileBrowserModel

Implements

  • IDisposable

Index

Constructors

constructor

  • new FileBrowserModel(contentsManager: IContentsManager, sessionManager: INotebookSessionManager): FileBrowserModel
  • Construct a new file browser view model.

    Parameters

    • contentsManager: IContentsManager
    • sessionManager: INotebookSessionManager

    Returns FileBrowserModel

Properties

Private _ascending

_ascending: boolean

Private _contentsManager

_contentsManager: IContentsManager

Private _kernelSpecs

_kernelSpecs: IKernelSpecId[]

Private _max_upload_size_mb

_max_upload_size_mb: number

Private _model

_model: IContentsModel

Private _selection

_selection: object

Type declaration

  • [key: string]: boolean

Private _sessionIds

_sessionIds: ISessionId[]

Private _sessionManager

_sessionManager: INotebookSessionManager

Private _sortKey

_sortKey: string

Private _unsortedNames

_unsortedNames: string[]

Accessors

fileChanged

isDisposed

  • get isDisposed(): boolean
  • Get whether the view model is disposed.

    Returns boolean

kernelSpecs

  • get kernelSpecs(): IKernelSpecId[]
  • Get a the list of available kernel specs.

    Notes

    This is a read-only property.

    Returns IKernelSpecId[]

openRequested

path

  • get path(): string
  • Get the current path.

    Notes

    This is a read-only property.

    Returns string

refreshed

selectionChanged

sessionIds

  • get sessionIds(): ISessionId[]
  • Get the session ids for active notebooks.

    Notes

    This is a read-only property.

    Returns ISessionId[]

sortAscending

  • get sortAscending(): boolean
  • set sortAscending(value: boolean): void
  • Get whether the items are sorted in ascending order.

    Returns boolean

  • Set whether the items are sorted in ascending order.

    Parameters

    • value: boolean

    Returns void

sortKey

  • get sortKey(): string
  • set sortKey(value: string): void
  • Get which key the items are sorted on.

    Returns string

  • Set which key the items are sorted on.

    Parameters

    • value: string

    Returns void

sortedItems

  • get sortedItems(): IContentsModel[]
  • Get the sorted list of items.

    Notes

    This is a read-only property and should be treated as immutable.

    Returns IContentsModel[]

Methods

Private _findSessions

  • _findSessions(): Promise<void>
  • Get the notebook sessions for the current directory.

    Returns Promise<void>

Private _getKernelSpecs

  • _getKernelSpecs(): void
  • Load the list of kernel specs.

    Returns void

Private _sort

  • _sort(): void
  • Sort the model items.

    Returns void

Private _upload

  • _upload(file: File): Promise<IContentsModel>
  • Perform the actual upload.

    Parameters

    • file: File

    Returns Promise<IContentsModel>

cd

  • cd(path?: string): Promise<void>
  • Change directory.

    Parameters

    • Default value path: string = ""

      The path to the file or directory.

    Returns Promise<void>

    A promise with the contents of the directory.

clearSelected

  • clearSelected(): void
  • Clear the selected items.

    Returns void

copy

  • copy(fromFile: string, toDir: string): Promise<IContentsModel>
  • Copy a file.

    Parameters

    • fromFile: string

      The path of the original file.

    • toDir: string

      The path to the target directory.

    Returns Promise<IContentsModel>

    A promise which resolves to the contents of the file.

delete

  • delete(path: string): Promise<void>
  • Delete a file.

    Parameters

    • path: string

    Returns Promise<void>

    A promise which resolves when the file is deleted.

deselect

  • deselect(name: string): void
  • De-select an item by name.

    Notes

    This is a no-op if the name is not valid or not selected.

    Parameters

    • name: string

    Returns void

dispose

  • dispose(): void
  • Dispose of the resources held by the view model.

    Returns void

download

  • download(path: string): Promise<IContentsModel>
  • Download a file.

    Parameters

    • path: string

    Returns Promise<IContentsModel>

    • A promise which resolves to the file contents.

getSelected

  • getSelected(): string[]
  • Get the list of selected names.

    Returns string[]

isSelected

  • isSelected(name: string): boolean
  • Check whether an item is selected.

    Notes

    Returns true for a valid name that is selected, false otherwise.

    Parameters

    • name: string

    Returns boolean

newUntitled

  • newUntitled(type: string, ext?: string): Promise<IContentsModel>
  • Create a new untitled file or directory in the current directory.

    Parameters

    • type: string

      The type of file object to create. One of ['file', 'notebook', 'directory'].

    • Optional ext: string

      Optional extension for 'file' types (defaults to '.txt').

    Returns Promise<IContentsModel>

    A promise containing the new file contents model.

open

  • open(name: string): Promise<void>
  • Open a file in the current by name.

    Parameters

    • name: string

    Returns Promise<void>

refresh

  • refresh(): Promise<void>
  • Refresh the current directory.

    Returns Promise<void>

rename

  • rename(path: string, newPath: string): Promise<IContentsModel>
  • Rename a file or directory.

    Parameters

    • path: string

      The path to the original file.

    • newPath: string

      The path to the new file.

    Returns Promise<IContentsModel>

    A promise containing the new file contents model.

select

  • select(name: string): void
  • Select an item by name.

    Notes

    This is a no-op if the name is not valid or already selected.

    Parameters

    • name: string

    Returns void

shutdown

  • shutdown(sessionId: ISessionId): Promise<void>
  • Shut down a notebook session by session id.

    Parameters

    • sessionId: ISessionId

    Returns Promise<void>

startSession

  • startSession(path: string, kernel: string): Promise<INotebookSession>
  • Start a new session on a notebook.

    Parameters

    • path: string
    • kernel: string

    Returns Promise<INotebookSession>

upload

  • upload(file: File, overwrite?: boolean): Promise<IContentsModel>
  • Upload a File object.

    Parameters

    • file: File

      The File object to upload.

    • Optional overwrite: boolean

      Whether to overwrite an existing file.

    Returns Promise<IContentsModel>

    A promise containing the new file contents model.

    Notes

    This will fail to upload files that are too big to be sent in one request to the server.

Generated using TypeDoc