Версия 0.3.1 Правки для работы в Docker.

This commit is contained in:
anibilag 2025-07-12 23:16:22 +03:00
parent 4cf6f8034c
commit 569d10a4ba
9 changed files with 33 additions and 29 deletions

Binary file not shown.

View File

@ -14,7 +14,7 @@ services:
- .:/app
- /app/node_modules
- ./uploads:/app/uploads
- ./db:/app/db
- ./db:/app/db:rw
environment:
- NODE_ENV=development
- CHOKIDAR_USEPOLLING=true

View File

@ -9,7 +9,7 @@ services:
restart: unless-stopped
volumes:
- ./uploads:/app/uploads
- ./lawn_scheduler.db:/app/lawn_scheduler.db
- ./lawn_scheduler.db:/app/db/lawn_scheduler.db
environment:
- NODE_ENV=production
networks:

View File

@ -1,7 +1,7 @@
{
"name": "lawn-mowing-scheduler",
"private": true,
"version": "0.3.0",
"version": "0.3.1",
"type": "module",
"scripts": {
"dev": "concurrently \"npm run server\" \"npm run client\"",

View File

@ -6,13 +6,13 @@ echo "Starting Lawn Scheduler in Development Mode..."
mkdir -p uploads
# Build and start services
docker-compose -f docker-compose.dev.yml down
docker-compose -f docker-compose.dev.yml build --no-cache
docker-compose -f docker-compose.dev.yml up -d
docker compose -f docker-compose.dev.yml down
docker compose -f docker-compose.dev.yml build --no-cache
docker compose -f docker-compose.dev.yml up -d
echo "Development environment started!"
echo "Frontend (Vite): http://localhost:8080"
echo "Backend API: http://localhost:3001"
echo ""
echo "To view logs: docker-compose -f docker-compose.dev.yml logs -f"
echo "To stop: docker-compose -f docker-compose.dev.yml down"
echo "To view logs: docker compose -f docker-compose.dev.yml logs -f"
echo "To stop: docker compose -f docker-compose.dev.yml down"

View File

@ -7,12 +7,12 @@ mkdir -p nginx/conf.d
mkdir -p uploads
# Build and start services
docker-compose down
docker-compose build --no-cache
docker-compose up -d
docker compose down
docker compose build --no-cache
docker compose up -d
echo "Application started!"
echo "Access the application at: http://localhost"
echo ""
echo "To view logs: docker-compose logs -f"
echo "To stop: docker-compose down"
echo "To view logs: docker compose logs -f"
echo "To stop: docker compose down"

View File

@ -642,6 +642,10 @@ app.put('/api/zones/:id', upload.single('image'), async (req, res) => {
args = [name, imagePath, lastMowedDate || null, parseInt(intervalDays), scheduleType || 'interval', parseFloat(area) || 0, req.params.id];
}
console.log('Updating zone with data:', { name, intervalDays, lastMowedDate, nextMowDate, scheduleType, area });
console.log('SQL:', sql);
console.log('ARGS:', args);
await db.execute({ sql, args });
// Delete old image if new one was provided

View File

@ -290,7 +290,7 @@ const Dashboard: React.FC = () => {
<div>
<p className="text-sm font-medium text-gray-600">Актуально</p>
<p className="text-2xl font-bold text-gray-900">{okCount}</p>
<p className="text-xs text-gray-500">обслужено зон</p>
<p className="text-xs text-gray-500">зон обслужено</p>
</div>
<CheckCircle className="h-8 w-8 text-emerald-500" />
</div>

View File

@ -1,17 +1,17 @@
import { Zone, ZoneFormData, MowingHistoryResponse, MowingStats, MowingFormData, Mower, MowerFormData, BulkMowingFormData } from '../types/zone';
const API_BASE = new URL('api', import.meta.env.VITE_API_URL).toString();
const API_BASE = import.meta.env.VITE_API_URL;
export const api = {
async getZones(): Promise<Zone[]> {
const response = await fetch(`${API_BASE}/zones`);
console.log(`${API_BASE}/zones`);
const response = await fetch(`${API_BASE}/api/zones`);
console.log(`${API_BASE}/api/zones`);
if (!response.ok) throw new Error('Failed to fetch zones');
return response.json();
},
async getZone(id: number): Promise<Zone> {
const response = await fetch(`${API_BASE}/zones/${id}`);
const response = await fetch(`${API_BASE}/api/zones/${id}`);
if (!response.ok) throw new Error('Failed to fetch zone');
return response.json();
},
@ -32,7 +32,7 @@ export const api = {
formData.append('image', data.image);
}
const response = await fetch(`${API_BASE}/zones`, {
const response = await fetch(`${API_BASE}/api/zones`, {
method: 'POST',
body: formData,
});
@ -60,7 +60,7 @@ export const api = {
formData.append('image', data.image);
}
const response = await fetch(`${API_BASE}/zones/${id}`, {
const response = await fetch(`${API_BASE}/api/zones/${id}`, {
method: 'PUT',
body: formData,
});
@ -70,14 +70,14 @@ export const api = {
},
async deleteZone(id: number): Promise<void> {
const response = await fetch(`${API_BASE}/zones/${id}`, {
const response = await fetch(`${API_BASE}/api/zones/${id}`, {
method: 'DELETE',
});
if (!response.ok) throw new Error('Failed to delete zone');
},
async markAsMowed(id: number, data?: MowingFormData): Promise<Zone> {
const response = await fetch(`${API_BASE}/zones/${id}/mow`, {
const response = await fetch(`${API_BASE}/api/zones/${id}/mow`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -89,7 +89,7 @@ export const api = {
},
async markAsTrimmed(id: number, data?: MowingFormData): Promise<void> {
const response = await fetch(`${API_BASE}/zones/${id}/trim`, {
const response = await fetch(`${API_BASE}/api/zones/${id}/trim`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -99,7 +99,7 @@ export const api = {
if (!response.ok) throw new Error('Failed to mark as trimmed');
},
async bulkMarkAsMowed(data: BulkMowingFormData): Promise<void> {
const response = await fetch(`${API_BASE}/zones/bulk-mow`, {
const response = await fetch(`${API_BASE}/api/zones/bulk-mow`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@ -118,25 +118,25 @@ export const api = {
params.append('zoneId', zoneId.toString());
}
const response = await fetch(`${API_BASE}/history?${params}`);
const response = await fetch(`${API_BASE}/api/history?${params}`);
if (!response.ok) throw new Error('Failed to fetch mowing history');
return response.json();
},
async getMowingStats(period = 30): Promise<MowingStats> {
const response = await fetch(`${API_BASE}/history/stats?period=${period}`);
const response = await fetch(`${API_BASE}/api/history/stats?period=${period}`);
if (!response.ok) throw new Error('Failed to fetch mowing statistics');
return response.json();
},
async getMowers(): Promise<Mower[]> {
const response = await fetch(`${API_BASE}/mowers`);
const response = await fetch(`${API_BASE}/api/mowers`);
if (!response.ok) throw new Error('Failed to fetch mowers');
return response.json();
},
async createMower(data: MowerFormData): Promise<Mower> {
const response = await fetch(`${API_BASE}/mowers`, {
const response = await fetch(`${API_BASE}/api/mowers`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',