Moderation Ui

This commit is contained in:
insert 2023-08-17 16:21:41 -04:00
parent e5a84e2147
commit 0455c763fd
No known key found for this signature in database
GPG key ID: 8F1F3466FB204C55
3 changed files with 84 additions and 5 deletions

View file

@ -262,6 +262,25 @@ app.get('/stats', async (req, res, next) => {
} }
}) })
app.get('/moddata', async (req, res, next) => {
try {
console.log(req.query)
console.log(req.query.name)
console.log(apex.utils.usernameToIRI('test'))
console.log(await apex.utils.usernameToIRI('test'))
var object = await apex.store.getObject(apex.utils.usernameToIRI(req.query.name))
console.log(object)
console.log(object.id)
console.log("test")
const queueSize = await apex.store.db.collection(`${object.id}-queue`).find().toArray()
// console.log(res.json({queueSize}))
console.log(queueSize)
res.json(queueSize)
} catch (err) {
next(err)
}
})
app.use(function (err, req, res, next) { app.use(function (err, req, res, next) {
console.error(err.message, req.body, err.stack) console.error(err.message, req.body, err.stack)
if (!res.headersSent) { if (!res.headersSent) {
@ -286,11 +305,10 @@ client.connect()
await apex.store.saveObject(systemUser) await apex.store.saveObject(systemUser)
apex.systemUser = systemUser apex.systemUser = systemUser
} }
apex.systemUser = await apex.store.getObject(apex.utils.usernameToIRI('testing'), true) apex.group = await apex.store.getObject(apex.utils.usernameToIRI('testing'), true)
if (!apex.systemUser) { if (!apex.group) {
const systemUser = await createGuppeActor('test', 'test', 'A project built on guppe groups\, it features a moderation ui', icon, 'Group') const group = await createGuppeActor('test', 'test', 'A project built on guppe groups\, it features a moderation ui', icon, 'Group')
await apex.store.saveObject(systemUser) await apex.store.saveObject(group)
apex.systemUser = systemUser
} }
let server let server
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {

View file

@ -2,6 +2,7 @@ import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import Home from './views/Home.vue' import Home from './views/Home.vue'
import Profile from './views/Profile.vue' import Profile from './views/Profile.vue'
import Moderation from './views/Moderation.vue'
Vue.use(Router) Vue.use(Router)
@ -18,6 +19,12 @@ export default new Router({
name: 'profile', name: 'profile',
component: Profile, component: Profile,
props: true props: true
},
{
path: '/mod/:name',
name: 'moderation',
component: Moderation,
props: true
} }
], ],
scrollBehavior (to, from, savedPosition) { scrollBehavior (to, from, savedPosition) {

View file

@ -0,0 +1,54 @@
<template>
<div class="w3-container">
<h1>Moderation for {{name}} </h1>
<ul style="list-style-type:none;">
<li v-for="item in queue">
<a :href="item.object[0]" target="_blank">{{ item.object[0] }}</a>
<a class="approve" :href="item.object[0]" target="_blank">Approve</a>
<a class="approve" :href="item.object[0]" target="_blank">Deny</a>
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'home',
components: {},
props: {
name: {
type: String,
required: true,
}
},
data () {
return {
queue: [],
error: null,
name: this.name,
domain: window.location.host
}
},
created () {
window.fetch(`/moddata?name=${this.name}`, {
method: 'get',
headers: {
accept: 'application/json'
}
}).then(res => res.json())
.then(json => {
console.log("test2")
console.log(json)
this.queue = json
})
.catch(err => (this.error = err.message))
}
}
</script>
<style>
a.approve {
float:right;
}
</style>