Allow configuration through a file and export images automatically

Introduce a configuration file for all settings, remove the web-based config editor, fix the grid display, and add automatic hourly PNG exports.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 0385ea33-cde8-4bbd-8fce-8d192d30eb41
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/870d08ce-da3b-4822-9874-c2fe2b7628b1/0385ea33-cde8-4bbd-8fce-8d192d30eb41/Zffw2vY
This commit is contained in:
freesemar93
2025-08-18 12:20:13 +00:00
parent 7e739f216d
commit 7968b56976
10 changed files with 218 additions and 272 deletions

View File

@@ -3,13 +3,13 @@ import { useQuery, useMutation } from "@tanstack/react-query";
import { queryClient } from "@/lib/queryClient";
import { Canvas } from "@/components/canvas";
import { ColorPalette } from "@/components/color-palette";
import { ConfigModal } from "@/components/config-modal";
import { Button } from "@/components/ui/button";
import { useWebSocket } from "@/hooks/use-websocket";
import { useToast } from "@/hooks/use-toast";
import { Grid } from "lucide-react";
import { DEFAULT_SELECTED_COLOR, generateUserId, getUsername } from "@/lib/config";
import { Pixel, CanvasConfig, InsertPixel, InsertCanvasConfig, WSMessage } from "@shared/schema";
import { Pixel, CanvasConfig, InsertPixel, WSMessage } from "@shared/schema";
import { apiRequest } from "@/lib/queryClient";
export default function CanvasPage() {
@@ -48,14 +48,7 @@ export default function CanvasPage() {
});
break;
case "config_updated":
// Invalidate config cache
queryClient.invalidateQueries({ queryKey: ['/api/config'] });
toast({
title: "Configuration updated",
description: "Canvas settings have been changed by an administrator.",
});
break;
case "cooldown_update":
if (message.data.userId === userId) {
@@ -98,16 +91,14 @@ export default function CanvasPage() {
},
});
// Config update mutation
const updateConfigMutation = useMutation({
mutationFn: async (configUpdate: InsertCanvasConfig) => {
const response = await apiRequest("POST", "/api/config", configUpdate);
return response.json();
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['/api/config'] });
},
});
// Set initial grid state from config
useEffect(() => {
if (config) {
setShowGrid(config.showGridByDefault);
}
}, [config]);
// Cooldown countdown
useEffect(() => {
@@ -148,9 +139,7 @@ export default function CanvasPage() {
});
};
const handleConfigUpdate = async (configUpdate: InsertCanvasConfig) => {
await updateConfigMutation.mutateAsync(configUpdate);
};
if (pixelsLoading || configLoading || !config) {
return (
@@ -185,8 +174,7 @@ export default function CanvasPage() {
<span>Grid</span>
</Button>
{/* Admin Config Button */}
<ConfigModal config={config} onConfigUpdate={handleConfigUpdate} />
{/* User Info */}
<div className="flex items-center space-x-2 px-3 py-2 bg-panel-hover rounded-lg">