import React from "react";
import "./weatherForecastData.css";
const WeatherForecastData = (props) => {
return (
);
function getData() {
const city = document.getElementById("city_text").value;
const region = document.getElementById("region_text").value;
const country = document.getElementById("country_text").value;
const latitude = document.getElementById("latitude_text").value;
const longitude = document.getElementById("longitude_text").value;
const name = document.getElementById("name").checked;
const regionCheckbox = document.getElementById("region").checked;
const countryCheckbox = document.getElementById("country").checked;
const lon = document.getElementById("lon").checked;
const lat = document.getElementById("lat").checked;
const tz_id = document.getElementById("tz_id").checked;
const localtime_epoch = document.getElementById("localtime_epoch").checked;
const localtime = document.getElementById("localtime").checked;
const last_updated_epoch =
document.getElementById("last_updated_epoch").checked;
const last_updated = document.getElementById("last_updated").checked;
const date = document.getElementById("date").checked;
const date_epoch = document.getElementById("date_epoch").checked;
const maxtemp = document.getElementById("maxtemp").checked;
const mintemp = document.getElementById("mintemp").checked;
const avgtemp = document.getElementById("avgtemp").checked;
const maxwind = document.getElementById("maxwind").checked;
const totalprecip = document.getElementById("totalprecip").checked;
const avgvis = document.getElementById("avgvis").checked;
const avghumidity = document.getElementById("avghumidity").checked;
const daily_will_it_rain =
document.getElementById("daily_will_it_rain").checked;
const daily_chance_of_rain = document.getElementById(
"daily_chance_of_rain"
).checked;
const daily_will_it_snow =
document.getElementById("daily_will_it_snow").checked;
const daily_chance_of_snow = document.getElementById(
"daily_chance_of_snow"
).checked;
const condition_text = document.getElementById("condition_text").checked;
const condition_icon = document.getElementById("condition_icon").checked;
const condition_code = document.getElementById("condition_code").checked;
const uv = document.getElementById("uv").checked;
const sunrise = document.getElementById("sunrise").checked;
const sunset = document.getElementById("sunset").checked;
const moonrise = document.getElementById("moonrise").checked;
const moonset = document.getElementById("moonset").checked;
const moon_phase = document.getElementById("moon_phase").checked;
const moon_illumination =
document.getElementById("moon_illumination").checked;
const hour_time_epoch = document.getElementById("hour_time_epoch").checked;
const hour_time = document.getElementById("hour_time").checked;
const hour_temp = document.getElementById("hour_temp").checked;
const hour_is_day = document.getElementById("hour_is_day").checked;
const hour_condition_text = document.getElementById(
"hour_condition_text"
).checked;
const hour_condition_icon = document.getElementById(
"hour_condition_icon"
).checked;
const hour_condition_code = document.getElementById(
"hour_condition_code"
).checked;
const hour_wind = document.getElementById("hour_wind").checked;
const hour_wind_degree =
document.getElementById("hour_wind_degree").checked;
const hour_wind_dir = document.getElementById("hour_wind_dir").checked;
const hour_pressure = document.getElementById("hour_pressure").checked;
const hour_precip = document.getElementById("hour_precip").checked;
const hour_humidity = document.getElementById("hour_humidity").checked;
const hour_cloud = document.getElementById("hour_cloud").checked;
const hour_feelslike = document.getElementById("hour_feelslike").checked;
const hour_windchill = document.getElementById("hour_windchill").checked;
const hour_heatindex = document.getElementById("hour_heatindex").checked;
const hour_dewpoint = document.getElementById("hour_dewpoint").checked;
const hour_vis = document.getElementById("hour_vis").checked;
const hour_gust = document.getElementById("hour_gust").checked;
const hour_uv = document.getElementById("hour_uv").checked;
let filterArray = [];
if (name) filterArray.push("name");
if (regionCheckbox) filterArray.push("region");
if (countryCheckbox) filterArray.push("country");
if (lon) filterArray.push("lon");
if (lat) filterArray.push("lat");
if (tz_id) filterArray.push("tz_id");
if (localtime_epoch) filterArray.push("localtime_epoch");
if (localtime) filterArray.push("localtime");
if (last_updated_epoch) filterArray.push("last_updated_epoch");
if (last_updated) filterArray.push("last_updated");
if (date) filterArray.push("date");
if (date_epoch) filterArray.push("date_epoch");
if (maxtemp) filterArray.push("maxtemp");
if (mintemp) filterArray.push("mintemp");
if (avgtemp) filterArray.push("avgtemp");
if (maxwind) filterArray.push("maxwind");
if (totalprecip) filterArray.push("totalprecip");
if (avgvis) filterArray.push("avgvis");
if (avghumidity) filterArray.push("avghumidity");
if (daily_will_it_rain) filterArray.push("daily_will_it_rain");
if (daily_chance_of_rain) filterArray.push("daily_chance_of_rain");
if (daily_will_it_snow) filterArray.push("daily_will_it_snow");
if (daily_chance_of_snow) filterArray.push("daily_chance_of_snow");
if (condition_text) filterArray.push("condition_text");
if (condition_icon) filterArray.push("condition_icon");
if (condition_code) filterArray.push("condition_code");
if (uv) filterArray.push("uv");
if (sunrise) filterArray.push("sunrise");
if (sunset) filterArray.push("sunset");
if (moonrise) filterArray.push("moonrise");
if (moonset) filterArray.push("moonset");
if (moon_phase) filterArray.push("moon_phase");
if (moon_illumination) filterArray.push("moon_illumination");
if (hour_time_epoch) filterArray.push("hourly_time_epoch");
if (hour_time) filterArray.push("hourly_time");
if (hour_temp) filterArray.push("hourly_temp");
if (hour_is_day) filterArray.push("hourly_is_day");
if (hour_condition_text) filterArray.push("hourly_condition_text");
if (hour_condition_icon) filterArray.push("hourly_condition_icon");
if (hour_condition_code) filterArray.push("hourly_condition_code");
if (hour_wind) filterArray.push("hourly_wind");
if (hour_wind_degree) filterArray.push("hourly_wind_degree");
if (hour_wind_dir) filterArray.push("hourly_wind_dir");
if (hour_pressure) filterArray.push("hourly_pressure");
if (hour_precip) filterArray.push("hourly_precip");
if (hour_humidity) filterArray.push("hourly_humidity");
if (hour_cloud) filterArray.push("hourly_cloud");
if (hour_feelslike) filterArray.push("hourly_feelslike");
if (hour_windchill) filterArray.push("hourly_windchill");
if (hour_heatindex) filterArray.push("hourly_heatindex");
if (hour_dewpoint) filterArray.push("hourly_dewpoint");
if (hour_vis) filterArray.push("hourly_vis");
if (hour_gust) filterArray.push("hourly_gust");
if (hour_uv) filterArray.push("hourly_uv");
let filterString = filterArray.join(",");
console.log("FilterString = " + filterString);
const apiUrl = `http://localhost:8080/forcastweather?q=${latitude_text},${longitude_text}&filter=${filterString}`;
fetch(apiUrl)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((data) => {
// Wetterdaten anzeigen
document.getElementById("weatherData").innerText = JSON.stringify(
data,
null,
2
);
document.getElementById("apiUrloutput").value = apiUrl;
})
.catch((error) => {
console.error("There was a problem with the fetch operation:", error);
});
}
function searchAPI() {
const cityInput = document.getElementById("city_text").value;
const apiUrl = `http://localhost:8080/search?city=${cityInput}`;
fetch(apiUrl)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.json();
})
.then((data) => {
setData(data);
})
.catch((error) => {
console.error("There was a problem with the fetch operation:", error);
});
}
function boolToWord(bool) {
return bool ? "yes" : "no";
}
};
const ListItem = ({ name, country, region, lat, lon }) => {
const handleClick = () => {
document.getElementById("city_text").value = name;
document.getElementById("region_text").value = country;
document.getElementById("country_text").value = region;
document.getElementById("latitude_text").value = lat;
document.getElementById("longitude_text").value = lon;
};
return (
{name}
Country: {country}
Region: {region}
Lat: {lat}, Lon: {lon}
);
};
export default WeatherForecastData;