Skip to content

Commit

Permalink
ServiceList setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tfloow committed Jan 22, 2024
1 parent 5851a3f commit 17f50d0
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 15 deletions.
9 changes: 9 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ def service(service):

return render_template("itemWebsite.html", service=service, url=url, UP=UP)

@app.route("/serviceList")
def serviceList():
dictService = []

for service in services:
dictService.append(dict(service=service, url=services[service]["url"], reportedStatus=dataReport.getLastReport(service), Status=services[service]["Last status"]))

return render_template("serviceList.html", serviceInfo=dictService)

# To handle error reporting
@app.route('/process', methods=['GET'])
def process():
Expand Down
2 changes: 2 additions & 0 deletions data/404-Test/log.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
date,UP
2024-01-22T13:26:59,True
2024-01-22T16:02:54,True
2024-01-22T16:17:41,True
2 changes: 2 additions & 0 deletions data/ADE/log.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ date,UP
2024-01-22T14:03:05,True
2024-01-22T14:03:07,True
2024-01-22T14:21:15,True
2024-01-22T15:51:14,False
2024-01-22T15:51:19,True
1 change: 1 addition & 0 deletions data/Gradescope/log.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
date,UP
2024-01-22T14:02:32,True
2024-01-22T14:21:28,True
2024-01-22T16:59:51,True
1 change: 1 addition & 0 deletions data/Intranet/log.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ date,UP
2024-01-22T12:32:30,True
2024-01-22T12:32:35,False
2024-01-22T14:21:46,True
2024-01-22T15:05:02,True
1 change: 1 addition & 0 deletions data/Pilou-Pilou/log.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
date,UP
2024-01-22T14:15:34,False
2024-01-22T15:11:51,False
1 change: 1 addition & 0 deletions data/UCLouvain/log.csv
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
date,UP
2024-01-22T17:00:28,True
11 changes: 11 additions & 0 deletions dataReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ def dataExtraction():
for service in serviceList:
os.system(f'cmd /c "curl {url}/extract?get={service} -o data/{service}/log.csv"')

def getLastReport(service):
with open("data/" + service + "/log.csv", "r") as file:
f = file.readlines()
lastValue = f[-1].split(",")[1].strip("\n")


if lastValue == "False":
return False
if lastValue == "True":
return True
return None

