From af2fcc31f8cbdb61cab91d3b102de2706bf1d717 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Tue, 10 Jan 2023 02:16:20 +0100 Subject: [PATCH] feat: WIP, admins only can see a table of users that have logged in the site --- client/pages/AdminPage.tsx | 24 +++++++++++++ client/styles/main.scss | 73 ++++++++++++++++++++++++++++++++++++++ server/auth.ts | 2 +- server/routes.ts | 4 +-- 4 files changed, 100 insertions(+), 3 deletions(-) diff --git a/client/pages/AdminPage.tsx b/client/pages/AdminPage.tsx index 178d4d4..b0179a7 100644 --- a/client/pages/AdminPage.tsx +++ b/client/pages/AdminPage.tsx @@ -105,6 +105,30 @@ export const AdminPage = ({}) => { Nessuna soluzione ancora da correggere )} + {user.role === 'admin' && ( + <> +
+
Utenti
+
+
Nome Utente
+
Username Ateneo
+
Ruolo
+
Ultimo Login
+
User 1
+
user1
+
admin
+
2/6/2075 20:32
+
User 2
+
user2
+
moderator
+
5/12/2102 20:61
+
User 3
+
user3
+
studente
+
11/5/2066 20:49
+
+ + )} ) diff --git a/client/styles/main.scss b/client/styles/main.scss index dab9ed1..1214788 100644 --- a/client/styles/main.scss +++ b/client/styles/main.scss @@ -494,6 +494,79 @@ main.page-scores { // Components // +.table { + display: grid; + + grid-template-columns: repeat(var(--cols), auto); + + box-shadow: -2px 4px 6px 1px #00000018, 0 0 4px 0px #00000010; + border: 1px solid #ddd; + border-radius: 0.5rem; + background: #ffffff; + + user-select: none; + + overflow: hidden; + + .cell { + padding: 0.5rem 1rem; + + border-right: 1px solid #ddd; + border-bottom: 1px solid #ddd; + + &.last-col { + border-right: none; + } + + &.last-row { + border-bottom: none; + } + + &.header { + font-weight: 400; + + padding-right: 1rem; + + background: #f0f0f0; + + display: flex; + align-items: center; + text-align: center; + justify-content: space-between; + } + + &:not(.header) { + user-select: text; + } + } + + @media screen and (max-width: $device-s-width), (pointer: coarse) { + display: flex; + flex-direction: column; + + width: 100%; + + .cell { + padding: 0.5rem 0.75rem; + + border-bottom: 1px dashed #ddd; + border-right: none; + + &.last-row { + border-bottom: 1px dashed #ddd; + } + + &.last-col { + border-bottom: 1px solid #bbb; + } + + &.last-row.last-col { + border-bottom: none; + } + } + } +} + details { width: 100%; max-width: 80ch; diff --git a/server/auth.ts b/server/auth.ts index 0049e5e..11e3b53 100644 --- a/server/auth.ts +++ b/server/auth.ts @@ -2,7 +2,7 @@ import { Router } from 'express' import { AuthorizationCode } from 'simple-oauth2' import fetch from 'node-fetch' -export function setupOauth(r: Router) { +export function setupOAuth(r: Router) { const config = { client: { id: process.env.OAUTH_CLIENT_ID ?? '', diff --git a/server/routes.ts b/server/routes.ts index 0364a09..2f62ed0 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -38,7 +38,7 @@ import { import { initialDatabaseValue } from './db/example-data' import { validateObjectKeys } from '../shared/utils' -import { setupOauth } from './auth' +import { setupOAuth } from './auth' export async function createApiRouter() { type SessionId = Opaque @@ -73,7 +73,7 @@ export async function createApiRouter() { const authRouter: Router = express.Router() - setupOauth(authRouter) + setupOAuth(authRouter) r.use('/auth', authRouter) r.get('/api/status', (req, res) => {