update table and add listing and collection class
This commit is contained in:
@@ -34,25 +34,13 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins");
|
||||
$admin_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/admin/tablelisting.admin.php';
|
||||
|
||||
/*
|
||||
$fields = array(
|
||||
'loginname' => $lng['login']['username'],
|
||||
'name' => $lng['customer']['name'],
|
||||
'diskspace' => $lng['customer']['diskspace'],
|
||||
'diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'traffic' => $lng['customer']['traffic'],
|
||||
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'deactivated' => $lng['admin']['deactivated']
|
||||
);
|
||||
*/
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Admins::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// get collection
|
||||
$collection = new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Admins::class, $userinfo);
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $admin_list_data['admin_list']['columns'], $result);
|
||||
// get list
|
||||
$json_result = Admins::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $admin_list_data['admin_list']['columns'], $collection->count());
|
||||
// get filtered collection
|
||||
$collection = new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Admins::class, $userinfo, $paging->getApiCommandParams());
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
@@ -115,7 +103,7 @@ if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
|
||||
*/
|
||||
|
||||
UI::twigBuffer('user/table.html.twig', [
|
||||
'api_response' => json_decode($json_result, true)['data'],
|
||||
'collection' => $collection->getData(),
|
||||
'table_options' => $admin_list_data['admin_list'],
|
||||
]);
|
||||
UI::twigOutputBuffer();
|
||||
|
||||
@@ -33,31 +33,14 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
|
||||
$customer_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/admin/tablelisting.customer.php';
|
||||
|
||||
/*
|
||||
$fields = array(
|
||||
'c.loginname' => $lng['login']['username'],
|
||||
'a.loginname' => $lng['admin']['admin'],
|
||||
'c.name' => $lng['customer']['name'],
|
||||
'c.email' => $lng['customer']['email'],
|
||||
'c.firstname' => $lng['customer']['firstname'],
|
||||
'c.company' => $lng['customer']['company'],
|
||||
'c.diskspace' => $lng['customer']['diskspace'],
|
||||
'c.diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'c.traffic' => $lng['customer']['traffic'],
|
||||
'c.traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
|
||||
);
|
||||
*/
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Customers::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
/*
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
*/
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $customer_list_data['customer_list']['columns'], $result);
|
||||
// get list
|
||||
$json_result = Customers::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
// get collection
|
||||
$collection = new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Customers::class, $userinfo);
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $customer_list_data['customer_list']['columns'], $collection->count());
|
||||
// get filtered collection
|
||||
$collection = new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Customers::class, $userinfo, $paging->getApiCommandParams());
|
||||
$collection->has('admin', \Froxlor\Api\Commands\Admins::class, 'adminid', 'adminid');
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
@@ -156,7 +139,7 @@ if ($page == 'customers' && $userinfo['customers'] != '0') {
|
||||
*/
|
||||
|
||||
UI::twigBuffer('user/table.html.twig', [
|
||||
'api_response' => json_decode($json_result, true)['data'],
|
||||
'collection' => $collection->getData(),
|
||||
'table_options' => $customer_list_data['customer_list'],
|
||||
]);
|
||||
UI::twigOutputBuffer();
|
||||
|
||||
@@ -24,6 +24,7 @@ use Froxlor\Api\Commands\Customers as Customers;
|
||||
use Froxlor\Api\Commands\Domains as Domains;
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\UI\Panel\UI;
|
||||
use Froxlor\UI\Request;
|
||||
|
||||
$id = (int) Request::get('id');
|
||||
@@ -34,54 +35,26 @@ if ($page == 'domains' || $page == 'overview') {
|
||||
$countcustomers = json_decode($json_result, true)['data'];
|
||||
|
||||
if ($action == '') {
|
||||
|
||||
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_domains");
|
||||
$fields = array(
|
||||
'd.domain_ace' => $lng['domains']['domainname'],
|
||||
'c.name' => $lng['customer']['name'],
|
||||
'c.firstname' => $lng['customer']['firstname'],
|
||||
'c.company' => $lng['customer']['company'],
|
||||
'c.loginname' => $lng['login']['username'],
|
||||
'd.aliasdomain' => $lng['domains']['aliasdomain']
|
||||
);
|
||||
try {
|
||||
// get total count
|
||||
$json_result = Domains::getLocal($userinfo)->listingCount();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
||||
// get list
|
||||
$json_result = Domains::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$domain_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/admin/tablelisting.domain.php';
|
||||
|
||||
$domains = '';
|
||||
$sortcode = $paging->getHtmlSortCode($lng);
|
||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
||||
try {
|
||||
// get collection
|
||||
$collection = new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Domains::class, $userinfo);
|
||||
// initialize pagination and filtering
|
||||
$paging = new \Froxlor\UI\Pagination($userinfo, $domain_list_data['domain_list']['columns'], $collection->count());
|
||||
// get filtered collection
|
||||
$collection = new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Domains::class, $userinfo, $paging->getApiCommandParams());
|
||||
$collection->has('customer', \Froxlor\Api\Commands\Customers::class, 'customerid', 'customerid');
|
||||
} catch (Exception $e) {
|
||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($result['list'] as $row) {
|
||||
formatDomainEntry($row, $idna_convert);
|
||||
$row['customername'] = \Froxlor\User::getCorrectFullUserDetails($row);
|
||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
||||
// display a nice list of IP's if it's not an alias for another domain
|
||||
if (isset($row['aliasdomainid']) && $row['aliasdomainid'] != null && isset($row['aliasdomain']) && $row['aliasdomain'] != '') {
|
||||
$row['ipandport'] = sprintf($lng['domains']['isaliasdomainof'], $row['aliasdomain']);
|
||||
} else {
|
||||
$row['ipandport'] = str_replace("\n", "<br />", $row['ipandport']);
|
||||
}
|
||||
eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";");
|
||||
$count++;
|
||||
}
|
||||
|
||||
$domainscount = $result['count'] . " / " . $paging->getEntries();
|
||||
|
||||
// Display the list
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domains") . "\";");
|
||||
UI::twigBuffer('user/table.html.twig', [
|
||||
'collection' => $collection->getData(),
|
||||
'table_options' => $domain_list_data['domain_list'],
|
||||
]);
|
||||
UI::twigOutputBuffer();
|
||||
} elseif ($action == 'delete' && $id != 0) {
|
||||
|
||||
try {
|
||||
|
||||
72
lib/Froxlor/UI/Collection.php
Normal file
72
lib/Froxlor/UI/Collection.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @author Maurice Preuß <hello@envoyr.com>
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Collection
|
||||
*
|
||||
*/
|
||||
class Collection
|
||||
{
|
||||
private array $items;
|
||||
private array $userInfo;
|
||||
private array $params;
|
||||
private string $class;
|
||||
|
||||
public function __construct($class, $userInfo, $params = [])
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->params = $params;
|
||||
$this->userInfo = $userInfo;
|
||||
|
||||
$this->items = $this->getListing($this->class, $this->params);
|
||||
}
|
||||
|
||||
private function getListing($class, $params)
|
||||
{
|
||||
return json_decode($class::getLocal($this->userInfo, $params)->listing(), true);
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return $this->get()['data']['count'];
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->get()['data'];
|
||||
}
|
||||
|
||||
public function getJson()
|
||||
{
|
||||
return json_encode($this->get());
|
||||
}
|
||||
|
||||
public function has($column, $class, $parentKey = 'id', $childKey = 'id', $params = [])
|
||||
{
|
||||
$attributes = $this->getListing($class, $params);
|
||||
|
||||
foreach ($this->items['data']['list'] as $key => $item) {
|
||||
foreach ($attributes['data']['list'] as $list) {
|
||||
if ($item[$parentKey] == $list[$childKey]) {
|
||||
$this->items['data']['list'][$key][$column] = $list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
lib/Froxlor/UI/Listing.php
Normal file
29
lib/Froxlor/UI/Listing.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Froxlor\UI;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @author Maurice Preuß <hello@envoyr.com>
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Listing
|
||||
*
|
||||
*/
|
||||
class Listing
|
||||
{
|
||||
public static function getVisibleColumnsForListing($listing, $default_columns)
|
||||
{
|
||||
// Hier käme dann die Logik, die das aus der DB zieht ...
|
||||
// alternativ nimmt er die $default_columns, wenn kein Eintrag
|
||||
// in der DB definiert ist
|
||||
|
||||
return $default_columns;
|
||||
}
|
||||
}
|
||||
@@ -22,38 +22,46 @@ return [
|
||||
'icon' => 'fa-solid fa-user',
|
||||
'columns' => [
|
||||
'adminid' => [
|
||||
'title' => '#',
|
||||
'label' => '#',
|
||||
'column' => 'adminid',
|
||||
'sortable' => true,
|
||||
],
|
||||
'loginname' => [
|
||||
'title' => $lng['login']['username'],
|
||||
'label' => $lng['login']['username'],
|
||||
'column' => 'loginname',
|
||||
'sortable' => true,
|
||||
],
|
||||
'name' => [
|
||||
'title' => $lng['customer']['name'],
|
||||
'label' => $lng['customer']['name'],
|
||||
'column' => 'name',
|
||||
],
|
||||
'diskspace' => [
|
||||
'title' => $lng['customer']['diskspace'],
|
||||
'label' => $lng['customer']['diskspace'],
|
||||
'column' => 'diskspace',
|
||||
'type' => 'usage',
|
||||
],
|
||||
'diskspace_used' => [
|
||||
'title' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'label' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'column' => 'diskspace_used',
|
||||
'type' => 'usage',
|
||||
],
|
||||
'traffic' => [
|
||||
'title' => $lng['customer']['traffic'],
|
||||
'label' => $lng['customer']['traffic'],
|
||||
'column' => 'traffic',
|
||||
'type' => 'usage',
|
||||
],
|
||||
'traffic_used' => [
|
||||
'title' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'label' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'column' => 'traffic_used',
|
||||
'type' => 'usage',
|
||||
],
|
||||
'deactivated' => [
|
||||
'title' => $lng['admin']['deactivated'],
|
||||
'label' => $lng['admin']['deactivated'],
|
||||
'column' => 'deactivated',
|
||||
'type' => 'boolean',
|
||||
],
|
||||
],
|
||||
'visible_columns' => getVisibleColumnsForListing('admin_list', [
|
||||
'visible_columns' => \Froxlor\UI\Listing::getVisibleColumnsForListing('admin_list', [
|
||||
'loginname',
|
||||
'name',
|
||||
'diskspace',
|
||||
@@ -68,7 +76,7 @@ return [
|
||||
'href' => '#',
|
||||
],
|
||||
'show' => [
|
||||
'title' => 'Show',
|
||||
'text' => 'Show',
|
||||
'href' => '#',
|
||||
]
|
||||
],
|
||||
@@ -90,13 +98,3 @@ return [
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
// Das müsste dann irgendwie als Klasse ausgelagert werden
|
||||
function getVisibleColumnsForListing($listing, $default_columns)
|
||||
{
|
||||
// Hier käme dann die Logik, die das aus der DB zieht ...
|
||||
// alternativ nimmt er die $default_columns, wenn kein Eintrag
|
||||
// in der DB definiert ist
|
||||
|
||||
return $default_columns;
|
||||
}
|
||||
|
||||
@@ -21,22 +21,61 @@ return [
|
||||
'title' => $lng['admin']['customers'],
|
||||
'icon' => 'fa-solid fa-user',
|
||||
'columns' => [
|
||||
'loginname' => [
|
||||
'title' => $lng['login']['username']
|
||||
'c.loginname' => [
|
||||
'label' => $lng['login']['username'],
|
||||
'column' => 'loginname',
|
||||
],
|
||||
'a.loginname' => [
|
||||
'label' => $lng['admin']['admin'],
|
||||
'column' => 'admin.loginname',
|
||||
],
|
||||
'c.name' => [
|
||||
'label' => $lng['customer']['name'],
|
||||
'column' => 'name',
|
||||
],
|
||||
'c.email' => [
|
||||
'label' => $lng['customer']['email'],
|
||||
'column' => 'email',
|
||||
],
|
||||
'c.firstname' => [
|
||||
'label' => $lng['customer']['firstname'],
|
||||
'column' => 'firstname',
|
||||
],
|
||||
'c.company' => [
|
||||
'label' => $lng['customer']['company'],
|
||||
'column' => 'company',
|
||||
],
|
||||
'c.diskspace' => [
|
||||
'label' => $lng['customer']['diskspace'],
|
||||
'column' => 'diskspace',
|
||||
'type' => 'usage'
|
||||
],
|
||||
'c.diskspace_used' => [
|
||||
'label' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'column' => 'diskspace_used',
|
||||
'type' => 'usage'
|
||||
],
|
||||
'c.traffic' => [
|
||||
'label' => $lng['customer']['traffic'],
|
||||
'column' => 'traffic',
|
||||
'type' => 'usage'
|
||||
],
|
||||
'c.traffic_used' => [
|
||||
'label' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
|
||||
'column' => 'traffic_used',
|
||||
'type' => 'usage'
|
||||
],
|
||||
],
|
||||
'visible_columns' => getVisibleColumnsForListing('admin_list', [
|
||||
'loginname',
|
||||
'visible_columns' => \Froxlor\UI\Listing::getVisibleColumnsForListing('customer_list', [
|
||||
'c.loginname',
|
||||
'a.loginname',
|
||||
'c.email',
|
||||
'c.firstname',
|
||||
'c.company',
|
||||
'c.diskspace',
|
||||
'c.diskspace_used',
|
||||
'c.traffic',
|
||||
'c.traffic_used',
|
||||
]),
|
||||
]
|
||||
];
|
||||
|
||||
// Das müsste dann irgendwie als Klasse ausgelagert werden
|
||||
function getVisibleColumnsForListing($listing, $default_columns)
|
||||
{
|
||||
// Hier käme dann die Logik, die das aus der DB zieht ...
|
||||
// alternativ nimmt er die $default_columns, wenn kein Eintrag
|
||||
// in der DB definiert ist
|
||||
|
||||
return $default_columns;
|
||||
}
|
||||
|
||||
58
lib/tablelisting/admin/admin/tablelisting.domain.php
Normal file
58
lib/tablelisting/admin/admin/tablelisting.domain.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @author Maurice Preuß <hello@envoyr.com>
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Tabellisting
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
'domain_list' => [
|
||||
'title' => $lng['admin']['domains'],
|
||||
'icon' => 'fa-solid fa-user',
|
||||
'columns' => [
|
||||
'd.domain_ace' => [
|
||||
'label' => $lng['domains']['domainname'],
|
||||
'column' => 'domain_ace',
|
||||
],
|
||||
'c.name' => [
|
||||
'label' => $lng['customer']['name'],
|
||||
'column' => 'customer.name',
|
||||
],
|
||||
'c.firstname' => [
|
||||
'label' => $lng['customer']['firstname'],
|
||||
'column' => 'customer.firstname',
|
||||
],
|
||||
'c.company' => [
|
||||
'label' => $lng['customer']['company'],
|
||||
'column' => 'customer.company',
|
||||
],
|
||||
'c.loginname' => [
|
||||
'label' => $lng['login']['username'],
|
||||
'column' => 'customer.loginname',
|
||||
],
|
||||
'd.aliasdomain' => [
|
||||
'label' => $lng['domains']['aliasdomain'],
|
||||
'column' => 'aliasdomain',
|
||||
],
|
||||
],
|
||||
'visible_columns' => \Froxlor\UI\Listing::getVisibleColumnsForListing('domain_list', [
|
||||
'd.domain_ace',
|
||||
'c.name',
|
||||
'c.firstname',
|
||||
'c.company',
|
||||
'c.loginname',
|
||||
'd.aliasdomain',
|
||||
]),
|
||||
]
|
||||
];
|
||||
@@ -1,4 +1,4 @@
|
||||
{% macro table(table_options, api_response, action, title = "") %}
|
||||
{% macro table(table_options, collection, action, title = "") %}
|
||||
|
||||
{% import "Froxlor/table/tablemacros.html.twig" as tablemacros %}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
</h3>
|
||||
{% endif %}
|
||||
|
||||
<div class="card">
|
||||
<div class="card table-responsive">
|
||||
<table class="table table-borderless table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for column in table_options.visible_columns %}
|
||||
<th class="p-3">{{ table_options.columns[column].title }}</th>
|
||||
<th class="p-3">{{ table_options.columns[column].label }}</th>
|
||||
{% endfor %}
|
||||
{% if table_options.actions %}
|
||||
<th class="p-3 text-end">Actions</th>
|
||||
@@ -25,16 +25,16 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for columns in api_response.list %}
|
||||
{% for columns in collection.list %}
|
||||
<tr class="{{ tablemacros.contextual_class(table_options.contextual_class, columns)|trim }}">
|
||||
{% for column in table_options.visible_columns %}
|
||||
<td class="p-3">
|
||||
{% if table_options.columns[column].type is empty %}
|
||||
{{ columns[column] }}
|
||||
{{ tablemacros.column(columns, table_options.columns[column].column)|trim }}
|
||||
{% elseif table_options.columns[column].type == 'boolean' %}
|
||||
{{ tablemacros.boolean(columns[column]) }}
|
||||
{{ tablemacros.boolean(tablemacros.column(columns, table_options.columns[column].column)|trim) }}
|
||||
{% elseif table_options.columns[column].type == 'usage' %}
|
||||
{{ tablemacros.usage(columns[column]) }}
|
||||
{{ tablemacros.usage(tablemacros.column(columns, table_options.columns[column].column)|trim) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% macro contextual_class(contextual_class, columns) %}
|
||||
{# this could be refactored as filter #}
|
||||
{% for i_key,i_column in columns %}
|
||||
{% for c_key, c_column in contextual_class %}
|
||||
{% if i_key == c_key %}
|
||||
@@ -12,7 +13,6 @@
|
||||
{{ c_column.return }}
|
||||
{% endif %}
|
||||
{% elseif c_column.column is not empty %}
|
||||
check for {{ columns[c_column.column] }}
|
||||
{# check for column #}
|
||||
{% if c_column.operator is empty and columns[c_column.column] == i_column %}
|
||||
{{ c_column.return }}
|
||||
@@ -37,4 +37,17 @@
|
||||
|
||||
{% macro usage(value) %}
|
||||
{{ value }}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro column(arr, str) %}
|
||||
{# this could be refactored as filter #}
|
||||
{% set strarr = str|split('.') %}
|
||||
|
||||
{% if strarr|length == 1 %}
|
||||
{{ arr[strarr[0]] }}
|
||||
{% elseif strarr|length == 2 %}
|
||||
{{ arr[strarr[0]][strarr[1]] }}
|
||||
{% else %}
|
||||
column depth not supported
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
@@ -4,6 +4,6 @@
|
||||
|
||||
{% import "Froxlor/table/table.html.twig" as table %}
|
||||
|
||||
{{ table.table(table_options, api_response, '#', table_options.title) }}
|
||||
{{ table.table(table_options, collection, '#', table_options.title) }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user