Skip to content
Merged

Dev #24

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
APP_ENV=dev
APP_SECRET=25aeff0645dafb0ce3dc54218fd03bed
APP_SECRET=

DATABASE_URL="pgsql://TimerAppUser:user123@db:5432/TimerAppDatabase?serverVersion=13&charset=utf8"

API_KEY=
AI_MODEL=
AI_URL=


MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
Expand All @@ -22,9 +24,19 @@ JWT_PUBLIC_KEY_PATH=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=
###< lexik/jwt-authentication-bundle ###

VITE_CACHE_DB_NAME=HabitAiCacheDev
VITE_CACHE_STORE_NAME=cache
VITE_GOOGLE_CLIENT_ID=643971601411-
VITE_CACHE_DB_NAME=
VITE_CACHE_STORE_NAME=
VITE_GOOGLE_CLIENT_ID=
VITE_GOOGLE_REDIRECT_URI=
VITE_PUSH_PUBLIC_KEY=
VITE_PUSH_PRIVATE_KEY=

MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0

MAILER_DSN=null://null

MERCURE_URL=https://example.com/.well-known/mercure

MERCURE_PUBLIC_URL=https://example.com/.well-known/mercure

MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package-lock.json
/public/bundles/
/var/
/vendor/
/ignorefiles
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
Expand Down
2 changes: 1 addition & 1 deletion assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import './bootstrap.js';
*/
import './styles/app.scss';

console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');

