Compare commits

..

No commits in common. "a8223d110bbe284a5efe3b07db9930f76fb3375b" and "f493dfaed04fb62adfa797364955469f4c0339d2" have entirely different histories.

4 changed files with 28 additions and 28 deletions

View File

@ -6,11 +6,5 @@
"password": "12345", "password": "12345",
"database": "appreports" "database": "appreports"
}, },
"port": "8080", "port": "8080"
"restrictClients": false,
"allowedClients": [
"127.0.0.1",
"::1"
],
"clearLogAfterDays": -1
} }

View File

@ -27,7 +27,11 @@ app.use(bodyParser.text({ type: '*/*' }));
app.post('/', (req, res, next) => { app.post('/', (req, res, next) => {
const json = tryParseJSON(req.body); const json = tryParseJSON(req.body);
if (typeof req.query.json != 'undefined') { if (typeof req.query.json != 'undefined') {
//json mod requests switch (json.action) {
case 'delete': {
pg.query('DELETE FROM "Log" WHERE ID = $1', json.data);
}
}
} else { } else {
pg.query( pg.query(
`INSERT INTO "Log" ("App", "Type", "Client", "Message", "Misc", "Stack") Values($1, $2, $3, $4, $5, $6)`, `INSERT INTO "Log" ("App", "Type", "Client", "Message", "Misc", "Stack") Values($1, $2, $3, $4, $5, $6)`,
@ -40,15 +44,6 @@ app.post('/', (req, res, next) => {
app.get('/', async (req, res, next) => { app.get('/', async (req, res, next) => {
if (typeof req.query.json != 'undefined') { if (typeof req.query.json != 'undefined') {
if (
config.restrictClients &&
!config.allowedClients.includes(req.connection.remoteAddress)
) {
console.log('blocked request from ' + req.connection.remoteAddress);
res.status(403).end();
return;
}
const data = await pg.query( const data = await pg.query(
`SELECT "ID", "Timestamp", "Type", "App", "Client", "Message", "Misc", "Stack" FROM "Log"` `SELECT "ID", "Timestamp", "Type", "App", "Client", "Message", "Misc", "Stack" FROM "Log"`
); );
@ -64,11 +59,6 @@ app.get('/', async (req, res, next) => {
.end( .end(
JSON.stringify({ headings: headings, data: rows, hidden: hiddenData }) JSON.stringify({ headings: headings, data: rows, hidden: hiddenData })
); );
try {
const clearLogInterval = Number.parseInt(config.clearLogAfterDays);
if (clearLogInterval > 0)
await pg.query(`DELETE FROM "Log" WHERE "Timestamp" < now() - interval '${clearLogInterval} days'`);
} catch (e) {}
} else { } else {
next(); next();
} }

View File

@ -8,12 +8,7 @@
:key="key" :key="key"
>{{value}}</th> >{{value}}</th>
</tr> </tr>
<tr v-for="(row,rowKey) in json.data" :key=rowKey> <Item v-for="(row,rowKey) in json.data" :key=rowKey :data=row :hidden=json.hidden></Item>
<td
v-for="(value,key) in row.filter((val,ind)=>!json.hidden.includes(ind))"
:key="key"
>{{value}}</td>
</tr>
</table> </table>
</div> </div>
<br /> <br />

21
web/src/Item.vue Normal file
View File

@ -0,0 +1,21 @@
<template>
<tr id="item">
<td
v-for="(value,key) in data.filter((val,ind)=>!hidden.includes(ind))"
:key="key"
>{{value}}</td>
</tr>
</template>
<script>
export default {
name: "Item",
properties: {
data: Object,
hidden: Array
}
};
</script>
<style scoped>
</style>