dba/settings
library moduleRA
Summary
Settings page.
- Tags
Author: Christian Grün, BaseX Team 2005-21, BSD License
__source : settings/settings.xqm
Imports
This module is imported by 0 modules. It imports 2 modules.
Variables
Functions
4.1 dba:settings
Arities: dba:settings#2RA
dba:settings
(
$error
as
xs:string?
, $info
as
xs:string?
)
as
element(html)
- error
as
xs:string?
error string - info
as
xs:string?
info string
element(html)
page
Invokes 6 functions from 4 modules
- html:button#2
- html:properties#1
- html:wrap#2
- options:get#1
- {http://basex.org/modules/db}system#0
- {http://www.w3.org/2005/xpath-functions}not#1
Invoked by 0 functions from 0 modules
Annotations
%rest:GET | () |
%rest:path | ('/dba/settings') |
%rest:query-param | ('error','{$error}') |
%rest:query-param | ('info','{$info}') |
%output:method | ('html') |
Source ( 76 lines)
function dba:settings(
$error as xs:string?,
$info as xs:string?
) as element(html) {
let $system := html:properties(db:system())
let $table-row := function($items) {
<tr><td>{ $items }</td></tr>
}
let $number := function($key, $label) {
$table-row((
$label,
<br/>,
<input name='{ $key }' type='number' value='{ options:get($key) }'/>
))
}
let $string := function($key, $label) {
$table-row((
$label,
<br/>,
<input name='{ $key }' type='text' value='{ options:get($key) }'/>
))
}
return html:wrap(map { 'header': $dba:CAT, 'info': $info, 'error': $error },
<tr>
<td width='33%'>
<form action='settings' method='post'>
<h2>Settings » { html:button('save', 'Save') }</h2>
<h3>Queries</h3>
<table>
{
$number($options:TIMEOUT, 'Timeout, in seconds (0 = disabled)'),
$number($options:MEMORY, 'Memory limit, in MB (0 = disabled)'),
$number($options:MAXCHARS, 'Maximum output size')
}
<tr>
<td colspan='2'>Permission:</td>
</tr>
<tr>
<td>
<select name='permission'>{
let $pm := options:get($options:PERMISSION)
for $p in $options:PERMISSIONS
return element option { attribute selected { }[$p = $pm], $p }
}</select>
</td>
</tr>
</table>
<h3>Tables</h3>
<table>{
$number($options:MAXROWS, 'Displayed table rows')
}</table>
<h3>Logs</h3>
<table>{
$string($options:IGNORE-LOGS, <span>Ignore entries (e.g. <code>/dba</code>):</span>)
}</table>
</form>
</td>
<td class='vertical'/>
<td width='33%'>
<form action='settings-gc' method='post'>
<h2>Global Options » { html:button('gc', 'GC') }</h2>
<table>{
$system/tr[th][3]/preceding-sibling::tr[not(th)]
}</table>
</form>
</td>
<td class='vertical'/>
<td width='33%'>
<h2>Local Options</h2>
<table>{
$system/tr[th][3]/following-sibling::tr
}</table>
</td>
</tr>
)
}
4.2 dba:settings-save
Arities: dba:settings-save#0R
dba:settings-save
(
)
as
element(rest:response)
element(rest:response)
redirection
Invokes 3 functions from 3 modules
- html:parameters#0
- options:save#1
- {http://basex.org/modules/web}redirect#2
Invoked by 0 functions from 0 modules
Annotations
%rest:POST | () |
%rest:path | ('/dba/settings') |
Source ( 5 lines)
function dba:settings-save(
) as element(rest:response) {
options:save(html:parameters()),
web:redirect($dba:CAT, map { 'info': 'Settings were saved.' })
}
Namespaces
The following namespaces are defined:
Prefix | Uri |
---|---|
dba | dba/settings 2 |
html | dba/html |
options | dba/options |
output | http://www.w3.org/2010/xslt-xquery-serialization |
rest | http://exquery.org/ns/restxq |
6 RestXQ
Paths defined 2.
Path | Method | Function |
---|---|---|
/dba/settings | GET | dba:settings#2 |
/dba/settings | POST | dba:settings-save#0 |
Source Code
(:~
: Settings page.
:
: @author Christian Grün, BaseX Team 2005-21, BSD License
:)
module namespace dba = 'dba/settings';
import module namespace options = 'dba/options' at '../lib/options.xqm';
import module namespace html = 'dba/html' at '../lib/html.xqm';
(:~ Top category :)
declare variable $dba:CAT := 'settings';
(:~
: Settings page.
: @param $error error string
: @param $info info string
: @return page
:)
declare
%rest:GET
%rest:path('/dba/settings')
%rest:query-param('error', '{$error}')
%rest:query-param('info', '{$info}')
%output:method('html')
function dba:settings(
$error as xs:string?,
$info as xs:string?
) as element(html) {
let $system := html:properties(db:system())
let $table-row := function($items) {
<tr><td>{ $items }</td></tr>
}
let $number := function($key, $label) {
$table-row((
$label,
<br/>,
<input name='{ $key }' type='number' value='{ options:get($key) }'/>
))
}
let $string := function($key, $label) {
$table-row((
$label,
<br/>,
<input name='{ $key }' type='text' value='{ options:get($key) }'/>
))
}
return html:wrap(map { 'header': $dba:CAT, 'info': $info, 'error': $error },
<tr>
<td width='33%'>
<form action='settings' method='post'>
<h2>Settings » { html:button('save', 'Save') }</h2>
<h3>Queries</h3>
<table>
{
$number($options:TIMEOUT, 'Timeout, in seconds (0 = disabled)'),
$number($options:MEMORY, 'Memory limit, in MB (0 = disabled)'),
$number($options:MAXCHARS, 'Maximum output size')
}
<tr>
<td colspan='2'>Permission:</td>
</tr>
<tr>
<td>
<select name='permission'>{
let $pm := options:get($options:PERMISSION)
for $p in $options:PERMISSIONS
return element option { attribute selected { }[$p = $pm], $p }
}</select>
</td>
</tr>
</table>
<h3>Tables</h3>
<table>{
$number($options:MAXROWS, 'Displayed table rows')
}</table>
<h3>Logs</h3>
<table>{
$string($options:IGNORE-LOGS, <span>Ignore entries (e.g. <code>/dba</code>):</span>)
}</table>
</form>
</td>
<td class='vertical'/>
<td width='33%'>
<form action='settings-gc' method='post'>
<h2>Global Options » { html:button('gc', 'GC') }</h2>
<table>{
$system/tr[th][3]/preceding-sibling::tr[not(th)]
}</table>
</form>
</td>
<td class='vertical'/>
<td width='33%'>
<h2>Local Options</h2>
<table>{
$system/tr[th][3]/following-sibling::tr
}</table>
</td>
</tr>
)
};
(:~
: Saves the settings.
: @return redirection
:)
declare
%rest:POST
%rest:path('/dba/settings')
function dba:settings-save(
) as element(rest:response) {
options:save(html:parameters()),
web:redirect($dba:CAT, map { 'info': 'Settings were saved.' })
};