This commit is contained in:
Билай Станислав 2024-12-27 13:50:37 +03:00
parent 28c8e24847
commit 1a54003030
21 changed files with 118 additions and 77 deletions

View File

@ -26,10 +26,13 @@
<div class="wrapper d-flex align-items-stretch"> <div class="wrapper d-flex align-items-stretch">
<nav id="sidebar"> <nav id="sidebar">
<div class="p-4 pt-5"> <div class="p-4 pt-5">
<a href="<?= '/admin/user/view/' . \kernel\modules\user\service\UserService::getAuthUser()->id ?>" class="img logo rounded-circle mb-5" <a href="<?= '/admin/user/profile' ?>" class="img logo rounded-circle mb-5"
style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/images/noPhoto.png' ?>);"></a> style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/default_user_photo/noPhoto.png' ?>);">
</a>
<p> <p>
<a href="<?= '/admin/user/profile' ?>">
<?= \kernel\modules\user\service\UserService::getAuthUsername() ?> <?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
</a>
</p> </p>
<?php \kernel\widgets\MenuWidget::create()->run(); ?> <?php \kernel\widgets\MenuWidget::create()->run(); ?>
<div class="footer"> <div class="footer">

View File

@ -13,8 +13,9 @@ class BootstrapSelectFilter extends Filter
{ {
$select = SelectBuilder::build($this->name, [ $select = SelectBuilder::build($this->name, [
'class' => 'form-control', 'class' => 'form-control',
'options' => $this->param, 'options' => $this->params['options'],
'value' => $this->value, 'value' => $this->value,
'prompt' => $this->params['prompt'] ?? null,
]); ]);
return "<td>" . $select->create()->fetch() . "</td>"; return "<td>" . $select->create()->fetch() . "</td>";

View File

@ -1,23 +0,0 @@
<?php
namespace kernel\filters;
use itguild\forms\builders\SelectBuilder;
use Itguild\Tables\Filter\Filter;
use kernel\helpers\Debug;
class BootstrapSelectFilterWithPrompt extends Filter
{
public function fetch(): string
{
$select = SelectBuilder::build($this->name, [
'class' => 'form-control',
'options' => $this->param,
'value' => $this->value,
'prompt' => "Не выбрано"
]);
return "<td>" . $select->create()->fetch() . "</td>";
}
}

View File

@ -156,24 +156,71 @@ class ModuleShopClientController extends AdminController
$this->redirect('/admin/module_shop_client', 302); $this->redirect('/admin/module_shop_client', 302);
} }
// public function actionSearch(int $page_number = 1): void
// {
// $request = new Request();
// $filters = $request->get();
//// Debug::dd($filters);
// if ($this->moduleService->issetModuleShopToken()) {
// if ($this->moduleService->isServerAvailable()) {
// $modules_info = [];
// $per_page = 8;
// $modules = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
// $modules = json_decode($modules->getBody()->getContents(), true);
// foreach ($modules as $module) {
// foreach ($filters as $key => $value) {
// if ($value === '') continue;
// if ($module[$key] !== $value) {
// break;
// }
//
// $modules_info[] = $module;
// }
// }
// $module_count = count($modules_info);
// $modules_info = array_slice($modules_info, $per_page * ($page_number - 1), $per_page);
//
// $this->cgView->render("index.php", [
// 'modules_info' => $modules_info,
// 'moduleService' => $this->moduleService,
// 'page_number' => $page_number,
// 'module_count' => $module_count,
// 'per_page' => $per_page,
// 'kernelService' => new KernelService(),
// 'adminThemeService' => new AdminThemeService(),
// 'filterValues' => $filters
// ]);
// } else {
// $this->cgView->render("module_shop_error_connection.php");
// }
//
// } else {
// $this->cgView->render("login_at_module_shop.php");
// }
// }
public function actionSearch(int $page_number = 1): void public function actionSearch(int $page_number = 1): void
{ {
$request = new Request(); $request = new Request();
$filters = $request->get(); $filters = $request->get();
if ($this->moduleService->issetModuleShopToken()) { if ($this->moduleService->issetModuleShopToken()) {
if ($this->moduleService->isServerAvailable()) { if ($this->moduleService->isServerAvailable()) {
$modules_info = []; // $modules_info = [];
$per_page = 8; $per_page = 8;
$modules = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug'); $modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
$modules = json_decode($modules->getBody()->getContents(), true); $modules_info = json_decode($modules_info->getBody()->getContents(), true);
foreach ($modules as $module) { foreach ($modules_info as $key => $module) {
foreach ($filters as $key => $value) { foreach ($filters as $column => $value) {
if ($value === '') continue; if ($value === '') continue;
if ($module[$key] !== $value) { if (is_numeric($value)) {
break; if ($module[$column] !== $value) {
unset($modules_info[$key]);
}
} elseif (is_string($value)) {
if (!str_contains($module[$column], $value)) {
unset($modules_info[$key]);
}
} }
$modules_info[] = $module;
} }
} }
$module_count = count($modules_info); $module_count = count($modules_info);

View File

@ -12,6 +12,7 @@
use Itguild\Tables\ListJsonTable; use Itguild\Tables\ListJsonTable;
use kernel\widgets\ActionButtonWidget; use kernel\widgets\ActionButtonWidget;
$meta = []; $meta = [];
$meta['columns'] = [ $meta['columns'] = [
"name" => "Название", "name" => "Название",
@ -42,11 +43,14 @@ $table->addAction(function ($row, $url) use ($moduleService) {
$table->columns([ $table->columns([
'type' => [ 'type' => [
'filter' => [ 'filter' => [
'class' => \kernel\filters\BootstrapSelectFilterWithPrompt::class, 'class' => \kernel\filters\BootstrapSelectFilter::class,
'param' => [ 'params' => [
'options' => [
'kernel' => 'kernel', 'kernel' => 'kernel',
'entity' => 'entity', 'entity' => 'entity',
], ],
'prompt' => 'Не выбрано'
],
'value' => $filterValues['type'] ?? '' 'value' => $filterValues['type'] ?? ''
], ],
] ]

View File

@ -26,8 +26,6 @@ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
'searchParams' => $get, 'searchParams' => $get,
])); ]));
//\kernel\helpers\Debug::dd((new \kernel\Request())->get());
$view->setTitle("Список постов"); $view->setTitle("Список постов");
$view->setMeta([ $view->setMeta([
'description' => 'Список постов системы' 'description' => 'Список постов системы'
@ -72,12 +70,13 @@ $table->columns([
return User::find($data)->username; return User::find($data)->username;
}, },
'filter' => [ 'filter' => [
'class' => \kernel\filters\BootstrapSelectFilterWithPrompt::class, 'class' => \kernel\filters\BootstrapSelectFilter::class,
'param' => \kernel\modules\user\service\UserService::createUsernameArr(), 'params' => [
'value' => $get['user_id'] ?? '', 'options' => \kernel\modules\user\service\UserService::createUsernameArr(),
'prompt' => 'dsds' 'prompt' => 'Не выбрано'
],
'value' => $get['user_id'] ?? '',
], ],
'prompt' => 'dsds'
] ]
]); ]);

View File

@ -144,4 +144,13 @@ class UserController extends AdminController
$this->redirect("/admin/user/"); $this->redirect("/admin/user/");
} }
public function actionProfile(): void
{
$user = UserService::getAuthUser();
if (!$user){
throw new Exception(message: "The user not found");
}
$this->cgView->render("view.php", ['user' => $user]);
}
} }

View File

@ -17,6 +17,7 @@ App::$collector->group(["prefix" => "admin"], function (RouteCollector $router){
App::$collector->any('/update/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionUpdate']); App::$collector->any('/update/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionUpdate']);
App::$collector->any("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']); App::$collector->any("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']);
App::$collector->get('/delete/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionDelete']); App::$collector->get('/delete/{id}', [\kernel\modules\user\controllers\UserController::class, 'actionDelete']);
App::$collector->get('/profile', [\kernel\modules\user\controllers\UserController::class, 'actionProfile']);
}); });
}); });
}); });

