add other page and js, css

This commit is contained in:
Данил 2022-09-18 19:27:23 +03:00
parent 25f68a498a
commit 1e33e0a6d8
8 changed files with 279 additions and 0 deletions

43
web/src/gallery.html Normal file
View file

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>EveryNasa</title>
<link rel="icon" href="/static/image/icons/favicon.png">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="/static/style/gallery.css" type="text/css">
</head>
<body style="background: #131313; color: white;">
<nav class="navbar navbar-expand-lg bg-dark navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<img src="/static/image/icons/favicon.png" width="45" alt="EveryNasa">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/settings">Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/about">About</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<header class="header-row">
</header>
</div>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.min.js" integrity="sha384-ODmDIVzN+pFdexxHEHFBQH3/9/vQ9uori45z4JjnFsRydbmQbmL5t1tQ0culUzyK" crossorigin="anonymous"></script>
<script src="/static/scripts/gallery.js" type="application/javascript"></script>
</body>
</html>

59
web/src/settings.html Normal file
View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>EveryNasa</title>
<link rel="icon" href="/static/image/icons/favicon.png">
<link rel="stylesheet" href="/static/style/settings.css" type="text/css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
<body style="background: #131313; color: white;">
<nav class="navbar navbar-expand-lg bg-dark navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="/" draggable="false">
<img src="/static/image/icons/favicon.png" width="45" id="everynasa-logo" alt="EveryNasa">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/settings">Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/about">About</a>
</li>
</ul>
</div>
</div>
</nav>
<h1 id="title">Application Settings</h1>
<div class="container">
<header class="header-row">
<div class="settings">
<p class="title"><strong>Automatic updates</strong></p>
<p class="desc">EveryNasa will automatically perform an update at startup.</p>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="updateSwitch">
<label class="form-check-label" for="updateText" id="updateText">Off</label>
</div>
</div>
<div class="settings">
<p class="title"><strong>Add a program to the startup</strong></p>
<p class="desc">EverNasa will automatically start when you log in.</p>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="autorunSwitch">
<label class="form-check-label" for="autorunText" id="autorunText">Off</label>
</div>
</div>
</header>
</div>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.min.js" integrity="sha384-ODmDIVzN+pFdexxHEHFBQH3/9/vQ9uori45z4JjnFsRydbmQbmL5t1tQ0culUzyK" crossorigin="anonymous"></script>
<script src="/static/scripts/switch.js"></script>
</body>
</html>

View file

@ -0,0 +1,17 @@
$.ajax({
url: `https://api.nasa.gov/planetary/apod?api_key=1gI9G84ZafKDEnrbydviGknReOGiVK9jqrQBE3et&start_date=${new Date().toLocaleString().slice(6, 10)}-${new Date().toLocaleString().slice(3, 5)}-01&end_date=${new Date().toLocaleString().slice(6,10)}-${new Date().toLocaleString().slice(3, 5)}-${new Date().toLocaleString().slice(3, 5)}`,
type: "GET",
success: function(data){
for (let i = 0; i < data.length; i++) {
if (data[i].media_type == "image") {
$(".header-row").append(`
<span>
<div class="card">
<img src="${data[i].url}" alt="${data[i].title}" class="card-img-top">
</div>
</span>
`)
}
}
}
});

View file

@ -0,0 +1,84 @@
$.ajax({
url: "http://localhost:8080/api/get/settings",
type: "GET",
success: function(data){
if(data["autoupdate"] === 1){
$("#updateSwitch").attr("checked", "true");
$("#updateText").text("On");
}
if(data["autostart"] === 1) {
$("#autorunSwitch").attr("checked", "true");
$("#autorunText").text("On");
}
}
})
$("#updateSwitch").click(function(){
$.ajax({
url: "http://localhost:8080/api/get/settings",
type: "GET",
success: function(data){
if(data["autoupdate"] === 1){
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autoupdate: 0
},
success: function(){
$("#updateSwitch").removeAttr("checked");
$("#updateText").text("Off");
}
})
} else {
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autoupdate: 1
},
success: function(){
$("#updateSwitch").attr("checked", "true");
$("#updateText").text("On");
}
})
}
}
});
})
$("#autorunSwitch").click(function(){
$.ajax({
url: "http://localhost:8080/api/get/settings",
type: "GET",
success: function(data){
if(data["autostart"] === 1){
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autostart: 0
},
success: function(){
$("#autorunSwitch").removeAttr("checked");
$("#autorunText").text("Off");
}
})
} else {
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autostart: 1
},
success: function(){
$("#autorunSwitch").attr("checked", "true");
$("#autorunText").text("On");
}
})
}
}
});
})

View file

@ -0,0 +1,2 @@
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))

View file

@ -0,0 +1,7 @@
$.ajax({
url: "http://localhost:8080/api/get/version",
type: "GET",
success: function(data){
$("#program-version").text(data.message);
}
})

View file

@ -0,0 +1,37 @@
.card {
border-radius: 8%;
width: 250px;
height: 200px;
overflow: hidden;
margin: 10px;
background-color: #131313;
}
.card img {
width: initial;
height: 100%;
}
.image {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
}
.header-row .card {
display: flex;
flex-direction: column;
justify-content: center;
}
.header-row span > .card {
margin: auto;
}
.header-row span img {
width: 30px;
height: auto;
}

View file

@ -0,0 +1,30 @@
#everynasa-logo {
user-drag: none;
-webkit-user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
#title {
margin-top: 0.6em;
margin-left: 0.5em;
}
.title {
margin-top: 2.3em;
}
.desc {
margin-top: -0.7em;
}
p, .form-check {
margin-left: -18em;
margin-top: -0.8em;
}
#update-desc {
margin-top: -0.8rem;
}