sort entries, add email mailto link

This commit is contained in:
b1ek 2023-02-20 12:53:03 +10:00
parent 9eb34fd46a
commit e4cdc78e1f
2 changed files with 11 additions and 6 deletions

View File

@ -16,17 +16,21 @@ async function handler(req, res, next) {
const errors = req.query.error;
let data = {};
let sqldata = await Sequelize.Guestbook.findAll({
where: {
hidden: false
}
},
order: [
['id', 'DESC']
]
});
if (!sqldata) throw new Error('Failed to get guestbook entries');
for (let i = 0; i != sqldata.length; i++) {
/*for (let i = 0; i != sqldata.length; i++) {
data[sqldata[i].id] = sqldata[i];
}
}*/
const data = sqldata;
res.send(await Helpers.ViewLoader.load('guestbook.pug', {
current_route: req.originalUrl,

View File

@ -86,7 +86,7 @@ block content
p No records available.
else
table(class='gb_entries')
each entry, id in data
each entry, i in data
tr(id='gb_entry_' + id)
td(width='20%' class='gb_sender_data')
p(style='font-size:9pt')
@ -96,7 +96,8 @@ block content
| Sender: #{entry.name}
br
if (!entry.hidemail)
| Email: #{entry.email}
| Email:
a(href='mailto:' + entry.email)= entry.email
else
| Email:
span(class='gb_hidden_mail' style='width:' + (10 * entry.email.length) + 'px')