* [MOD] Plugins module icon is now on main menu

* [MOD] Code refactoring
This commit is contained in:
nuxsmin
2018-08-31 00:11:55 +02:00
parent b106ae6892
commit 42471b4680
13 changed files with 252 additions and 302 deletions

View File

@@ -132,7 +132,7 @@ final class PluginGrid extends GridBase
$gridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
$gridActionSearch->setName('frmSearchPlugin');
$gridActionSearch->setTitle(__('Buscar Plugin'));
$gridActionSearch->setOnSubmitFunction('appMgmt/search');
$gridActionSearch->setOnSubmitFunction('plugin/search');
$gridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::PLUGIN_SEARCH));
return $gridActionSearch;
@@ -149,7 +149,7 @@ final class PluginGrid extends GridBase
$gridAction->setName(__('Ver Plugin'));
$gridAction->setTitle(__('Ver Plugin'));
$gridAction->setIcon($this->icons->getIconView());
$gridAction->setOnClickFunction('appMgmt/show');
$gridAction->setOnClickFunction('plugin/show');
$gridAction->setFilterRowSource('available', 0);
$gridAction->addData('action-route', Acl::getActionRoute(ActionsInterface::PLUGIN_VIEW));

View File

@@ -256,6 +256,7 @@ final class LayoutHelper extends HelperBase
public function getMenu(Acl $acl)
{
$icons = $this->theme->getIcons();
$actions = [];
$actionSearch = new DataGridAction();
$actionSearch->setId(ActionsInterface::ACCOUNT);
@@ -267,7 +268,7 @@ final class LayoutHelper extends HelperBase
'route' => Acl::getActionRoute(ActionsInterface::ACCOUNT)
]);
$this->view->append('actions', $actionSearch);
$actions[] = $actionSearch;
if ($acl->checkUserAccess(ActionsInterface::ACCOUNT_CREATE)) {
$actionNewAccount = new DataGridAction();
@@ -280,7 +281,7 @@ final class LayoutHelper extends HelperBase
'route' => Acl::getActionRoute(ActionsInterface::ACCOUNT_CREATE)
]);
$this->view->append('actions', $actionNewAccount);
$actions[] = $actionNewAccount;
}
if ($acl->checkUserAccess(ActionsInterface::ACCESS_MANAGE)) {
@@ -294,7 +295,7 @@ final class LayoutHelper extends HelperBase
'route' => Acl::getActionRoute(ActionsInterface::ACCESS_MANAGE)
]);
$this->view->append('actions', $actionAccessManager);
$actions[] = $actionAccessManager;
}
if ($acl->checkUserAccess(ActionsInterface::ITEMS_MANAGE)) {
@@ -308,7 +309,7 @@ final class LayoutHelper extends HelperBase
'route' => Acl::getActionRoute(ActionsInterface::ITEMS_MANAGE)
]);
$this->view->append('actions', $actionItemManager);
$actions[] = $actionItemManager;
}
if ($acl->checkUserAccess(ActionsInterface::CONFIG)) {
@@ -322,7 +323,7 @@ final class LayoutHelper extends HelperBase
'route' => Acl::getActionRoute(ActionsInterface::CONFIG)
]);
$this->view->append('actions', $actionConfigManager);
$actions[] = $actionConfigManager;
}
if ($acl->checkUserAccess(ActionsInterface::EVENTLOG) && $this->configData->isLogEnabled()) {
@@ -336,9 +337,24 @@ final class LayoutHelper extends HelperBase
'route' => Acl::getActionRoute(ActionsInterface::EVENTLOG)
]);
$this->view->append('actions', $actionEventlog);
$actions[] = $actionEventlog;
}
if ($acl->checkUserAccess(ActionsInterface::PLUGIN)) {
$actionPlugins = new DataGridAction();
$actionPlugins->setId(ActionsInterface::PLUGIN);
$actionPlugins->setTitle(__('Plugins'));
$actionPlugins->setIcon($icons->getIconByName('extension'));
$actionPlugins->setData([
'historyReset' => 1,
'view' => 'plugin',
'route' => Acl::getActionRoute(ActionsInterface::PLUGIN)
]);
$actions[] = $actionPlugins;
}
$this->view->assign('actions', $actions);
$this->view->assign('useMenu', true);
}

View File

