Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
arch-linux committed Feb 14, 2024
2 parents 36aa2b2 + 321badc commit c6aeba4
Show file tree
Hide file tree
Showing 18 changed files with 719 additions and 322 deletions.
10 changes: 6 additions & 4 deletions auth.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const passport = require('passport');
const Users = require(__dirname + "/models/users.model.js").Users;
const login_logs = require(__dirname + "/models/login_logs.model.js").login_logs;
const jwt = require('jsonwebtoken');




function generateAccessToken(username) {
return jwt.sign(username, process.env.TOKEN_HASH, { expiresIn: '7 days' });
}
const GoogleStrategy = require('passport-google-oauth2').Strategy;

const GOOGLE_CLIENT_ID = process.env.google_oauth_key;
Expand Down Expand Up @@ -34,11 +35,12 @@ passport.use(new GoogleStrategy({
is_new_user: true
})
userDidLogin(profile.id,request.headers['x-forwarded-for']);
profile.token = generateAccessToken( { username: profile.email} );
} else {
//current user
//lets log this
userDidLogin(profile.id,request.headers['x-forwarded-for']);

profile.token = generateAccessToken( { username: profile.email } );
}

return done(null, profile);
Expand Down
10 changes: 5 additions & 5 deletions internal_routes/debugAircraft.pug
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ html
};
function fetchAircraftData() {
var tail_number = document.getElementById('tail_number').value;
location.href = '/debugAircraft?tail_number=' + tail_number;
location.href = '/debug/aircraft?tail_number=' + tail_number;
}
body
if error
div#errorBox.error-box
span.close-btn(onclick="closeErrorBox()") ×
| #{error} was not found in our records, please create it.
.form-container
form(action="/debugAircraft" method="post")
form(action="/debug/aircraft/" method="post")
.form-field
label(for="tail_number") Tail:
input(type="text" id="tail_number" name="tail_number" value=tail_number required)
Expand Down Expand Up @@ -133,8 +133,8 @@ html
textarea(id="owner_id" name="owner_id") #{owner_id}
.form-field
input(type="submit" value="Submit Changes")
button(type="button" onclick="location.href='/debug'") Back
button(type="button" onclick="location.href='/debugNewAircraft'") New Aircraft
button(type="button" onclick="location.href='/debug/'") Back
button(type="button" onclick="location.href='/debug/newAircraft'") New Aircraft
.form-field
button(type="button" onclick="location.href='/debugAllAircraft'") List All Aircraft
button(type="button" onclick="location.href='/debug/allAircraft'") List All Aircraft
div#error-box.error-box
6 changes: 3 additions & 3 deletions internal_routes/debugAllAircraft.pug
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ html
each airplane in airplanes
tr
td
a(href=`/debugAircraft?tail_number=${airplane.reg}`)= airplane.reg
a(href=`/debug/aircraft?tail_number=${airplane.reg}`)= airplane.reg
td= airplane.model
td
if airplane.owner_id
a(href=`/debugUser?userid=${airplane.owner_id}`) #{airplane.owner_name}
a(href=`/debug/user?userid=${airplane.owner_id}`) #{airplane.owner_name}
else
|
td= airplane.regowner
td= airplane.icao
td= airplane.hours
h5 Found #{airplanes.length} aircraft in system.
button.back-button(type="button" onclick="location.href='/debugAircraft'") Back
button.back-button(type="button" onclick="location.href='/debug/aircraft'") Back
87 changes: 87 additions & 0 deletions internal_routes/debugAllFiles.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
doctype html
html
head
title List All Files
style.
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
.container {
background-color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
max-width: 800px;
margin: 0 auto;
text-align: center;
}
h1 {
margin-bottom: 20px;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #4a90e2;
color: white;
}
.delete-button {
background-color: #ff4d4d;
color: white;
border: none;
cursor: pointer;
padding: 5px 10px;
border-radius: 5px;
}
.back-button, .new-button {
padding: 10px 15px;
background-color: #4a90e2;
color: white;
border: none;
cursor: pointer;
margin: 0 5px; /* Adjusted for spacing */
text-align: center;
}
.form-buttons {
display: flex;
justify-content: center; /* Changed to center for the buttons to be next to each other */
margin-top: 10px;
}
body
.container
h1 List All Files
table
thead
tr
th Edit
th User
th Location
th Extension
th Timestamp
th Delete

