Home Reference Source

Function

Static Public Summary
public

cancelRestRequests(category: *)

public

capitalize(str: *): *

Capitalize the first character of a string.

public

confirm(params: Object)

Prompt the user to confirm an action.

public

defineFlags(options: Array, allOption: string): Object

Create a set of flags that can be OR'd (|) together to define a set of options.

public

exposePluginConfig(pluginName: *, route: *)

Expose a plugin configuration page via the admin plugins page.

public
public

formatCount(n: integer, opts: Object): *

Like formatSize, but more generic.

public

formatDate(datestr: *, resolution: *): *

Format a date string to the given resolution.

public

formatSize(sizeBytes: *): *

Format a size in bytes into a human-readable string with metric unit prefixes.

public

Get the root path to the API.

public
public
public

getModelClassByName(name: *): *

Return the model class name given its collection name.

public

getPluginConfigRoute(pluginName: *): *

public
public

handleClose(name: *, options: *, nameId: *)

public

handleOpen(name: *, options: *, nameId: *)

public

localeComparator(model1: *, model2: *): *

This comparator can be used by collections that wish to support locale-based sorting.

public

localeSort(a1: *, a2: *): *

This comparator can be passed to the sort function on javascript arrays.

public

login(username: *, password: *, cors: *, otpToken: *): *

Log in to the server.

public

logout(): *

public
public

parseQueryString(queryString: *): *

public

registerPluginNamespace(pluginName: *, symbols: *)

Expose the symbols for a girder plugin under the window.girder.plugins namespace.

public

restRequest(opts: Object): $.Promise

Make a request to the REST API.

public

Set the root path to the API.

public

setCurrentToken(token: *)

public

setCurrentUser(user: *)

public
public

splitRoute(route: *): {"name": *, "base": *}

public

wrap(obj: *, funcName: *, wrapper: *)

Wrap the prototype method of a given object.

Static Private Summary
private

_whenAll(promises: *): *

Static Public

public cancelRestRequests(category: *) source

import {cancelRestRequests} from '@girder/lint/src/rest.js'

Params:

NameTypeAttributeDescription
category *

public capitalize(str: *): * source

import {capitalize} from '@girder/lint/src/misc.js'

Capitalize the first character of a string.

Params:

NameTypeAttributeDescription
str *

Return:

*

public confirm(params: Object) source

import {confirm} from '@girder/lint/src/dialog.js'

Prompt the user to confirm an action.

Params:

NameTypeAttributeDescription
params Object
  • optional

Parameters controlling this function's behavior.

params.text String
  • optional

The text to prompt the user with.

params.yesText String
  • optional

The text for the confirm button.

params.yesClass String
  • optional

Class string to apply to the confirm button.

params.noText String
  • optional

The text for the no/cancel button.

params.escapedHtml Boolean
  • optional

If you want to render the text as HTML rather than plain text, set this to true to acknowledge that you have escaped any user-created data within the text to prevent XSS exploits.

params.msgConfirmation Boolean
  • optional

If you want to add a new security before perform an action. This will ask to enter a specific string "params.yesText params.name"

params.additionalText String
  • optional

Additional text to display before the confirmation input.

params.name String
  • optional

The name to enter in order to confirm an action.

params.confirmCallback Function
  • optional

Callback function when the user confirms the action.

public defineFlags(options: Array, allOption: string): Object source

import {defineFlags} from '@girder/lint/src/misc.js'

Create a set of flags that can be OR'd (|) together to define a set of options.

Params:

NameTypeAttributeDescription
options Array

An array of strings defining the option names.

allOption string

If you want an option that enables all options, pass its name as this parameter.

Return:

Object

An object mapping the names of options to values.

public exposePluginConfig(pluginName: *, route: *) source

import {exposePluginConfig} from '@girder/lint/src/utilities/PluginUtils.js'

Expose a plugin configuration page via the admin plugins page.

Params:

NameTypeAttributeDescription
pluginName *

The canonical plugin name, i.e. its directory name

route *

The route to trigger that will render the plugin config.

public fetchCurrentUser(): * source

import {fetchCurrentUser} from '@girder/lint/src/auth.js'

Return:

*

public formatCount(n: integer, opts: Object): * source

import {formatCount} from '@girder/lint/src/misc.js'

Like formatSize, but more generic. Returns a human-readable format of an integer using metric prefixes. The caller is expected to append any unit string if necessary.

Params:

NameTypeAttributeDescription
n integer

The number to format.

opts Object
  • optional
  • default: {}

Formatting options. These include:

  • {integer} [maxLen] Max number of digits in the output.
  • {integer} [base=1000] Base for the prefixes (usually 1000 or 1024).
  • {string} [sep=''] Separator between numeric value and metric prefix.

Return:

*

public formatDate(datestr: *, resolution: *): * source

import {formatDate} from '@girder/lint/src/misc.js'

Format a date string to the given resolution.

Params:

NameTypeAttributeDescription
datestr *

The date string to format.

resolution *

The resolution, defaults to 'day'. Minimum is month.

Return:

*

public formatSize(sizeBytes: *): * source

import {formatSize} from '@girder/lint/src/misc.js'

Format a size in bytes into a human-readable string with metric unit prefixes.

Params:

NameTypeAttributeDescription
sizeBytes *

Return:

*

public getApiRoot(): string source

import {getApiRoot} from '@girder/lint/src/rest.js'

Get the root path to the API.

This may be an absolute path, or a path relative to the application root. It will never include a trailing slash.

Return:

string

public getCurrentToken(): * source

import {getCurrentToken} from '@girder/lint/src/auth.js'

Return:

*

public getCurrentUser(): * source

import {getCurrentUser} from '@girder/lint/src/auth.js'

Return:

*

public getModelClassByName(name: *): * source

import {getModelClassByName} from '@girder/lint/src/misc.js'

Return the model class name given its collection name.

Params:

NameTypeAttributeDescription
name *

Collection name, e.g. 'user'

Return:

*

public getPluginConfigRoute(pluginName: *): * source

import {getPluginConfigRoute} from '@girder/lint/src/utilities/PluginUtils.js'

Params:

NameTypeAttributeDescription
pluginName *

Return:

*

public getUploadChunkSize(): * source

import {getUploadChunkSize} from '@girder/lint/src/rest.js'

Return:

*

public handleClose(name: *, options: *, nameId: *) source

import {handleClose} from '@girder/lint/src/dialog.js'

Params:

NameTypeAttributeDescription
name *
options *
nameId *

public handleOpen(name: *, options: *, nameId: *) source

import {handleOpen} from '@girder/lint/src/dialog.js'

Params:

NameTypeAttributeDescription
name *
options *
nameId *

public localeComparator(model1: *, model2: *): * source

import {localeComparator} from '@girder/lint/src/misc.js'

This comparator can be used by collections that wish to support locale-based sorting. The locale specifies how upper and lower case are compared.

Params:

NameTypeAttributeDescription
model1 *
model2 *

Return:

*

public localeSort(a1: *, a2: *): * source

import {localeSort} from '@girder/lint/src/misc.js'

This comparator can be passed to the sort function on javascript arrays.

Params:

NameTypeAttributeDescription
a1 *
a2 *

Return:

*

public login(username: *, password: *, cors: *, otpToken: *): * source

import {login} from '@girder/lint/src/auth.js'

Log in to the server. If successful, sets the value of currentUser and currentToken and triggers the "g:login" and "g:login.success". On failure, triggers the "g:login.error" event.

Params:

NameTypeAttributeDescription
username *

The username or email to login as.

password *

The password to use.

cors *

If the girder server is on a different origin, set this to "true" to save the auth cookie on the current domain. Alternatively, you may set the global option "girder.corsAuth = true".

otpToken *

