Angular: ajenti.core

This Angular module contains core components of Ajenti frontend.

Services

class config()
data

Config file content object

load()

Gets complete configuration data of the backend

Returns:promise
save()

Updates and saves configuration data

Returns:promise
getUserConfig()

Gets per-user configuration data of the backend

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

Updates and saves per-user configuration data

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

promise

class core()
pageReload()

Reloads the current URL

restart()

Restarts the Ajenti process

class hotkeys()

Captures shortcut key events

ENTER, ESC

Respective key codes

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

user

Name of the logged in user

effective

Effective UID of the server process

machine.name

User-provided name of the machine

isSuperuser

Whether current user is a superuser or not

auth(username, password, mode)

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

login()

Redirects user to a login dialog

logout()

Deauthenticates current session

elevate()

Redirects user to a sudo elevation dialog

class messagebox()

Provides interface to modal messagebox engine

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()
info(title, text)
success(title, text)
warning(title, text)
error(title, text)

Shows an appropriately styled notification

custom(style, title, text, url)

Shows a clickable notification leading to url.

class pageTitle()

Alters page <title> and global heading.

set(text)

Sets title text

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

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

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