diff --git a/composer.lock b/composer.lock index 8e21dbf..85f25c5 100644 --- a/composer.lock +++ b/composer.lock @@ -6260,7 +6260,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -6268,6 +6268,6 @@ "ext-ctype": "*", "ext-iconv": "*" }, - "platform-dev": [], - "plugin-api-version": "2.6.0" + "platform-dev": {}, + "plugin-api-version": "2.9.0" } diff --git a/composer.phar b/composer.phar new file mode 100755 index 0000000..43f4b99 Binary files /dev/null and b/composer.phar differ diff --git a/migrations/Version20260812162507.php b/migrations/Version20260812162507.php new file mode 100644 index 0000000..3f72071 --- /dev/null +++ b/migrations/Version20260812162507.php @@ -0,0 +1,31 @@ +addSql('CREATE TABLE exercise_session (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(255) DEFAULT NULL, started_at DATETIME NOT NULL, ended_at DATETIME DEFAULT NULL, duration INT NOT NULL, distance NUMERIC(10, 0) NOT NULL, calories INT NOT NULL, notes LONGTEXT DEFAULT NULL, source VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci`'); + $this->addSql('ALTER TABLE settings CHANGE latitude latitude VARCHAR(255) DEFAULT NULL, CHANGE longitude longitude VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE settings RENAME INDEX uniq_settings_user TO UNIQ_E545A0C5A76ED395'); + $this->addSql('ALTER TABLE task CHANGE is_outdoor is_outdoor TINYINT NOT NULL, CHANGE weather_profile weather_profile VARCHAR(30) NOT NULL'); + $this->addSql('ALTER TABLE weather_forecast RENAME INDEX idx_forecast_settings TO IDX_CB36DFBF59949888'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP TABLE exercise_session'); + $this->addSql('ALTER TABLE settings CHANGE latitude latitude NUMERIC(10, 7) DEFAULT NULL, CHANGE longitude longitude NUMERIC(10, 7) DEFAULT NULL'); + $this->addSql('ALTER TABLE settings RENAME INDEX uniq_e545a0c5a76ed395 TO UNIQ_SETTINGS_USER'); + $this->addSql('ALTER TABLE task CHANGE is_outdoor is_outdoor TINYINT DEFAULT 0 NOT NULL, CHANGE weather_profile weather_profile VARCHAR(30) DEFAULT \'none\' NOT NULL'); + $this->addSql('ALTER TABLE weather_forecast RENAME INDEX idx_cb36dfbf59949888 TO IDX_FORECAST_SETTINGS'); + } +} diff --git a/src/Controller/BraindumpController.php b/src/Controller/BraindumpController.php new file mode 100644 index 0000000..9123d3f --- /dev/null +++ b/src/Controller/BraindumpController.php @@ -0,0 +1,47 @@ +render('braindump/index.html.twig'); + } + + #[Route('/braindump/dump', name: 'app_braindump_dump', methods: ['POST'])] + public function dump( + Request $request, + HttpClientInterface $client + ): Response { + if (!$this->isCsrfTokenValid( + 'braindump_dump', + $request->getPayload()->getString('_token') + )) { + throw $this->createAccessDeniedException('Invalid CSRF token.'); + } + + $brainDump = $request->getPayload()->getString('brain_dump'); + + $response = $client->request('POST', 'http://192.168.1.238:11434/api/generate', [ + 'json' => [ + 'model' => 'qwen3:4b', + 'prompt' => $brainDump, + 'stream' => false, + ], + ]); + + $data = $response->toArray(); + + return $this->render('braindump/_task_result.html.twig', [ + 'response' => $data['response'] ?? 'No response received.', + ]); + } +} \ No newline at end of file diff --git a/src/Controller/ExcerciseSessionController.php b/src/Controller/ExcerciseSessionController.php deleted file mode 100644 index c844623..0000000 --- a/src/Controller/ExcerciseSessionController.php +++ /dev/null @@ -1,18 +0,0 @@ -render('excercise_session/index.html.twig', [ - 'controller_name' => 'ExcerciseSessionController', - ]); - } -} diff --git a/src/Controller/ExerciseSessionController.php b/src/Controller/ExerciseSessionController.php new file mode 100644 index 0000000..6b7f66d --- /dev/null +++ b/src/Controller/ExerciseSessionController.php @@ -0,0 +1,81 @@ +render('exercise_session/index.html.twig', [ + 'exercise_sessions' => $exerciseSessionRepository->findAll(), + ]); + } + + #[Route('/new', name: 'app_exercise_session_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $exerciseSession = new ExerciseSession(); + $form = $this->createForm(ExerciseSessionType::class, $exerciseSession); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($exerciseSession); + $entityManager->flush(); + + return $this->redirectToRoute('app_exercise_session_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('exercise_session/new.html.twig', [ + 'exercise_session' => $exerciseSession, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_exercise_session_show', methods: ['GET'])] + public function show(ExerciseSession $exerciseSession): Response + { + return $this->render('exercise_session/show.html.twig', [ + 'exercise_session' => $exerciseSession, + ]); + } + + #[Route('/{id}/edit', name: 'app_exercise_session_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, ExerciseSession $exerciseSession, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(ExerciseSessionType::class, $exerciseSession); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_exercise_session_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('exercise_session/edit.html.twig', [ + 'exercise_session' => $exerciseSession, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_exercise_session_delete', methods: ['POST'])] + public function delete(Request $request, ExerciseSession $exerciseSession, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$exerciseSession->getId(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($exerciseSession); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_exercise_session_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Form/ExerciseSessionType.php b/src/Form/ExerciseSessionType.php new file mode 100644 index 0000000..bc9661a --- /dev/null +++ b/src/Form/ExerciseSessionType.php @@ -0,0 +1,39 @@ +add('type') + ->add('startedAt', null, [ + 'widget' => 'single_text', + ]) + ->add('endedAt', null, [ + 'widget' => 'single_text', + ]) + ->add('duration') + ->add('distance') + ->add('calories') + ->add('notes') + ->add('source') + ->add('createdAt', null, [ + 'widget' => 'single_text', + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => ExerciseSession::class, + ]); + } +} diff --git a/templates/braindump/_task_result.html.twig b/templates/braindump/_task_result.html.twig new file mode 100644 index 0000000..45bb1b6 --- /dev/null +++ b/templates/braindump/_task_result.html.twig @@ -0,0 +1,5 @@ +
{{ response|nl2br }}
+| Id | +Type | +StartedAt | +EndedAt | +Duration | +Distance | +Calories | +Notes | +Source | +CreatedAt | +actions | +
|---|---|---|---|---|---|---|---|---|---|---|
| {{ exercise_session.id }} | +{{ exercise_session.type }} | +{{ exercise_session.startedAt ? exercise_session.startedAt|date('Y-m-d H:i:s') : '' }} | +{{ exercise_session.endedAt ? exercise_session.endedAt|date('Y-m-d H:i:s') : '' }} | +{{ exercise_session.duration }} | +{{ exercise_session.distance }} | +{{ exercise_session.calories }} | +{{ exercise_session.notes }} | +{{ exercise_session.source }} | +{{ exercise_session.createdAt ? exercise_session.createdAt|date('Y-m-d H:i:s') : '' }} | ++ show + edit + | +
| no records found | +||||||||||
| Id | +{{ exercise_session.id }} | +
|---|---|
| Type | +{{ exercise_session.type }} | +
| StartedAt | +{{ exercise_session.startedAt ? exercise_session.startedAt|date('Y-m-d H:i:s') : '' }} | +
| EndedAt | +{{ exercise_session.endedAt ? exercise_session.endedAt|date('Y-m-d H:i:s') : '' }} | +
| Duration | +{{ exercise_session.duration }} | +
| Distance | +{{ exercise_session.distance }} | +
| Calories | +{{ exercise_session.calories }} | +
| Notes | +{{ exercise_session.notes }} | +
| Source | +{{ exercise_session.source }} | +
| CreatedAt | +{{ exercise_session.createdAt ? exercise_session.createdAt|date('Y-m-d H:i:s') : '' }} | +