Angular: ajenti.core

This Angular module contains core components of Ajenti frontend.

Services

class config()
config.data

Config file content object

config.load()

Gets complete configuration data of the backend

Returns:promise
config.save()

Updates and saves configuration data

Returns:promise
config.getUserConfig()

Gets per-user configuration data of the backend

Returns:promise → per-user Ajenti config object
config.setUserConfig(config)

Updates and saves per-user configuration data

Arguments:
  • config (object) – updated configuration data from getUserConfig()
Returns:

promise

class core()
core.pageReload()

Reloads the current URL

core.restart()

Restarts the Ajenti process

class hotkeys()

Captures shortcut key events

hotkeys.ENTER, ESC

Respective key codes

hotkeys.on(scope, handler, mode='keydown')

Registers a hotkey handler in the provided scope

Arguments:
  • scope ($scope) – $scope to install handler into
  • handler (function(keyCode,rawEvent)) – handler function. If the function returns a truthy value, event is cancelled and other handlers aren’t notified.
  • mode (string) – one of keydown, keypress or keyup.
class identity()

Provides info on the authentication status and user/machine identity

identity.user

Name of the logged in user

identity.effective

Effective UID of the server process

identity.machine.name

User-provided name of the machine

identity.isSuperuser

Whether current user is a superuser or not

identity.auth(username, password, mode)

Attempts to authenticate current session as username:password with a mode of normal or sudo

identity.login()

Redirects user to a login dialog

identity.logout()

Deauthenticates current session

identity.elevate()

Redirects user to a sudo elevation dialog

class messagebox()

Provides interface to modal messagebox engine

messagebox.show(options)

Opens a new messagebox.

Arguments:
  • options (object) –
  • options.title (string) –
  • options.text (string) –
  • options.positive (string) – positive action button text. Clicking it will resolve the returned promise.
  • options.negative (string) – negative action button text. Clicking it will reject the returned promise.
  • options.template (string) – (optional) custom body template
  • options.scrollable (boolean) – whether message body is scrollable
  • options.progress (boolean) – whether to display an indeterminate progress indicator in the message
Returns:

a Promise-like object with an additional close() method.

class notify()
notify.info(title, text)
notify.success(title, text)
notify.warning(title, text)
notify.error(title, text)

Shows an appropriately styled notification

notify.custom(style, title, text, url)

Shows a clickable notification leading to url.

class pageTitle()

Alters page <title> and global heading.

pageTitle.set(text)

Sets title text

pageTitle.set(expression, scope)

Sets an title expression to be watched. Example:

$scope.getTitle = (page) -> someService.getPageTitle(page)
$scope.page = ...

pageTitle.set("getTitle(page)", $scope)
class push()

Processes incoming push messages (see aj.plugins.core.api.push). This service has no public methods.

This service broadcasts events that can be received as:

$scope.$on 'push:pluginname', (message) ->
    processMessage(message)...
class tasks()

An interface to the tasks engine (see aj.plugins.core.api.tasks).

tasks.tasks

A list of task descriptors for the currently running tasks. Updated automatically.

tasks.start(cls, args, kwargs)

Starts a server-side task.

Arguments:
  • cls (string) – full task class name (aj.plugins.pluginname....)
  • args (array) – task arguments
  • kwargs (object) – task keyword arguments
Returns:

a promise, resolved once the task actually starts

Directives

autofocus()

Automatically focuses the input. Example:

<input type="text" autofocus ng:model="..." />
checkbox()

Renders a checkbox. Example:

<span checkbox ng:model="..." text="Enable something"></span>
dialog()

A modal dialog

Example:

<dialog ng:show="showDialog">
    <div class="modal-header">
        <h4>
            Heading
        </h4>
    </div>
    <div class="modal-body scrollable">
        ...
    </div>
    <div class="modal-footer">
        <a ng:click="..." class="btn btn-default btn-flat">
            Do something
        </a>
    </div>
</dialog>
Arguments:
  • ngShow (expression) –
  • dialogClass (string) –
floating-toolbar()

A toolbar pinned to the bottom edge. Example:

<div class="floating-toolbar-padder"></div>

<floating-toolbar>
    <a ng:click="..." class="btn btn-default btn-flat">
        Do something useful
    </a>
</floating-toolbar>

<!-- accented toolbar for selection actions -->

<floating-toolbar class="accented" ng:show="haveSelectedItems">
    Some action buttons here
</floating-toolbar>
ng-enter()

Action handler for Enter key in inputs. Example:

<input type="text" ng:enter="commitStuff()" ng:model="..." />
progress-spinner()
root-access()

Blocks its inner content if the current user is not a superuser.

smart-progress()

An improved version of ui-bootstrap’s progressbar

Arguments:
  • animate (boolean) –
  • value (float) –
  • max (float) –
  • text (string) –
  • maxText (string) –

Filters

bytesFilter(value, precision)
Arguments:
  • value (int) – number of bytes
  • precision (int) – number of fractional digits in the output
Returns:

string, e.g.: 123.45 KB

ordinalFilter(value)
Arguments:
  • value (int) –
Returns:

string, e.g.: 121st

pageFilter(list, page, pageSize)

Provides a page-based view on an array

Arguments:
  • list (array) – input data
  • page (int) – 1-based page index
  • pageSize (int) – page size
Returns:

array


Comments

comments powered by Disqus