@@ -34,7 +34,6 @@ use SP\Modules\Web\Controllers\Helpers\Grid\ClientGrid;
use SP\Modules\Web\Controllers\Helpers\Grid\CustomFieldGrid;
use SP\Modules\Web\Controllers\Helpers\Grid\FileGrid;
use SP\Modules\Web\Controllers\Helpers\Grid\ItemPresetGrid;
use SP\Modules\Web\Controllers\Helpers\Grid\PluginGrid;
use SP\Modules\Web\Controllers\Helpers\Grid\TagGrid;
use SP\Modules\Web\Controllers\Helpers\TabsGridHelper;
use SP\Services\Account\AccountFileService;
@@ -44,7 +43,6 @@ use SP\Services\Category\CategoryService;
use SP\Services\Client\ClientService;
use SP\Services\CustomField\CustomFieldDefService;
use SP\Services\ItemPreset\ItemPresetService;
use SP\Services\Plugin\PluginService;
use SP\Services\Tag\TagService;
/**
@@ -117,10 +115,6 @@ final class ItemManagerController extends ControllerBase
$this->tabsGridHelper->addTab($this->getItemPresetList());
}
if ($this->checkAccess(Acl::PLUGIN)) {
$this->tabsGridHelper->addTab($this->getPluginsList());
}
$this->eventDispatcher->notifyEvent('show.itemlist.items', new Event($this));
$this->tabsGridHelper->renderTabs(Acl::getActionRoute(Acl::ITEMS_MANAGE), $this->request->analyzeInt('tabIndex', 0));
@@ -240,20 +234,6 @@ final class ItemManagerController extends ControllerBase
->updatePager();
}
/**
* Returns plugins' data tab
*
* @return \SP\Html\DataGrid\DataGridTab
* @throws \SP\Core\Exceptions\ConstraintException
* @throws \SP\Core\Exceptions\QueryException
*/
protected function getPluginsList()
{
return $this->dic->get(PluginGrid::class)
->getGrid($this->dic->get(PluginService::class)->search($this->itemSearchData))
->updatePager();
}
/**
* @return TabsGridHelper
*/

View File

