port "Admin Queue and History" and "Remote Administration Instances" to eT2

This commit is contained in:
Ralf Becker 2016-05-07 16:57:18 +00:00
parent 00b898bb2e
commit b4148d1b5a
4 changed files with 91 additions and 50 deletions

View File

@ -11,6 +11,7 @@
*/ */
use EGroupware\Api; use EGroupware\Api;
use EGroupware\Api\Etemplate;
/** /**
* UI for the admin comand queue * UI for the admin comand queue
@ -47,7 +48,13 @@ class admin_cmds
catch (Exception $e) { catch (Exception $e) {
$row['title'] = $e->getMessage(); $row['title'] = $e->getMessage();
} }
$readonlys["delete[$row[id]]"] = $row['status'] != admin_cmd::scheduled; $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' :
json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
if ($row['status'] == admin_cmd::scheduled)
{
$row['class'] = 'AllowDelete';
}
} }
//_debug_array($rows); //_debug_array($rows);
return $total; return $total;
@ -60,7 +67,7 @@ class admin_cmds
*/ */
static function index(array $content=null) static function index(array $content=null)
{ {
$tpl = new etemplate('admin.cmds'); $tpl = new Etemplate('admin.cmds');
if (!is_array($content)) if (!is_array($content))
{ {
@ -74,6 +81,9 @@ class admin_cmds
'no_cat' => true, // I disable the cat-selectbox 'no_cat' => true, // I disable the cat-selectbox
'order' => 'cmd_created', 'order' => 'cmd_created',
'sort' => 'DESC', 'sort' => 'DESC',
'row_id' => 'id',
'default_cols' => 'title,created,creator,status',
'actions' => self::cmd_actions(),
); );
} }
} }
@ -94,6 +104,21 @@ class admin_cmds
),array(),$content); ),array(),$content);
} }
/**
* Acctions for command list/index
*
* As we only allow to delete scheduled command, which we currently can only create via admin-cli,
* I have not (yet) implemented delete of scheduled commands.
*
* @return array
*/
static function cmd_actions()
{
return array(
);
}
/** /**
* get_rows for remote instances * get_rows for remote instances
* *
@ -114,7 +139,7 @@ class admin_cmds
*/ */
static function remotes(array $content=null) static function remotes(array $content=null)
{ {
$tpl = new etemplate('admin.remotes'); $tpl = new Etemplate('admin.remotes');
if (!is_array($content)) if (!is_array($content))
{ {
@ -128,7 +153,8 @@ class admin_cmds
'no_cat' => true, // I disable the cat-selectbox 'no_cat' => true, // I disable the cat-selectbox
'order' => 'remote_name', 'order' => 'remote_name',
'sort' => 'ASC', 'sort' => 'ASC',
'header_right' => 'admin.remotes.header_right', 'row_id' => 'remote_id',
'actions' => self::remote_actions(),
); );
} }
} }
@ -137,12 +163,17 @@ class admin_cmds
//_debug_array($content); //_debug_array($content);
unset($content['msg']); unset($content['msg']);
if ($content['nm']['rows']['edit']) if ($content['nm']['action'])
{ {
list($id) = each($content['nm']['rows']['edit']); switch($content['nm']['action'])
unset($content['nm']['rows']); {
case 'edit':
$content['remote'] = admin_cmd::read_remote($id); $content['remote'] = admin_cmd::read_remote($content['nm']['selected'][0]);
break;
case 'add':
$content['remote'] = array('remote_domain' => 'default');
}
unset($content['nm']['action']);
} }
elseif($content['remote']['button']) elseif($content['remote']['button'])
{ {
@ -180,6 +211,34 @@ class admin_cmds
} }
} }
$tpl->exec('admin.admin_cmds.remotes',$content,array(),array(),$content); $tpl->exec('admin.admin_cmds.remotes',$content,array(),array(),$content);
}
/**
* Actions for remotes list
*
* @return array
*/
static function remote_actions()
{
return array(
'edit' => array(
'caption' => 'Edit',
'default' => true,
'allowOnMultiple' => false,
'nm_action' => 'submit',
'group' => $group=0,
),
'add' => array(
'caption' => 'Add',
'nm_action' => 'submit',
'group' => ++$group,
),
/* not (yet) implemented
'delete' => array(
'caption' => 'Delete',
'nm_action' => 'submit',
'group' => ++$group,
),*/
);
} }
} }

