mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-07 00:46:59 +01:00
* [ADD] Eventlog UI with search option
This commit is contained in:
@@ -127,6 +127,18 @@
|
||||
<text>Registro de Eventos</text>
|
||||
<route>eventlog/index</route>
|
||||
</action>
|
||||
<action multiple="1">
|
||||
<id>905</id>
|
||||
<name>EVENTLOG_SEARCH</name>
|
||||
<text>Buscar Eventos</text>
|
||||
<route>eventlog/search</route>
|
||||
</action>
|
||||
<action multiple="1">
|
||||
<id>906</id>
|
||||
<name>EVENTLOG_CLEAR</name>
|
||||
<text>Limpiar Eventos</text>
|
||||
<route>eventlog/clear</route>
|
||||
</action>
|
||||
<action multiple="1">
|
||||
<id>100</id>
|
||||
<name>ACCOUNT_VIEW</name>
|
||||
|
||||
@@ -173,6 +173,8 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
|
||||
* Delete action
|
||||
*
|
||||
* @param $id
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
*/
|
||||
public function deleteAction($id)
|
||||
{
|
||||
@@ -202,8 +204,6 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
|
||||
|
||||
/**
|
||||
* Saves create action
|
||||
*
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function saveCreateAction()
|
||||
{
|
||||
@@ -239,7 +239,6 @@ class ApiTokenController extends ControllerBase implements CrudControllerInterfa
|
||||
* @param $id
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function saveEditAction($id)
|
||||
{
|
||||
|
||||
111
app/modules/web/Controllers/EventlogController.php
Normal file
111
app/modules/web/Controllers/EventlogController.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Modules\Web\Controllers;
|
||||
|
||||
use SP\Core\Acl\ActionsInterface;
|
||||
use SP\Http\JsonResponse;
|
||||
use SP\Modules\Web\Controllers\Helpers\ItemsGridHelper;
|
||||
use SP\Modules\Web\Controllers\Traits\ItemTrait;
|
||||
use SP\Modules\Web\Controllers\Traits\JsonTrait;
|
||||
use SP\Services\EventLog\EventlogService;
|
||||
|
||||
/**
|
||||
* Class EventlogController
|
||||
*
|
||||
* @package SP\Modules\Web\Controllers
|
||||
*/
|
||||
class EventlogController extends ControllerBase
|
||||
{
|
||||
use JsonTrait, ItemTrait;
|
||||
|
||||
/**
|
||||
* @var EventlogService
|
||||
*/
|
||||
protected $eventLogService;
|
||||
|
||||
/**
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
if (!$this->acl->checkUserAccess(ActionsInterface::EVENTLOG)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('index');
|
||||
|
||||
$this->view->assign('data', $this->getSearchGrid());
|
||||
|
||||
$this->view();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
protected function getSearchGrid()
|
||||
{
|
||||
$itemsGridHelper = $this->dic->get(ItemsGridHelper::class);
|
||||
$itemSearchData = $this->getSearchData($this->configData);
|
||||
|
||||
return $itemsGridHelper->updatePager($itemsGridHelper->getEventLogGrid($this->eventLogService->search($itemSearchData)), $itemSearchData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function searchAction()
|
||||
{
|
||||
if (!$this->acl->checkUserAccess(ActionsInterface::EVENTLOG_SEARCH)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view->addTemplate('datagrid-table-simple', 'grid');
|
||||
$this->view->assign('data', $this->getSearchGrid());
|
||||
|
||||
$this->returnJsonResponseData(['html' => $this->render()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* clearAction
|
||||
*/
|
||||
public function clearAction()
|
||||
{
|
||||
try {
|
||||
$this->eventLogService->clear();
|
||||
|
||||
$this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Registro de eventos vaciado'));
|
||||
} catch (\Exception $e) {
|
||||
processException($e);
|
||||
|
||||
$this->returnJsonResponseException($e);
|
||||
}
|
||||
}
|
||||
|
||||
protected function initialize()
|
||||
{
|
||||
$this->eventLogService = $this->dic->get(EventlogService::class);
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ class AccountActionsHelper extends HelperBase
|
||||
{
|
||||
$action = new DataGridAction();
|
||||
$action->setId(ActionsInterface::ACCOUNT_COPY);
|
||||
$action->setType(DataGridActionType::NEW_ITEM);
|
||||
$action->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$action->setName(__('Copiar Cuenta'));
|
||||
$action->setTitle(__('Copiar Cuenta'));
|
||||
$action->addClass('btn-action');
|
||||
|
||||
@@ -30,12 +30,15 @@ use SP\Bootstrap;
|
||||
use SP\Core\Acl\Acl;
|
||||
use SP\Core\Acl\ActionsInterface;
|
||||
use SP\Core\UI\ThemeIconsBase;
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\Html\Assets\FontIcon;
|
||||
use SP\Html\DataGrid\DataGrid;
|
||||
use SP\Html\DataGrid\DataGridAction;
|
||||
use SP\Html\DataGrid\DataGridActionSearch;
|
||||
use SP\Html\DataGrid\DataGridActionType;
|
||||
use SP\Html\DataGrid\DataGridData;
|
||||
use SP\Html\DataGrid\DataGridHeader;
|
||||
use SP\Html\DataGrid\DataGridInterface;
|
||||
use SP\Html\DataGrid\DataGridPager;
|
||||
use SP\Html\DataGrid\DataGridTab;
|
||||
use SP\Repositories\CustomField\CustomFieldDefRepository;
|
||||
@@ -101,7 +104,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::CATEGORY_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nueva Categoría'));
|
||||
$GridActionNew->setTitle(__('Nueva Categoría'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -207,7 +210,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::CLIENT_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Cliente'));
|
||||
$GridActionNew->setTitle(__('Nuevo Cliente'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -291,7 +294,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::CUSTOMFIELD_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Campo'));
|
||||
$GridActionNew->setTitle(__('Nuevo Campo'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -597,7 +600,7 @@ class ItemsGridHelper extends HelperBase
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::USER_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Usuario'));
|
||||
$GridActionNew->setTitle(__('Nuevo Usuario'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -612,7 +615,7 @@ class ItemsGridHelper extends HelperBase
|
||||
) {
|
||||
$GridActionLdapSync = new DataGridAction();
|
||||
$GridActionLdapSync->setId(ActionsInterface::LDAP_SYNC);
|
||||
$GridActionLdapSync->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionLdapSync->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionLdapSync->setName(__('Importar usuarios de LDAP'));
|
||||
$GridActionLdapSync->setTitle(__('Importar usuarios de LDAP'));
|
||||
$GridActionLdapSync->setIcon(new FontIcon('get_app'));
|
||||
@@ -717,7 +720,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::GROUP_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Grupo'));
|
||||
$GridActionNew->setTitle(__('Nuevo Grupo'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -806,7 +809,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::PROFILE_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Perfil'));
|
||||
$GridActionNew->setTitle(__('Nuevo Perfil'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -897,7 +900,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::APITOKEN_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nueva Autorización'));
|
||||
$GridActionNew->setTitle(__('Nueva Autorización'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -998,7 +1001,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::PUBLICLINK_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Enlace'));
|
||||
$GridActionNew->setTitle(__('Nuevo Enlace'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -1086,7 +1089,7 @@ class ItemsGridHelper extends HelperBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(ActionsInterface::TAG_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nueva Etiqueta'));
|
||||
$GridActionNew->setTitle(__('Nueva Etiqueta'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -1216,6 +1219,118 @@ class ItemsGridHelper extends HelperBase
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return DataGrid
|
||||
* @throws \SP\Core\Dic\ContainerException
|
||||
*/
|
||||
public function getEventLogGrid(array $data)
|
||||
{
|
||||
// Grid Header
|
||||
$GridHeaders = new DataGridHeader();
|
||||
$GridHeaders->addHeader(__('ID'));
|
||||
$GridHeaders->addHeader(__('Fecha / Hora'));
|
||||
$GridHeaders->addHeader(__('Nivel'));
|
||||
$GridHeaders->addHeader(__('Evento'));
|
||||
$GridHeaders->addHeader(__('Login'));
|
||||
$GridHeaders->addHeader(__('IP'));
|
||||
$GridHeaders->addHeader(__('Descripción'));
|
||||
|
||||
$isDemoMode = $this->configData->isDemoEnabled();
|
||||
|
||||
// Grid Data
|
||||
$GridData = new DataGridData();
|
||||
$GridData->setDataRowSourceId('id');
|
||||
$GridData->addDataRowSource('id');
|
||||
$GridData->addDataRowSource('date');
|
||||
$GridData->addDataRowSource('level');
|
||||
$GridData->addDataRowSource('action');
|
||||
$GridData->addDataRowSource('login');
|
||||
$GridData->addDataRowSource('ipAddress', false,
|
||||
function ($value) use ($isDemoMode) {
|
||||
return $isDemoMode ? preg_replace('#\d+#', '*', $value) : $value;
|
||||
});
|
||||
$GridData->addDataRowSource('description', false,
|
||||
function ($value) use ($isDemoMode) {
|
||||
if ($isDemoMode) {
|
||||
$value = preg_replace('/\\d+\\.\\d+\\.\\d+\\.\\d+/', "*.*.*.*", $value);
|
||||
}
|
||||
|
||||
$text = str_replace(';;', PHP_EOL, utf8_decode($value));
|
||||
|
||||
if (preg_match('/^SQL.*/m', $text)) {
|
||||
$text = preg_replace('/([[:alpha:]_]+),/m', '\\1,<br>', $text);
|
||||
$text = preg_replace('/(UPDATE|DELETE|TRUNCATE|INSERT|SELECT|WHERE|LEFT|ORDER|LIMIT|FROM)/m', '<br>\\1', $text);
|
||||
}
|
||||
|
||||
if (strlen($text) >= 150) {
|
||||
$text = wordwrap($text, 150, PHP_EOL, true);
|
||||
}
|
||||
|
||||
return str_replace(PHP_EOL, '<br>', $text);
|
||||
});
|
||||
$GridData->setData($data);
|
||||
|
||||
// Grid
|
||||
$Grid = new DataGrid();
|
||||
$Grid->setId('tblEventLog');
|
||||
$Grid->setDataTableTemplate('datagrid-table-simple', 'grid');
|
||||
$Grid->setDataRowTemplate('datagrid-rows', $this->view->getBase());
|
||||
$Grid->setDataPagerTemplate('datagrid-nav-full', 'grid');
|
||||
$Grid->setHeader($GridHeaders);
|
||||
$Grid->setData($GridData);
|
||||
$Grid->setTitle(__('Registro de Eventos'));
|
||||
$Grid->setTime(round(microtime() - $this->queryTimeStart, 5));
|
||||
|
||||
// Grid Actions
|
||||
$GridActionSearch = new DataGridActionSearch();
|
||||
$GridActionSearch->setId(ActionsInterface::EVENTLOG_SEARCH);
|
||||
$GridActionSearch->setType(DataGridActionType::SEARCH_ITEM);
|
||||
$GridActionSearch->setName('frmSearchEvent');
|
||||
$GridActionSearch->setTitle(__('Buscar Evento'));
|
||||
$GridActionSearch->setOnSubmitFunction('eventlog/search');
|
||||
$GridActionSearch->addData('action-route', Acl::getActionRoute(ActionsInterface::EVENTLOG_SEARCH));
|
||||
|
||||
$Grid->setDataActions($GridActionSearch);
|
||||
|
||||
$GridActionClear = new DataGridAction();
|
||||
$GridActionClear->setId(ActionsInterface::EVENTLOG_CLEAR);
|
||||
$GridActionClear->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionClear->setName(__('Vaciar registro de eventos'));
|
||||
$GridActionClear->setTitle(__('Vaciar registro de eventos'));
|
||||
$GridActionClear->setIcon($this->icons->getIconClear());
|
||||
$GridActionClear->setOnClickFunction('eventlog/clear');
|
||||
$GridActionClear->addData('action-route', Acl::getActionRoute(ActionsInterface::EVENTLOG_CLEAR));
|
||||
$GridActionClear->addData('action-next', Acl::getActionRoute(ActionsInterface::EVENTLOG));
|
||||
|
||||
$Grid->setDataActions($GridActionClear);
|
||||
|
||||
$Grid->setPager($this->getPager($GridActionSearch)
|
||||
->setOnClickFunction('eventlog/nav')
|
||||
);
|
||||
|
||||
return $Grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar los datos del paginador
|
||||
*
|
||||
* @param DataGridInterface $dataGrid
|
||||
* @param ItemSearchData $itemSearchData
|
||||
* @return DataGridInterface
|
||||
*/
|
||||
public function updatePager(DataGridInterface $dataGrid, ItemSearchData $itemSearchData)
|
||||
{
|
||||
$dataGrid->getPager()
|
||||
->setLimitStart($itemSearchData->getLimitStart())
|
||||
->setLimitCount($itemSearchData->getLimitCount())
|
||||
->setFilterOn($itemSearchData->getSeachString() !== '');
|
||||
|
||||
$dataGrid->updatePager();
|
||||
|
||||
return $dataGrid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $data SP\Html\DataGrid\DataGridTab
|
||||
* @var $this \SP\Mvc\View\Template
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- Rows -->
|
||||
<?php if ($data->getData()->getDataCount() > 0):
|
||||
foreach ($data->getData()->getData() as $dataIndex => $dataItem):
|
||||
if ($dataIndex === 'count'): continue; endif; ?>
|
||||
|
||||
<tr data-item-id="<?php echo $dataItem->{$data->getData()->getDataRowSourceId()}; ?>">
|
||||
<?php foreach ($data->getData()->getDataRowSources() as $rowSrc): ?>
|
||||
<?php $value = $rowSrc['isMethod'] === true && method_exists($dataItem, $rowSrc['name']) ? $dataItem->{$rowSrc['name']}() : $dataItem->{$rowSrc['name']}; ?>
|
||||
<?php $value = $rowSrc['filter'] !== null && $rowSrc['filter'] ? $rowSrc['filter']($value) : $value; ?>
|
||||
<td class="cell-data"><?php echo $value !== '' ? $value : ' '; // Fix height ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
/** @var \SP\Mvc\View\Template $this */
|
||||
include $this->includeTemplate('datagrid-grid', 'grid');
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $icons SP\Core\UI\ThemeIconsBase
|
||||
* @var $data SP\Html\DataGrid\DataGridTab
|
||||
* @var $this \SP\Mvc\View\Template
|
||||
* @var $action SP\Html\DataGrid\DataGridAction|SP\Html\DataGrid\DataGridActionSearch
|
||||
*/
|
||||
|
||||
if (!isset($index)): $index = 0; endif;
|
||||
?>
|
||||
|
||||
<div class="tab-actions">
|
||||
<ul>
|
||||
<?php foreach ($data->getDataActions() as $action):
|
||||
if ($action->getType() === \SP\Html\DataGrid\DataGridActionType::MENUBAR_ITEM):
|
||||
?>
|
||||
<li>
|
||||
<button
|
||||
id="btn-add-<?php echo $action->getId(); ?>"
|
||||
type="button"
|
||||
class="btn-action mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored mdl-color--indigo-A200 mdl-js-ripple-effect"
|
||||
data-nextaction-id="<?php echo $data->getOnCloseAction(); ?>"
|
||||
data-onclick="<?php echo $action->getOnClick(); ?>"
|
||||
<?php foreach ($action->getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?>>
|
||||
<i class="material-icons"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
</button>
|
||||
<span for="btn-add-<?php echo $action->getId(); ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $action->getTitle(); ?></span>
|
||||
</li>
|
||||
<?php elseif ($action->getType() === \SP\Html\DataGrid\DataGridActionType::SEARCH_ITEM): ?>
|
||||
<li class="datagrid-action-search">
|
||||
<form method="post" id="<?php echo $action->getName(); ?>"
|
||||
name="<?php echo $action->getName(); ?>"
|
||||
class="form-action"
|
||||
data-target="#data-table-<?php echo $data->getId(); ?>"
|
||||
data-onsubmit="<?php echo $action->getOnSubmit(); ?>"
|
||||
<?php foreach ($action->getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?>>
|
||||
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable">
|
||||
<label class="mdl-button mdl-js-button mdl-button--icon"
|
||||
id="btn-search-<?php echo $index; ?>"
|
||||
for="search-<?php echo $index; ?>">
|
||||
<i class="material-icons">search</i>
|
||||
</label>
|
||||
<span for="btn-search-<?php echo $index; ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $action->getTitle(); ?></span>
|
||||
|
||||
<div class="mdl-textfield__expandable-holder">
|
||||
<input class="mdl-textfield__input" type="text"
|
||||
id="search-<?php echo $index; ?>" name="search"/>
|
||||
<label class="mdl-textfield__label"
|
||||
for="search-<?php echo $index; ?>"><?php echo $action->getTitle(); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="reset" id="btn-reset-<?php echo $index; ?>"
|
||||
class="btn-clear mdl-button mdl-js-button mdl-button--icon">
|
||||
<i class="material-icons"><?php echo $icons->getIconClear()->getIcon(); ?></i>
|
||||
</button>
|
||||
<span for="btn-reset-<?php echo $index; ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $icons->getIconClear()->getTitle(); ?></span>
|
||||
|
||||
<input type="hidden" name="sk" value="">
|
||||
<input type="hidden" name="activetab" value="<?php echo $index; ?>">
|
||||
<input type="hidden" name="start" value="0">
|
||||
<input type="hidden" name="count"
|
||||
value="<?php echo $data->getPager()->getLimitCount(); ?>">
|
||||
<input type="hidden" name="isAjax" value="1">
|
||||
</form>
|
||||
</li>
|
||||
<?php endif; endforeach; ?>
|
||||
<li>
|
||||
<button type="button" id="btn-back-<?php echo $index; ?>"
|
||||
class="btn-back mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored <?php echo $icons->getIconBack()->getClassButton(); ?>"
|
||||
title="<?php echo $icons->getIconBack()->getTitle(); ?>">
|
||||
<i class="material-icons"><?php echo $icons->getIconBack()->getIcon(); ?></i>
|
||||
</button>
|
||||
<span for="btn-back-<?php echo $index; ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $icons->getIconBack()->getTitle(); ?></span>
|
||||
</li>
|
||||
<?php if (count($data->getDataActionsMenu()) > 0): ?>
|
||||
<li>
|
||||
<button id="<?php echo $data->getId(); ?>-menu-lower-right"
|
||||
class="mdl-button mdl-js-button mdl-button--icon">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
|
||||
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
|
||||
for="<?php echo $data->getId(); ?>-menu-lower-right">
|
||||
<?php foreach ($data->getDataActionsMenu() as $action): ?>
|
||||
<li class="btn-action mdl-menu__item"
|
||||
data-onclick="<?php echo $action->getOnClick(); ?>"
|
||||
data-action-id="<?php echo $action->getId(); ?>"
|
||||
data-selection="#data-table-<?php echo $data->getId(); ?>">
|
||||
<i class="material-icons <?php echo $action->getIcon()->getClass(); ?>"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
<?php echo __('Eliminar Seleccionados'); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="data-table-<?php echo $data->getId(); ?>">
|
||||
<?php if ($data->getDataTableTemplate()): ?>
|
||||
<?php include $data->getDataTableTemplate(); ?>
|
||||
<?php else: ?>
|
||||
<?php include __DIR__ . DIRECTORY_SEPARATOR . 'datagrid-table.inc'; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -14,11 +14,10 @@ use SP\Html\Html;
|
||||
if ($dataIndex === 'count'): continue; endif;
|
||||
$numFields = count($data->getData()->getDataRowSources()); ?>
|
||||
|
||||
<tr data-item-id="<?php echo $dataItem->{$data->getData()->getDataRowSourceId()}; ?>"
|
||||
data-activetab="<?php echo $index; ?>">
|
||||
<tr data-item-id="<?php echo $dataItem->{$data->getData()->getDataRowSourceId()}; ?>">
|
||||
<?php foreach ($data->getData()->getDataRowSources() as $rowSrc): ?>
|
||||
<?php $value = $rowSrc['isMethod'] === true && method_exists($dataItem, $rowSrc['name']) ? $dataItem->{$rowSrc['name']}() : $dataItem->{$rowSrc['name']}; ?>
|
||||
<?php $value = $rowSrc['filter'] !== null && is_callable($rowSrc['filter']) ? $rowSrc['filter']($value) : $value; ?>
|
||||
<?php $value = $rowSrc['filter'] !== null && $rowSrc['filter'] ? $rowSrc['filter']($value) : $value; ?>
|
||||
<td class="cell-data"><?php echo $value !== '' ? Html::truncate($value, 150 / $numFields) : ' '; // Fix height ?></td>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -33,10 +32,10 @@ use SP\Html\Html;
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<td class="cell-actions">
|
||||
<div>
|
||||
<?php if (count($data->getDataActions()) > 0):
|
||||
foreach ($data->getDataActions() as $action):
|
||||
<?php if ($data->getDataActionsCount() > 0): ?>
|
||||
<td class="cell-actions">
|
||||
<div>
|
||||
<?php foreach ($data->getDataActions() as $action):
|
||||
if (!$action->isSkip()):
|
||||
$filter = $action->getFilterRowSource();
|
||||
|
||||
@@ -60,11 +59,9 @@ use SP\Html\Html;
|
||||
class="mdl-tooltip mdl-tooltip--top"><?php echo $action->getTitle(); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</div>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @var $data SP\Html\DataGrid\DataGridTab
|
||||
* @var $this SP\Core\Template
|
||||
* @var $action SP\Html\DataGrid\DataGridAction|SP\Html\DataGrid\DataGridActionSearch
|
||||
*/
|
||||
?>
|
||||
|
||||
<table class="mdl-data-table mdl-js-data-table table-responsive data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($data->getHeader()->getHeaders() as $header): ?>
|
||||
<th class="mdl-data-table__cell--non-numeric"><?php echo $header; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="data-rows-<?php echo $data->getId(); ?>">
|
||||
<?php include $data->getDataRowTemplate(); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Pager -->
|
||||
<?php include $data->getDataPagerTemplate(); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
sysPassApp.sk.set("<?php echo $sk; ?>");
|
||||
</script>
|
||||
@@ -13,7 +13,9 @@
|
||||
<th class="mdl-data-table__cell--non-numeric"><?php echo $header; ?></th>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<th class="mdl-data-table__cell--non-numeric"> </th>
|
||||
<?php if ($data->getDataActionsCount() > 0): ?>
|
||||
<th class="mdl-data-table__cell--non-numeric"> </th>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
@@ -16,102 +16,8 @@
|
||||
class="mdl-tabs__panel"
|
||||
data-tab-route="<?php echo $tabsRoute; ?>"
|
||||
data-tab-index="<?php echo $index; ?>">
|
||||
<div class="tab-actions">
|
||||
<ul>
|
||||
<?php foreach ($data->getDataActions() as $action):
|
||||
if ($action->getType() === \SP\Html\DataGrid\DataGridActionType::NEW_ITEM):
|
||||
?>
|
||||
<li>
|
||||
<button
|
||||
id="btn-add-<?php echo $action->getId(); ?>"
|
||||
type="button"
|
||||
class="btn-action mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored mdl-color--indigo-A200 mdl-js-ripple-effect"
|
||||
data-nextaction-id="<?php echo $data->getOnCloseAction(); ?>"
|
||||
data-onclick="<?php echo $action->getOnClick(); ?>"
|
||||
<?php foreach ($action->getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?>>
|
||||
<i class="material-icons"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
</button>
|
||||
<span for="btn-add-<?php echo $action->getId(); ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $action->getTitle(); ?></span>
|
||||
</li>
|
||||
<?php elseif ($action->getType() === \SP\Html\DataGrid\DataGridActionType::SEARCH_ITEM): ?>
|
||||
<li class="datagrid-action-search">
|
||||
<form method="post" id="<?php echo $action->getName(); ?>"
|
||||
name="<?php echo $action->getName(); ?>"
|
||||
class="form-action"
|
||||
data-target="#data-table-<?php echo $data->getId(); ?>"
|
||||
data-onsubmit="<?php echo $action->getOnSubmit(); ?>"
|
||||
<?php foreach ($action->getData() as $dataName => $dataValue): echo 'data-', $dataName, '=', '"', $dataValue, '"'; endforeach; ?>>
|
||||
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable">
|
||||
<label class="mdl-button mdl-js-button mdl-button--icon"
|
||||
id="btn-search-<?php echo $index; ?>"
|
||||
for="search-<?php echo $index; ?>">
|
||||
<i class="material-icons">search</i>
|
||||
</label>
|
||||
<span for="btn-search-<?php echo $index; ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $action->getTitle(); ?></span>
|
||||
|
||||
<div class="mdl-textfield__expandable-holder">
|
||||
<input class="mdl-textfield__input" type="text"
|
||||
id="search-<?php echo $index; ?>" name="search"/>
|
||||
<label class="mdl-textfield__label"
|
||||
for="search-<?php echo $index; ?>"><?php echo $action->getTitle(); ?></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="reset" id="btn-reset-<?php echo $index; ?>"
|
||||
class="btn-clear mdl-button mdl-js-button mdl-button--icon">
|
||||
<i class="material-icons"><?php echo $icons->getIconClear()->getIcon(); ?></i>
|
||||
</button>
|
||||
<span for="btn-reset-<?php echo $index; ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $icons->getIconClear()->getTitle(); ?></span>
|
||||
|
||||
<input type="hidden" name="sk" value="">
|
||||
<input type="hidden" name="activetab" value="<?php echo $index; ?>">
|
||||
<input type="hidden" name="start" value="0">
|
||||
<input type="hidden" name="count"
|
||||
value="<?php echo $data->getPager()->getLimitCount(); ?>">
|
||||
<input type="hidden" name="isAjax" value="1">
|
||||
</form>
|
||||
</li>
|
||||
<?php endif; endforeach; ?>
|
||||
<li>
|
||||
<button type="button" id="btn-back-<?php echo $index; ?>"
|
||||
class="btn-back mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-button--colored <?php echo $icons->getIconBack()->getClassButton(); ?>"
|
||||
title="<?php echo $icons->getIconBack()->getTitle(); ?>">
|
||||
<i class="material-icons"><?php echo $icons->getIconBack()->getIcon(); ?></i>
|
||||
</button>
|
||||
<span for="btn-back-<?php echo $index; ?>"
|
||||
class="mdl-tooltip mdl-tooltip--bottom"><?php echo $icons->getIconBack()->getTitle(); ?></span>
|
||||
</li>
|
||||
<?php if (count($data->getDataActionsMenu()) > 0): ?>
|
||||
<li>
|
||||
<button id="<?php echo $data->getId(); ?>-menu-lower-right"
|
||||
class="mdl-button mdl-js-button mdl-button--icon">
|
||||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
|
||||
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect"
|
||||
for="<?php echo $data->getId(); ?>-menu-lower-right">
|
||||
<?php foreach ($data->getDataActionsMenu() as $action): ?>
|
||||
<li class="btn-action mdl-menu__item"
|
||||
data-onclick="<?php echo $action->getOnClick(); ?>"
|
||||
data-action-id="<?php echo $action->getId(); ?>"
|
||||
data-selection="#data-table-<?php echo $data->getId(); ?>">
|
||||
<i class="material-icons <?php echo $action->getIcon()->getClass(); ?>"><?php echo $action->getIcon()->getIcon(); ?></i>
|
||||
<?php echo __('Eliminar Seleccionados'); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="data-table-<?php echo $data->getId(); ?>">
|
||||
<?php include __DIR__ . DIRECTORY_SEPARATOR . 'datagrid-table.inc'; ?>
|
||||
</div>
|
||||
<?php include __DIR__ . DIRECTORY_SEPARATOR . 'datagrid-grid.inc'; ?>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -263,7 +263,7 @@ class AccountSearchController extends ControllerBase implements ActionsInterface
|
||||
|
||||
$GridActionCopy = new DataGridAction();
|
||||
$GridActionCopy->setId(self::ACCOUNT_COPY);
|
||||
$GridActionCopy->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionCopy->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionCopy->setName(__('Copiar Cuenta'));
|
||||
$GridActionCopy->setTitle(__('Copiar Cuenta'));
|
||||
$GridActionCopy->setIcon($this->icons->getIconCopy());
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace SP\Controller\Grids;
|
||||
|
||||
defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Config\Config;
|
||||
use SP\Core\Acl\Acl;
|
||||
use SP\Core\Acl\ActionsInterface;
|
||||
use SP\Core\Exceptions\InvalidArgumentException;
|
||||
@@ -86,7 +85,7 @@ class Items extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::CATEGORY_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nueva Categoría'));
|
||||
$GridActionNew->setTitle(__('Nueva Categoría'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -160,7 +159,7 @@ class Items extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::CLIENT_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Cliente'));
|
||||
$GridActionNew->setTitle(__('Nuevo Cliente'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -236,7 +235,7 @@ class Items extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::CUSTOMFIELD_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Campo'));
|
||||
$GridActionNew->setTitle(__('Nuevo Campo'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -511,7 +510,7 @@ class Items extends GridBase
|
||||
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::USER_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Usuario'));
|
||||
$GridActionNew->setTitle(__('Nuevo Usuario'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -525,7 +524,7 @@ class Items extends GridBase
|
||||
) {
|
||||
$GridActionLdapSync = new DataGridAction();
|
||||
$GridActionLdapSync->setId(self::LDAP_SYNC);
|
||||
$GridActionLdapSync->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionLdapSync->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionLdapSync->setName(__('Importar usuarios de LDAP'));
|
||||
$GridActionLdapSync->setTitle(__('Importar usuarios de LDAP'));
|
||||
$GridActionLdapSync->setIcon(new FontIcon('get_app'));
|
||||
@@ -622,7 +621,7 @@ class Items extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::GROUP_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Grupo'));
|
||||
$GridActionNew->setTitle(__('Nuevo Grupo'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -694,7 +693,7 @@ class Items extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::PROFILE_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nuevo Perfil'));
|
||||
$GridActionNew->setTitle(__('Nuevo Perfil'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -778,7 +777,7 @@ class Items extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::APITOKEN_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nueva Autorización'));
|
||||
$GridActionNew->setTitle(__('Nueva Autorización'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
@@ -940,7 +939,7 @@ class Items extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::TAG_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nueva Etiqueta'));
|
||||
$GridActionNew->setTitle(__('Nueva Etiqueta'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
|
||||
@@ -91,7 +91,7 @@ class Notices extends GridBase
|
||||
// Grid item's actions
|
||||
$GridActionNew = new DataGridAction();
|
||||
$GridActionNew->setId(self::NOTICE_USER_CREATE);
|
||||
$GridActionNew->setType(DataGridActionType::NEW_ITEM);
|
||||
$GridActionNew->setType(DataGridActionType::MENUBAR_ITEM);
|
||||
$GridActionNew->setName(__('Nueva Notificación'));
|
||||
$GridActionNew->setTitle(__('Nueva Notificación'));
|
||||
$GridActionNew->setIcon($this->icons->getIconAdd());
|
||||
|
||||
@@ -64,7 +64,33 @@ class Acl implements ActionsInterface
|
||||
*/
|
||||
public static function getActionRoute($actionId)
|
||||
{
|
||||
return self::$action->getActionById($actionId)->getRoute();
|
||||
try {
|
||||
return self::$action->getActionById($actionId)->getRoute();
|
||||
} catch (ActionNotFoundException $e) {
|
||||
processException($e);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el nombre de la acción indicada
|
||||
*
|
||||
* @param int $actionId El id de la acción
|
||||
* @param bool $translate
|
||||
* @return string
|
||||
* @internal param bool $shortName Si se devuelve el nombre corto de la acción
|
||||
*/
|
||||
public static function getActionInfo($actionId, $translate = true)
|
||||
{
|
||||
try {
|
||||
$text = self::$action->getActionById($actionId)->getText();
|
||||
return $translate ? __($text) : $text;
|
||||
} catch (ActionNotFoundException $e) {
|
||||
processException($e);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,6 +197,7 @@ class Acl implements ActionsInterface
|
||||
case self::APITOKEN_SEARCH:
|
||||
return $userProfile->isMgmApiTokens();
|
||||
case self::EVENTLOG:
|
||||
case self::EVENTLOG_SEARCH:
|
||||
return $userProfile->isEvl();
|
||||
case self::NOTICE:
|
||||
case self::NOTICE_USER:
|
||||
@@ -187,19 +214,4 @@ class Acl implements ActionsInterface
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtener el nombre de la acción indicada
|
||||
*
|
||||
* @param int $actionId El id de la acción
|
||||
* @param bool $translate
|
||||
* @return string
|
||||
* @internal param bool $shortName Si se devuelve el nombre corto de la acción
|
||||
*/
|
||||
public static function getActionInfo($actionId, $translate = true)
|
||||
{
|
||||
$text = self::$action->getActionById($actionId)->getText();
|
||||
|
||||
return $translate ? __($text) : $text;
|
||||
}
|
||||
}
|
||||
37
lib/SP/Core/Acl/ActionNotFoundException.php
Normal file
37
lib/SP/Core/Acl/ActionNotFoundException.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Core\Acl;
|
||||
|
||||
use SP\Core\Exceptions\SPException;
|
||||
|
||||
/**
|
||||
* Class ActionNotFoundException
|
||||
*
|
||||
* @package SP\Core\Acl
|
||||
*/
|
||||
class ActionNotFoundException extends SPException
|
||||
{
|
||||
|
||||
}
|
||||
@@ -61,6 +61,7 @@ class Actions
|
||||
*
|
||||
* @param FileStorageInterface $fileStorage
|
||||
* @param XmlFileStorageInterface $xmlFileStorage
|
||||
* @throws \SP\Core\Exceptions\FileNotFoundException
|
||||
*/
|
||||
public function __construct(FileStorageInterface $fileStorage, XmlFileStorageInterface $xmlFileStorage)
|
||||
{
|
||||
@@ -73,6 +74,7 @@ class Actions
|
||||
* Loads actions from cache file
|
||||
*
|
||||
* @param FileStorageInterface $fileStorage
|
||||
* @throws \SP\Core\Exceptions\FileNotFoundException
|
||||
*/
|
||||
protected function loadCache(FileStorageInterface $fileStorage)
|
||||
{
|
||||
@@ -93,6 +95,8 @@ class Actions
|
||||
|
||||
/**
|
||||
* Sets an array of actions using id as key
|
||||
*
|
||||
* @throws \SP\Core\Exceptions\FileNotFoundException
|
||||
*/
|
||||
protected function map()
|
||||
{
|
||||
@@ -104,7 +108,7 @@ class Actions
|
||||
|
||||
foreach ($this->load() as $a) {
|
||||
if (isset($this->actions[$a['id']])) {
|
||||
throw new \RuntimeException('Duplicated action id');
|
||||
throw new \RuntimeException('Duplicated action id: ' . $a['id']);
|
||||
}
|
||||
|
||||
$action = clone $actionBase;
|
||||
@@ -121,6 +125,7 @@ class Actions
|
||||
* Loads actions from DB
|
||||
*
|
||||
* @return ActionData[]
|
||||
* @throws \SP\Core\Exceptions\FileNotFoundException
|
||||
*/
|
||||
protected function load()
|
||||
{
|
||||
@@ -142,9 +147,14 @@ class Actions
|
||||
*
|
||||
* @param $id
|
||||
* @return ActionData
|
||||
* @throws ActionNotFoundException
|
||||
*/
|
||||
public function getActionById($id)
|
||||
{
|
||||
if (!isset($this->actions[$id])) {
|
||||
throw new ActionNotFoundException(__u('Acción no encontrada'), ActionNotFoundException::ERROR);
|
||||
}
|
||||
|
||||
return $this->actions[$id];
|
||||
}
|
||||
}
|
||||
@@ -164,4 +164,6 @@ interface ActionsInterface
|
||||
const LDAP_CONFIG = 1080;
|
||||
const LDAP_SYNC = 1081;
|
||||
const EVENTLOG = 90;
|
||||
const EVENTLOG_SEARCH = 905;
|
||||
const EVENTLOG_CLEAR = 906;
|
||||
}
|
||||
@@ -33,5 +33,29 @@ defined('APP_ROOT') || die();
|
||||
*/
|
||||
class DataGrid extends DataGridBase
|
||||
{
|
||||
/**
|
||||
* Título de la pestaña
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_title = '';
|
||||
|
||||
/**
|
||||
* @param $title string
|
||||
* @return DataGrid
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->_title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ defined('APP_ROOT') || die();
|
||||
*/
|
||||
class DataGridActionType
|
||||
{
|
||||
const NEW_ITEM = 1;
|
||||
const MENUBAR_ITEM = 1;
|
||||
const VIEW_ITEM = 2;
|
||||
const EDIT_ITEM = 3;
|
||||
const DELETE_ITEM = 4;
|
||||
|
||||
@@ -28,7 +28,6 @@ defined('APP_ROOT') || die();
|
||||
|
||||
use SP\Core\Acl\ActionsInterface;
|
||||
use SP\Core\Exceptions\FileNotFoundException;
|
||||
use SP\Core\Exceptions\SPException;
|
||||
use SP\Core\Traits\InjectableTrait;
|
||||
use SP\Core\UI\Theme;
|
||||
use SplObjectStorage;
|
||||
@@ -78,12 +77,20 @@ abstract class DataGridBase implements DataGridInterface
|
||||
* @var DataGridActionInterface[]
|
||||
*/
|
||||
protected $_actions;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_actionsCount = 0;
|
||||
/**
|
||||
* Las acciones asociadas a los elementos de la matriz que se muestran en un menú
|
||||
*
|
||||
* @var DataGridActionInterface[]
|
||||
*/
|
||||
protected $_actionsMenu;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_actionsMenuCount = 0;
|
||||
/**
|
||||
* La acción a realizar al cerrar la matriz
|
||||
*
|
||||
@@ -114,6 +121,12 @@ abstract class DataGridBase implements DataGridInterface
|
||||
* @var string
|
||||
*/
|
||||
protected $_rowsTemplate;
|
||||
/**
|
||||
* La plantilla a utilizar para presentar la tabla
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_tableTemplate;
|
||||
/**
|
||||
* @var Theme
|
||||
*/
|
||||
@@ -215,7 +228,7 @@ abstract class DataGridBase implements DataGridInterface
|
||||
|
||||
/**
|
||||
* @param DataGridActionInterface $action
|
||||
* @param bool $isMenu Añadir al menu de acciones
|
||||
* @param bool $isMenu Añadir al menu de acciones
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataActions(DataGridActionInterface $action, $isMenu = false)
|
||||
@@ -226,12 +239,20 @@ abstract class DataGridBase implements DataGridInterface
|
||||
}
|
||||
|
||||
$this->_actions->attach($action);
|
||||
|
||||
if (!$action->isSkip()) {
|
||||
$this->_actionsCount++;
|
||||
}
|
||||
} else {
|
||||
if (null === $this->_actionsMenu) {
|
||||
$this->_actionsMenu = new SplObjectStorage();
|
||||
}
|
||||
|
||||
$this->_actionsMenu->attach($action);
|
||||
|
||||
if (!$action->isSkip()) {
|
||||
$this->_actionsMenuCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -257,7 +278,7 @@ abstract class DataGridBase implements DataGridInterface
|
||||
* Establecer la plantilla utilizada para la cabecera
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
* @param string $base Directorio base para la plantilla
|
||||
* @param string $base Directorio base para la plantilla
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataHeaderTemplate($template, $base = null)
|
||||
@@ -265,7 +286,7 @@ abstract class DataGridBase implements DataGridInterface
|
||||
try {
|
||||
$this->_headerTemplate = $this->checkTemplate($template, $base);
|
||||
} catch (FileNotFoundException $e) {
|
||||
debugLog($e->getMessage());
|
||||
processException($e);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -285,7 +306,7 @@ abstract class DataGridBase implements DataGridInterface
|
||||
$file = $this->theme->getViewsPath() . DIRECTORY_SEPARATOR . $template;
|
||||
|
||||
if (!is_readable($file)) {
|
||||
throw new FileNotFoundException(SPException::ERROR, sprintf(__('No es posible obtener la plantilla "%s" : %s'), $template, $file));
|
||||
throw new FileNotFoundException(sprintf(__('No es posible obtener la plantilla "%s" : %s'), $template, $file));
|
||||
}
|
||||
|
||||
return $file;
|
||||
@@ -332,7 +353,7 @@ abstract class DataGridBase implements DataGridInterface
|
||||
* Establecer la plantilla utilizada para el paginador
|
||||
*
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
* @param string $base Directorio base para la plantilla
|
||||
* @param string $base Directorio base para la plantilla
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataPagerTemplate($template, $base = null)
|
||||
@@ -358,7 +379,7 @@ abstract class DataGridBase implements DataGridInterface
|
||||
|
||||
/**
|
||||
* @param string $template El nombre de la plantilla a utilizar
|
||||
* @param string $base Directorio base para la plantilla
|
||||
* @param string $base Directorio base para la plantilla
|
||||
* @return mixed
|
||||
*/
|
||||
public function setDataRowTemplate($template, $base = null)
|
||||
@@ -366,7 +387,7 @@ abstract class DataGridBase implements DataGridInterface
|
||||
try {
|
||||
$this->_rowsTemplate = $this->checkTemplate($template, $base);
|
||||
} catch (FileNotFoundException $e) {
|
||||
debugLog($e->getMessage());
|
||||
processException($e);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -481,4 +502,44 @@ abstract class DataGridBase implements DataGridInterface
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDataTableTemplate()
|
||||
{
|
||||
return $this->_tableTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $template
|
||||
* @param null $base
|
||||
* @return DataGridBase
|
||||
*/
|
||||
public function setDataTableTemplate($template, $base = null)
|
||||
{
|
||||
try {
|
||||
$this->_tableTemplate = $this->checkTemplate($template, $base);
|
||||
} catch (FileNotFoundException $e) {
|
||||
processException($e);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDataActionsMenuCount()
|
||||
{
|
||||
return $this->_actionsMenuCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDataActionsCount()
|
||||
{
|
||||
return $this->_actionsCount;
|
||||
}
|
||||
}
|
||||
@@ -40,13 +40,13 @@ abstract class DataGridDataBase implements DataGridDataInterface
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_data = array();
|
||||
private $_data = [];
|
||||
/**
|
||||
* Las columnas a mostrar de los datos obtenidos
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_sources = array();
|
||||
private $_sources = [];
|
||||
/**
|
||||
* La columna que identifica cada elemento de los datos de la matriz
|
||||
*
|
||||
@@ -58,7 +58,7 @@ abstract class DataGridDataBase implements DataGridDataInterface
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_sourcesWithIcon = array();
|
||||
private $_sourcesWithIcon = [];
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
@@ -73,13 +73,17 @@ abstract class DataGridDataBase implements DataGridDataInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param bool $isMethod
|
||||
* @param null $filter
|
||||
* @param string $source
|
||||
* @param bool $isMethod
|
||||
* @param callable $filter
|
||||
*/
|
||||
public function addDataRowSource($source, $isMethod = false, $filter = null)
|
||||
public function addDataRowSource($source, $isMethod = false, callable $filter = null)
|
||||
{
|
||||
$this->_sources[] = ['name' => $source, 'isMethod' => $isMethod, 'filter' => $filter];
|
||||
$this->_sources[] = [
|
||||
'name' => $source,
|
||||
'isMethod' => $isMethod,
|
||||
'filter' => $filter
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +134,11 @@ abstract class DataGridDataBase implements DataGridDataInterface
|
||||
*/
|
||||
public function addDataRowSourceWithIcon($source, IconInterface $icon, $value = 1)
|
||||
{
|
||||
$this->_sourcesWithIcon[] = ['field' => $source, 'icon' => $icon, 'value' => $value];
|
||||
$this->_sourcesWithIcon[] = [
|
||||
'field' => $source,
|
||||
'icon' => $icon,
|
||||
'value' => $value
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,11 +38,11 @@ interface DataGridDataInterface
|
||||
/**
|
||||
* Establecer los orígenes de datos de la consulta
|
||||
*
|
||||
* @param string $source
|
||||
* @param bool $isMethod
|
||||
* @param null $filter
|
||||
* @param string $source
|
||||
* @param bool $isMethod
|
||||
* @param callable|null $filter
|
||||
*/
|
||||
public function addDataRowSource($source, $isMethod = false, $filter = null);
|
||||
public function addDataRowSource($source, $isMethod = false, callable $filter = null);
|
||||
|
||||
/**
|
||||
* Devolver los orígenes de datos de la consulta
|
||||
|
||||
@@ -193,4 +193,10 @@ interface DataGridInterface
|
||||
* @return DataGridActionInterface[]
|
||||
*/
|
||||
public function getDataActionsMenuFiltered($filter);
|
||||
|
||||
/**
|
||||
* Actualizar los datos del paginador
|
||||
* @return static
|
||||
*/
|
||||
public function updatePager();
|
||||
}
|
||||
@@ -53,6 +53,7 @@ interface DataGridPagerInterface
|
||||
* Establecer el registro de inicio de la página
|
||||
*
|
||||
* @param int $limitStart
|
||||
* @return static
|
||||
*/
|
||||
public function setLimitStart($limitStart);
|
||||
|
||||
@@ -67,6 +68,7 @@ interface DataGridPagerInterface
|
||||
* Establecer el número de registros en una página
|
||||
*
|
||||
* @param int $limitCount
|
||||
* @return static
|
||||
*/
|
||||
public function setLimitCount($limitCount);
|
||||
|
||||
@@ -95,6 +97,7 @@ interface DataGridPagerInterface
|
||||
* Establecer si está activado el filtro
|
||||
*
|
||||
* @param bool $filterOn
|
||||
* @return static
|
||||
*/
|
||||
public function setFilterOn($filterOn);
|
||||
|
||||
|
||||
91
lib/SP/Repositories/EventLog/EventlogRepository.php
Normal file
91
lib/SP/Repositories/EventLog/EventlogRepository.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Repositories\EventLog;
|
||||
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\Repositories\Repository;
|
||||
use SP\Storage\DbWrapper;
|
||||
use SP\Storage\QueryData;
|
||||
|
||||
/**
|
||||
* Class EventlogRepository
|
||||
*
|
||||
* @package SP\Repositories\EventLog
|
||||
*/
|
||||
class EventlogRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Clears the event log
|
||||
*
|
||||
* @return bool con el resultado
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$queryData = new QueryData();
|
||||
$queryData->setQuery('TRUNCATE TABLE EventLog');
|
||||
$queryData->setOnErrorMessage(__u('Error al vaciar el registro de eventos'));
|
||||
|
||||
return DbWrapper::getQuery($queryData, $this->db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for items by a given filter
|
||||
*
|
||||
* @param ItemSearchData $itemSearchData
|
||||
* @return mixed
|
||||
*/
|
||||
public function search(ItemSearchData $itemSearchData)
|
||||
{
|
||||
$queryData = new QueryData();
|
||||
$queryData->setSelect('id,FROM_UNIXTIME(date) AS date,action,level,login,ipAddress,description');
|
||||
$queryData->setFrom('EventLog');
|
||||
$queryData->setOrder('id DESC');
|
||||
|
||||
if ($itemSearchData->getSeachString() !== '') {
|
||||
$queryData->setWhere('action LIKE ? OR ipAddress LIKE ? OR description LIKE ?');
|
||||
|
||||
$search = '%' . $itemSearchData->getSeachString() . '%';
|
||||
$queryData->addParam($search);
|
||||
$queryData->addParam($search);
|
||||
$queryData->addParam($search);
|
||||
}
|
||||
|
||||
$queryData->setLimit('?,?');
|
||||
$queryData->addParam($itemSearchData->getLimitStart());
|
||||
$queryData->addParam($itemSearchData->getLimitCount());
|
||||
|
||||
DbWrapper::setFullRowCount();
|
||||
|
||||
/** @var array $queryRes */
|
||||
$queryRes = DbWrapper::getResultsArray($queryData, $this->db);
|
||||
|
||||
$queryRes['count'] = $queryData->getQueryNumRows();
|
||||
|
||||
return $queryRes;
|
||||
}
|
||||
}
|
||||
71
lib/SP/Services/EventLog/EventlogService.php
Normal file
71
lib/SP/Services/EventLog/EventlogService.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
* sysPass is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* sysPass is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Services\EventLog;
|
||||
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\Repositories\EventLog\EventlogRepository;
|
||||
use SP\Services\Service;
|
||||
|
||||
/**
|
||||
* Class EventlogService
|
||||
*
|
||||
* @package SP\Services\EventLog
|
||||
*/
|
||||
class EventlogService extends Service
|
||||
{
|
||||
/**
|
||||
* @var EventlogRepository
|
||||
*/
|
||||
protected $eventLogRepository;
|
||||
|
||||
/**
|
||||
* @param ItemSearchData $itemSearchData
|
||||
* @return mixed
|
||||
*/
|
||||
public function search(ItemSearchData $itemSearchData)
|
||||
{
|
||||
return $this->eventLogRepository->search($itemSearchData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws \SP\Core\Exceptions\ConstraintException
|
||||
* @throws \SP\Core\Exceptions\QueryException
|
||||
* @throws \SP\Core\Exceptions\SPException
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
return $this->eventLogRepository->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->eventLogRepository = $this->dic->get(EventlogRepository::class);
|
||||
}
|
||||
}
|
||||
@@ -1356,32 +1356,39 @@ sysPass.Actions = function (Common) {
|
||||
*
|
||||
* @type {{nav: eventlog.nav, clear: eventlog.clear}}
|
||||
*/
|
||||
var eventlog = {
|
||||
nav: function ($obj) {
|
||||
if ($obj.data("start") === undefined) {
|
||||
return false;
|
||||
}
|
||||
const eventlog = {
|
||||
search: function ($obj) {
|
||||
log.info("eventlog:search");
|
||||
|
||||
var opts = Common.appRequests().getRequestOpts();
|
||||
opts.url = ajaxUrl.eventlog;
|
||||
const $target = $($obj.data("target"));
|
||||
const opts = Common.appRequests().getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
|
||||
opts.method = "get";
|
||||
opts.type = "html";
|
||||
opts.data = {
|
||||
actionId: $obj.data("action-id"),
|
||||
sk: Common.sk.get(),
|
||||
isAjax: 1,
|
||||
start: $obj.data("start"),
|
||||
count: $obj.data("count"),
|
||||
current: $obj.data("current")
|
||||
};
|
||||
opts.data = $obj.serialize();
|
||||
|
||||
Common.appRequests().getActionCall(opts, function (response) {
|
||||
$("#content").html(response);
|
||||
Common.scrollUp();
|
||||
Common.appRequests().getActionCall(opts, function (json) {
|
||||
if (json.status === 0) {
|
||||
$target.html(json.data.html);
|
||||
} else {
|
||||
$target.html(Common.msg.html.error(json.description));
|
||||
}
|
||||
|
||||
Common.sk.set(json.csrf);
|
||||
});
|
||||
},
|
||||
nav: function ($obj) {
|
||||
log.info("eventlog:nav");
|
||||
|
||||
const $form = $("#" + $obj.data("action-form"));
|
||||
|
||||
$form.find("[name='start']").val($obj.data("start"));
|
||||
$form.find("[name='count']").val($obj.data("count"));
|
||||
$form.find("[name='sk']").val(Common.sk.get());
|
||||
|
||||
eventlog.search($form);
|
||||
},
|
||||
clear: function ($obj) {
|
||||
var atext = "<div id=\"alert\"><p id=\"alert-text\">" + Common.config().LANG[20] + "</p></div>";
|
||||
const atext = "<div id=\"alert\"><p id=\"alert-text\">" + Common.config().LANG[20] + "</p></div>";
|
||||
|
||||
mdlDialog().show({
|
||||
text: atext,
|
||||
@@ -1398,17 +1405,20 @@ sysPass.Actions = function (Common) {
|
||||
onClick: function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var opts = Common.appRequests().getRequestOpts();
|
||||
opts.url = ajaxUrl.eventlog;
|
||||
const $target = $($obj.data("target"));
|
||||
const opts = Common.appRequests().getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
|
||||
opts.method = "get";
|
||||
opts.data = {clear: 1, sk: Common.sk.get(), isAjax: 1};
|
||||
opts.data = {sk: Common.sk.get(), isAjax: 1};
|
||||
|
||||
Common.appRequests().getActionCall(opts, function (json) {
|
||||
Common.msg.out(json);
|
||||
|
||||
if (json.status == 0) {
|
||||
doAction({actionId: $obj.data("nextaction-id")});
|
||||
if (json.status === 0) {
|
||||
getContent({r: $obj.data("action-next")});
|
||||
}
|
||||
|
||||
Common.sk.set(json.csrf);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
44
public/js/app-actions.min.js
vendored
44
public/js/app-actions.min.js
vendored
@@ -5,7 +5,7 @@ sysPass.Actions=function(c){var e=c.log,k=0,f={entrypoint:"/index.php",doAction:
|
||||
"export":"/ajax/ajax_configSave.php","import":"/ajax/ajax_configSave.php"},file:"/ajax/ajax_filesMgmt.php",link:"/index.php",plugin:"/ajax/ajax_itemSave.php",account:{save:"/index.php",saveFavorite:"/ajax/ajax_itemSave.php",request:"/ajax/ajax_itemSave.php",getFiles:"/index.php",search:"/index.php?r=account/search"},appMgmt:{show:"/index.php",save:"/index.php",search:"/index.php"},eventlog:"/ajax/ajax_eventlog.php",wiki:{show:"/ajax/ajax_wiki.php"},notice:{show:"/ajax/ajax_noticeShow.php",search:"/ajax/ajax_noticeSearch.php"}};
|
||||
Object.freeze(f);var m=function(a,b){var d={r:a.r+(void 0!==a.itemId?"/"+a.itemId:""),isAjax:1},g=c.appRequests().getRequestOpts();g.url=f.doAction;g.method="get";g.type="html";g.addHistory=!0;g.data=d;c.appRequests().getActionCall(g,function(a){var d=$("#content");d.empty().html(a);a=c.triggers().views;a.common(d);if(void 0!==b&&"function"===typeof a[b])a[b]();d=$(".mdl-layout__content");0<d.scrollTop()&&d.animate({scrollTop:0},1E3)})},l=function(a,b){e.info("getContent");a.isAjax=1;var d=c.appRequests().getRequestOpts();
|
||||
d.url=f.doAction;d.method="get";d.type="html";d.addHistory=!0;d.data=a;c.appRequests().getActionCall(d,function(a){var d=$("#content");d.empty().html(a);a=c.triggers().views;a.common(d);if(void 0!==b&&"function"===typeof a[b])a[b]();d=$(".mdl-layout__content");0<d.scrollTop()&&d.animate({scrollTop:0},1E3)})},n=function(a,b){$.magnificPopup.open({items:{src:a||"",type:"inline"},callbacks:{open:function(){var a=$("#box-popup");c.appTriggers().views.common(a);a.find(":input:text:visible:first").focus();
|
||||
void 0!==b&&"function"===typeof b.open&&b.open()},close:function(){void 0!==b&&"function"===typeof b.close&&b.close()}},showCloseBtn:!1})},v=function(a,b){var d=$('<div id="box-popup" class="image">'+b+"</div>"),g=d.find("img");if(0===g.length)return n(b);g.hide();$.magnificPopup.open({items:{src:d,type:"inline"},callbacks:{open:function(){var a=this;g.on("click",function(){a.close()});setTimeout(function(){var a=c.resizeImage(g);d.css({backgroundColor:"#fff",width:a.width,height:"auto"});g.show("slow")},
|
||||
void 0!==b&&"function"===typeof b.open&&b.open()},close:function(){void 0!==b&&"function"===typeof b.close&&b.close()}},showCloseBtn:!1})},w=function(a,b){var d=$('<div id="box-popup" class="image">'+b+"</div>"),g=d.find("img");if(0===g.length)return n(b);g.hide();$.magnificPopup.open({items:{src:d,type:"inline"},callbacks:{open:function(){var a=this;g.on("click",function(){a.close()});setTimeout(function(){var a=c.resizeImage(g);d.css({backgroundColor:"#fff",width:a.width,height:"auto"});g.show("slow")},
|
||||
500)}}})},p={view:function(a){e.info("account:show");l(c.appRequests().getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},viewHistory:function(a){e.info("account:showHistory");l(c.appRequests().getRouteForQuery(a.data("action-route"),a.val()),"account")},edit:function(a){e.info("account:edit");l(c.appRequests().getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},"delete":function(a){e.info("account:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[3]+
|
||||
"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(d){d=c.appRequests().getRequestOpts();d.url=f.account.save;d.data={r:"account/saveDelete/"+a.data("item-id"),sk:c.sk.get()};c.appRequests().getActionCall(d,function(a){c.msg.out(a);p.search()})}}})},viewPass:function(a){e.info("account:showpass");var b=a.data("parent-id")||0,b=0===b?a.data("item-id"):
|
||||
b,d=a.data("history")||0,g=c.appRequests().getRequestOpts();g.url=f.entrypoint;g.method="get";g.data={r:a.data("action-route")+"/"+b+"/"+d,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(g,function(a){0!==a.status?c.msg.out(a):(a=$(a.data.html),n(a),k=setTimeout(function(){$.magnificPopup.close()},3E4),a.on("mouseleave",function(){clearTimeout(k);k=setTimeout(function(){$.magnificPopup.close()},3E4)}).on("mouseenter",function(){0!==k&&clearTimeout(k)}))})},copyPass:function(a){e.info("account:copypass");
|
||||
@@ -16,8 +16,8 @@ f.entrypoint+"?r="+a.data("action-route")+"/"+a.data("history-id")+"/"+a.data("i
|
||||
sk:c.sk.get()};c.appRequests().getActionCall(b,function(c){a.html(c)})},search:function(a){e.info("account:search");var b=$("#frmSearch");b.find("input[name='sk']").val(c.sk.get());b.find("input[name='skey']").val();b.find("input[name='sorder']").val();void 0!==a&&b.find("input[name='start']").val(0);a=c.appRequests().getRequestOpts();a.url=f.account.search;a.method="get";a.data=b.serialize();c.appRequests().getActionCall(a,function(a){10===a.status&&c.msg.out(a);c.sk.set(a.data.sk);$("#res-content").empty().html(a.data.html)})},
|
||||
save:function(a){e.info("account:save");var b=c.appRequests().getRequestOpts();b.url=f.account.save+"?r="+a.data("action-route")+"/"+a.data("item-id");b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&l(c.appRequests().getRouteForQuery(a.data.nextAction,a.data.itemId),"account")})}},r={get:function(a){e.info("items:get");var b=a[0].selectize;b.clearOptions();b.load(function(d){var g=c.appRequests().getRequestOpts();g.url=
|
||||
f.updateItems;g.method="get";g.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:a.data("sk")};c.appRequests().getActionCall(g,function(g){d(g.data);b.setValue(a.data("selected-id"),!0);c.appTriggers().updateFormHash()})})},update:function(a){e.info("items:update");var b=$("#"+a.data("item-dst"))[0].selectize;b.clearOptions();b.load(function(b){var d=c.appRequests().getRequestOpts();d.url=f.updateItems;d.method="get";d.data={r:a.data("item-route"),sk:c.sk.get()};c.appRequests().getActionCall(d,
|
||||
function(a){b(a)})})}},t={logout:function(){c.redirect("index.php?r=login/logout")},login:function(a){e.info("main:login");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("route");b.method="get";b.data=a.serialize();c.appRequests().getActionCall(b,function(b){var d=$(".extra-hidden");switch(b.status){case 0:c.redirect(b.data.url);break;case 2:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();0<d.length&&d.hide();$("#mpass").prop("disabled",
|
||||
!1).val("");$("#smpass").show();break;case 5:c.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();0<d.length&&d.hide();$("#oldpass").prop("disabled",!1).val("");$("#soldpass").show();break;default:c.msg.out(b),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){e.info("main:install");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("route");b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(a){b(a)})})}},t={logout:function(){c.redirect("index.php?r=login/logout")},login:function(a){e.info("main:login");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("route");b.method="get";b.data=a.serialize();c.appRequests().getActionCall(b,function(d){var b=$(".extra-hidden");switch(d.status){case 0:c.redirect(d.data.url);break;case 2:c.msg.out(d);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();0<b.length&&b.hide();$("#mpass").prop("disabled",
|
||||
!1).val("");$("#smpass").show();break;case 5:c.msg.out(d);a.find("input[type='text'],input[type='password']").val("");a.find("input:first").focus();0<b.length&&b.hide();$("#oldpass").prop("disabled",!1).val("");$("#soldpass").show();break;default:c.msg.out(d),a.find("input[type='text'],input[type='password']").val(""),a.find("input:first").focus()}})},install:function(a){e.info("main:install");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("route");b.data=a.serialize();c.appRequests().getActionCall(b,
|
||||
function(a){c.msg.out(a);0===a.status&&setTimeout(function(){c.redirect("index.php?r=login/index")},1E3)})},upgrade:function(a){e.info("main:upgrade");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[59]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=a.find("input[name='useTask']");var d=$("#taskStatus");d.empty().html(c.config().LANG[62]);
|
||||
if(0<b.length&&1==b.val()){b=c.appRequests().getRequestOpts();b.url=f.main.task;b.data={source:a.find("input[name='lock']").val(),taskId:a.find("input[name='taskId']").val()};var e=c.appRequests().getActionEvent(b,function(a){a=a.task+" - "+a.message+" - "+a.time+" - "+a.progress+"%";a+="<br>"+c.config().LANG[62];d.empty().html(a)})}b=c.appRequests().getRequestOpts();b.url=f.main.upgrade;b.method="get";b.useFullLoading=!0;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);
|
||||
0!==b.status?a.find(":input[name=h]").val(""):(void 0!==e&&e.close(),setTimeout(function(){c.redirect("index.php")},5E3))})}}})},getUpdates:function(){e.info("main:getUpdates");var a=c.appRequests().getRequestOpts();a.url=f.main.getUpdates;a.type="html";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};c.appRequests().getActionCall(a,function(a){$("#updates").html(a);void 0!==componentHandler&&componentHandler.upgradeDom()},function(){$("#updates").html("!")})}},h={state:{tab:{index:0,
|
||||
@@ -26,22 +26,22 @@ function(b){if(0!==b.status)c.msg.out(b);else{var d=a.data("item-dst");n(b.data.
|
||||
onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=f.entrypoint;b.method="get";b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){c.msg.out(a);l({r:h.state.tab.route,tabIndex:h.state.tab.index})})}}})},save:function(a){e.info("appMgmt:save");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+
|
||||
"?r="+a.data("route");b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&(!0===h.state.tab.refresh&&l({r:h.state.tab.route,tabIndex:h.state.tab.index}),$.magnificPopup.close())})},search:function(a){e.info("appMgmt:search");var b=$(a.data("target")),d=c.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");d.method="get";d.data=a.serialize();c.appRequests().getActionCall(d,function(a){0===a.status?b.html(a.data.html):b.html(c.msg.html.error(a.description));
|
||||
c.sk.set(a.csrf)})},nav:function(a){e.info("appMgmt:nav");var b=$("#"+a.data("action-form"));b.find("[name='start']").val(a.data("start"));b.find("[name='count']").val(a.data("count"));b.find("[name='sk']").val(c.sk.get());u.search(b)},ldapSync:function(a){e.info("appMgmt:ldapSync");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[57]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],
|
||||
onClick:function(b){b=c.appRequests().getRequestOpts();b.url=f.appMgmt.save;b.data={actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1,ldap_loginattribute:$("#ldap_loginattribute").val(),ldap_nameattribute:$("#ldap_nameattribute").val(),ldap_ads:$("#ldap_ads").prop("checked")};c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}}})}};return{doAction:m,appMgmt:u,account:p,file:{view:function(a){e.info("file:view");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint;b.method="get";b.data=
|
||||
{r:a.data("action-route")+"/"+a.data("item-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(b){if(1===b.status)return c.msg.out(b);v(a,b.data.html)})},download:function(a){e.info("file:download");a={r:a.data("action-route")+"/"+a.data("item-id"),sk:c.sk.get()};$.fileDownload(f.entrypoint,{httpMethod:"GET",data:a})},"delete":function(a){e.info("file:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[15]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],
|
||||
onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=f.entrypoint;b.method="get";b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&p.listFiles($("#list-account-files"))})}}})}},checks:{ldap:function(a){e.info("checks:ldap");a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());var b=c.appRequests().getRequestOpts();
|
||||
b.url=f.checks;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);var b=$("#ldap-results");b.find(".list-wrap").html(c.appTheme().html.getList(a.data));b.show("slow")})},wiki:function(a){e.info("checks:wiki");a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());var b=c.appRequests().getRequestOpts();b.url=f.checks;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){e.info("config:save");
|
||||
h.state.update(a);var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&(!0===h.state.tab.refresh?l({r:h.state.tab.route,tabIndex:h.state.tab.index}):void 0!==a.data("reload")&&setTimeout(function(){c.redirect("index.php")},2E3))})},masterpass:function(a){var b='<div id="alert"><p id="alert-text">'+c.config().LANG[59]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],
|
||||
onClick:function(b){b.preventDefault();c.msg.error(c.config().LANG[44]);a.find(":input[type=password]").val("")}},positive:{title:c.config().LANG[43],onClick:function(b){b=a.find("input[name='useTask']");var d=$("#taskStatus");d.empty().html(c.config().LANG[62]);0<b.length&&1==b.val()&&(b=c.appRequests().getRequestOpts(),b.url=f.main.task,b.data={source:a.find("input[name='lock']").val(),taskId:a.find("input[name='taskId']").val()},c.appRequests().getActionEvent(b,function(a){a=a.task+" - "+a.message+
|
||||
" - "+a.time+" - "+a.progress+"%";a+="<br>"+c.config().LANG[62];d.empty().html(a)}));b=c.appRequests().getRequestOpts();b.url=f.config.save;b.useFullLoading=!0;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);a.find(":input[type=password]").val("");void 0!==task&&task.close()})}}})},backup:function(a){e.info("config:backup");h.state.update(a);var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.useFullLoading=!0;b.data=a.serialize();
|
||||
c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&l({r:h.state.tab.route,tabIndex:h.state.tab.index})})},"export":function(a){e.info("config:export");h.state.update(a);var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&l({r:h.state.tab.route,tabIndex:h.state.tab.index})})},"import":function(a){e.info("config:import");var b=c.appRequests().getRequestOpts();
|
||||
b.url=f.entrypoint+"?r="+a.data("action-route");b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},refreshMpass:function(a){e.info("config:import");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.data={sk:a.data("sk"),isAjax:1};c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},main:t,user:{savePreferences:function(a){e.info("user:savePreferences");var b=c.appRequests().getRequestOpts();b.url=f.user.savePreferences;b.data=
|
||||
a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);setTimeout(function(){c.redirect("index.php")},2E3)})},password:function(a){e.info("user:password");var b=c.appRequests().getRequestOpts();b.type="html";b.method="get";b.url=f.user.password;b.data={actionId:a.data("action-id"),itemId:a.data("item-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){0===a.length?t.logout():n(a)})},passreset:function(a){e.info("user:passreset");var b=c.appRequests().getRequestOpts();
|
||||
b.url=f.user.passreset;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},2E3)})}},link:{save:function(a){e.info("link:save");var b=a.data("item-id"),d=c.appRequests().getRequestOpts();d.url=f.entrypoint;d.data={r:a.data("action-route"),accountId:b,notify:0,sk:c.sk.get(),isAjax:1};var g='<div id="alert"><p id="alert-text">'+c.config().LANG[48]+"</p></div>";mdlDialog().show({text:g,negative:{title:c.config().LANG[44],
|
||||
onClick:function(e){e.preventDefault();c.appRequests().getActionCall(d,function(d){c.msg.out(d);0===d.status&&l({r:a.data("action-next")+"/"+b})})}},positive:{title:c.config().LANG[43],onClick:function(e){e.preventDefault();d.data.notify=1;c.appRequests().getActionCall(d,function(d){c.msg.out(d);0===d.status&&l({r:a.data("action-next")+"/"+b})})}}})},refresh:function(a){e.info("link:refresh");h.state.update(a);var b=a.data("item-id"),d=c.appRequests().getRequestOpts();d.url=f.entrypoint;d.data={r:a.data("action-route")+
|
||||
"/"+b,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(d,function(d){c.msg.out(d);0===d.status&&((d=a.data("action-next"))?l({r:d+"/"+b}):l({r:h.state.tab.route,tabIndex:h.state.tab.index}))})}},eventlog:{nav:function(a){if(void 0===a.data("start"))return!1;var b=c.appRequests().getRequestOpts();b.url=f.eventlog;b.method="get";b.type="html";b.data={actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1,start:a.data("start"),count:a.data("count"),current:a.data("current")};c.appRequests().getActionCall(b,
|
||||
function(a){$("#content").html(a);c.scrollUp()})},clear:function(a){var b='<div id="alert"><p id="alert-text">'+c.config().LANG[20]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b=c.appRequests().getRequestOpts();b.url=f.eventlog;b.method="get";b.data={clear:1,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){c.msg.out(b);
|
||||
0==b.status&&m({actionId:a.data("nextaction-id")})})}}})}},ajaxUrl:f,plugin:{toggle:function(a){e.info("plugin:enable");a={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")};var b=c.appRequests().getRequestOpts();b.url=f.appMgmt.save;b.data=a;c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&setTimeout(function(){c.redirect("index.php")},2E3)})},reset:function(a){e.info("plugin:reset");var b='<div id="alert"><p id="alert-text">'+
|
||||
c.config().LANG[58]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")};var d=c.appRequests().getRequestOpts();d.url=f.appMgmt.save;d.data=b;c.appRequests().getActionCall(d,function(a){c.msg.out(a)})}}})}},notice:{check:function(a){e.info("notice:check");
|
||||
var b={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()},d=c.appRequests().getRequestOpts();d.url=f.appMgmt.save;d.data=b;c.appRequests().getActionCall(d,function(b){c.msg.out(b);0===b.status&&m({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},search:function(a){e.info("notice:search");var b=$(a.data("target")),d=c.appRequests().getRequestOpts();d.url=f.notice.search;d.method="get";d.data=a.serialize();c.appRequests().getActionCall(d,function(a){0===a.status?b.html(a.data.html):
|
||||
b.html(c.msg.html.error(a.description));c.sk.set(a.csrf)})},show:function(a){e.info("notice:show");var b=c.appRequests().getRequestOpts();b.url=f.notice.show;b.method="get";b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),activeTab:a.data("activetab"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){0!==a.status?c.msg.out(a):n(a.data.html)})}},wiki:{show:function(a){e.info("wiki:show");var b=c.appRequests().getRequestOpts();b.url=f.wiki.show;b.method="get";b.data={pageName:a.data("pagename"),
|
||||
actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){0!==a.status?c.msg.out(a):n(a.data.html)})}},items:r}};
|
||||
onClick:function(b){b=c.appRequests().getRequestOpts();b.url=f.appMgmt.save;b.data={actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1,ldap_loginattribute:$("#ldap_loginattribute").val(),ldap_nameattribute:$("#ldap_nameattribute").val(),ldap_ads:$("#ldap_ads").prop("checked")};c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}}})}},v={search:function(a){e.info("eventlog:search");var b=$(a.data("target")),d=c.appRequests().getRequestOpts();d.url=f.entrypoint+"?r="+a.data("action-route");
|
||||
d.method="get";d.data=a.serialize();c.appRequests().getActionCall(d,function(a){0===a.status?b.html(a.data.html):b.html(c.msg.html.error(a.description));c.sk.set(a.csrf)})},nav:function(a){e.info("eventlog:nav");var b=$("#"+a.data("action-form"));b.find("[name='start']").val(a.data("start"));b.find("[name='count']").val(a.data("count"));b.find("[name='sk']").val(c.sk.get());v.search(b)},clear:function(a){var b='<div id="alert"><p id="alert-text">'+c.config().LANG[20]+"</p></div>";mdlDialog().show({text:b,
|
||||
negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();$(a.data("target"));b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.method="get";b.data={sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&l({r:a.data("action-next")});c.sk.set(b.csrf)})}}})}};return{doAction:m,appMgmt:u,account:p,file:{view:function(a){e.info("file:view");
|
||||
var b=c.appRequests().getRequestOpts();b.url=f.entrypoint;b.method="get";b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(b){if(1===b.status)return c.msg.out(b);w(a,b.data.html)})},download:function(a){e.info("file:download");a={r:a.data("action-route")+"/"+a.data("item-id"),sk:c.sk.get()};$.fileDownload(f.entrypoint,{httpMethod:"GET",data:a})},"delete":function(a){e.info("file:delete");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[15]+
|
||||
"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b=c.appRequests().getRequestOpts();b.url=f.entrypoint;b.method="get";b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:c.sk.get()};c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&p.listFiles($("#list-account-files"))})}}})}},checks:{ldap:function(a){e.info("checks:ldap");
|
||||
a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());var b=c.appRequests().getRequestOpts();b.url=f.checks;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);var b=$("#ldap-results");b.find(".list-wrap").html(c.appTheme().html.getList(a.data));b.show("slow")})},wiki:function(a){e.info("checks:wiki");a=$(a.data("src"));a.find("[name='sk']").val(c.sk.get());var b=c.appRequests().getRequestOpts();b.url=f.checks;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);
|
||||
0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){e.info("config:save");h.state.update(a);var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);0===b.status&&(!0===h.state.tab.refresh?l({r:h.state.tab.route,tabIndex:h.state.tab.index}):void 0!==a.data("reload")&&setTimeout(function(){c.redirect("index.php")},2E3))})},masterpass:function(a){var b='<div id="alert"><p id="alert-text">'+
|
||||
c.config().LANG[59]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(b){b.preventDefault();c.msg.error(c.config().LANG[44]);a.find(":input[type=password]").val("")}},positive:{title:c.config().LANG[43],onClick:function(b){b=a.find("input[name='useTask']");var d=$("#taskStatus");d.empty().html(c.config().LANG[62]);0<b.length&&1==b.val()&&(b=c.appRequests().getRequestOpts(),b.url=f.main.task,b.data={source:a.find("input[name='lock']").val(),taskId:a.find("input[name='taskId']").val()},
|
||||
c.appRequests().getActionEvent(b,function(a){a=a.task+" - "+a.message+" - "+a.time+" - "+a.progress+"%";a+="<br>"+c.config().LANG[62];d.empty().html(a)}));b=c.appRequests().getRequestOpts();b.url=f.config.save;b.useFullLoading=!0;b.data=a.serialize();c.appRequests().getActionCall(b,function(b){c.msg.out(b);a.find(":input[type=password]").val("");void 0!==task&&task.close()})}}})},backup:function(a){e.info("config:backup");h.state.update(a);var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+
|
||||
"?r="+a.data("action-route");b.useFullLoading=!0;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&l({r:h.state.tab.route,tabIndex:h.state.tab.index})})},"export":function(a){e.info("config:export");h.state.update(a);var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0===a.status&&l({r:h.state.tab.route,tabIndex:h.state.tab.index})})},"import":function(a){e.info("config:import");
|
||||
var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a)})},refreshMpass:function(a){e.info("config:import");var b=c.appRequests().getRequestOpts();b.url=f.entrypoint+"?r="+a.data("action-route");b.data={sk:a.data("sk"),isAjax:1};c.appRequests().getActionCall(b,function(a){c.msg.out(a)})}},main:t,user:{savePreferences:function(a){e.info("user:savePreferences");var b=c.appRequests().getRequestOpts();
|
||||
b.url=f.user.savePreferences;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);setTimeout(function(){c.redirect("index.php")},2E3)})},password:function(a){e.info("user:password");var b=c.appRequests().getRequestOpts();b.type="html";b.method="get";b.url=f.user.password;b.data={actionId:a.data("action-id"),itemId:a.data("item-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){0===a.length?t.logout():n(a)})},passreset:function(a){e.info("user:passreset");
|
||||
var b=c.appRequests().getRequestOpts();b.url=f.user.passreset;b.data=a.serialize();c.appRequests().getActionCall(b,function(a){c.msg.out(a);0==a.status&&setTimeout(function(){c.redirect("index.php")},2E3)})}},link:{save:function(a){e.info("link:save");var b=a.data("item-id"),d=c.appRequests().getRequestOpts();d.url=f.entrypoint;d.data={r:a.data("action-route"),accountId:b,notify:0,sk:c.sk.get(),isAjax:1};var g='<div id="alert"><p id="alert-text">'+c.config().LANG[48]+"</p></div>";mdlDialog().show({text:g,
|
||||
negative:{title:c.config().LANG[44],onClick:function(e){e.preventDefault();c.appRequests().getActionCall(d,function(d){c.msg.out(d);0===d.status&&l({r:a.data("action-next")+"/"+b})})}},positive:{title:c.config().LANG[43],onClick:function(e){e.preventDefault();d.data.notify=1;c.appRequests().getActionCall(d,function(d){c.msg.out(d);0===d.status&&l({r:a.data("action-next")+"/"+b})})}}})},refresh:function(a){e.info("link:refresh");h.state.update(a);var b=a.data("item-id"),d=c.appRequests().getRequestOpts();
|
||||
d.url=f.entrypoint;d.data={r:a.data("action-route")+"/"+b,sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(d,function(d){c.msg.out(d);0===d.status&&((d=a.data("action-next"))?l({r:d+"/"+b}):l({r:h.state.tab.route,tabIndex:h.state.tab.index}))})}},eventlog:v,ajaxUrl:f,plugin:{toggle:function(a){e.info("plugin:enable");a={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")};var b=c.appRequests().getRequestOpts();b.url=f.appMgmt.save;b.data=a;c.appRequests().getActionCall(b,
|
||||
function(a){c.msg.out(a);0===a.status&&setTimeout(function(){c.redirect("index.php")},2E3)})},reset:function(a){e.info("plugin:reset");var b='<div id="alert"><p id="alert-text">'+c.config().LANG[58]+"</p></div>";mdlDialog().show({text:b,negative:{title:c.config().LANG[44],onClick:function(a){a.preventDefault();c.msg.error(c.config().LANG[44])}},positive:{title:c.config().LANG[43],onClick:function(b){b.preventDefault();b={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get(),activeTab:a.data("activetab")};
|
||||
var d=c.appRequests().getRequestOpts();d.url=f.appMgmt.save;d.data=b;c.appRequests().getActionCall(d,function(a){c.msg.out(a)})}}})}},notice:{check:function(a){e.info("notice:check");var b={itemId:a.data("item-id"),actionId:a.data("action-id"),sk:c.sk.get()},d=c.appRequests().getRequestOpts();d.url=f.appMgmt.save;d.data=b;c.appRequests().getActionCall(d,function(b){c.msg.out(b);0===b.status&&m({actionId:a.data("nextaction-id"),itemId:a.data("activetab")})})},search:function(a){e.info("notice:search");
|
||||
var b=$(a.data("target")),d=c.appRequests().getRequestOpts();d.url=f.notice.search;d.method="get";d.data=a.serialize();c.appRequests().getActionCall(d,function(a){0===a.status?b.html(a.data.html):b.html(c.msg.html.error(a.description));c.sk.set(a.csrf)})},show:function(a){e.info("notice:show");var b=c.appRequests().getRequestOpts();b.url=f.notice.show;b.method="get";b.data={itemId:a.data("item-id"),actionId:a.data("action-id"),activeTab:a.data("activetab"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,
|
||||
function(a){0!==a.status?c.msg.out(a):n(a.data.html)})}},wiki:{show:function(a){e.info("wiki:show");var b=c.appRequests().getRequestOpts();b.url=f.wiki.show;b.method="get";b.data={pageName:a.data("pagename"),actionId:a.data("action-id"),sk:c.sk.get(),isAjax:1};c.appRequests().getActionCall(b,function(a){0!==a.status?c.msg.out(a):n(a.data.html)})}},items:r}};
|
||||
|
||||
Reference in New Issue
Block a user