Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Karakas
SWP_SS24_Wetterdaten_sammeln
Commits
3e8cd911
Commit
3e8cd911
authored
May 10, 2024
by
EnesKarakas
Browse files
Frontend
parent
0a033491
Changes
4
Hide whitespace changes
Inline
Side-by-side
frontend/index.html
View file @
3e8cd911
...
...
@@ -4,8 +4,40 @@
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<link
rel=
"stylesheet"
href=
"styles/styles.css"
/>
<script
src=
"scripts/script.js"
></script>
<title>
Wetterdaten sammeln
</title>
<title>
Wetter App
</title>
</head>
<body></body>
<body>
<div
class=
"container"
>
<div
class=
"box"
>
<h1>
Wetterdaten abrufen
</h1>
<div
class=
"filter"
>
<label
for=
"city"
>
Stadt:
</label>
<input
type=
"text"
id=
"city"
placeholder=
"Stadt"
/><br
/>
<label
for=
"start"
>
Startdatum:
</label>
<input
type=
"date"
id=
"start"
value=
"2024-04-24"
/><br
/>
<label
for=
"end"
>
Enddatum:
</label>
<input
type=
"date"
id=
"end"
value=
"2024-05-08"
/><br
/>
<label
for=
"storage"
>
Speicherort:
</label>
<select
id=
"storage"
>
<option
value=
"local"
>
Lokal
</option>
<option
value=
"database"
>
Datenbank
</option></select
><br
/>
<label
for=
"format"
>
Datenformat:
</label>
<select
id=
"format"
>
<option
value=
"json"
>
JSON
</option>
<option
value=
"csv"
>
CSV
</option>
<option
value=
"xml"
>
XML
</option></select
><br
/>
<button
onclick=
"getData()"
>
Daten abrufen
</button>
</div>
</div>
<div
class=
"box"
>
<h2>
Wetterdaten
</h2>
<pre
id=
"weatherData"
></pre>
</div>
</div>
<script
type=
"text/javascript"
src=
"scripts/script.js"
></script>
</body>
</html>
frontend/scripts/script.js
View file @
3e8cd911
function
getData
()
{
const
city
=
document
.
getElementById
(
"
city
"
).
value
;
const
start
=
document
.
getElementById
(
"
start
"
).
value
;
const
end
=
document
.
getElementById
(
"
end
"
).
value
;
const
storageOption
=
document
.
getElementById
(
"
storage
"
).
value
;
const
formatOption
=
document
.
getElementById
(
"
format
"
).
value
;
const
apiKey
=
"
1244099aeaee4b179e6111803241304
"
;
const
apiUrl
=
`https://api.weatherapi.com/v1/current.json?key=
${
apiKey
}
&q=
${
city
}
&aqi=no`
;
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
);
})
.
catch
((
error
)
=>
{
console
.
error
(
"
There was a problem with the fetch operation:
"
,
error
);
});
}
frontend/styles/styles.css
View file @
3e8cd911
body
{
font-family
:
Arial
,
sans-serif
;
margin
:
0
;
padding
:
0
;
}
.container
{
max-width
:
800px
;
margin
:
20px
auto
;
padding
:
20px
;
border
:
1px
solid
#ccc
;
border-radius
:
5px
;
box-shadow
:
0
0
10px
rgba
(
0
,
0
,
0
,
0.1
);
}
.box
{
margin-bottom
:
20px
;
}
.filter
label
{
display
:
block
;
margin-bottom
:
5px
;
}
.filter
input
[
type
=
"text"
],
.filter
select
{
width
:
100%
;
padding
:
8px
;
margin-bottom
:
10px
;
border
:
1px
solid
#ccc
;
border-radius
:
5px
;
}
.filter
button
{
padding
:
10px
20px
;
background-color
:
#007bff
;
color
:
#fff
;
border
:
none
;
border-radius
:
5px
;
cursor
:
pointer
;
transition
:
background-color
0.3s
;
}
.filter
button
:hover
{
background-color
:
#0056b3
;
}
#weatherData
{
white-space
:
pre-wrap
;
/* Umbruch von langen Zeilen */
}
src/main/java/com/SWP/SS24/Wetterdaten_sammeln/Application.java
View file @
3e8cd911
...
...
@@ -8,6 +8,7 @@ public class Application {
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
Application
.
class
,
args
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment