commit 85fdb4e1e82c2f3a20369f1399dd13050b2d43b2
parent fb74f22df28e721458179f09f311500f2308b58a
Author: William Lindholm <william_lindholm@outlook.com>
Date: Sun, 5 Nov 2023 13:51:37 +0100
Fixed new main layout.
Diffstat:
7 files changed, 185 insertions(+), 32 deletions(-)
diff --git a/WebAPI/routes.py b/WebAPI/routes.py
@@ -30,7 +30,7 @@ class contact(Resource):
prediction = spam_detection.detect_spam(message_content)
rounded_prediction = float(f'{prediction:.2f}')
- if prediction < .05:
+ if prediction < 0.5:
try:
mailer.send_notification(formatted_subject, formatted_message)
except Exception as e:
diff --git a/WebInterface/routes.py b/WebInterface/routes.py
@@ -29,7 +29,7 @@ def home():
for message in messages
]
- return render_template('home.html', messages=formatted_messages)
+ return render_template('newhome.html', messages=formatted_messages)
@web_interface.route('/login', methods=['GET', 'POST'])
diff --git a/database/db.sql b/database/db.sql
@@ -0,0 +1,21 @@
+CREATE TABLE IF NOT EXISTS messages (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ name TEXT NOT NULL,
+ email TEXT NOT NULL,
+ subject TEXT NOT NULL,
+ message_content TEXT NOT NULL,
+ timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
+ relevance NUMERIC
+);
+
+CREATE TABLE IF NOT EXISTS users (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ username TEXT UNIQUE NOT NULL,
+ email TEXT UNIQUE NOT NULL,
+ hashed_password TEXT NOT NULL,
+ salt TEXT NOT NULL,
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME,
+ last_login DATETIME,
+ is_admin BOOLEAN DEFAULT FALSE
+);
+\ No newline at end of file
diff --git a/static/css/main.css b/static/css/main.css
@@ -0,0 +1,56 @@
+.user-view {
+ background: rgb(57,75,166);
+ background: linear-gradient(268deg, #629da7, #301621);
+}
+
+.sidenav {
+ width: 250px;
+}
+
+.header {
+ font-family: 'Roboto', sans-serif;
+ border-bottom: 1px solid rgba(0,0,0,0.14);
+}
+
+h1 {
+ font-size: 52px;
+ line-height: 1.2;
+ background: -webkit-linear-gradient(#eee, #333);
+ -webkit-background-clip: text;
+ -webkit-text-fill-color: transparent;
+ margin: 0;
+ padding: 0.2em 0;
+}
+
+.truncate-td {
+ max-width: 400px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.content {
+ margin-left: 200px;
+}
+
+@media only screen and (max-width : 992px) {
+ .content {
+ margin-left: 0;
+ }
+}
+
+.nav-center {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.sidenav-trigger {
+ color: black;
+ flex-shrink: 0;
+}
+
+h1.mobile {
+ text-align: center;
+ flex-grow: 1;
+}
+\ No newline at end of file
diff --git a/static/img/nav-bg.png b/static/img/nav-bg.png
Binary files differ.
diff --git a/templates/home.html b/templates/home.html
@@ -6,36 +6,6 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<title>Messages</title>
- <style>
- #sidebar {
- position: fixed;
- top: 0;
- left: 0;
- width: 250px;
- height: 100%;
- background: #343a40;
- transition: all 0.3s ease;
- }
- #sidebar.active {
- left: -250px;
- }
- #sidebar-toggle-btn-open {
- position: fixed;
- left: 20px;
- top: 20px;
- font-size: 30px;
- cursor: pointer;
- color: #333;
- }
- #sidebar-toggle-btn-close {
- position: absolute;
- right: 20px;
- top: 20px;
- font-size: 30px;
- cursor: pointer;
- color: #ddd;
- }
- </style>
</head>
<body>
diff --git a/templates/newhome.html b/templates/newhome.html
@@ -0,0 +1,103 @@
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Messages</title>
+
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
+ <link rel="preconnect" href="https://fonts.googleapis.com">
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap" rel="stylesheet">
+ <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
+</head>
+
+<body>
+
+<ul id="slide-out" class="sidenav">
+ <li>
+ <div class="user-view">
+ <i class="material-icons medium" style="color: white;">account_circle</i>
+ <a href="#name"><span class="white-text name">John Doe</span></a>
+ <a href="#email"><span class="white-text email">jdandturk@gmail.com</span></a>
+ </div>
+ </li>
+ <li><a class="waves-effect" href="#!">Messages</a></li>
+ <li>
+ <div class="divider"></div>
+ </li>
+ <li><a class="subheader">Settings</a></li>
+ <li><a class="waves-effect" href="#!">Account</a></li>
+ <li><a class="waves-effect" href="#!">Admin</a></li>
+</ul>
+
+<ul class="sidenav sidenav-fixed">
+ <li>
+ <div class="user-view">
+ <i class="material-icons medium" style="color: white;">account_circle</i>
+ <a href="#name"><span class="white-text name">John Doe</span></a>
+ <a href="#email"><span class="white-text email">jdandturk@gmail.com</span></a>
+ </div>
+ </li>
+ <li><a class="waves-effect" href="#!">Messages</a></li>
+ <li>
+ <div class="divider"></div>
+ </li>
+ <li><a class="subheader">Settings</a></li>
+ <li><a class="waves-effect" href="#!">Account</a></li>
+ <li><a class="waves-effect" href="#!">Admin</a></li>
+</ul>
+
+<div class="header">
+ <div class="content">
+ <div class="container hide-on-med-and-down">
+ <h1>Messages</h1>
+ </div>
+ <div class="hide-on-large-only">
+ <div class="container" style="display: flex; justify-content: space-between; align-items: center;">
+ <a href="#" data-target="slide-out" class="sidenav-trigger" style="flex-shrink: 0;"><i class="material-icons">menu</i></a>
+ <h1 class="mobile">Messages</h1>
+ <div style="width: 24px;"></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+
+<div class="content">
+ <div class="container">
+ <br>
+ <table class="highlight responsive-table">
+ <thead>
+ <tr>
+ <th>Subject</th>
+ <th>Sender</th>
+ <th>Email</th>
+ <th>Timestamp</th>
+ <th>Relevance</th>
+ <th class="truncate">Message</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for message in messages %}
+ <tr>
+ <td>{{ message.subject }}</td>
+ <td>{{ message.name }}</td>
+ <td>{{ message.email }}</td>
+ <td>{{ message.timestamp }}</td>
+ <td>{{ message.relevance }}</td>
+ <td class="truncate-td">{{ message.message_content }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+</div>
+
+<script>
+ document.addEventListener('DOMContentLoaded', function() {
+ var elems = document.querySelectorAll('.sidenav');
+ var instances = M.Sidenav.init(elems);
+ });
+</script>
+</body>
+\ No newline at end of file