View File

@ -133,8 +133,8 @@ class admin_hooks
{ {
$file['phpInfo'] = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')"; $file['phpInfo'] = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')";
} }
$file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index'); $file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index&ajax=true');
$file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes'); $file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes&ajax=true');
$file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index'); $file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index');
$file['Changelog and versions'] = Egw::link('/about.php'); $file['Changelog and versions'] = Egw::link('/about.php');

View File

@ -5,14 +5,13 @@
<template id="admin.cmds.rows" template="" lang="" group="0" version="1.5.001"> <template id="admin.cmds.rows" template="" lang="" group="0" version="1.5.001">
<grid width="100%"> <grid width="100%">
<columns> <columns>
<column width="30%" minWidth="300"/>
<column/> <column/>
<column/> <column/>
<column/> <column/>
<column/> <column width="120"/>
<column/> <column width="120"/>
<column/> <column width="30%" minWidth="120"/>
<column/>
<column/>
<column/> <column/>
<column/> <column/>
</columns> </columns>
@ -20,33 +19,27 @@
<row class="th"> <row class="th">
<nextmatch-header label="Title" id="title"/> <nextmatch-header label="Title" id="title"/>
<nextmatch-header label="Requested" id="requested"/> <nextmatch-header label="Requested" id="requested"/>
<nextmatch-sortheader label="Scheduled" id="cmd_scheduled"/> <nextmatch-sortheader label="Scheduled" id="scheduled"/>
<nextmatch-filterheader options="Remote" id="remote_id"/> <nextmatch-filterheader options="Remote" id="remote_id"/>
<nextmatch-sortheader label="Created" id="cmd_created"/> <nextmatch-sortheader label="Created" id="created"/>
<nextmatch-accountfilter id="creator" options="Creator"/> <nextmatch-accountfilter empty_label="Creator" id="creator"/>
<nextmatch-filterheader id="status" options="Status"/> <nextmatch-filterheader empty_label="Status" id="status"/>
<nextmatch-sortheader label="Modified" id="cmd_modified"/> <nextmatch-sortheader label="Modified" id="modified"/>
<nextmatch-accountfilter options="Modifier" id="modifier"/> <nextmatch-accountfilter options="Modifier" id="modifier"/>
<description/>
</row> </row>
<row class="row" disabled="!@1"> <row class="row $row_cont[class]">
<description id="${row}[title]"/> <description id="${row}[title]" statustext="$row_cont[data]"/>
<url-email id="${row}[requested]" options=",,,$row_cont[requested_email]" readonly="true"/> <url-email id="${row}[requested]" options=",,,$row_cont[requested_email]" readonly="true"/>
<date-time id="${row}[scheduled]" readonly="true"/> <date-time id="${row}[scheduled]" readonly="true"/>
<menulist> <select id="${row}[remote_id]" readonly="true"/>
<menupopup id="${row}[remote_id]" readonly="true"/>
</menulist>
<date-time id="${row}[created]" readonly="true"/> <date-time id="${row}[created]" readonly="true"/>
<url-email id="${row}[creator]" options=",,,$row_cont[creator_email]" readonly="true"/> <select-account id="${row}[creator]" readonly="true" statustext="$row_cont[creator_email]"/>
<vbox options="0,0"> <vbox>
<menulist> <select id="${row}[status]" readonly="true"/>
<menupopup id="${row}[status]" readonly="true"/>
</menulist>
<description id="${row}[error]" class="redItalic"/> <description id="${row}[error]" class="redItalic"/>
</vbox> </vbox>
<date-time id="${row}[modified]" readonly="true"/> <date-time id="${row}[modified]" readonly="true"/>
<url-email id="${row}[modifier]" readonly="true" options=",,,$row_cont[modifier_email]"/> <select-account id="${row}[modifier]" readonly="true" statustext="$row_cont[modifier_email]"/>
<button image="delete" label="Cancel" id="delete[$row_cont[id]]" statustext="Cancel this scheduled command" onclick="et2_dialog.confirm(widget,'Cancel this scheduled command','Cancel');"/>
</row> </row>
</rows> </rows>
</grid> </grid>