if __name__ == "__main__":
dataExtraction()
18 changes: 9 additions & 9 deletions services.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
{
"404-Test": {
"Last access time": "2024-01-22T13:36:43",
"Last access time": "2024-01-22T17:55:49",
"Last status": false,
"url": "https://www.google.com/404"
},
"ADE": {
"Last access time": "2024-01-22T13:31:30",
"Last access time": "2024-01-22T17:56:09",
"Last status": true,
"url": "https://horaire.uclouvain.be/direct/"
},
"ADE-Scheduler": {
"Last access time": "2024-01-22T13:36:43",
"Last access time": "2024-01-22T17:55:49",
"Last status": true,
"url": "https://ade-scheduler.info.ucl.ac.be/calendar/"
},
"Comproved": {
"Last access time": "2024-01-22T13:36:43",
"Last access time": "2024-01-22T17:55:49",
"Last status": true,
"url": "https://app.comproved.com/universite-de-louvain"
},
"Gradescope": {
"Last access time": "2024-01-22T13:36:44",
"Last access time": "2024-01-22T17:55:50",
"Last status": true,
"url": "https://www.gradescope.com/"
},
"Intranet": {
"Last access time": "2024-01-22T13:36:44",
"Last access time": "2024-01-22T17:55:50",
"Last status": true,
"url": "https://intranet.uclouvain.be"
},
"Moodle": {
"Last access time": "2024-01-22T13:36:44",
"Last access time": "2024-01-22T17:55:50",
"Last status": true,
"url": "https://moodle.uclouvain.be/"
},
"Pilou-Pilou": {
"Last access time": "2024-01-22T13:36:44",
"Last access time": "2024-01-22T17:55:50",
"Last status": false,
"url": "https://perso.uclouvain.be/vincent.legat/zoulab/"
},
"UCLouvain": {
"Last access time": "2024-01-22T13:36:45",
"Last access time": "2024-01-22T17:55:51",
"Last status": true,
"url": "https://www.uclouvain.be/"
}
Expand Down
2 changes: 1 addition & 1 deletion static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ body {
background-color: rgb(0, 12, 51);
text-align: left;
margin: 0;
padding: 0;
padding: 10px;

display: flex;
align-items: center; /* Center vertically */
Expand Down
9 changes: 8 additions & 1 deletion static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ h1{
iframe{
overflow: hidden; /* So I don't have any scroll */

width: 420px;
width: 400px;
height: 200px;

margin: 10px;
Expand All @@ -32,6 +32,13 @@ iframe{
justify-content: center; /* Center horizontally */
}

/*For mobile*/
@media (max-width: 600px) {
iframe {
width: 320px;
}
}

/* Default link style */
a {
color: blue;
Expand Down
13 changes: 11 additions & 2 deletions static/styleItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
}




.container {
max-width: 100%; /* Set your desired maximum width */
min-width: 100px; /* Set your desired minimum width */
Expand Down Expand Up @@ -83,6 +81,17 @@
background-color: rgb(153, 103, 95);
}

/*For mobile*/
@media (max-width: 600px) {
#down {
padding: 10px 100px 10px 100px;
}

#up {
padding: 10px 115px 10px 115px;
}
}

/* Define the CSS class */
.big-gap {
margin-top: 1000px; /* Adjust the value as needed to achieve the desired gap */
Expand Down
70 changes: 70 additions & 0 deletions static/styleServiceList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
table{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;

border-collapse: collapse;
}

/* Default link style */
a {
color: blue;
text-decoration: none; /* Remove underline */
}

/* Visited link style */
a:visited {
color: blue; /* Set the color for visited links */
}

h3{
font-style: italic;
}

h4{
color: rgb(50, 56, 61);
}

th, td{
text-align: center;
margin-top:12px;
border-bottom: 1px solid #adacac;
padding-left: 10px;
}

.report-up{
color: green;
}

.report-down{
color: red;
}

.report-none{
color: lightslategray;
align-items: center;
}

.thumb{
background-color: lightgray;
width: 70px;
font-size: 20px;

display: flex;
justify-content: center;
align-items: center;

border-radius: 15px;
border-style:solid;
border-width: 2px;

margin: 0 auto;
}

.line-sep{
display: block;
border-bottom: 1px solid #dddddd; /* Add a bottom border for the divider */
margin-bottom: 4px; /* Adjust margin for better spacing */
background-color: red;
}
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div id="header">
<a href="/"><span class="header-button"> <b>Home</b> </span></a>
<a href="https://github.com/Tfloow/UCLouvainDown"><span class="header-button"> <b>Github</b> </span></a>
<span class="header-button"> <b>ServiceList</b> </span>
<a href="/serviceList"><span class="header-button"> <b>ServiceList</b> </span></a>
</div>

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion templates/itemWebsite.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{% endblock %}


{% block content %}
{% block content %}
<h2>Status for {{ service }} @ <a href={{ url }} id="urlTO"> {{ url }} </a> </h2>

{% if UP %}
Expand Down
42 changes: 42 additions & 0 deletions templates/serviceList.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends "base.html" %}
{% block head %}
<title>ServiceList</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styleItem.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='styleServiceList.css') }}">
<link rel="icon" type="image/x-icon" href="/static/ico/icoDOWN.png">
{% endblock %}


{% block content %}
<table border="0">

<tr>
<th> <h3>Service</h3> </th>
<th> <h3>URL</h3> </th>
<th> <h3>Reported Status by Users</h3> </th>
<th> <h3>Status</h3> </th>
</tr>
{% for serviceInfo in serviceInfo %}
<tr>


<th> <h4>{{ serviceInfo["service"] }}</h4> </th>
<th> <h5><a href={{ serviceInfo["url"] }}>{{ serviceInfo["url"] }}</a></h5> </th>
{% if serviceInfo["reportedStatus"] %}
<th class="report-up"> <div class="thumb"> {{ serviceInfo["reportedStatus"] }} </div> </th>
{% elif serviceInfo["reportedStatus"] == False %}
<th class="report-down"> <div class="thumb"> {{ serviceInfo["reportedStatus"] }} </div> </th>
{% else %}
<th class="report-none"> <div class="thumb"> {{ serviceInfo["reportedStatus"] }} </div> </th>
{% endif %}

{% if serviceInfo["Status"] %}
<th id="up"> &nbsp;&nbsp;Up&nbsp;&nbsp; </th>
{% else %}
<th id="down"> Down</th>
{% endif %}
</tr>
{% endfor %}

</table>
{% endblock %}

0 comments on commit 17f50d0

Please sign in to comment.