8 changes: 1 addition & 7 deletions assets/react/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ const RouterDom = () => {
try {
const res = await fetch('/api/auth/check');
const data = await res.json();
console.log(data);
const ok = res.ok;
setIsAuthenticated(ok);

if(ok){
console.log('Зов пениса');
subscribePush();
}

Expand Down Expand Up @@ -83,7 +81,6 @@ const RouterDom = () => {


const getPlatform = () => {
console.log('Дошли')
const ua = navigator.userAgent;

let os = 'Unknown OS';
Expand All @@ -100,7 +97,6 @@ const RouterDom = () => {
else if (/Safari/.test(ua) && !/Chrome/.test(ua)) browser = 'Safari';
else if (/Edg/.test(ua)) browser = 'Edge';
else if (/OPR/.test(ua)) browser = 'Opera';
console.log('тоже')
return `${browser}_${os}`;
};

Expand All @@ -121,9 +117,7 @@ const RouterDom = () => {
return;
}
}
console.log('Service Worker зарегистрирован:');
const registration = await navigator.serviceWorker.register('/serviceWorker/ServiceWorker.js');
console.log('Service Worker зарегистрирован:', registration);

const subscription = await registration.pushManager.subscribe({
userVisibleOnly: true,
Expand All @@ -136,7 +130,7 @@ const RouterDom = () => {
keys: subscription.toJSON().keys
};

console.log('Отправляем данные подписки:', pushData);


await fetch('/api/save/subscription/web', {
method: 'POST',
Expand Down
17 changes: 16 additions & 1 deletion assets/react/Services/Ctn/RequestServices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,29 @@ export class RequestServices {
return response.json() as Promise<R>;
}

async get<R>(fetchUrl: string, method: string = "GET", body?: any, accessMassiveKey?: string): Promise<R[] | R | false> {
async get<R>(fetchUrl: string, method: string = "GET", body?: any): Promise<R | false> {
try {
const data = await this._request<R>(fetchUrl, method, method !== "GET" ? body : undefined);
return data;
} catch (e) {
await this.logError("Ошибка GET-запроса", { fetchUrl, error: e });
return false;
}
}

async getArray<R>(fetchUrl: string, method: string = "GET", body?: any, accessMassiveKey?: string): Promise<R[] | false> {
try {
let data = await this._request<R | R[]>(fetchUrl, method, method !== "GET" ? body : undefined);

if (accessMassiveKey && typeof data === "object" && !Array.isArray(data)) {
data = (data as any)[accessMassiveKey];
}

if (!Array.isArray(data)) {
if (data == null) return [];
return [data as R];
}

return data;
} catch (e) {
await this.logError("Ошибка GET-запроса", { fetchUrl, error: e });
Expand Down
5 changes: 2 additions & 3 deletions assets/react/Services/Habits/HabitsPageLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const useHabitsLogic = (habitsService: HabitsService) => {
return setHabits([]);
}
setIsLoading(false);
setHabits(result || []);
setHabits(result);
};

const fetchHabitsStatistic = async () => {
Expand All @@ -56,7 +56,6 @@ export const useHabitsLogic = (habitsService: HabitsService) => {
}


console.log(statistic)
setIsLoading(false);
setHabitsStatistic(statistic || [])
}
Expand All @@ -71,7 +70,7 @@ export const useHabitsLogic = (habitsService: HabitsService) => {
}

setIsLoading(false);
setTemplates(templates || [])
setTemplates(templates)
}

const saveHabitProgress = async (habitId: number, countProgress: number) => {
Expand Down
8 changes: 4 additions & 4 deletions assets/react/Services/Habits/HabitsService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ export class HabitsService {
}


async getHabitsAll(limit: number = 50, offset: number = 0): Promise<DataType[] | false | DataType> {
return await this.reqService.get<DataType>(`habits`, `/api/get/Habits/all?limit=${limit}&offset=${offset}`, 'GET');
async getHabitsAll(limit: number = 50, offset: number = 0): Promise<DataType[] | false> {
return await this.reqService.getArray<DataType>(`habits`, `/api/get/Habits/all?limit=${limit}&offset=${offset}`, 'GET');
}

async getHabitsTemplatesAll(): Promise<HabitTemplate[] | false | HabitTemplate>{
return await this.reqService.get<HabitTemplate>(`habits_templates`, `/api/Habits/templates/all`, 'GET');
async getHabitsTemplatesAll(): Promise<HabitTemplate[] | false>{
return await this.reqService.getArray<HabitTemplate>(`habits_templates`, `/api/Habits/templates/all`, 'GET');
}

async getHabitsStatisticAll(): Promise<any | false>{
Expand Down
2 changes: 1 addition & 1 deletion assets/react/Services/Pomodoro/PomodoroTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const usePomodoroTimer = (PomodoroUseCase: PomodoroService) => {
timeEnd: Math.floor(Date.now() / 1000),
created_date: Math.floor(Date.now() / 1000),
};
console.log(pomodoroData);

await PomodoroUseCase.createPomodro(pomodoroData);
}

Expand Down
1 change: 0 additions & 1 deletion assets/react/Services/Tasks/TasksService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class TasksService {
'/api/list/tasks/all',
'GET',
undefined,
'result'
);

return response;
Expand Down
12 changes: 10 additions & 2 deletions assets/react/pages/Pomodor/PomodoroPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ const langUseCase = new LangStorageUseCase(langStorage);


const Pomodoro = () => {
const [dataPomodoro, setDataPomodoro] = useState<PomodoroData | null>(null);
const [dataPomodoro, setDataPomodoro] = useState<PomodoroData>({
todayPomos: 0,
todayFocusTime: 0,
totalPomodorCount: 0,
habitsList: [],
tasksList: [],
pomodorHistory: [],
});

const [activeTab, setActiveTab] = useState('Pomodoro');
const [langCode, setLangCode] = useState('en');
const { t, i18n } = useTranslation('translation');
Expand Down Expand Up @@ -97,7 +105,7 @@ const Pomodoro = () => {
};


if (!translationsLoaded || !dataPomodoro) return <Loading />;
if (!translationsLoaded) return <Loading />;


const { todayPomos, todayFocusTime, totalPomodorCount, habitsList, tasksList, pomodorHistory } = dataPomodoro;
Expand Down
1 change: 0 additions & 1 deletion assets/react/pages/Tasks/TasksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ const TasksPage: React.FC = () => {
setLoading(true);
const allTasksResult = await tasksService.getTasksAll();
setAllTasks(Array.isArray(allTasksResult) ? allTasksResult : []);
console.log(allTasks)
} catch (err: any) {
setError(err.message);
setAllTasks([]);
Expand Down
4 changes: 0 additions & 4 deletions assets/react/pages/chunk/Habits/HabitsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ const HabitModal: React.FC<HabitModalProps> = ({habitTemplates, onClose, onEdit,

useEffect(() => {
if (edit && editData) {
console.log('То что содержить edit data')
console.log(editData);
const notificationRaw = editData.notification_date || '';
const timeOnly = notificationRaw.length >= 5 ? notificationRaw.substring(0, 5) : '';

Expand All @@ -87,7 +85,6 @@ const HabitModal: React.FC<HabitModalProps> = ({habitTemplates, onClose, onEdit,
purposeCount: editData.count,
date: editData.date
});
console.log(data);
setStep(2);
}
}, [edit, editData]);
Expand Down Expand Up @@ -237,7 +234,6 @@ const HabitModal: React.FC<HabitModalProps> = ({habitTemplates, onClose, onEdit,
if (!validateStep(step) || !editData?.habit_id) return;

const payload: EditDataType = {
cacheId: data.cacheId,
habitId: editData.habit_id,
title: data.title,
quote: data.quote,
Expand Down
1 change: 0 additions & 1 deletion assets/react/ui/props/Habits/PomodoroData.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export type PomodoroData = {
cacheId: number;
todayPomos: number;
todayFocusTime: number;
totalPomodorCount: number;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-symfony": "*",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10",
"symfony/browser-kit": "6.4.*",
"symfony/css-selector": "6.4.*",
"symfony/debug-bundle": "6.4.*",
Expand Down
2 changes: 1 addition & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
];
];
7 changes: 7 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ services:
App\Infrastructure\Service\FilterCriteriaApply\FilterApplicator\ApplyFilter:
arguments:
$criterionAppliers: !tagged_iterator app.criterion_applier

App\Infrastructure\Service\AiService\AiIntegration:
arguments:
$apiKey: '%env(API_KEY)%'
$headerName: '%env(AI_MODEL)%'
$aiUrl: '%env(AI_URL)%'

4 changes: 2 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
environment:
XDEBUG_MODE: "${XDEBUG_MODE:-off}"
TEST_DATABASE_URL: pgsql://TimerAppUser:user123@db:5432/TimerAppDatabase?serverVersion=13&charset=utf8
TEST_ELASTICSEARCH_INDEX_PREFIX: test_questionnaire_
TEST_ELASTICSEARCH_INDEX_PREFIX: test_timer_app_
extra_hosts:
- host.docker.internal:host-gateway
db:
Expand All @@ -35,7 +35,7 @@ services:
db_test:
image: postgres:13
ports:
- '11009:5432'
- '11010:5432'
container_name: timer_app_pgsql_test
restart: unless-stopped
environment:
Expand Down
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,9 @@
</listeners>

<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension">
<parameter name="clock-mock-namespaces" value="App" />
<parameter name="dns-mock-namespaces" value="App" />
</bootstrap>
</extensions>
</phpunit>
2 changes: 0 additions & 2 deletions public/serviceWorker/ServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
self.addEventListener('install', (event) => {
console.log('Service Worker установлен');
event.waitUntil(self.skipWaiting());
});

self.addEventListener('activate', (event) => {
console.log('Service Worker активирован');
event.waitUntil(self.clients.claim());
});

Expand Down
13 changes: 13 additions & 0 deletions src/Domain/Service/AiService/AiInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Domain\Service\AiService;

interface AiInterface
{
/**
* @return array<string, mixed> Возвращает декодированный JSON как массив
*/
public function integration(string $prompt): array;

public function generateText(string $prompt): string;
}
Loading