View File

@ -41,58 +41,47 @@
<hbox span="all"> <hbox span="all">
<button label="Save" id="button[save]" statustext="Saves this entry"/> <button label="Save" id="button[save]" statustext="Saves this entry"/>
<button id="button[apply]" label="Apply" statustext="Apply the changes"/> <button id="button[apply]" label="Apply" statustext="Apply the changes"/>
<button label="Cancel" id="button[cancel]" statustext="leave without saveing the entry"/> <button label="Cancel" id="button[cancel]" statustext="leave without saveing the entry" novalidate="true"/>
</hbox> </hbox>
</row> </row>
</rows> </rows>
</grid> </grid>
</template> </template>
<template id="admin.remotes.header_right" template="" lang="" group="0" version="1.5.001">
<button rows="1" cols="1" id="add" label="Add" statustext="Add a new remote instance"/>
</template>
<template id="admin.remotes.rows" template="" lang="" group="0" version="1.5.001"> <template id="admin.remotes.rows" template="" lang="" group="0" version="1.5.001">
<grid> <grid>
<columns> <columns>
<column/> <column/>
<column/> <column/>
<column/> <column/>
<column/>
</columns> </columns>
<rows> <rows>
<row class="th"> <row class="th">
<nextmatch-sortheader label="Name" id="remote_name"/> <nextmatch-sortheader label="Name" id="remote_name"/>
<nextmatch-sortheader label="URL" id="remote_url"/> <nextmatch-sortheader label="URL" id="remote_url"/>
<nextmatch-sortheader label="Instance" id="remote_domain"/> <nextmatch-sortheader label="Instance" id="remote_domain"/>
<description value="Actions"/>
</row> </row>
<row class="row"> <row class="row">
<description id="${row}[remote_name]"/> <description id="${row}[remote_name]"/>
<description options=",$row_cont[remote_url]/?domain=$row_cont[remote_domain],,,_blank" id="${row}[remote_url]"/> <description options=",$row_cont[remote_url]/?domain=$row_cont[remote_domain],,,_blank" id="${row}[remote_url]"/>
<description id="${row}[remote_domain]" no_lang="1"/> <description id="${row}[remote_domain]" no_lang="1"/>
<hbox align="center">
<button image="edit" label="Edit" id="edit[$row_cont[remote_id]]"/>
</hbox>
</row> </row>
</rows> </rows>
</grid> </grid>
</template> </template>
<template id="admin.remotes.header_left" template="" lang="" group="0" version="1.5.001">
<button id="add" label="Add" statustext="Add a new remote instance"/>
</template>
<template id="admin.remotes" template="" lang="" group="0" version="1.5.001"> <template id="admin.remotes" template="" lang="" group="0" version="1.5.001">
<grid width="100%"> <grid width="100%">
<columns> <columns>
<column/> <column/>
</columns> </columns>
<rows> <rows>
<row disabled="!@msg">
<description span="all" class="redItalic" id="msg"/>
</row>
<row disabled="!@remote"> <row disabled="!@remote">
<template content="remote" span="all" class="border" id="admin.remotes.edit"/> <template content="remote" span="all" class="border" id="admin.remotes.edit"/>
</row> </row>
<row disabled="1">
<template align="right" id="admin.remotes.header_right"/>
</row>
<row> <row>
<nextmatch id="nm" options="admin.remotes.rows"/> <nextmatch id="nm" options="admin.remotes.rows" header_left="admin.remotes.header_left"/>
</row> </row>
</rows> </rows>
</grid> </grid>