15 Commits

Author SHA1 Message Date
3d6c9bfecd fix: update docker-compose configuration and restore backend service 2025-11-26 19:33:11 +01:00
77111958a2 Merge branch 'development' into debian12 2025-11-26 19:32:59 +01:00
04c82dd9d4 added react build 2025-11-26 19:28:15 +01:00
9b0f7daa2c fix: update error response status and improve success message handling in weather fetching 2025-08-03 23:52:23 +02:00
20bee1018c fixed bug: Error handling when submitting form with wrong api key 2025-08-03 23:47:32 +02:00
0361a743ef feat: add last updated timestamp to WeatherData component 2025-08-03 22:24:17 +02:00
f32ddd837b feat: update release notes to include last updated time feature in web panel 2025-08-03 22:21:46 +02:00
38ef97b553 feat: add last updated timestamp to WeatherData component 2025-08-03 22:21:19 +02:00
f70629fa55 fix: remove port from weather API URL for consistency 2025-08-03 20:42:18 +02:00
d84d876735 fix: update weather API URL to use HTTPS for improved security 2025-08-03 20:36:04 +02:00
574f094bac changed protocol 2025-08-03 20:31:13 +02:00
71da186bd6 changed networking for hosting 2025-08-03 20:26:24 +02:00
ff77629a01 feat: add release notes with new features and improvements 2025-08-03 19:52:35 +02:00
4c42bd94ea fix: add cursor pointer to buttons for better UX and update WeatherForm instructions 2025-08-03 19:45:01 +02:00
4f98bf4e9a refactor: uncomment frontend service configuration in docker-compose.yml 2025-08-03 19:14:39 +02:00
12 changed files with 95 additions and 35 deletions

View File

