mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-23 20:54:48 -04:00
[admin] timesheets overview improvements
This commit is contained in:
parent
105ac35034
commit
186835ec0c
@ -107,13 +107,6 @@
|
||||
link="/admin/timesheets"
|
||||
header="Volunteering timesheets"
|
||||
/>
|
||||
<AdminDashboardCard
|
||||
v-if="$isGranted('org')"
|
||||
v-show="!filterAttention"
|
||||
icon="file-spreadsheet"
|
||||
link="/admin/timesheets/overview"
|
||||
header="Timesheets overview"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template v-for="({name, config: localeConfig, url, published}, locale) in allLocales" v-if="$isGranted('panel', locale) && stats[locale]">
|
||||
|
@ -2,11 +2,15 @@
|
||||
<Page wide>
|
||||
<NotFound v-if="!$isGranted('panel')"/>
|
||||
<div v-else>
|
||||
<p>
|
||||
<p class="d-flex justify-content-between">
|
||||
<nuxt-link to="/admin">
|
||||
<Icon v="user-cog"/>
|
||||
<T>admin.header</T>
|
||||
</nuxt-link>
|
||||
<nuxt-link to="/admin/timesheets/overview">
|
||||
<Icon v="file-spreadsheet"/>
|
||||
Overview
|
||||
</nuxt-link>
|
||||
</p>
|
||||
<div v-html="moderation.timesheets"/>
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
<template>
|
||||
<Page wide>
|
||||
<NotFound v-if="!$isGranted('org')"/>
|
||||
<NotFound v-if="!$isGranted('panel')"/>
|
||||
<div v-else>
|
||||
<p>
|
||||
<p class="d-flex justify-content-between">
|
||||
<nuxt-link to="/admin">
|
||||
<Icon v="user-cog"/>
|
||||
<T>admin.header</T>
|
||||
</nuxt-link>
|
||||
</p>
|
||||
<h2>
|
||||
<nuxt-link to="/admin/timesheets">
|
||||
<Icon v="file-spreadsheet"/>
|
||||
Fill out yours
|
||||
</nuxt-link>
|
||||
</p> <h2>
|
||||
<Icon v="file-spreadsheet"/>
|
||||
Timesheets overview
|
||||
</h2>
|
||||
@ -49,10 +52,10 @@
|
||||
<tr v-for="(hours, username) in hoursSummary">
|
||||
<th><LocaleLink locale="_" :link="`/@${username}`">@{{username}}</LocaleLink></th>
|
||||
<td>{{ hours }}</td>
|
||||
<td>{{ hoursSum && username !== 'andrea' ? ((100 * hours / hoursSum).toFixed(1) + '%') : '—'}}</td>
|
||||
<td>{{ hoursSum && timesheets[username].transfer !== 'skip' ? ((100 * hours / hoursSum).toFixed(1) + '%') : '—'}}</td>
|
||||
<td>
|
||||
<p><strong>{{timesheets[username].transfer}}</strong></p>
|
||||
<ul>
|
||||
<ul v-if="timesheets[username]">
|
||||
<li v-for="(value, key) in timesheets[username].details" v-if="value">
|
||||
<strong>{{ key }}:</strong> {{ value }}
|
||||
</li>
|
||||
@ -127,7 +130,7 @@ export default {
|
||||
hoursSum() {
|
||||
let sum = 0;
|
||||
for (let username in this.hoursSummary) {
|
||||
if (!this.hoursSummary.hasOwnProperty(username) || username === 'andrea') { continue; }
|
||||
if (!this.hoursSummary.hasOwnProperty(username) || this.timesheets[username].transfer === 'skip') { continue; }
|
||||
sum += this.hoursSummary[username];
|
||||
}
|
||||
return sum;
|
||||
|
@ -568,13 +568,17 @@ router.post('/admin/timesheet', handleErrorAsync(async (req, res) => {
|
||||
}));
|
||||
|
||||
router.get('/admin/timesheets', handleErrorAsync(async (req, res) => {
|
||||
if (!req.isGranted('org')) {
|
||||
if (!req.isGranted('panel')) {
|
||||
return res.status(401).json({error: 'Unauthorised'});
|
||||
}
|
||||
|
||||
const timesheetsByUsername = {};
|
||||
for (let {username, timesheets} of await req.db.all(SQL`SELECT username, timesheets FROM users WHERE timesheets IS NOT NULL`)) {
|
||||
timesheetsByUsername[username] = JSON.parse(timesheets);
|
||||
timesheets = JSON.parse(timesheets);
|
||||
if (!req.isGranted('org')) {
|
||||
delete timesheets['details'];
|
||||
}
|
||||
timesheetsByUsername[username] = timesheets;
|
||||
}
|
||||
|
||||
return res.json(timesheetsByUsername);
|
||||
|
Loading…
x
Reference in New Issue
Block a user