View File

@ -1,9 +1,9 @@
// Responsive images (ensure images don't scale beyond their parents) // Responsive default_user_photo (ensure default_user_photo don't scale beyond their parents)
// //
// This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s. // This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s.
// We previously tried the "images are responsive by default" approach in Bootstrap v2, // We previously tried the "default_user_photo are responsive by default" approach in Bootstrap v2,
// and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps) // and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps)
// which weren't expecting the images within themselves to be involuntarily resized. // which weren't expecting the default_user_photo within themselves to be involuntarily resized.
// See also https://github.com/twbs/bootstrap/issues/18178 // See also https://github.com/twbs/bootstrap/issues/18178
.img-fluid { .img-fluid {
@include img-fluid; @include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img { img {
vertical-align: middle; vertical-align: middle;
border-style: none; // Remove the border on images inside links in IE 10-. border-style: none; // Remove the border on default_user_photo inside links in IE 10-.
} }
svg { svg {

View File

@ -5,12 +5,12 @@
// Responsive image // Responsive image
// //
// Keep images from scaling beyond the width of their parents. // Keep default_user_photo from scaling beyond the width of their parents.
@mixin img-fluid { @mixin img-fluid {
// Part 1: Set a maximum relative to the parent // Part 1: Set a maximum relative to the parent
max-width: 100%; max-width: 100%;
// Part 2: Override the height to auto, otherwise images will be stretched // Part 2: Override the height to auto, otherwise default_user_photo will be stretched
// when setting a width and height attribute on the img element. // when setting a width and height attribute on the img element.
height: auto; height: auto;
} }

View File

@ -1,9 +1,9 @@
// Responsive images (ensure images don't scale beyond their parents) // Responsive default_user_photo (ensure default_user_photo don't scale beyond their parents)
// //
// This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s. // This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s.
// We previously tried the "images are responsive by default" approach in Bootstrap v2, // We previously tried the "default_user_photo are responsive by default" approach in Bootstrap v2,
// and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps) // and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps)
// which weren't expecting the images within themselves to be involuntarily resized. // which weren't expecting the default_user_photo within themselves to be involuntarily resized.
// See also https://github.com/twbs/bootstrap/issues/18178 // See also https://github.com/twbs/bootstrap/issues/18178
.img-fluid { .img-fluid {
@include img-fluid; @include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img { img {
vertical-align: middle; vertical-align: middle;
border-style: none; // Remove the border on images inside links in IE 10-. border-style: none; // Remove the border on default_user_photo inside links in IE 10-.
} }
svg { svg {

View File

@ -5,12 +5,12 @@
// Responsive image // Responsive image
// //
// Keep images from scaling beyond the width of their parents. // Keep default_user_photo from scaling beyond the width of their parents.
@mixin img-fluid { @mixin img-fluid {
// Part 1: Set a maximum relative to the parent // Part 1: Set a maximum relative to the parent
max-width: 100%; max-width: 100%;
// Part 2: Override the height to auto, otherwise images will be stretched // Part 2: Override the height to auto, otherwise default_user_photo will be stretched
// when setting a width and height attribute on the img element. // when setting a width and height attribute on the img element.
height: auto; height: auto;
} }

View File

@ -1,9 +1,9 @@
// Responsive images (ensure images don't scale beyond their parents) // Responsive default_user_photo (ensure default_user_photo don't scale beyond their parents)
// //
// This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s. // This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s.
// We previously tried the "images are responsive by default" approach in Bootstrap v2, // We previously tried the "default_user_photo are responsive by default" approach in Bootstrap v2,
// and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps) // and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps)
// which weren't expecting the images within themselves to be involuntarily resized. // which weren't expecting the default_user_photo within themselves to be involuntarily resized.
// See also https://github.com/twbs/bootstrap/issues/18178 // See also https://github.com/twbs/bootstrap/issues/18178
.img-fluid { .img-fluid {
@include img-fluid; @include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img { img {
vertical-align: middle; vertical-align: middle;
border-style: none; // Remove the border on images inside links in IE 10-. border-style: none; // Remove the border on default_user_photo inside links in IE 10-.
} }
svg { svg {

View File

@ -5,12 +5,12 @@
// Responsive image // Responsive image
// //
// Keep images from scaling beyond the width of their parents. // Keep default_user_photo from scaling beyond the width of their parents.
@mixin img-fluid { @mixin img-fluid {
// Part 1: Set a maximum relative to the parent // Part 1: Set a maximum relative to the parent
max-width: 100%; max-width: 100%;
// Part 2: Override the height to auto, otherwise images will be stretched // Part 2: Override the height to auto, otherwise default_user_photo will be stretched
// when setting a width and height attribute on the img element. // when setting a width and height attribute on the img element.
height: auto; height: auto;
} }

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -1,9 +1,9 @@
// Responsive images (ensure images don't scale beyond their parents) // Responsive default_user_photo (ensure default_user_photo don't scale beyond their parents)
// //
// This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s. // This is purposefully opt-in via an explicit class rather than being the default for all `<img>`s.
// We previously tried the "images are responsive by default" approach in Bootstrap v2, // We previously tried the "default_user_photo are responsive by default" approach in Bootstrap v2,
// and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps) // and abandoned it in Bootstrap v3 because it breaks lots of third-party widgets (including Google Maps)
// which weren't expecting the images within themselves to be involuntarily resized. // which weren't expecting the default_user_photo within themselves to be involuntarily resized.
// See also https://github.com/twbs/bootstrap/issues/18178 // See also https://github.com/twbs/bootstrap/issues/18178
.img-fluid { .img-fluid {
@include img-fluid; @include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img { img {
vertical-align: middle; vertical-align: middle;
border-style: none; // Remove the border on images inside links in IE 10-. border-style: none; // Remove the border on default_user_photo inside links in IE 10-.
} }
svg { svg {

View File

@ -5,12 +5,12 @@
// Responsive image // Responsive image
// //
// Keep images from scaling beyond the width of their parents. // Keep default_user_photo from scaling beyond the width of their parents.
@mixin img-fluid { @mixin img-fluid {
// Part 1: Set a maximum relative to the parent // Part 1: Set a maximum relative to the parent
max-width: 100%; max-width: 100%;
// Part 2: Override the height to auto, otherwise images will be stretched // Part 2: Override the height to auto, otherwise default_user_photo will be stretched
// when setting a width and height attribute on the img element. // when setting a width and height attribute on the img element.
height: auto; height: auto;
} }