tbody
each file in files
tr
td
a(href=`/debug/file?fileuid=${file.file_uid}`)= 'Edit'
td
a(href=`/debug/user?userid=${file.user_id_uploaded}`)= file.friendly_name
td= file.file_name
td= file.file_extension
td= new Date(file.timestamp * 1000).toLocaleString()
td
button.delete-button(type="button" onclick=`if(confirm('Are you sure you want to delete this file?')){fetch('/file/delete/id', {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({id: '${file.file_uid}'})}).then(response => response.json()).then(data => location.reload() ).catch(error => console.error('Error:', error));}`) Delete
h5 Found #{files.length} files in system.
.form-buttons
button.back-button(type="button" onclick="location.href='/debug/file'") Back
button.new-button(type="button" onclick="location.href='/debug/fileUpload'") New
4 changes: 2 additions & 2 deletions internal_routes/debugAllUsers.pug
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ html
each user in users
tr
td
a(href=`/debugUser?userid=${user.user_id}`)= user.user_id
a(href=`/debug/user?userid=${user.user_id}`)= user.user_id
td= user.name
td= user.email
button.back-button(type="button" onclick="location.href='/debugUser'") Back
button.back-button(type="button" onclick="location.href='/debug/user'") Back
69 changes: 0 additions & 69 deletions internal_routes/debugAssignUserPlanes.pug

This file was deleted.

100 changes: 100 additions & 0 deletions internal_routes/debugFile.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
doctype html
html
head
title File Management Tool
style.
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
.form-container {
background-color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
max-width: 600px; /* Adjusted for potentially wider content */
margin: 0 auto;
}
.form-field {
margin-bottom: 15px;
display: flex;
flex-wrap: wrap;
align-items: center;
}
.form-field label {
display: block;
margin-bottom: 5px;
flex-basis: 100%;
}
.form-field input, .form-field textarea, .form-field select {
flex-grow: 1;
padding: 10px;
border-radius: 5px;
border: 1px solid #ddd;
box-sizing: border-box;
}
.form-buttons {
display: flex;
justify-content: space-between;
margin-top: 10px;
}
.form-buttons button, .form-buttons input[type="submit"] {
padding: 10px 15px;
font-size: 1em;
background-color: #4a90e2; /* Blue color */
color: white;
border: none;
cursor: pointer;
flex: 1; /* Flex grow */
margin: 0 5px; /* Spacing between buttons */
box-sizing: border-box;
}
.form-field input[type="checkbox"], .form-field button {
flex-grow: 0;
flex-shrink: 0;
}
body
.form-container
form(action="/file/update" method="post")
if file
.form-field
label(for="file_uid") File UID:
input(type="text" id="file_uid" name="file_uid" value=file.file_uid)
.form-field
label(for="user_id_uploaded") User ID Uploaded:
input(type="text" id="user_id_uploaded" name="user_id_uploaded" value=file.user_id_uploaded)
.form-field
label(for="timestamp") Timestamp:
input(type="text" id="timestamp" name="timestamp" value=file.timestamp)
.form-field
label(for="type") Type:
input(type="text" id="type" name="type" value=file.type)
.form-field
label(for="linked_aircraft_id") Linked Aircraft ID:
input(type="number" id="linked_aircraft_id" name="linked_aircraft_id" value=file.linked_aircraft_id)
.form-field
label(for="hand_written") Hand Written:
input(type="checkbox" id="hand_written" name="hand_written" checked=file.hand_written)
.form-field
label(for="title") Title:
input(type="text" id="title" name="title" value=file.title)
.form-field
label(for="parsed_content") Parsed Content (JSON):
textarea(id="parsed_content" name="parsed_content")= JSON.stringify(file.parsed_content ? file.parsed_content : {})
.form-field
label(for="full_location") Full Location:
input(type="text" id="full_location" name="full_location" value=file.full_location)
.form-field
label(for="file_name") File Name:
input(type="text" id="file_name" name="file_name" value=file.file_name)
.form-field
label(for="description") Description:
textarea(id="description" name="description")= file.description ? file.description : ''
else
p No file selected.
.form-buttons
button(type="button" onclick="location.href=/debug/") Main Debug
input(type="submit" value="Save Changes")
button(type="button" onclick="location.href='/debug/allFiles'") List All

8 changes: 6 additions & 2 deletions internal_routes/debugMain.pug
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ html
tr
td User Debug
td
a.button(href="/debugUser") User Debug
a.button(href="/debug/user") User Debug
tr
td Aircraft Debug
td
a.button(href="/debugAircraft") Aircraft Debug
a.button(href="/debug/aircraft") Aircraft Debug
tr
td File Managment
td
a.button(href="/debug/allFiles") File Debug

4 changes: 2 additions & 2 deletions internal_routes/debugNewAircraftForm.pug
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ html
body
h1.title Initialize New Aircraft
.form-container
form(action="/debugNewAircraft" method="post")
form(action="/debug/newAircraft" method="post")
.form-field
label(for="tail_number") Aircraft Tail Number:
input(type="text" id="tail_number" name="tail_number" required)
.form-buttons
input(type="submit" value="Submit")
button(type="button" onclick="location.href='/debugAircraft'") Back
button(type="button" onclick="location.href='/debug/aircraft'") Back
div#error-box.error-box
Loading

0 comments on commit c6aeba4

Please sign in to comment.