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">
<nav id="sidebar">
<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"
style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/images/noPhoto.png' ?>);"></a>
<a href="<?= '/admin/user/profile' ?>" class="img logo rounded-circle mb-5"
style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/default_user_photo/noPhoto.png' ?>);">
</a>
<p>
<?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
<a href="<?= '/admin/user/profile' ?>">
<?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
</a>
</p>
<?php \kernel\widgets\MenuWidget::create()->run(); ?>
<div class="footer">
@ -74,15 +77,15 @@
</div>
</nav>
<?php if (\kernel\Flash::hasMessage("error")): ?>
<div class="alert alert-danger alert-dismissible mainAlert">
<?= \kernel\Flash::getMessage("error"); ?>
<button type="button" class="btn-close closeAlertBtn"></button>
</div>
<div class="alert alert-danger alert-dismissible mainAlert">
<?= \kernel\Flash::getMessage("error"); ?>
<button type="button" class="btn-close closeAlertBtn"></button>
</div>
<?php endif; ?>
<?php if (\kernel\Flash::hasMessage("success")): ?>
<div class="alert alert-success alert-dismissible">
<?= \kernel\Flash::getMessage("success"); ?>
<button type="button" class="btn-close closeAlertBtn" ></button>
<button type="button" class="btn-close closeAlertBtn"></button>
</div>
<?php endif; ?>
<?= $content ?>

View File

@ -13,8 +13,9 @@ class BootstrapSelectFilter extends Filter
{
$select = SelectBuilder::build($this->name, [
'class' => 'form-control',
'options' => $this->param,
'options' => $this->params['options'],
'value' => $this->value,
'prompt' => $this->params['prompt'] ?? null,
]);
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);
}
// 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
{
$request = new Request();
$filters = $request->get();
if ($this->moduleService->issetModuleShopToken()) {
if ($this->moduleService->isServerAvailable()) {
$modules_info = [];
// $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) {
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
foreach ($modules_info as $key => $module) {
foreach ($filters as $column => $value) {
if ($value === '') continue;
if ($module[$key] !== $value) {
break;
if (is_numeric($value)) {
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);
@ -209,7 +256,7 @@ class ModuleShopClientController extends AdminController
$moduleShopService = new ModuleShopService();
$result = $moduleShopService->email_auth($address);
if ($result['status'] == 'success'){
if ($result['status'] == 'success') {
$this->cgView->render('enter_code.php', ['email' => $address]);
}
@ -224,7 +271,7 @@ class ModuleShopClientController extends AdminController
$moduleShopService = new ModuleShopService();
$result = $moduleShopService->code_check($code);
if (isset($result['access_token'])){
if (isset($result['access_token'])) {
$envFile = \EnvEditor\EnvFile::loadFrom(ROOT_DIR . "/.env");

View File

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

View File

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

View File

@ -144,4 +144,13 @@ class UserController extends AdminController
$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("/edit/{id}", [\kernel\modules\user\controllers\UserController::class, 'actionEdit']);
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.
// 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)
// 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
.img-fluid {
@include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img {
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 {

View File

@ -5,12 +5,12 @@
// 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 {
// Part 1: Set a maximum relative to the parent
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.
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.
// 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)
// 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
.img-fluid {
@include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img {
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 {

View File

@ -5,12 +5,12 @@
// 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 {
// Part 1: Set a maximum relative to the parent
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.
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.
// 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)
// 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
.img-fluid {
@include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img {
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 {

View File

@ -5,12 +5,12 @@
// 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 {
// Part 1: Set a maximum relative to the parent
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.
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.
// 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)
// 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
.img-fluid {
@include img-fluid;

View File

@ -249,7 +249,7 @@ figure {
img {
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 {

View File

@ -5,12 +5,12 @@
// 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 {
// Part 1: Set a maximum relative to the parent
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.
height: auto;
}