mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
Compare commits
10 Commits
remove_ina
...
2.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fda4aabdd | ||
|
|
bc376a72ee | ||
|
|
d360a9044c | ||
|
|
8b4e5740d7 | ||
|
|
c8fb5af44d | ||
|
|
24cea2b0b2 | ||
|
|
eea9732100 | ||
|
|
f425decf2c | ||
|
|
8b57f6dd47 | ||
|
|
dda6fc299a |
@@ -3,7 +3,7 @@
|
|||||||
root = true
|
root = true
|
||||||
|
|
||||||
[*]
|
[*]
|
||||||
indent_style = space
|
indent_style = tab
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
@@ -17,8 +17,5 @@ insert_final_newline = unset
|
|||||||
indent_style = unset
|
indent_style = unset
|
||||||
insert_final_newline = unset
|
insert_final_newline = unset
|
||||||
|
|
||||||
[MakeFile]
|
|
||||||
indent_style = space
|
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|||||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"typescript.preferences.importModuleSpecifier": "non-relative",
|
"typescript.preferences.importModuleSpecifier": "non-relative",
|
||||||
/* Prefer tabs over spaces for accessibility */
|
/* Prefer tabs over spaces for accessibility */
|
||||||
"editor.insertSpaces": true,
|
"editor.insertSpaces": false,
|
||||||
"editor.detectIndentation": false,
|
"editor.detectIndentation": false,
|
||||||
/* Explorer */
|
/* Explorer */
|
||||||
"explorer.fileNesting.enabled": true,
|
"explorer.fileNesting.enabled": true,
|
||||||
"explorer.fileNesting.patterns": {
|
"explorer.fileNesting.patterns": {
|
||||||
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
|
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
|
||||||
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, rollup.config.mjs, tsconfig.json, eslint.config.js",
|
"package.json": "pnpm-lock.yaml, tsconfig.json, eslint.config.js, .babelrc, vite.config.ts, .editorconfig",
|
||||||
"Makefile": "*compose.yml, Dockerfile, .dockerignore, *startup.sh"
|
"Makefile": "*compose.yml, Dockerfile, servers_pgadmin.json, .dockerignore"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,10 +53,9 @@ ENV PORT=$PORT
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=production-deps /app/node_modules /app/node_modules
|
COPY --from=production-deps /app/node_modules /app/node_modules
|
||||||
COPY --from=build /app/build /app
|
COPY --from=build /app/build /app
|
||||||
COPY --from=build /app/startup.sh /app/startup.sh
|
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE $PORT
|
EXPOSE $PORT
|
||||||
|
|
||||||
# Start app
|
# Start app
|
||||||
CMD node bin/console.js migration:run --force && sh startup.sh
|
CMD node bin/console.js migration:run --force && node bin/server.js
|
||||||
|
|||||||
10
Makefile
10
Makefile
@@ -1,11 +1,13 @@
|
|||||||
dev:
|
dev:
|
||||||
@docker compose down
|
@docker compose down
|
||||||
@docker compose -f dev.docker-compose.yml up -d --wait
|
@docker compose -f dev.compose.yml pull
|
||||||
|
@docker compose -f dev.compose.yml up -d --wait
|
||||||
@node ace migration:fresh
|
@node ace migration:fresh
|
||||||
@./dev.startup.sh
|
@pnpm run dev
|
||||||
|
|
||||||
prod:
|
prod:
|
||||||
@docker compose -f dev.docker-compose.yml down
|
@docker compose -f dev.compose.yml down
|
||||||
|
@docker compose pull
|
||||||
@docker compose up -d --build --wait
|
@docker compose up -d --build --wait
|
||||||
|
|
||||||
seed:
|
seed:
|
||||||
@@ -13,7 +15,7 @@ seed:
|
|||||||
|
|
||||||
down:
|
down:
|
||||||
@-docker compose down
|
@-docker compose down
|
||||||
@-docker compose -f dev.docker-compose.yml down
|
@-docker compose -f dev.compose.yml down
|
||||||
|
|
||||||
release:
|
release:
|
||||||
@pnpm run release
|
@pnpm run release
|
||||||
|
|||||||
14
adonisrc.ts
14
adonisrc.ts
@@ -14,7 +14,6 @@ export default defineConfig({
|
|||||||
() => import('@adonisjs/core/commands'),
|
() => import('@adonisjs/core/commands'),
|
||||||
() => import('@adonisjs/lucid/commands'),
|
() => import('@adonisjs/lucid/commands'),
|
||||||
() => import('@izzyjs/route/commands'),
|
() => import('@izzyjs/route/commands'),
|
||||||
() => import('adonisjs-scheduler/commands'),
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -46,10 +45,6 @@ export default defineConfig({
|
|||||||
() => import('@adonisjs/ally/ally_provider'),
|
() => import('@adonisjs/ally/ally_provider'),
|
||||||
() => import('@izzyjs/route/izzy_provider'),
|
() => import('@izzyjs/route/izzy_provider'),
|
||||||
() => import('#providers/route_provider'),
|
() => import('#providers/route_provider'),
|
||||||
{
|
|
||||||
file: () => import('adonisjs-scheduler/scheduler_provider'),
|
|
||||||
environment: ['console'],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -60,14 +55,7 @@ export default defineConfig({
|
|||||||
| List of modules to import before starting the application.
|
| List of modules to import before starting the application.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
preloads: [
|
preloads: [() => import('#start/routes'), () => import('#start/kernel')],
|
||||||
() => import('#start/routes'),
|
|
||||||
() => import('#start/kernel'),
|
|
||||||
{
|
|
||||||
file: () => import('#start/scheduler'),
|
|
||||||
environment: ['console'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ class UserWithRelationCountDto {
|
|||||||
fullname: this.user.name,
|
fullname: this.user.name,
|
||||||
avatarUrl: this.user.avatarUrl,
|
avatarUrl: this.user.avatarUrl,
|
||||||
isAdmin: this.user.isAdmin,
|
isAdmin: this.user.isAdmin,
|
||||||
createdAt: this.user.createdAt,
|
createdAt: this.user.createdAt.toString(),
|
||||||
updatedAt: this.user.updatedAt,
|
updatedAt: this.user.updatedAt.toString(),
|
||||||
count: {
|
lastSeenAt:
|
||||||
link: Number(this.user.$extras.totalLinks),
|
this.user.lastSeenAt?.toString() ?? this.user.updatedAt.toString(),
|
||||||
collection: Number(this.user.$extras.totalCollections),
|
linksCount: Number(this.user.$extras.totalLinks),
|
||||||
},
|
collectionsCount: Number(this.user.$extras.totalCollections),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import logger from '@adonisjs/core/services/logger';
|
|||||||
import db from '@adonisjs/lucid/services/db';
|
import db from '@adonisjs/lucid/services/db';
|
||||||
import { RouteName } from '@izzyjs/route/types';
|
import { RouteName } from '@izzyjs/route/types';
|
||||||
|
|
||||||
const INACTIVE_USER_THRESHOLD = 7;
|
|
||||||
|
|
||||||
export default class UsersController {
|
export default class UsersController {
|
||||||
private redirectTo: RouteName = 'auth.login';
|
private redirectTo: RouteName = 'auth.login';
|
||||||
|
|
||||||
@@ -77,18 +75,4 @@ export default class UsersController {
|
|||||||
.withCount('collections', (q) => q.as('totalCollections'))
|
.withCount('collections', (q) => q.as('totalCollections'))
|
||||||
.withCount('links', (q) => q.as('totalLinks'));
|
.withCount('links', (q) => q.as('totalLinks'));
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllInactiveUsers() {
|
|
||||||
const users = await this.getAllUsersWithTotalRelations();
|
|
||||||
const inactiveUsers = users.filter((user) => {
|
|
||||||
const totalLinks = Number(user.$extras.totalLinks);
|
|
||||||
const totalCollections = Number(user.$extras.totalCollections);
|
|
||||||
|
|
||||||
const isOlderThan7Days =
|
|
||||||
Math.abs(user.updatedAt.diffNow('days').days) > INACTIVE_USER_THRESHOLD;
|
|
||||||
|
|
||||||
return (totalLinks === 0 || totalCollections === 0) && isOlderThan7Days;
|
|
||||||
});
|
|
||||||
return inactiveUsers ?? [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
app/middleware/silent_auth_middleware.ts
Normal file
9
app/middleware/silent_auth_middleware.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import type { HttpContext } from '@adonisjs/core/http';
|
||||||
|
import type { NextFn } from '@adonisjs/core/types/http';
|
||||||
|
|
||||||
|
export default class SilentAuthMiddleware {
|
||||||
|
async handle(ctx: HttpContext, next: NextFn) {
|
||||||
|
await ctx.auth.check();
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
}
|
||||||
16
app/middleware/update_user_last_seen_middleware.ts
Normal file
16
app/middleware/update_user_last_seen_middleware.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import type { HttpContext } from '@adonisjs/core/http';
|
||||||
|
import type { NextFn } from '@adonisjs/core/types/http';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
|
export default class UpdateUserLastSeenMiddleware {
|
||||||
|
async handle(ctx: HttpContext, next: NextFn) {
|
||||||
|
const user = ctx.auth.user;
|
||||||
|
if (user) {
|
||||||
|
user.lastSeenAt = DateTime.local();
|
||||||
|
await user.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = await next();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import type { GoogleToken } from '@adonisjs/ally/types';
|
|||||||
import { column, computed, hasMany } from '@adonisjs/lucid/orm';
|
import { column, computed, hasMany } from '@adonisjs/lucid/orm';
|
||||||
import type { HasMany } from '@adonisjs/lucid/types/relations';
|
import type { HasMany } from '@adonisjs/lucid/types/relations';
|
||||||
import AppBaseModel from './app_base_model.js';
|
import AppBaseModel from './app_base_model.js';
|
||||||
|
import { DateTime } from 'luxon';
|
||||||
|
|
||||||
export default class User extends AppBaseModel {
|
export default class User extends AppBaseModel {
|
||||||
@column()
|
@column()
|
||||||
@@ -44,4 +45,10 @@ export default class User extends AppBaseModel {
|
|||||||
get fullname() {
|
get fullname() {
|
||||||
return this.nickName || this.name;
|
return this.nickName || this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@column.dateTime({
|
||||||
|
autoCreate: true,
|
||||||
|
autoUpdate: true,
|
||||||
|
})
|
||||||
|
declare lastSeenAt: DateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import UsersController from '#controllers/users_controller';
|
|
||||||
import { inject } from '@adonisjs/core';
|
|
||||||
import { BaseCommand } from '@adonisjs/core/ace';
|
|
||||||
import type { CommandOptions } from '@adonisjs/core/types/ace';
|
|
||||||
|
|
||||||
export default class RemoveInactiveUsers extends BaseCommand {
|
|
||||||
static commandName = 'remove:inactive-users';
|
|
||||||
static description = '';
|
|
||||||
|
|
||||||
static options: CommandOptions = {};
|
|
||||||
|
|
||||||
@inject()
|
|
||||||
async run(usersController: UsersController) {
|
|
||||||
const inactiveUsers = await usersController.getAllInactiveUsers();
|
|
||||||
await Promise.all(inactiveUsers.map((user) => user.delete()));
|
|
||||||
console.log(`Removed ${inactiveUsers.length} inactive users`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@ services:
|
|||||||
|
|
||||||
pgadmin:
|
pgadmin:
|
||||||
container_name: pgadmin
|
container_name: pgadmin
|
||||||
image: dpage/pgadmin4:8.6
|
image: dpage/pgadmin4:8
|
||||||
restart: always
|
restart: always
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD', 'wget', '-O', '-', 'http://localhost:80/misc/ping']
|
test: ['CMD', 'wget', '-O', '-', 'http://localhost:80/misc/ping']
|
||||||
@@ -5,7 +5,14 @@ export default class CreateUsersTable extends BaseSchema {
|
|||||||
static tableName = 'users';
|
static tableName = 'users';
|
||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
this.schema.createTableIfNotExists(CreateUsersTable.tableName, (table) => {
|
const exists = await this.schema.hasTable(CreateUsersTable.tableName);
|
||||||
|
if (exists) {
|
||||||
|
return console.warn(
|
||||||
|
`Table ${CreateUsersTable.tableName} already exists.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.schema.createTable(CreateUsersTable.tableName, (table) => {
|
||||||
table.string('email', 254).notNullable().unique();
|
table.string('email', 254).notNullable().unique();
|
||||||
table.string('name', 254).notNullable();
|
table.string('name', 254).notNullable();
|
||||||
table.string('nick_name', 254).nullable();
|
table.string('nick_name', 254).nullable();
|
||||||
|
|||||||
@@ -8,9 +8,14 @@ export default class CreateCollectionTable extends BaseSchema {
|
|||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||||
this.schema.createTableIfNotExists(
|
const exists = await this.schema.hasTable(CreateCollectionTable.tableName);
|
||||||
CreateCollectionTable.tableName,
|
if (exists) {
|
||||||
(table) => {
|
return console.warn(
|
||||||
|
`Table ${CreateCollectionTable.tableName} already exists.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.schema.createTable(CreateCollectionTable.tableName, (table) => {
|
||||||
table.string('name', 254).notNullable();
|
table.string('name', 254).notNullable();
|
||||||
table.string('description', 254).nullable();
|
table.string('description', 254).nullable();
|
||||||
table
|
table
|
||||||
@@ -33,8 +38,7 @@ export default class CreateCollectionTable extends BaseSchema {
|
|||||||
.onDelete('CASCADE');
|
.onDelete('CASCADE');
|
||||||
|
|
||||||
defaultTableFields(table);
|
defaultTableFields(table);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async down() {
|
async down() {
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ export default class CreateLinksTable extends BaseSchema {
|
|||||||
static tableName = 'links';
|
static tableName = 'links';
|
||||||
|
|
||||||
async up() {
|
async up() {
|
||||||
this.schema.createTableIfNotExists(CreateLinksTable.tableName, (table) => {
|
const exists = await this.schema.hasTable(CreateLinksTable.tableName);
|
||||||
|
if (exists) {
|
||||||
|
return console.warn(`Table ${CreateLinksTable.tableName} already
|
||||||
|
exists.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.schema.createTable(CreateLinksTable.tableName, (table) => {
|
||||||
table.string('name', 254).notNullable();
|
table.string('name', 254).notNullable();
|
||||||
table.string('description', 254).nullable();
|
table.string('description', 254).nullable();
|
||||||
table.text('url').notNullable();
|
table.text('url').notNullable();
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { BaseSchema } from '@adonisjs/lucid/schema';
|
||||||
|
|
||||||
|
export default class extends BaseSchema {
|
||||||
|
protected tableName = 'users';
|
||||||
|
|
||||||
|
async up() {
|
||||||
|
this.schema.alterTable(this.tableName, (table) => {
|
||||||
|
table.timestamp('last_seen_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async down() {
|
||||||
|
this.schema.dropTable(this.tableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ services:
|
|||||||
|
|
||||||
pgadmin:
|
pgadmin:
|
||||||
container_name: pgadmin
|
container_name: pgadmin
|
||||||
image: dpage/pgadmin4:8.6
|
image: dpage/pgadmin4:8
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- PGADMIN_DEFAULT_EMAIL=myemail@gmail.com
|
- PGADMIN_DEFAULT_EMAIL=myemail@gmail.com
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
(trap 'kill 0' SIGINT; node ace scheduler:run & pnpm run dev)
|
|
||||||
|
|
||||||
wait -n
|
|
||||||
exit $?
|
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
getPaginationRowModel,
|
getPaginationRowModel,
|
||||||
getSortedRowModel,
|
getSortedRowModel,
|
||||||
PaginationState,
|
PaginationState,
|
||||||
|
SortingState,
|
||||||
useReactTable,
|
useReactTable,
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
@@ -50,13 +51,19 @@ const Resizer = styled.div<{ isResizing: boolean }>(
|
|||||||
type TableProps<T> = {
|
type TableProps<T> = {
|
||||||
columns: ColumnDef<T>[];
|
columns: ColumnDef<T>[];
|
||||||
data: T[];
|
data: T[];
|
||||||
|
defaultSorting?: SortingState;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Table<T>({ columns, data }: TableProps<T>) {
|
export default function Table<T>({
|
||||||
|
columns,
|
||||||
|
data,
|
||||||
|
defaultSorting = [],
|
||||||
|
}: TableProps<T>) {
|
||||||
const [pagination, setPagination] = useState<PaginationState>({
|
const [pagination, setPagination] = useState<PaginationState>({
|
||||||
pageIndex: 0,
|
pageIndex: 0,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
});
|
});
|
||||||
|
const [sorting, setSorting] = useState<SortingState>(defaultSorting);
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data,
|
data,
|
||||||
@@ -65,11 +72,13 @@ export default function Table<T>({ columns, data }: TableProps<T>) {
|
|||||||
columnResizeMode: 'onChange',
|
columnResizeMode: 'onChange',
|
||||||
state: {
|
state: {
|
||||||
pagination,
|
pagination,
|
||||||
|
sorting,
|
||||||
},
|
},
|
||||||
onPaginationChange: setPagination,
|
onPaginationChange: setPagination,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
getPaginationRowModel: getPaginationRowModel(),
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
getSortedRowModel: getSortedRowModel(),
|
getSortedRowModel: getSortedRowModel(),
|
||||||
|
onSortingChange: setSorting,
|
||||||
debugTable: true,
|
debugTable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"role": "Role",
|
"role": "Role",
|
||||||
"created_at": "Created at",
|
"created_at": "Created at",
|
||||||
"updated_at": "Updated at",
|
"last_seen_at": "Last seen at",
|
||||||
"admin": "Administrator",
|
"admin": "Administrator",
|
||||||
"user": "User",
|
"user": "User",
|
||||||
"users": "Users",
|
"users": "Users",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"role": "Rôle",
|
"role": "Rôle",
|
||||||
"created_at": "Création",
|
"created_at": "Création",
|
||||||
"updated_at": "Mise à jour",
|
"last_seen_at": "Dernière connexion",
|
||||||
"admin": "Administrateur",
|
"admin": "Administrateur",
|
||||||
"user": "Utilisateur",
|
"user": "Utilisateur",
|
||||||
"users": "Utilisateurs",
|
"users": "Utilisateurs",
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function AdminDashboard({
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
accessorKey: 'id',
|
accessorKey: 'id',
|
||||||
header: (
|
header: () => (
|
||||||
<>
|
<>
|
||||||
# <span css={{ color: theme.colors.grey }}>({users.length})</span>
|
# <span css={{ color: theme.colors.grey }}>({users.length})</span>
|
||||||
</>
|
</>
|
||||||
@@ -69,8 +69,8 @@ function AdminDashboard({
|
|||||||
cell: (info) => info.getValue(),
|
cell: (info) => info.getValue(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'count',
|
accessorKey: 'collectionsCount',
|
||||||
header: (
|
header: () => (
|
||||||
<>
|
<>
|
||||||
{t('common:collection.collections', { count: totalCollections })}{' '}
|
{t('common:collection.collections', { count: totalCollections })}{' '}
|
||||||
<span css={{ color: theme.colors.grey }}>
|
<span css={{ color: theme.colors.grey }}>
|
||||||
@@ -78,17 +78,17 @@ function AdminDashboard({
|
|||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
cell: (info) => (info.getValue() as any)?.collection,
|
cell: (info) => info.getValue(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'count',
|
accessorKey: 'linksCount',
|
||||||
header: (
|
header: () => (
|
||||||
<>
|
<>
|
||||||
{t('common:link.links', { count: totalLinks })}{' '}
|
{t('common:link.links', { count: totalLinks })}{' '}
|
||||||
<span css={{ color: theme.colors.grey }}>({totalLinks})</span>
|
<span css={{ color: theme.colors.grey }}>({totalLinks})</span>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
cell: (info: any) => info.getValue()?.link,
|
cell: (info: any) => info.getValue(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'isAdmin',
|
accessorKey: 'isAdmin',
|
||||||
@@ -110,12 +110,23 @@ function AdminDashboard({
|
|||||||
cell: RenderDateCell,
|
cell: RenderDateCell,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'updatedAt',
|
accessorKey: 'lastSeenAt',
|
||||||
header: t('admin:updated_at'),
|
header: t('admin:last_seen_at'),
|
||||||
cell: RenderDateCell,
|
cell: RenderDateCell,
|
||||||
},
|
},
|
||||||
] as ColumnDef<UserWithRelationCount>[],
|
] satisfies ColumnDef<UserWithRelationCount>[],
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
return <Table columns={columns} data={users} />;
|
return (
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
data={users}
|
||||||
|
defaultSorting={[
|
||||||
|
{
|
||||||
|
id: 'lastSeenAt',
|
||||||
|
desc: true,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
7
inertia/types/app.d.ts
vendored
7
inertia/types/app.d.ts
vendored
@@ -24,10 +24,9 @@ type UserWithRelationCount = CommonBase & {
|
|||||||
fullname: string;
|
fullname: string;
|
||||||
avatarUrl: string;
|
avatarUrl: string;
|
||||||
isAdmin: string;
|
isAdmin: string;
|
||||||
count: {
|
linksCount: number;
|
||||||
link: number;
|
collectionsCount: number;
|
||||||
collection: number;
|
lastSeenAt: string;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type Link = CommonBase & {
|
type Link = CommonBase & {
|
||||||
|
|||||||
42
package.json
42
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "my-links",
|
"name": "my-links",
|
||||||
"version": "2.1.2",
|
"version": "2.2.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -33,8 +33,7 @@
|
|||||||
"#tests/*": "./tests/*.js",
|
"#tests/*": "./tests/*.js",
|
||||||
"#start/*": "./start/*.js",
|
"#start/*": "./start/*.js",
|
||||||
"#config/*": "./config/*.js",
|
"#config/*": "./config/*.js",
|
||||||
"#lib/*": "./app/lib/*.js",
|
"#lib/*": "./app/lib/*.js"
|
||||||
"#routes/*": "./start/routes/*.js"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@adonisjs/assembler": "^7.8.2",
|
"@adonisjs/assembler": "^7.8.2",
|
||||||
@@ -42,56 +41,55 @@
|
|||||||
"@adonisjs/prettier-config": "^1.4.0",
|
"@adonisjs/prettier-config": "^1.4.0",
|
||||||
"@adonisjs/tsconfig": "^1.4.0",
|
"@adonisjs/tsconfig": "^1.4.0",
|
||||||
"@emotion/babel-plugin": "^11.12.0",
|
"@emotion/babel-plugin": "^11.12.0",
|
||||||
"@faker-js/faker": "^9.0.1",
|
"@faker-js/faker": "^9.0.3",
|
||||||
"@japa/assert": "^3.0.0",
|
"@japa/assert": "^3.0.0",
|
||||||
"@japa/plugin-adonisjs": "^3.0.1",
|
"@japa/plugin-adonisjs": "^3.0.1",
|
||||||
"@japa/runner": "^3.1.4",
|
"@japa/runner": "^3.1.4",
|
||||||
"@swc/core": "^1.7.26",
|
"@swc/core": "^1.7.26",
|
||||||
"@types/luxon": "^3.4.2",
|
"@types/luxon": "^3.4.2",
|
||||||
"@types/node": "^20.14.10",
|
"@types/node": "^20.14.10",
|
||||||
"@types/react": "^18.3.7",
|
"@types/react": "^18.3.11",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
"@types/react-toggle": "^4.0.5",
|
"@types/react-toggle": "^4.0.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
"@typescript-eslint/eslint-plugin": "^8.8.0",
|
||||||
"@vitejs/plugin-react": "^4.3.1",
|
"@vitejs/plugin-react": "^4.3.2",
|
||||||
"eslint": "^9.10.0",
|
"eslint": "^9.12.0",
|
||||||
"hot-hook": "^0.2.6",
|
"hot-hook": "^0.3.0",
|
||||||
"husky": "^9.1.6",
|
"husky": "^9.1.6",
|
||||||
"lint-staged": "^15.2.10",
|
"lint-staged": "^15.2.10",
|
||||||
"pino-pretty": "^11.2.2",
|
"pino-pretty": "^11.2.2",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"release-it": "^17.6.0",
|
"release-it": "^17.7.0",
|
||||||
"ts-node-maintained": "^10.9.4",
|
"ts-node-maintained": "^10.9.4",
|
||||||
"typescript": "~5.6.2",
|
"typescript": "~5.5.4",
|
||||||
"vite": "^5.4.6"
|
"vite": "^5.4.8"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adonisjs/ally": "^5.0.2",
|
"@adonisjs/ally": "^5.0.2",
|
||||||
"@adonisjs/auth": "^9.2.3",
|
"@adonisjs/auth": "^9.2.3",
|
||||||
"@adonisjs/core": "^6.13.1",
|
"@adonisjs/core": "^6.14.0",
|
||||||
"@adonisjs/cors": "^2.2.1",
|
"@adonisjs/cors": "^2.2.1",
|
||||||
"@adonisjs/inertia": "^1.1.0",
|
"@adonisjs/inertia": "^1.2.2",
|
||||||
"@adonisjs/lucid": "^21.2.0",
|
"@adonisjs/lucid": "^21.2.0",
|
||||||
"@adonisjs/session": "^7.4.2",
|
"@adonisjs/session": "^7.5.0",
|
||||||
"@adonisjs/shield": "^8.1.1",
|
"@adonisjs/shield": "^8.1.1",
|
||||||
"@adonisjs/static": "^1.1.1",
|
"@adonisjs/static": "^1.1.1",
|
||||||
"@adonisjs/vite": "^3.0.0",
|
"@adonisjs/vite": "^3.0.0",
|
||||||
"@emotion/react": "11.12.0",
|
"@emotion/react": "11.12.0",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
"@inertiajs/react": "^1.2.0",
|
"@inertiajs/react": "^1.2.0",
|
||||||
"@izzyjs/route": "^1.1.0-0",
|
"@izzyjs/route": "^1.2.0",
|
||||||
"@tanstack/react-table": "^8.20.5",
|
"@tanstack/react-table": "^8.20.5",
|
||||||
"@vinejs/vine": "^2.1.0",
|
"@vinejs/vine": "^2.1.0",
|
||||||
"adonisjs-scheduler": "^1.0.5",
|
|
||||||
"bentocache": "^1.0.0-beta.9",
|
"bentocache": "^1.0.0-beta.9",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"edge.js": "^6.0.2",
|
"edge.js": "^6.2.0",
|
||||||
"hex-rgb": "^5.0.0",
|
"hex-rgb": "^5.0.0",
|
||||||
"i18next": "^23.15.1",
|
"i18next": "^23.15.2",
|
||||||
"knex": "^3.1.0",
|
"knex": "^3.1.0",
|
||||||
"luxon": "^3.5.0",
|
"luxon": "^3.5.0",
|
||||||
"node-html-parser": "^6.1.13",
|
"node-html-parser": "^6.1.13",
|
||||||
"pg": "^8.12.0",
|
"pg": "^8.13.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
@@ -99,7 +97,7 @@
|
|||||||
"react-hotkeys-hook": "^4.5.1",
|
"react-hotkeys-hook": "^4.5.1",
|
||||||
"react-i18next": "^15.0.2",
|
"react-i18next": "^15.0.2",
|
||||||
"react-icons": "^5.3.0",
|
"react-icons": "^5.3.0",
|
||||||
"react-select": "^5.8.0",
|
"react-select": "^5.8.1",
|
||||||
"react-swipeable": "^7.0.1",
|
"react-swipeable": "^7.0.1",
|
||||||
"react-toggle": "^4.1.3",
|
"react-toggle": "^4.1.3",
|
||||||
"reflect-metadata": "^0.2.2"
|
"reflect-metadata": "^0.2.2"
|
||||||
@@ -114,7 +112,7 @@
|
|||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"useTabs": false,
|
"useTabs": true,
|
||||||
"quoteProps": "as-needed",
|
"quoteProps": "as-needed",
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"arrowParens": "always",
|
"arrowParens": "always",
|
||||||
|
|||||||
2042
pnpm-lock.yaml
generated
2042
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -41,6 +41,8 @@ router.use([
|
|||||||
() => import('@adonisjs/session/session_middleware'),
|
() => import('@adonisjs/session/session_middleware'),
|
||||||
() => import('@adonisjs/shield/shield_middleware'),
|
() => import('@adonisjs/shield/shield_middleware'),
|
||||||
() => import('@adonisjs/auth/initialize_auth_middleware'),
|
() => import('@adonisjs/auth/initialize_auth_middleware'),
|
||||||
|
() => import('#middleware/silent_auth_middleware'),
|
||||||
|
() => import('#middleware/update_user_last_seen_middleware'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import '#routes/admin';
|
import './routes/admin.js';
|
||||||
import '#routes/app';
|
import './routes/app.js';
|
||||||
import '#routes/auth';
|
import './routes/auth.js';
|
||||||
import '#routes/collection';
|
import './routes/collection.js';
|
||||||
import '#routes/favicon';
|
import './routes/favicon.js';
|
||||||
import '#routes/link';
|
import './routes/link.js';
|
||||||
import '#routes/search';
|
import './routes/search.js';
|
||||||
import '#routes/shared_collection';
|
import './routes/shared_collection.js';
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import scheduler from 'adonisjs-scheduler/services/main';
|
|
||||||
|
|
||||||
scheduler.command('remove:inactive-users').cron('0 20 * * *');
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
(trap 'kill 0' SIGINT; node ace scheduler:run & pnpm start)
|
|
||||||
|
|
||||||
wait -n
|
|
||||||
exit $?
|
|
||||||
Reference in New Issue
Block a user