@@ -6,7 +6,7 @@ You can find the web version of the Weather App at [https://weather.the1s.de](ht
## Version ## Version
Currently hosted version: **1.0.1** Currently hosted version: **development branch (latest)**
## Dev info ## Dev info

9
RELEASE_NOTES.md Normal file
View File

@@ -0,0 +1,9 @@
## Release Notes
### New Features
- Changed **web panel** backend, so you don't need to set the API key anymore. [Web Panel](https://weather.the1s.de)
- You can now see the **last updated** time in the web panel.
### Improvements
- Changed Website Icons to lucide react icons
- Changed overall handling of the panel

View File

@@ -14,7 +14,7 @@ router.get("/fetchWeather", async (req, res) => {
`https://api.openweathermap.org/geo/1.0/direct?q=${city}&appid=${apiKey}` `https://api.openweathermap.org/geo/1.0/direct?q=${city}&appid=${apiKey}`
); );
if (!locationResponse.ok) { if (!locationResponse.ok) {
return res.status(404).json({ return res.status(500).json({
error: "Error fetching location data. (Error: x32)", error: "Error fetching location data. (Error: x32)",
success: "false", success: "false",
data: null, data: null,

View File

@@ -1,26 +1,24 @@
services: services:
# frontend: frontend:
# container_name: weather-frontend container_name: weather-frontend
# build: ./frontend build: ./frontend
# ports: networks:
# - "7002:7002" - proxynet
# # networks: ports:
# # - proxynet - "7002:80"
# environment: restart: unless-stopped
# - CHOKIDAR_USEPOLLING=true
# volumes:
# - ./frontend:/app
# - /app/node_modules
# restart: unless-stopped
backend: backend:
container_name: weather-backend container_name: backend
build: ./backend build: ./backend
networks:
- proxynet
ports: ports:
- "7001:7001" - "7001:7001"
volumes: volumes:
- ./backend:/app - ./backend:/bikelane-backend
- /app/node_modules
restart: unless-stopped restart: unless-stopped
#networks:
# proxynet: networks:
# external: true proxynet:
external: true

View File

@@ -1,12 +1,19 @@
FROM node:20-alpine FROM node:22-alpine AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package.json package-lock.json ./
RUN npm install RUN npm ci
COPY . . COPY . .
RUN npm run build
EXPOSE 7002 FROM nginx:alpine AS runner
CMD ["npm", "run", "dev"] WORKDIR /usr/share/nginx/html
COPY --from=builder /app/dist .
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

18
frontend/nginx.conf Normal file
View File

@@ -0,0 +1,18 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
expires 1y;
access_log off;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
}

View File

@@ -53,7 +53,7 @@ const ChangeAPI: React.FC<Props> = ({ currentAPIKey, onClose }) => {
</div> </div>
<button <button
type="submit" type="submit"
className="bg-gradient-to-r from-blue-600 to-blue-400 text-white font-bold px-6 py-3 rounded-xl shadow-lg hover:from-blue-700 hover:to-blue-500 transition-all" className="cursor-pointer bg-gradient-to-r from-blue-600 to-blue-400 text-white font-bold px-6 py-3 rounded-xl shadow-lg hover:from-blue-700 hover:to-blue-500 transition-all"
onClick={handleUpdate} onClick={handleUpdate}
> >
Update API Key Update API Key

View File

@@ -1,7 +1,6 @@
import React from "react"; import React from "react";
import ChangeAPI from "./ChangeAPI"; import ChangeAPI from "./ChangeAPI";
import ChangePreferences from "./ChangePreferences"; import ChangePreferences from "./ChangePreferences";
import { myToast } from "../utils/toastify";
import { useState } from "react"; import { useState } from "react";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import logo from "../assets/cloud-sun-fill.png"; import logo from "../assets/cloud-sun-fill.png";
@@ -22,15 +21,15 @@ const Header: React.FC = () => {
className="w-10 h-10 drop-shadow-lg" className="w-10 h-10 drop-shadow-lg"
/> />
<h1 className="text-4xl font-extrabold tracking-wide drop-shadow-lg"> <h1 className="text-4xl font-extrabold tracking-wide drop-shadow-lg">
Weather App - <strong>Web</strong> Weather App - <strong>Local hosted</strong>
</h1> </h1>
</div> </div>
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">
{" "} {" "}
{/* Added container for buttons */} {/* Added container for buttons */}
<button <button
className="bg-gray-200 text-gray-400 font-bold px-6 py-3 rounded-xl shadow-lg border border-gray-300 flex items-center gap-2 cursor-not-allowed opacity-60" className="cursor-pointer bg-white text-blue-700 font-bold px-6 py-3 rounded-xl shadow-lg hover:bg-blue-100 transition-all border border-blue-200 flex items-center gap-2"
onClick={() => myToast("You don't need to set an API Key!", "info")} onClick={() => setApiCard(true)}
> >
<span className="flex items-center gap-2"> <span className="flex items-center gap-2">
<KeyRound /> <KeyRound />

View File

@@ -1,5 +1,6 @@
import React from "react"; import React from "react";
import { Sunrise, Sunset } from "lucide-react"; import { Sunrise, Sunset } from "lucide-react";
import { getDateTime } from "../utils/utils";
const WeatherData: React.FC = () => { const WeatherData: React.FC = () => {
const weatherRaw = localStorage.getItem("weather"); const weatherRaw = localStorage.getItem("weather");
@@ -75,6 +76,11 @@ const WeatherData: React.FC = () => {
: "--:--"} : "--:--"}
</span> </span>
</div> </div>
<div className="flex items-center gap-3">
<span className="text-base text-gray-600 italic font-semibold">
Last updated: {getDateTime()}
</span>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -22,8 +22,6 @@ const WeatherCard: React.FC = () => {
.promise(fetchWeather(city, getUnit()), { .promise(fetchWeather(city, getUnit()), {
pending: "Fetching weather data...", pending: "Fetching weather data...",
success: "Weather data loaded successfully!", success: "Weather data loaded successfully!",
error:
"Failed to load weather data. Please check your entered city name. (Error: x4040)",
}) })
.then(() => { .then(() => {
if (localStorage.getItem("weather")) { if (localStorage.getItem("weather")) {
@@ -52,7 +50,7 @@ const WeatherCard: React.FC = () => {
Current weather will be displayed here. Current weather will be displayed here.
</p> </p>
<p className="mb-2 text-gray-600"> <p className="mb-2 text-gray-600">
<strong>You don't need an API Key!</strong> <strong>Make sure to set your API key in the header section.</strong>
</p> </p>
<form onSubmit={handleSubmit} className="flex flex-col gap-4 mt-4"> <form onSubmit={handleSubmit} className="flex flex-col gap-4 mt-4">
<label htmlFor="city" className="font-medium text-gray-700"> <label htmlFor="city" className="font-medium text-gray-700">

View File

@@ -3,7 +3,7 @@ import { myToast } from "./toastify";
export const fetchWeather = async (city: string, units: string) => { export const fetchWeather = async (city: string, units: string) => {
try { try {
const response = await fetch( const response = await fetch(
`http://localhost:7001/api/fetchWeather?city=${encodeURIComponent( `https://backend.weather.the1s.de/api/fetchWeather?city=${encodeURIComponent(
city city
)}&units=${encodeURIComponent(units)}`, )}&units=${encodeURIComponent(units)}`,
{ {
@@ -21,6 +21,7 @@ export const fetchWeather = async (city: string, units: string) => {
return; return;
} }
localStorage.setItem("weather", JSON.stringify(responseData.data)); localStorage.setItem("weather", JSON.stringify(responseData.data));
myToast(responseData.success, "success");
return; return;
} catch (error) { } catch (error) {
const errorMsg = JSON.stringify(error); const errorMsg = JSON.stringify(error);

View File

@@ -0,0 +1,24 @@
export const getDateTime = () => {
const now = new Date();
const day = now.getDate();
const month = now.toLocaleString("en-GB", { month: "long" });
const hours = now.getHours().toString().padStart(2, "0");
const minutes = now.getMinutes().toString().padStart(2, "0");
// Ordinal suffix
const getOrdinal = (n: number) => {
if (n > 3 && n < 21) return "th";
switch (n % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
};
return `${day}${getOrdinal(day)} ${month}, ${hours}:${minutes}`;
};