add: better css & milestone
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,2 +1,6 @@
|
|||||||
.env
|
.env
|
||||||
bozo
|
bozo
|
||||||
|
bin
|
||||||
|
lib
|
||||||
|
lib64
|
||||||
|
pyvenv.cfg
|
19
main.py
19
main.py
@ -24,10 +24,25 @@ def update():
|
|||||||
f.write(values)
|
f.write(values)
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
|
|
||||||
|
def record():
|
||||||
|
global values
|
||||||
|
tmp = values.split(' ')
|
||||||
|
today = datetime.datetime.today()
|
||||||
|
longer = 0
|
||||||
|
if len(tmp) == 0:
|
||||||
|
return 0
|
||||||
|
if len(tmp) < 2:
|
||||||
|
return abs(datetime.datetime.strptime(tmp[0], "%Y-%m-%d") - today).days
|
||||||
|
for i in range(0, len(tmp) - 1):
|
||||||
|
if abs((datetime.datetime.strptime(tmp[i], "%Y-%m-%d").date() - datetime.datetime.strptime(tmp[i + 1], "%Y-%m-%d").date()).days) > longer:
|
||||||
|
longer = abs((datetime.datetime.strptime(tmp[i], "%Y-%m-%d").date() - datetime.datetime.strptime(tmp[i + 1], "%Y-%m-%d").date()).days)
|
||||||
|
if abs((today - datetime.datetime.strptime(tmp[-1], "%Y-%m-%d")).days) > longer:
|
||||||
|
longer = abs((today - datetime.datetime.strptime(tmp[-1], "%Y-%m-%d")).days)
|
||||||
|
return longer
|
||||||
|
|
||||||
@app.route("/", methods = ['GET'])
|
@app.route("/", methods = ['GET'])
|
||||||
def normal():
|
def normal():
|
||||||
print(values.split(" "))
|
return render_template('home.html', longer = record(), dates = wrap(values, 10), total = len(values.split(' ')), days = (datetime.datetime.today().date() - datetime.datetime.strptime(values.split(' ')[-1], "%Y-%m-%d").date()).days)
|
||||||
return render_template('home.html', dates = wrap(values, 10), total = len(values.split(' ')), days = (datetime.datetime.today().date() - datetime.datetime.strptime(values.split(' ')[-1], "%Y-%m-%d").date()).days)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,116 +1,144 @@
|
|||||||
<link rel="stylesheet" href="../styles.css">
|
<!DOCTYPE html>
|
||||||
<style>
|
<html lang="fr">
|
||||||
body {
|
<head>
|
||||||
font-family: "Helvetica Neue", Helvetica, Arial;
|
<meta charset="UTF-8">
|
||||||
font-weight: regular;
|
<title>CA42 - Compteur</title>
|
||||||
}
|
|
||||||
h1, h2 {
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
header {
|
|
||||||
min-height: 100px;
|
|
||||||
background: #29AC51;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
h1 {
|
|
||||||
padding: 30px;
|
|
||||||
margin: auto;
|
|
||||||
font-size: 50px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#desc {
|
|
||||||
max-width: 550px;
|
|
||||||
text-align: center;
|
|
||||||
margin: auto;
|
|
||||||
padding: 50px 0px 25px 0px;
|
|
||||||
}
|
|
||||||
#counter {
|
|
||||||
max-width: 500px;
|
|
||||||
margin: auto;
|
|
||||||
padding: 25px 0 50px 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
font-size: 50px;
|
|
||||||
font-family: 'Teko', sans-serif;
|
|
||||||
}
|
|
||||||
#days {
|
|
||||||
font-family: 'Aldrich', sans-serif;
|
|
||||||
font-size: 55px;
|
|
||||||
padding: 50px 0 50px 0;
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
#record {
|
|
||||||
font-family: 'Teko', sans-serif;
|
|
||||||
font-size: 30px;
|
|
||||||
}
|
|
||||||
#incident-btn {
|
|
||||||
padding: 35px 45px 35px 45px;
|
|
||||||
max-width: 150px;
|
|
||||||
text-align: center;
|
|
||||||
margin: auto;
|
|
||||||
color: #fff;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 30px;
|
|
||||||
background: #B00000;
|
|
||||||
border-bottom: solid #A20000 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
#incident-btn:hover {
|
|
||||||
background-color: #ff0000;
|
|
||||||
}
|
|
||||||
.btn-text {
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
<link href="https://fonts.googleapis.com/css2?family=Aldrich&family=Roboto&family=Teko&display=swap" rel="stylesheet">
|
||||||
<script>
|
|
||||||
// JavaScript function to handle button click
|
<style>
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
body {
|
||||||
const incidentBtn = document.getElementById("incident-btn");
|
font-family: 'Roboto', Helvetica, Arial, sans-serif;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2 {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
min-height: 100px;
|
||||||
|
background: #29AC51;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
header h1 {
|
||||||
|
padding: 30px;
|
||||||
|
margin: auto;
|
||||||
|
font-size: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#desc {
|
||||||
|
max-width: 550px;
|
||||||
|
text-align: center;
|
||||||
|
margin: auto;
|
||||||
|
padding: 10px 0 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#counter {
|
||||||
|
max-width: 500px;
|
||||||
|
margin: auto;
|
||||||
|
padding: 10px 0 20px 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 50px;
|
||||||
|
font-family: 'Roboto', Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
#days {
|
||||||
|
font-family: 'Aldrich', sans-serif;
|
||||||
|
font-size: 55px;
|
||||||
|
padding: 10px 0 50px 0;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
#record {
|
||||||
|
font-family: 'Teko', sans-serif;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#incident-btn {
|
||||||
|
padding: 35px 45px;
|
||||||
|
max-width: 150px;
|
||||||
|
text-align: center;
|
||||||
|
margin: auto;
|
||||||
|
color: #fff;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 30px;
|
||||||
|
background: #B00000;
|
||||||
|
border-bottom: solid #A20000 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#incident-btn:hover {
|
||||||
|
background-color: #ff0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-text {
|
||||||
|
text-align: center;
|
||||||
|
padding-top: 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
incidentBtn.addEventListener("click", function () {
|
|
||||||
// Make a POST request to the /api/update route
|
|
||||||
fetch("/api/update", {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (response.redirected) {
|
|
||||||
// If the request is successful and we are redirected
|
|
||||||
window.location.href = response.url;
|
|
||||||
} else {
|
|
||||||
alert("Error: Could not update the incident.");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error("Error:", error);
|
|
||||||
alert("An error occurred while updating the incident.");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<header>
|
<header>
|
||||||
<h1>ca42</h1>
|
<h1>ca42</h1>
|
||||||
</header>
|
</header>
|
||||||
<div id="desc">
|
|
||||||
<p>Nombres de jours sans problèmes sanitaires a 42 Angoulême.</p>
|
<div id="desc">
|
||||||
|
<p>
|
||||||
|
Nombres de jours sans problèmes sanitaires à 42 Angoulême.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="counter">
|
||||||
|
<h2>Jours depuis le dernier problème:</h2>
|
||||||
|
<p id="days">{{days}}</p>
|
||||||
|
<div>
|
||||||
|
<p id="last-incident"></p>
|
||||||
</div>
|
</div>
|
||||||
<div id="counter">
|
<div>
|
||||||
<h1>Jours depuis le dernier problème:</h1>
|
<p id="record">
|
||||||
<div>
|
Nombre total de problèmes : {{total}}<br>
|
||||||
<p id="days">{{days}}</p>
|
Record de jours sans problèmes: {{longer}}
|
||||||
</div>
|
</p>
|
||||||
<div>
|
|
||||||
<p id="last-incident"></p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p id="record">Nombre total de problèmes : {{total}}<p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="incident-btn" form action>Incident</div>
|
</div>
|
||||||
<p class="btn-text">Note: Un accident par jour pour éviter la redondance</p>
|
|
||||||
|
<div id="incident-btn">Incident</div>
|
||||||
|
<p class="btn-text">Note: Un accident par jour pour éviter la redondance</p>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const incidentBtn = document.getElementById("incident-btn");
|
||||||
|
|
||||||
|
incidentBtn.addEventListener("click", function () {
|
||||||
|
fetch("/api/update", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.redirected) {
|
||||||
|
window.location.href = response.url;
|
||||||
|
} else {
|
||||||
|
alert("Error: Could not update the incident.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error:", error);
|
||||||
|
alert("An error occurred while updating the incident.");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
Reference in New Issue
Block a user