2020-06-03 21:29:40 +02:00
|
|
|
<?php
|
2022-11-29 21:21:26 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-06-03 21:29:40 +02:00
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
2023-01-09 22:51:12 +01:00
|
|
|
use App\Services\Attachments\AttachmentPathResolver;
|
2023-03-03 23:42:02 +01:00
|
|
|
use App\Services\Attachments\AttachmentSubmitHandler;
|
2023-01-09 22:51:12 +01:00
|
|
|
use App\Services\Attachments\AttachmentURLGenerator;
|
|
|
|
use App\Services\Attachments\BuiltinAttachmentsFinder;
|
2022-12-18 17:28:42 +01:00
|
|
|
use App\Services\Misc\GitVersionInfo;
|
2022-11-06 01:07:10 +01:00
|
|
|
use App\Services\Misc\DBInfoHelper;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
2020-06-03 21:29:40 +02:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
2023-01-09 22:51:12 +01:00
|
|
|
use Symfony\Component\Routing\Generator\UrlGenerator;
|
2020-06-03 21:29:40 +02:00
|
|
|
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Route(path: '/tools')]
|
2020-06-03 21:29:40 +02:00
|
|
|
class ToolsController extends AbstractController
|
|
|
|
{
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Route(path: '/reel_calc', name: 'tools_reel_calculator')]
|
2020-08-21 21:36:22 +02:00
|
|
|
public function reelCalculator(): Response
|
2020-06-03 21:29:40 +02:00
|
|
|
{
|
2020-06-03 22:19:59 +02:00
|
|
|
$this->denyAccessUnlessGranted('@tools.reel_calculator');
|
|
|
|
|
2023-02-04 22:55:16 +01:00
|
|
|
return $this->render('tools/reel_calculator/reel_calculator.html.twig');
|
2020-06-03 21:29:40 +02:00
|
|
|
}
|
2022-11-06 01:07:10 +01:00
|
|
|
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Route(path: '/server_infos', name: 'tools_server_infos')]
|
2023-03-03 23:42:02 +01:00
|
|
|
public function systemInfos(GitVersionInfo $versionInfo, DBInfoHelper $DBInfoHelper,
|
|
|
|
AttachmentSubmitHandler $attachmentSubmitHandler): Response
|
2022-11-06 01:07:10 +01:00
|
|
|
{
|
|
|
|
$this->denyAccessUnlessGranted('@system.server_infos');
|
|
|
|
|
2023-02-05 00:14:57 +01:00
|
|
|
return $this->render('tools/server_infos/server_infos.html.twig', [
|
2022-11-06 01:07:10 +01:00
|
|
|
//Part-DB section
|
|
|
|
'git_branch' => $versionInfo->getGitBranchName(),
|
|
|
|
'git_commit' => $versionInfo->getGitCommitHash(),
|
|
|
|
'default_locale' => $this->getParameter('partdb.locale'),
|
|
|
|
'default_timezone' => $this->getParameter('partdb.timezone'),
|
|
|
|
'default_currency' => $this->getParameter('partdb.default_currency'),
|
|
|
|
'default_theme' => $this->getParameter('partdb.global_theme'),
|
|
|
|
'enabled_locales' => $this->getParameter('partdb.locale_menu'),
|
|
|
|
'demo_mode' => $this->getParameter('partdb.demo_mode'),
|
2023-06-11 14:50:47 +02:00
|
|
|
'gpdr_compliance' => $this->getParameter('partdb.gdpr_compliance'),
|
2022-11-06 01:07:10 +01:00
|
|
|
'use_gravatar' => $this->getParameter('partdb.users.use_gravatar'),
|
|
|
|
'email_password_reset' => $this->getParameter('partdb.users.email_pw_reset'),
|
|
|
|
'enviroment' => $this->getParameter('kernel.environment'),
|
|
|
|
'is_debug' => $this->getParameter('kernel.debug'),
|
|
|
|
'email_sender' => $this->getParameter('partdb.mail.sender_email'),
|
|
|
|
'email_sender_name' => $this->getParameter('partdb.mail.sender_name'),
|
|
|
|
'allow_attachments_downloads' => $this->getParameter('partdb.attachments.allow_downloads'),
|
|
|
|
'detailed_error_pages' => $this->getParameter('partdb.error_pages.show_help'),
|
|
|
|
'error_page_admin_email' => $this->getParameter('partdb.error_pages.admin_email'),
|
2023-03-03 23:42:02 +01:00
|
|
|
'configured_max_file_size' => $this->getParameter('partdb.attachments.max_file_size'),
|
|
|
|
'effective_max_file_size' => $attachmentSubmitHandler->getMaximumAllowedUploadSize(),
|
2023-03-04 17:27:09 +01:00
|
|
|
'saml_enabled' => $this->getParameter('partdb.saml.enabled'),
|
2022-11-06 01:07:10 +01:00
|
|
|
|
|
|
|
//PHP section
|
|
|
|
'php_version' => PHP_VERSION,
|
|
|
|
'php_uname' => php_uname('a'),
|
|
|
|
'php_sapi' => PHP_SAPI,
|
2023-06-11 14:15:46 +02:00
|
|
|
'php_extensions' => [...get_loaded_extensions()],
|
2022-11-06 01:07:10 +01:00
|
|
|
'php_opcache_enabled' => ini_get('opcache.enable'),
|
|
|
|
'php_upload_max_filesize' => ini_get('upload_max_filesize'),
|
|
|
|
'php_post_max_size' => ini_get('post_max_size'),
|
|
|
|
|
|
|
|
//DB section
|
|
|
|
'db_type' => $DBInfoHelper->getDatabaseType() ?? 'Unknown',
|
|
|
|
'db_version' => $DBInfoHelper->getDatabaseVersion() ?? 'Unknown',
|
2023-01-16 00:06:14 +01:00
|
|
|
'db_size' => $DBInfoHelper->getDatabaseSize(),
|
2023-01-16 00:15:15 +01:00
|
|
|
'db_name' => $DBInfoHelper->getDatabaseName() ?? 'Unknown',
|
|
|
|
'db_user' => $DBInfoHelper->getDatabaseUsername() ?? 'Unknown',
|
2022-11-06 01:07:10 +01:00
|
|
|
]);
|
|
|
|
}
|
2023-01-09 22:51:12 +01:00
|
|
|
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Route(path: '/builtin_footprints', name: 'tools_builtin_footprints_viewer')]
|
2023-01-10 15:15:13 +01:00
|
|
|
public function builtInFootprintsViewer(BuiltinAttachmentsFinder $builtinAttachmentsFinder, AttachmentURLGenerator $urlGenerator): Response
|
2023-01-09 22:51:12 +01:00
|
|
|
{
|
2023-01-09 23:40:54 +01:00
|
|
|
$this->denyAccessUnlessGranted('@tools.builtin_footprints_viewer');
|
|
|
|
|
2023-01-09 22:51:12 +01:00
|
|
|
$grouped_footprints = $builtinAttachmentsFinder->getListOfFootprintsGroupedByFolder();
|
2023-06-11 14:15:46 +02:00
|
|
|
$grouped_footprints = array_map(fn($group) => array_map(fn($placeholder_filepath) => [
|
|
|
|
'filename' => basename((string) $placeholder_filepath),
|
|
|
|
'assets_path' => $urlGenerator->placeholderPathToAssetPath($placeholder_filepath),
|
|
|
|
], $group), $grouped_footprints);
|
2023-01-09 22:51:12 +01:00
|
|
|
|
2023-02-04 22:55:16 +01:00
|
|
|
return $this->render('tools/builtin_footprints_viewer/builtin_footprints_viewer.html.twig', [
|
2023-01-09 22:51:12 +01:00
|
|
|
'grouped_footprints' => $grouped_footprints,
|
|
|
|
]);
|
|
|
|
}
|
2023-01-12 00:14:31 +01:00
|
|
|
|
2023-05-28 01:21:05 +02:00
|
|
|
#[Route(path: '/ic_logos', name: 'tools_ic_logos')]
|
2023-01-12 00:14:31 +01:00
|
|
|
public function icLogos(): Response
|
|
|
|
{
|
|
|
|
$this->denyAccessUnlessGranted('@tools.ic_logos');
|
|
|
|
|
2023-02-04 22:55:16 +01:00
|
|
|
return $this->render('tools/ic_logos/ic_logos.html.twig');
|
2023-01-12 00:14:31 +01:00
|
|
|
}
|
2020-08-21 21:36:22 +02:00
|
|
|
}
|