modify table

This commit is contained in:
Paolo Asperti 2016-09-14 23:35:45 +02:00
parent fee905ac79
commit 04097ff49d
9 changed files with 64 additions and 7 deletions

View File

@ -137,6 +137,8 @@ rm -rf %{buildroot}
%files -f %{name}-%{version}-%{release}-filelist
%defattr(0644,root,root,755)
%doc README.md LICENSE.txt
%attr(0644,srvmgr,srvmgr) %ghost %{_localstatedir}/log/doraemon/access_log
%attr(0644,srvmgr,srvmgr) %ghost %{_localstatedir}/log/doraemon/error_log
%changelog

View File

@ -3,7 +3,6 @@
/* /usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon.php */
$L['Doraemon_Title'] = 'Doraemon';
$L['Key_label'] = 'Hostname';
$L['hostname_label'] = 'Hostname';
$L['MacAddress_label'] = 'MAC Address';
$L['shutdown_label'] = 'Shutdown';

View File

@ -6,3 +6,4 @@ $L['Hosts_Title'] = 'Hosts';
$L['Create_Host_Header'] = 'Create a new host';
$L['Update_Host_Header'] = 'Update host "${0}"';
$L['Role_label'] = 'Role';
$L['Key_label'] = 'Hostname';

View File

@ -6,3 +6,4 @@ $L['Rooms_Title'] = 'Rooms';
$L['Create_Room_Header'] = 'Create a new room';
$L['Update_Room_Header'] = 'Update room "${0}"';
$L['Name_label'] = 'Name';
$L['Key_label'] = 'Room';

View File

@ -3,7 +3,6 @@
/* /usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon.php */
$L['Doraemon_Title'] = 'Doraemon';
$L['Key_label'] = 'Hostname';
$L['hostname_label'] = 'Hostname';
$L['MacAddress_label'] = 'MAC Address';
$L['shutdown_label'] = 'Spegni';

View File

@ -6,3 +6,4 @@ $L['Hosts_Title'] = 'Hosts';
$L['Create_Host_Header'] = 'Crea un nuovo host';
$L['Update_Host_Header'] = 'Modifica il nome host "${0}"';
$L['Role_label'] = 'Ruolo';
$L['Key_label'] = 'Hostname';

View File

@ -6,3 +6,4 @@ $L['Rooms_Title'] = 'Stanze';
$L['Create_Room_Header'] = 'Crea una nuova stanza';
$L['Update_Room_Header'] = 'Modifica il nome stanza "${0}"';
$L['Name_label'] = 'Nome';
$L['Key_label'] = 'Stanza';

View File

@ -3,6 +3,7 @@
namespace NethServer\Module\Doraemon\Rooms;
use Nethgui\System\PlatformInterface as Validate;
use Nethgui\Controller\Table\Modify as Table;
class Modify extends \Nethgui\Controller\Table\Modify
@ -12,7 +13,10 @@ class Modify extends \Nethgui\Controller\Table\Modify
{
$parameterSchema = array(
// was: Validate::HOSTNAME_FQDN, but we need hostname
array('Name', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::KEY),
array('Name', Validate::ANYTHING, Table::KEY),
array('AclRead', Validate::USERNAME_COLLECTION, Table::FIELD, 'AclRead', ','), // ACL
array('AclWrite', Validate::USERNAME_COLLECTION, Table::FIELD, 'AclWrite', ','), // ACL
// array('MacAddress', Validate::MACADDRESS, \Nethgui\Controller\Table\Modify::FIELD),
// array('Role', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD),
// array('Role', Validate::ROLES_COLLECTION ??? TODO!!!, \Nethgui\Controller\Table\Modify::FIELD),
@ -21,6 +25,16 @@ class Modify extends \Nethgui\Controller\Table\Modify
parent::initialize();
}
public function bind(\Nethgui\Controller\RequestInterface $request)
{
parent::bind($request);
if($request->isMutation()) {
// save the old values for later usage:
$this->originalAclRead = $this->getPlatform()->getDatabase('accounts')->getProp($this->parameters['ibay'], 'AclRead');
$this->originalAclWrite = $this->getPlatform()->getDatabase('accounts')->getProp($this->parameters['ibay'], 'AclWrite');
}
}
public function validate(\Nethgui\Controller\ValidationReportInterface $report)
{
if ($this->getIdentifier() === 'delete') {
@ -50,6 +64,26 @@ class Modify extends \Nethgui\Controller\Table\Modify
'delete' => 'Nethgui\Template\Table\Delete',
);
$view->setTemplate($templates[$this->getIdentifier()]);
$owners = array(array('locals', $view->translate('locals_group_label')));
$subjects = array(array('locals', $view->translate('locals_group_label')));
foreach ($this->getPlatform()->getDatabase('accounts')->getAll('group') as $keyName => $props) {
$entry = array($keyName, sprintf("%s (%s)", isset($props['Description']) ? $props['Description'] : $keyName, $keyName));
$owners[] = $entry;
$subjects[] = $entry;
}
$view['OwningGroupDatasource'] = $owners;
foreach ($this->getPlatform()->getDatabase('accounts')->getAll('user') as $keyName => $props) {
$entry = array($keyName, sprintf("%s (%s)", trim($props['FirstName'] . ' ' . $props['LastName']), $keyName));
$subjects[] = $entry;
}
$view['AclSubjects'] = $subjects;
}
}

View File

@ -1,5 +1,7 @@
<?php
/* @var $view \Nethgui\Renderer\Xhtml */
$view->requireFlag($view::INSET_FORM);
if ($view->getModule()->getIdentifier() == 'update') {
// disable updating of hostname
@ -11,11 +13,28 @@ if ($view->getModule()->getIdentifier() == 'update') {
$template = 'Create_Room_Header';
}
echo $view->header('hostname')->setAttribute('template', $T($template));
echo $view->header('doraemon')->setAttribute('template', $view->translate($template));
echo $view->panel()
->insert($view->textInput('Name'))
// ->insert($view->textInput('Name', $keyFlags))
;
->insert($view->textInput('ibay', $keyFlags))
->insert($view->textInput('Description'))
->insert($view->selector('OwningGroup', $view::SELECTOR_DROPDOWN))
->insert($view->checkBox('GroupAccess', 'rw')->setAttribute('uncheckedValue', 'r'))
->insert($view->checkBox('OtherAccess', 'r')->setAttribute('uncheckedValue', ''))
->insert($view->objectPicker()
->setAttribute('objects', 'AclSubjects')
->setAttribute('objectLabel', 1)
->insert($view->checkBox('AclRead', FALSE, $view::STATE_CHECKED))
->insert($view->checkBox('AclWrite', FALSE))
);
echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_CANCEL | $view::BUTTON_HELP);
$actionId = $view->getUniqueId();
$view->includeJavascript("
jQuery(function($){
$('#${actionId}').on('nethguishow', function () {
$(this).find('.Tabs').tabs('select', 0);
});
});
");