- Added new controller components/Filter.php

- Added new library FilterCmptLib
- Fixed includes paths in FHC-Footer and FHC-Header
- Moved the LogsViewer tool to VUE+BS5
This commit is contained in:
Paolo
2022-06-02 10:32:26 +02:00
parent 061780a0d2
commit 29002124cc
8 changed files with 1823 additions and 26 deletions
@@ -0,0 +1,61 @@
<?php
$filterCmptArray = array(
'query' => '
SELECT wsl.webservicelog_id AS "LogId",
wsl.request_id AS "RequestId",
wsl.execute_time AS "ExecutionTime",
wsl.execute_user AS "ExecutedBy",
wsl.beschreibung AS "Description",
wsl.request_data AS "Data",
wsl.webservicetyp_kurzbz AS "WebserviceType"
FROM system.tbl_webservicelog wsl
ORDER BY wsl.execute_time DESC
',
'requiredPermissions' => 'admin',
'datasetRepresentation' => 'tablesorter',
'columnsAliases' => array(
'Log id',
'Request id',
'Execution time',
'Executed by',
'Producer',
'Data',
'Webservice type'
),
'formatRow' => function($datasetRaw) {
$datasetRaw->ExecutionTime = date_format(date_create($datasetRaw->ExecutionTime), 'd.m.Y H:i:s:u');
return $datasetRaw;
},
'markRow' => function($datasetRaw) {
$mark = '';
if (strpos($datasetRaw->RequestId, 'error') != false)
{
$mark = 'text-red';
}
if (strpos($datasetRaw->RequestId, 'info') != false)
{
$mark = 'text-green';
}
if (strpos($datasetRaw->RequestId, 'warning') != false)
{
$mark = 'text-orange';
}
if (strpos($datasetRaw->RequestId, 'debug') != false)
{
$mark = 'text-info';
}
return $mark;
}
);
$filterCmptArray['app'] = 'core';
$filterCmptArray['datasetName'] = 'logs';
+20 -16
View File
@@ -15,7 +15,7 @@ $config['navigation_header'] = array(
'description' => 'Organisation',
'sort' => 20,
'requiredPermissions' => 'basis/vilesci:r',
'children'=> array(
'children' => array(
'vilesci' => array(
'link' => base_url('vilesci'),
'icon' => '',
@@ -40,7 +40,7 @@ $config['navigation_header'] = array(
'description' => 'Lehre',
'sort' => 30,
'requiredPermissions' => 'basis/vilesci:r',
'children'=> array(
'children' => array(
'cis' => array(
'link' => CIS_ROOT,
'icon' => '',
@@ -71,16 +71,16 @@ $config['navigation_header'] = array(
'lehre/lehrauftrag_erteilen:r'
)
),
'zverfueg' => array(
'link' => site_url('lehre/lvplanung/AdminZeitverfuegbarkeit'),
'description' => 'Zeitverf&uuml;gbarkeit',
'expand' => true,
'sort' => 45,
'requiredPermissions' => array(
'lehre/zeitverfuegbarkeit:rw',
'lehre/zeitverfuegbarkeit:rw'
)
),
'zverfueg' => array(
'link' => site_url('lehre/lvplanung/AdminZeitverfuegbarkeit'),
'description' => 'Zeitverf&uuml;gbarkeit',
'expand' => true,
'sort' => 45,
'requiredPermissions' => array(
'lehre/zeitverfuegbarkeit:rw',
'lehre/zeitverfuegbarkeit:rw'
)
),
'zgvueberpruefung' => array(
'link' => site_url('system/infocenter/ZGVUeberpruefung'),
'description' => 'ZGV Überprüfung',
@@ -98,7 +98,7 @@ $config['navigation_header'] = array(
'description' => 'Personen',
'sort' => 40,
'requiredPermissions' => 'basis/vilesci:r',
'children'=> array(
'children' => array(
'messages' => array(
'link' => site_url('system/messages/MessageClient/read'),
'icon' => '',
@@ -129,7 +129,7 @@ $config['navigation_header'] = array(
'expand' => false,
'sort' => 50,
'requiredPermissions' => 'admin:r',
'children'=> array(
'children' => array(
'extensions' => array(
'link' => site_url('system/extensions/Manager'),
'description' => 'Extensions Manager',
@@ -194,7 +194,8 @@ $config['navigation_menu']['lehre/lehrauftrag/Lehrauftrag/*'] = array(
'icon' => 'dashboard',
'sort' => 1,
'requiredPermissions' => array('lehre/lehrauftrag_bestellen:r','lehre/lehrauftrag_erteilen:r')
),'lehrauftragBestellen' => array(
),
'lehrauftragBestellen' => array(
'link' => site_url('lehre/lehrauftrag/Lehrauftrag'),
'description' => 'Lehrauftrag bestellen',
'icon' => '',
@@ -216,6 +217,7 @@ $config['navigation_menu']['lehre/lehrauftrag/Lehrauftrag/*'] = array(
'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r')
)
);
$config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array(
'lehrauftragDashboard' => array(
'link' => site_url('lehre/lehrauftrag/Lehrauftrag/Dashboard'),
@@ -223,7 +225,8 @@ $config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array(
'icon' => 'dashboard',
'sort' => 1,
'requiredPermissions' => array('lehre/lehrauftrag_bestellen:r','lehre/lehrauftrag_erteilen:r')
),'lehrauftragBestellen' => array(
),
'lehrauftragBestellen' => array(
'link' => site_url('lehre/lehrauftrag/Lehrauftrag'),
'description' => 'Lehrauftrag bestellen',
'icon' => '',
@@ -245,3 +248,4 @@ $config['navigation_menu']['lehre/lehrauftrag/LehrauftragErteilen/*'] = array(
'requiredPermissions' => array('lehre/lehrauftrag_erteilen:r')
)
);
@@ -0,0 +1,294 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the FilterCmptLib (back-end)
* Provides data to the ajax get calls about the filter cmpt
* Accepts ajax post calls to change the filter data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
* NOTE: extends the FHC_Controller instead of the Auth_Controller because the FilterCmpt has its
* own permissions check
*/
class Filter extends FHC_Controller
{
const FILTER_UNIQUE_ID = 'filterUniqueId'; // Name of the filter cmpt unique id
const FILTER_TYPE = 'filterType'; //
/**
* Calls the parent's constructor and loads the FilterCmptLib
*/
public function __construct()
{
parent::__construct();
// Loads authentication library and starts authentication
$this->load->library('AuthLib');
// Loads the FilterCmptLib with HTTP GET/POST parameters
$this->_loadFilterCmptLib();
// Checks if the caller is allow to read this data
$this->_isAllowed();
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Retrieves data about the current filter from the session and will be written on the output in JSON format
*/
public function getFilter()
{
$this->outputJsonSuccess($this->filtercmptlib->getSession());
}
/**
* Retrieves the number of records present in the current dataset and will be written on the output in JSON format
*/
public function rowNumber()
{
$rowNumber = 0;
$dataset = $this->filtercmptlib->getSessionElement(FilterCmptLib::SESSION_DATASET);
if (isset($dataset) && is_array($dataset))
{
$rowNumber = count($dataset);
}
$this->outputJsonSuccess($rowNumber);
}
/**
* Change the sort of the selected fields of the current filter and
* its data will be written on the output in JSON format
*/
public function sortSelectedFields()
{
$selectedFields = $this->input->post('selectedFields');
if ($this->filtercmptlib->sortSelectedFields($selectedFields) == true)
{
$this->getFilter();
}
else
{
$this->outputJsonError('Wrong parameter');
}
}
/**
* Remove a selected field from the current filter and
* its data will be written on the output in JSON format
*/
public function removeSelectedField()
{
$selectedField = $this->input->post('selectedField');
if ($this->filtercmptlib->removeSelectedField($selectedField) == true)
{
$this->getFilter();
}
else
{
$this->outputJsonError('Wrong parameter');
}
}
/**
* Add a field to the current filter and its data will be written on the output in JSON format
*/
public function addSelectedField()
{
$selectedField = $this->input->post('selectedField');
if ($this->filtercmptlib->addSelectedField($selectedField) == true)
{
$this->getFilter();
}
else
{
$this->outputJsonError('Wrong parameter');
}
}
/**
* Remove an applied filter (SQL where condition) from the current filter
*/
public function removeAppliedFilter()
{
$appliedFilter = $this->input->post('appliedFilter');
if ($this->filtercmptlib->removeAppliedFilter($appliedFilter) == true)
{
$this->outputJsonSuccess('Removed');
}
else
{
$this->outputJsonError('Wrong parameter');
}
}
/**
* Apply all the applied filters (SQL where conditions) to the current filter
*/
public function applyFilters()
{
$appliedFilters = $this->input->post('appliedFilters');
$appliedFiltersOperations = $this->input->post('appliedFiltersOperations');
$appliedFiltersConditions = $this->input->post('appliedFiltersConditions');
$appliedFiltersOptions = $this->input->post('appliedFiltersOptions');
if ($this->filtercmptlib->applyFilters(
$appliedFilters,
$appliedFiltersOperations,
$appliedFiltersConditions,
$appliedFiltersOptions
) == true)
{
$this->outputJsonSuccess('Applied');
}
else
{
$this->outputJsonError('Wrong parameter');
}
}
/**
* Add a filter (SQL where clause) to be applied to the current filter
*/
public function addFilter()
{
$filter = $this->input->post('filter');
if ($this->filtercmptlib->addFilter($filter) == true)
{
$this->getFilter();
}
else
{
$this->outputJsonError('Wrong parameter');
}
}
/**
* Save the current filter as a custom filter for this user with the given description
*/
public function saveCustomFilter()
{
$customFilterDescription = $this->input->post('customFilterDescription');
if ($this->filtercmptlib->saveCustomFilter($customFilterDescription) == true)
{
$this->outputJsonSuccess('Saved');
}
else
{
$this->outputJsonError('An error occurred while saving a custom filter');
}
}
/**
* Remove a custom filter by its filter_id
*/
public function removeCustomFilter()
{
$filter_id = $this->input->post('filter_id');
if ($this->filtercmptlib->removeCustomFilter($filter_id) == true)
{
$this->outputJsonSuccess('Removed');
}
else
{
$this->outputJsonError('Wrong parameter');
}
}
/**
* Reloads the dataset
*/
public function reloadDataset()
{
$this->filtercmptlib->reloadDataset();
$this->outputJsonSuccess('Success');
}
/**
* Define the navigation menu for the current filter widget
*/
public function generateFilterMenu()
{
// Generates the filters menu
$this->outputJsonSuccess($this->filtercmptlib->generateFilterMenu($this->input->get(FilterCmptLib::NAVIGATION_PAGE)));
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Checks if the user is allowed to use this filter
*/
private function _isAllowed()
{
if (!$this->filtercmptlib->isAllowed())
{
$this->terminateWithJsonError('You are not allowed to access to this content');
}
}
/**
* Loads the FilterCmptLib with the FILTER_UNIQUE_ID parameter
* If the parameter FILTER_UNIQUE_ID is not given then the execution of the controller is terminated and
* an error message is printed
*/
private function _loadFilterCmptLib()
{
// If the parameter FILTER_UNIQUE_ID is present in the HTTP GET or POST
if (isset($_GET[self::FILTER_UNIQUE_ID]) || isset($_POST[self::FILTER_UNIQUE_ID]))
{
$filterUniqueId = null;
// If it is present in the HTTP GET
if (isset($_GET[self::FILTER_UNIQUE_ID]))
{
$filterUniqueId = $this->input->get(self::FILTER_UNIQUE_ID); // is retrieved from the HTTP GET
}
elseif (isset($_POST[self::FILTER_UNIQUE_ID])) // Else if it is present in the HTTP POST
{
$filterUniqueId = $this->input->post(self::FILTER_UNIQUE_ID); // is retrieved from the HTTP POST
}
// Loads the FilterCmptLib that contains all the used logic
$this->load->library('FilterCmptLib');
$this->filtercmptlib->setFilterUniqueId($filterUniqueId);
}
else // Otherwise an error will be written in the output
{
$this->terminateWithJsonError('Parameter "'.self::FILTER_UNIQUE_ID.'" not provided!');
}
// If provided
if (isset($_GET[self::FILTER_TYPE]) || isset($_POST[self::FILTER_TYPE]))
{
$filterType = null;
// If it is present in the HTTP GET
if (isset($_GET[self::FILTER_TYPE]))
{
$filterType = $this->input->get(self::FILTER_TYPE); // is retrieved from the HTTP GET
}
elseif (isset($_POST[self::FILTER_TYPE])) // Else if it is present in the HTTP POST
{
$filterType = $this->input->post(self::FILTER_TYPE); // is retrieved from the HTTP POST
}
$this->filtercmptlib->setFilterType($filterType);
}
$this->filtercmptlib->setFilterId($this->input->get('filterId'));
}
}
File diff suppressed because it is too large Load Diff
+1
View File
@@ -77,3 +77,4 @@
echo $this->widgetlib->widget('FilterWidget', $filterWidgetArray);
?>
+5 -4
View File
@@ -7,6 +7,7 @@
'tablesorter2' => true,
'vue3' => true,
'ajaxlib' => true,
'jqueryui1' => true,
'filtercomponent' => true,
'navigationcomponent' => true,
'phrases' => array(
@@ -21,8 +22,8 @@
<div id="main">
<!-- NavigationWidget -->
<navigation-widget :add-side-menu-entries="appSideMenuEntries"></navigation-widget>
<!-- Navigation component -->
<core-navigation-cmpt :add-side-menu-entries="appSideMenuEntries"></core-navigation-cmpt>
<div id="content">
<div class="row">
@@ -33,8 +34,8 @@
</div>
</div>
<div>
<!-- FilterWidget -->
<filter-widget filter-type="LogsViewer" @nw-new-entry="newSideMenuEntryHandler"></filter-widget>
<!-- Filter component -->
<core-filter-cmpt filter-type="LogsViewer" @nw-new-entry="newSideMenuEntryHandler"></core-filter-cmpt>
</div>
</div>
</div>
@@ -82,7 +82,6 @@
{
generateJSsInclude('vendor/mottie/tablesorter/dist/js/jquery.tablesorter.min.js');
generateJSsInclude('vendor/mottie/tablesorter/dist/js/jquery.tablesorter.widgets.min.js');
generateJSsInclude('vendor/mottie/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js');
}
// Tabulator 4 JS
+1 -5
View File
@@ -67,11 +67,7 @@
if ($captcha3 === true) generateCSSsInclude('vendor/dapphp/securimage/securimage.css');
// Table sorter CSS
if ($tablesorter2 === true)
{
generateCSSsInclude('vendor/mottie/tablesorter/dist/css/theme.default.min.css');
generateCSSsInclude('vendor/mottie/tablesorter/dist/css/jquery.tablesorter.pager.min.css');
}
if ($tablesorter2 === true) generateCSSsInclude('vendor/mottie/tablesorter/dist/css/theme.default.min.css');
// Tabulator 4 CSS
if ($tabulator4 === true)