@@ -34,6 +34,7 @@ use SP\Http\JsonResponse;
use SP\Modules\Web\Controllers\Helpers\Grid\PluginGrid;
use SP\Modules\Web\Controllers\Traits\ItemTrait;
use SP\Modules\Web\Controllers\Traits\JsonTrait;
use SP\Plugin\PluginManager;
use SP\Services\Plugin\PluginService;
/**
@@ -98,7 +99,6 @@ final class PluginController extends ControllerBase
}
$this->view->addTemplate('datagrid-table', 'grid');
$this->view->assign('index', $this->request->analyzeInt('activetab', 0));
$this->view->assign('data', $this->getSearchGrid());
return $this->returnJsonResponseData(['html' => $this->render()]);
@@ -147,8 +147,10 @@ final class PluginController extends ControllerBase
$this->view->addTemplate('plugin');
$pluginData = $pluginId ? $this->pluginService->getById($pluginId) : new PluginData();
$pluginInfo = $this->dic->get(PluginManager::class)->getPluginInfo($pluginData->name);
$this->view->assign('plugin', $pluginData);
$this->view->assign('pluginInfo', $pluginInfo);
$this->view->assign('sk', $this->session->generateSecurityKey());
$this->view->assign('nextAction', Acl::getActionRoute(Acl::ITEMS_MANAGE));

View File

@@ -29,52 +29,46 @@ use SP\Core\UI\ThemeIcons;
use SP\Html\Assets\FontIcon;
$themeIcons = new ThemeIcons();
// Iconos de Acciones
$themeIcons->iconAdd = new FontIcon('add', 'mdl-color-text--indigo-A200', __u('Añadir'));
$themeIcons->iconView = new FontIcon('visibility', 'mdl-color-text--indigo-A200', __u('Ver Detalles'));
$themeIcons->iconViewPass = new FontIcon('lock_open', 'mdl-color-text--indigo-A200', __u('Ver Clave'));
$themeIcons->iconEdit = new FontIcon('mode_edit', 'mdl-color-text--amber-A200', __u('Editar'));
$themeIcons->iconDelete = new FontIcon('remove_circle', 'mdl-color-text--red-A200', __u('Eliminar'));
$themeIcons->iconEditPass = new FontIcon('lock_outline', 'mdl-color-text--amber-A200', __u('Cambiar Clave'));
$themeIcons->iconAppAdmin = new FontIcon('star', 'mdl-color-text--amber-A100', __u('Admin Aplicación'));
$themeIcons->iconAccAdmin = new FontIcon('star_half', 'mdl-color-text--amber-A100', __u('Admin Cuentas'));
$themeIcons->iconLdapUser = new FontIcon('business', 'mdl-color-text--deep-purple-A100', __u('Usuario de LDAP'));
$themeIcons->iconDisabled = new FontIcon('error', 'mdl-color-text--red-A100', __u('Deshabilitado'));
$themeIcons->iconEnabled = new FontIcon('check_circle', 'mdl-color-text--teal-500', __u('Habilitado'));
$themeIcons->iconRefresh = new FontIcon('refresh', 'mdl-color-text--teal-500', __u('Actualizar'));
$themeIcons->iconCopy = new FontIcon('content_copy', 'mdl-color-text--indigo-A200', __u('Copiar'));
$themeIcons->iconClipboard = new FontIcon('content_paste', 'mdl-color-text--indigo-A200');
$themeIcons->iconEmail = new FontIcon('email', 'mdl-color-text--indigo-A200', __u('Email'));
$themeIcons->iconOptional = new FontIcon('settings');
$themeIcons->iconPublicLink = new FontIcon('link', 'mdl-color-text--teal-500');
$themeIcons->iconBack = new FontIcon('arrow_back', 'mdl-color-text--indigo-A200', __u('Volver'));
$themeIcons->iconRestore = new FontIcon('restore', 'mdl-color-text--teal-500', __u('Restaurar'));
$themeIcons->iconSave = new FontIcon('save', 'mdl-color-text--teal-500', __u('Guardar'));
$themeIcons->iconHelp = new FontIcon('help_outline', 'mdl-color-text--indigo-A100', __u('Ayuda'));
$themeIcons->iconClear = new FontIcon('clear_all', 'mdl-color--indigo-A200', __u('Limpiar'));
$themeIcons->iconPlay = new FontIcon('play_circle_filled', 'mdl-color-text--teal-500', __u('Realizar'));
$themeIcons->iconDownload = new FontIcon('file_download', 'mdl-color-text--indigo-A200', __u('Descargar'));
$themeIcons->iconWarning = new FontIcon('warning', 'mdl-color-text--amber-A100', __u('Aviso'));
$themeIcons->iconCheck = new FontIcon('cached', 'mdl-color-text--indigo-A200', __u('Comprobar'));
$themeIcons->iconSearch = new FontIcon('search', 'mdl-color-text--indigo-A200', __u('Buscar'));
$themeIcons->iconAccount = new FontIcon('account_box', 'mdl-color-text--indigo-A200');
$themeIcons->iconGroup = new FontIcon('group_work', 'mdl-color-text--indigo-A200');
$themeIcons->iconSettings = new FontIcon('settings', 'mdl-color-text--indigo-A200', __u('Configuración'));
$themeIcons->iconHeadline = new FontIcon('view_headline', 'mdl-color-text--indigo-A200');
$themeIcons->iconInfo = new FontIcon('info_outline', 'mdl-color-text--indigo-A200', __u('Información'));
$themeIcons->iconCritical = new FontIcon('error_outline', 'mdl-color-text--red-A200', __u('Crítico'));
$themeIcons->iconNotices = new FontIcon('notifications', 'mdl-color-text--indigo-A200', __u('Notificaciones'));
$themeIcons->iconRemove = new FontIcon('remove', 'mdl-color-text--indigo-A200', __u('Eliminar'));
// Iconos de Navegación
$themeIcons->iconNavPrev = new FontIcon('chevron_left', null, __u('Página anterior'));
$themeIcons->iconNavNext = new FontIcon('chevron_right', null, __u('Página siguiente'));
$themeIcons->iconNavFirst = new FontIcon('arrow_back', null, __u('Primera página'));
$themeIcons->iconNavLast = new FontIcon('arrow_forward', null, __u('Última página'));
// Iconos de Ordenación
$themeIcons->iconUp = new FontIcon('arrow_drop_up');
$themeIcons->iconDown = new FontIcon('arrow_drop_down');
$themeIcons->addIcon('add', new FontIcon('add', 'mdl-color-text--indigo-A200', __u('Añadir')));
$themeIcons->addIcon('view', new FontIcon('visibility', 'mdl-color-text--indigo-A200', __u('Ver Detalles')));
$themeIcons->addIcon('viewPass', new FontIcon('lock_open', 'mdl-color-text--indigo-A200', __u('Ver Clave')));
$themeIcons->addIcon('edit', new FontIcon('mode_edit', 'mdl-color-text--amber-A200', __u('Editar')));
$themeIcons->addIcon('delete', new FontIcon('remove_circle', 'mdl-color-text--red-A200', __u('Eliminar')));
$themeIcons->addIcon('editPass', new FontIcon('lock_outline', 'mdl-color-text--amber-A200', __u('Cambiar Clave')));
$themeIcons->addIcon('appAdmin', new FontIcon('star', 'mdl-color-text--amber-A100', __u('Admin Aplicación')));
$themeIcons->addIcon('accAdmin', new FontIcon('star_half', 'mdl-color-text--amber-A100', __u('Admin Cuentas')));
$themeIcons->addIcon('ldapUser', new FontIcon('business', 'mdl-color-text--deep-purple-A100', __u('Usuario de LDAP')));
$themeIcons->addIcon('disabled', new FontIcon('error', 'mdl-color-text--red-A100', __u('Deshabilitado')));
$themeIcons->addIcon('enabled', new FontIcon('check_circle', 'mdl-color-text--teal-500', __u('Habilitado')));
$themeIcons->addIcon('refresh', new FontIcon('refresh', 'mdl-color-text--teal-500', __u('Actualizar')));
$themeIcons->addIcon('copy', new FontIcon('content_copy', 'mdl-color-text--indigo-A200', __u('Copiar')));
$themeIcons->addIcon('clipboard', new FontIcon('content_paste', 'mdl-color-text--indigo-A200'));
$themeIcons->addIcon('email', new FontIcon('email', 'mdl-color-text--indigo-A200', __u('Email')));
$themeIcons->addIcon('optional', new FontIcon('settings'));
$themeIcons->addIcon('publicLink', new FontIcon('link', 'mdl-color-text--teal-500'));
$themeIcons->addIcon('back', new FontIcon('arrow_back', 'mdl-color-text--indigo-A200', __u('Volver')));
$themeIcons->addIcon('restore', new FontIcon('restore', 'mdl-color-text--teal-500', __u('Restaurar')));
$themeIcons->addIcon('save', new FontIcon('save', 'mdl-color-text--teal-500', __u('Guardar')));
$themeIcons->addIcon('help', new FontIcon('help_outline', 'mdl-color-text--indigo-A100', __u('Ayuda')));
$themeIcons->addIcon('clear', new FontIcon('clear_all', 'mdl-color--indigo-A200', __u('Limpiar')));
$themeIcons->addIcon('play', new FontIcon('play_circle_filled', 'mdl-color-text--teal-500', __u('Realizar')));
$themeIcons->addIcon('download', new FontIcon('file_download', 'mdl-color-text--indigo-A200', __u('Descargar')));
$themeIcons->addIcon('warning', new FontIcon('warning', 'mdl-color-text--amber-A100', __u('Aviso')));
$themeIcons->addIcon('check', new FontIcon('cached', 'mdl-color-text--indigo-A200', __u('Comprobar')));
$themeIcons->addIcon('search', new FontIcon('search', 'mdl-color-text--indigo-A200', __u('Buscar')));
$themeIcons->addIcon('account', new FontIcon('account_box', 'mdl-color-text--indigo-A200'));
$themeIcons->addIcon('group', new FontIcon('group_work', 'mdl-color-text--indigo-A200'));
$themeIcons->addIcon('settings', new FontIcon('settings', 'mdl-color-text--indigo-A200', __u('Configuración')));
$themeIcons->addIcon('headline', new FontIcon('view_headline', 'mdl-color-text--indigo-A200'));
$themeIcons->addIcon('info', new FontIcon('info_outline', 'mdl-color-text--indigo-A200', __u('Información')));
$themeIcons->addIcon('critical', new FontIcon('error_outline', 'mdl-color-text--red-A200', __u('Crítico')));
$themeIcons->addIcon('notices', new FontIcon('notifications', 'mdl-color-text--indigo-A200', __u('Notificaciones')));
$themeIcons->addIcon('remove', new FontIcon('remove', 'mdl-color-text--indigo-A200', __u('Eliminar')));
$themeIcons->addIcon('previous', new FontIcon('chevron_left', null, __u('Página anterior')));
$themeIcons->addIcon('next', new FontIcon('chevron_right', null, __u('Página siguiente')));
$themeIcons->addIcon('first', new FontIcon('arrow_back', null, __u('Primera página')));
$themeIcons->addIcon('last', new FontIcon('arrow_forward', null, __u('Última página')));
$themeIcons->addIcon('up', new FontIcon('arrow_drop_up'));
$themeIcons->addIcon('down', new FontIcon('arrow_drop_down'));
return $themeIcons;

View File

@@ -6,8 +6,7 @@
* @var $action SP\Html\DataGrid\DataGridAction|SP\Html\DataGrid\DataGridActionSearch
*/
if (!isset($index)): $index = 0; endif;
?>
if (!isset($index)): $index = 0; endif; ?>
<div class="tab-actions">
<ul>
@@ -92,7 +91,7 @@ if (!isset($index)): $index = 0; endif;
<li class="btn-action mdl-menu__item"
data-selection="#data-table-<?php echo $data->getId(); ?>"
data-onclick="<?php echo $action->getOnClick(); ?>"
<?php foreach ($action->getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?>>
<?php foreach ($action->getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?>>
<i class="material-icons <?php echo $action->getIcon()->getClass(); ?>"><?php echo $action->getIcon()->getIcon(); ?></i>
<?php echo $action->getTitle(); ?>
</li>

View File

@@ -0,0 +1,4 @@
<h5 class="datagrid-header-title"><?php echo __('Plugins'); ?></h5>
<?php
/** @var \SP\Mvc\View\Template $this */
include $this->includeTemplate('datagrid-grid', 'grid');

View File

@@ -1,8 +1,11 @@
<?php
/** @var \SP\DataModel\PluginData $plugin */
/** @var \SP\Plugin\PluginInterface $pluginInfo */
/** @var \SP\Core\UI\ThemeIcons $icons */
/**
* @var \SP\DataModel\PluginData $plugin
* @var \SP\Plugin\PluginInterface $pluginInfo
* @var \SP\Core\UI\ThemeIcons $icons
*/
?>
<div id="box-popup">
<h2 class="center"><?php echo $header; ?><i class="btn-popup-close material-icons">close</i></h2>
@@ -15,7 +18,7 @@
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="name" name="name" type="text"
class="mdl-textfield__input mdl-color-text--indigo-400"
value="<?php echo $plugin->getName(); ?>" <?php echo $isReadonly; ?>>
value="<?php echo $plugin->getName(); ?>" <?php echo $readonly; ?>>
<label class="mdl-textfield__label"
for="name"><?php echo __('Nombre del plugin'); ?></label>
</div>
@@ -27,7 +30,7 @@
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="version" name="version" type="text"
class="mdl-textfield__input mdl-color-text--indigo-400"
value="<?php echo implode('.', $pluginInfo->getVersion()); ?>" <?php echo $isReadonly; ?>>
value="<?php echo implode('.', $pluginInfo->getVersion()); ?>" <?php echo $readonly; ?>>
<label class="mdl-textfield__label"
for="version"><?php echo __('Versión del plugin'); ?></label>
</div>
@@ -39,7 +42,7 @@
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="compatible_version" name="compatible_version" type="text"
class="mdl-textfield__input mdl-color-text--indigo-400"
value="<?php echo implode('.', $pluginInfo->getCompatibleVersion()); ?>" <?php echo $isReadonly; ?>>
value="<?php echo implode('.', $pluginInfo->getCompatibleVersion()); ?>" <?php echo $readonly; ?>>
<label class="mdl-textfield__label"
for="compatible_version"><?php echo __('Versión de sysPass compatible'); ?></label>
</div>
@@ -51,7 +54,7 @@
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input id="author" name="author" type="text"
class="mdl-textfield__input mdl-color-text--indigo-400"
value="<?php echo $pluginInfo->getAuthor(); ?>" <?php echo $isReadonly; ?>>
value="<?php echo $pluginInfo->getAuthor(); ?>" <?php echo $readonly; ?>>
<label class="mdl-textfield__label"
for="author"><?php echo __('Autor del plugin'); ?></label>
</div>