optimize reset and ux
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
|
mto.kernel.dir: '%kernel.project_dir%'
|
||||||
|
|
||||||
mto.index.chunk_size: 800
|
mto.index.chunk_size: 800
|
||||||
mto.index.chunk_overlap: 100
|
mto.index.chunk_overlap: 100
|
||||||
mto.index.embedding_model: 'nomic-embed-text'
|
mto.index.embedding_model: 'nomic-embed-text'
|
||||||
@@ -11,6 +13,8 @@ parameters:
|
|||||||
|
|
||||||
mto.vector.python_bin: '/var/www/html/.venv/bin/python3'
|
mto.vector.python_bin: '/var/www/html/.venv/bin/python3'
|
||||||
mto.vector.ingest_script: '/src/Vector/vector_ingest.py'
|
mto.vector.ingest_script: '/src/Vector/vector_ingest.py'
|
||||||
|
|
||||||
|
mto.vector.data.path: '%kernel.project_dir%/var/knowledge'
|
||||||
mto.vector.timeout: 600
|
mto.vector.timeout: 600
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ final class DashboardController extends AbstractController
|
|||||||
{
|
{
|
||||||
return $this->render('admin/dashboard/index.html.twig');
|
return $this->render('admin/dashboard/index.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,24 +8,21 @@ use App\Entity\IngestJob;
|
|||||||
use App\Service\DocumentService;
|
use App\Service\DocumentService;
|
||||||
use App\Service\FormatText;
|
use App\Service\FormatText;
|
||||||
use App\Service\IngestJobService;
|
use App\Service\IngestJobService;
|
||||||
|
use Doctrine\DBAL\Connection;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
use Symfony\Component\Uid\Uuid;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||||
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\Uid\Uuid;
|
||||||
|
|
||||||
#[Route('/admin/documents')]
|
#[Route('/admin/documents')]
|
||||||
class DocumentController extends AbstractController
|
class DocumentController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(
|
|
||||||
private readonly FormatText $formatText,
|
|
||||||
)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route('', name: 'admin_documents')]
|
#[Route('', name: 'admin_documents')]
|
||||||
public function index(EntityManagerInterface $em): Response
|
public function index(EntityManagerInterface $em): Response
|
||||||
@@ -63,14 +60,14 @@ class DocumentController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/new', name: 'admin_document_new')]
|
#[Route('/new', name: 'admin_document_new')]
|
||||||
public function new(Request $request, DocumentService $documentService): Response
|
public function new(Request $request, DocumentService $documentService, FormatText $formatText): Response
|
||||||
{
|
{
|
||||||
if ($request->isMethod('POST')) {
|
if ($request->isMethod('POST')) {
|
||||||
|
|
||||||
|
|
||||||
$file = $request->files->get('file');
|
$file = $request->files->get('file');
|
||||||
$title = $request->request->get('title') ?: $file->getClientOriginalName();
|
$title = $request->request->get('title') ?: $file->getClientOriginalName();
|
||||||
$title = $this->formatText->slugify($title);
|
$title = $formatText->slugify($title);
|
||||||
|
|
||||||
if (!$file || !$title) {
|
if (!$file || !$title) {
|
||||||
$this->addFlash('error', 'Titel und Datei sind erforderlich.');
|
$this->addFlash('error', 'Titel und Datei sind erforderlich.');
|
||||||
@@ -111,7 +108,8 @@ class DocumentController extends AbstractController
|
|||||||
Request $request,
|
Request $request,
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
DocumentService $documentService
|
DocumentService $documentService
|
||||||
): Response {
|
): Response
|
||||||
|
{
|
||||||
|
|
||||||
$document = $em->getRepository(Document::class)->find($id);
|
$document = $em->getRepository(Document::class)->find($id);
|
||||||
|
|
||||||
@@ -169,7 +167,8 @@ class DocumentController extends AbstractController
|
|||||||
Request $request,
|
Request $request,
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
DocumentService $documentService
|
DocumentService $documentService
|
||||||
): RedirectResponse {
|
): RedirectResponse
|
||||||
|
{
|
||||||
|
|
||||||
if (!$this->isCsrfTokenValid('activate_version', $request->request->get('_token'))) {
|
if (!$this->isCsrfTokenValid('activate_version', $request->request->get('_token'))) {
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
@@ -199,7 +198,8 @@ class DocumentController extends AbstractController
|
|||||||
Request $request,
|
Request $request,
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
IngestJobService $jobService,
|
IngestJobService $jobService,
|
||||||
): ?RedirectResponse {
|
): ?RedirectResponse
|
||||||
|
{
|
||||||
$dryRun = false;
|
$dryRun = false;
|
||||||
if (!$this->isCsrfTokenValid('ingest_version', $request->request->get('_token'))) {
|
if (!$this->isCsrfTokenValid('ingest_version', $request->request->get('_token'))) {
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
@@ -265,4 +265,28 @@ class DocumentController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route(
|
||||||
|
'/reset',
|
||||||
|
name: 'admin_document_reset',
|
||||||
|
methods: ['POST']
|
||||||
|
)]
|
||||||
|
public function resetCompleteSystem(ParameterBagInterface $params, Connection $connection): ?RedirectResponse
|
||||||
|
{
|
||||||
|
@unlink($params->get('mto.vector.data.path') . '/index.ndjson');
|
||||||
|
@unlink($params->get('mto.vector.data.path') . '/vector.index');
|
||||||
|
@unlink($params->get('mto.vector.data.path') . '/vector.index.meta.json');
|
||||||
|
$sql = '
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
TRUNCATE TABLE db.document;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
TRUNCATE TABLE db.document_version;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
TRUNCATE TABLE db.ingest_job;
|
||||||
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
';
|
||||||
|
$connection->executeQuery($sql);
|
||||||
|
return $this->redirectToRoute('admin_dashboard');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,17 @@
|
|||||||
|
|
||||||
<hr class="border-secondary">
|
<hr class="border-secondary">
|
||||||
|
|
||||||
|
<form method="post" action="/admin/documents/reset" class="text-danger" onsubmit="return resetSystem()">
|
||||||
|
<p class="fw-bold">Reset des Systems</p>
|
||||||
|
<p>Unwiderruflicher Reset des gesamten Systems</p>
|
||||||
|
<button type="submit" class="btn btn-outline-danger">Reset System</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function resetSystem() {
|
||||||
|
return confirm('Sind Sie sicher, dass Sie das gesamte System zurücksetzen möchten?');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user