fix(): fix images in profile & log. small backend change related to profile, logs imgproxy and gitutil.

This commit is contained in:
Aleksander Wilczyński 2024-12-27 01:48:11 +01:00
parent 895725dc66
commit 608894ee1e
Signed by: alekswilc
GPG Key ID: D4464A248E5F27FE
11 changed files with 36 additions and 12 deletions

7
.idea/copyright/profiles_settings.xml generated Normal file
View File

@ -0,0 +1,7 @@
<component name="CopyrightManager">
<settings default="gnu agpl alekswilc">
<module2copyright>
<element module="Project Files" copyright="gnu agpl alekswilc" />
</module2copyright>
</settings>
</component>

View File

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="457" name="TypeScript" />
</Languages>
</inspection_tool>
</profile>
</component>

6
.idea/jsLibraryMappings.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$/packages/frontend" libraries="{script}" />
</component>
</project>

View File

@ -64,7 +64,7 @@ export class LogRoute
if (process.env.IMGPROXY_KEY) if (process.env.IMGPROXY_KEY)
{ {
log.player.avatar = generateUrl(log.player.avatar); log.player.avatar = generateUrl(log.player.avatar, "rs:auto:256:256:1/f:png");
} }
res.status(200).json(new SuccessResponseBuilder().setCode(200).setData(log.toJSON())); res.status(200).json(new SuccessResponseBuilder().setCode(200).setData(log.toJSON()));

View File

@ -114,7 +114,7 @@ export class ProfilesRoute
if (process.env.IMGPROXY_KEY) if (process.env.IMGPROXY_KEY)
{ {
player.avatar = generateUrl(player.avatar); player.avatar = generateUrl(player.avatar, "rs:auto:256:256:1/f:png");
} }
res.json( res.json(

View File

@ -24,6 +24,7 @@ import { TrainsModule } from "./modules/trains.js";
import { Server, Station, Train } from "@simrail/types"; import { Server, Station, Train } from "@simrail/types";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { TMProfile } from "./mongo/profile.js"; import { TMProfile } from "./mongo/profile.js";
import { GitUtil } from "./util/git.js";
;(async () => ;(async () =>
{ {
@ -47,6 +48,7 @@ import { TMProfile } from "./mongo/profile.js";
} }
ApiModule.load(); // TODO: use fastify ApiModule.load(); // TODO: use fastify
GitUtil.getData();
if (process.env.NODE_ENV === "development") if (process.env.NODE_ENV === "development")
{ {

View File

@ -18,9 +18,9 @@ import { execSync } from "child_process";
export class GitUtil export class GitUtil
{ {
private static cache: { lastUpdated: number, version?: string, commit?: string } = undefined!; private static cache: { version?: string, commit?: string } = undefined!;
public static getLatestVersion() private static getLatestVersion()
{ {
try try
{ {
@ -32,7 +32,7 @@ export class GitUtil
} }
} }
public static getLatestCommit() private static getLatestCommit()
{ {
try try
{ {
@ -55,7 +55,6 @@ export class GitUtil
const data = { const data = {
version: this.getLatestVersion(), version: this.getLatestVersion(),
commit: this.getLatestCommit(), commit: this.getLatestCommit(),
lastUpdated: Date.now(),
}; };
this.cache = data; this.cache = data;

View File

@ -26,7 +26,7 @@ export const imgProxySign = (target: string) =>
return hmac.digest("base64url"); return hmac.digest("base64url");
}; };
export const generateUrl = (url: string, options: string = "preset:simrailpro") => export const generateUrl = (url: string, options: string = "rs:auto:128:128:1/f:png") =>
{ {
if (url.includes('https://imgproxy.alekswilc.dev/')) return url; if (url.includes('https://imgproxy.alekswilc.dev/')) return url;

View File

@ -44,8 +44,8 @@ export const StationLog = ({ data }: { data: TLogStationData }) =>
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark"> className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5"> <div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
<div <div
className="mx-auto w-full max-w-30 rounded-full bg-white/20 p-1 backdrop-blur sm:h-44 sm:max-w-44 sm:p-3"> className="mx-auto max-w-44 rounded-full">
<div className="relative drop-shadow-2"> <div className="relative">
<img className="rounded-full" <img className="rounded-full"
src={ data.player.avatar } src={ data.player.avatar }
alt="Player"/> alt="Player"/>

View File

@ -44,8 +44,8 @@ export const TrainLog = ({ data }: { data: TLogTrainData }) =>
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark"> className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5"> <div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
<div <div
className="mx-auto w-full max-w-30 rounded-full bg-white/20 p-1 backdrop-blur sm:h-44 sm:max-w-44 sm:p-3"> className="mx-auto max-w-44 rounded-full">
<div className="relative drop-shadow-2"> <div className="relative">
<img className="rounded-full" <img className="rounded-full"
src={ data.player.avatar } src={ data.player.avatar }
alt="Player"/> alt="Player"/>

View File

@ -87,7 +87,7 @@ export const ProfileCard = ({ data }: { data: TProfileData }) =>
className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark"> className="overflow-hidden rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5"> <div className="px-4 pt-6 text-center lg:pb-8 xl:pb-11.5">
<div <div
className="mx-auto max-w-30 rounded-full p-1"> className="mx-auto max-w-44 rounded-full">
<div className="relative rounded-full"> <div className="relative rounded-full">
<img className="rounded-full" src={ data.player.avatar } alt="profile"/> <img className="rounded-full" src={ data.player.avatar } alt="profile"/>
{ data.active && { data.active &&