An optional one-time password to include with the login.

Return:

*

public logout(): * source

import {logout} from '@girder/lint/src/auth.js'

Return:

*

public numberOutstandingRestRequests(category: *): * source

import {numberOutstandingRestRequests} from '@girder/lint/src/rest.js'

Params:

NameTypeAttributeDescription
category *

Return:

*

public parseQueryString(queryString: *): * source

import {parseQueryString} from '@girder/lint/src/misc.js'

Params:

NameTypeAttributeDescription
queryString *

Return:

*

public registerPluginNamespace(pluginName: *, symbols: *) source

import {registerPluginNamespace} from '@girder/lint/src/pluginUtils.js'

Expose the symbols for a girder plugin under the window.girder.plugins namespace. Required since each plugin is loaded dynamically.

Params:

NameTypeAttributeDescription
pluginName *
symbols *

public restRequest(opts: Object): $.Promise source

import {restRequest} from '@girder/lint/src/rest.js'

Make a request to the REST API.

This is a wrapper around {@link http://api.jquery.com/jQuery.ajax/ $.ajax}, which also handles authentication and routing to the Girder API, and provides a default for error notification.

Most users of this method should attach a "done" handler to the return value. In cases where the server is ordinarily expected to return a non-200 status (e.g. validating user input), the "error: null" argument should probably be provided, and errors should be processed via an attached "fail" handler.

Before this function is called, the API root must be set (which typically happens automatically).

Params:

NameTypeAttributeDescription
opts Object

Options for the request, most of which will be passed through to $.ajax.

opts.url string

The resource path, relative to the API root, without leading or trailing slashes. e.g. "user/login"

opts.method string
  • optional
  • default: 'GET'

The HTTP method to invoke.

opts.data string | Object
  • optional

The query string or form parameter object.

opts.error Function
  • optional
  • nullable: true

An error callback, as documented in {@link http://api.jquery.com/jQuery.ajax/ $.ajax}, or null. If not provided, this will have a default behavior of triggering a 'g:alert' global event, with details of the error, and logging the error to the console. It is recommended that you do not ever pass a non-null callback function, and handle errors via promise rejection handlers instead.

opts.girderToken string
  • optional

An alternative auth token to use for this request.

Return:

$.Promise

A jqXHR promise, which resolves and rejects {@link http://api.jquery.com/jQuery.ajax/#jqXHR as documented by $.ajax}.

public setApiRoot(root: string) source

import {setApiRoot} from '@girder/lint/src/rest.js'

Set the root path to the API.

Params:

NameTypeAttributeDescription
root string

The root path for the API.

public setCurrentToken(token: *) source

import {setCurrentToken} from '@girder/lint/src/auth.js'

Params:

NameTypeAttributeDescription
token *

public setCurrentUser(user: *) source

import {setCurrentUser} from '@girder/lint/src/auth.js'

Params:

NameTypeAttributeDescription
user *

public setUploadChunkSize(val: *) source

import {setUploadChunkSize} from '@girder/lint/src/rest.js'

Params:

NameTypeAttributeDescription
val *

public splitRoute(route: *): {"name": *, "base": *} source

import {splitRoute} from '@girder/lint/src/misc.js'

Params:

NameTypeAttributeDescription
route *

Return:

{"name": *, "base": *}

public wrap(obj: *, funcName: *, wrapper: *) source

Wrap the prototype method of a given object.

Params:

NameTypeAttributeDescription
obj *

The object whose prototype to extend, e.g. MyView

funcName *

The name of the function to wrap, e.g. "render"

wrapper *

The wrapper function, which should be a function taking the underlying wrapped function as its first argument. The wrapped function should be called with .call(this[, arguments]) inside of the wrapper in order to preserve "this" semantics.

Static Private

private _whenAll(promises: *): * source

import {_whenAll} from '@girder/lint/src/misc.js'

Params:

NameTypeAttributeDescription
promises *

Return:

*