feat(backend): preview version
This commit is contained in:
parent
14ab862b7d
commit
85f28115cf
@ -59,29 +59,6 @@ export class StationsRoute
|
||||
);
|
||||
});
|
||||
|
||||
app.get("/details/:id", async (req, res) =>
|
||||
{
|
||||
if (!req.params.id)
|
||||
{
|
||||
return res.redirect("/stations/");
|
||||
}
|
||||
const record = await MLog.findOne({ id: req.params.id });
|
||||
const blacklist = await MBlacklist.findOne({ steam: record?.userSteamId! });
|
||||
if (blacklist && blacklist.status)
|
||||
{
|
||||
return res.redirect("/stations/");
|
||||
}
|
||||
const player = await SteamUtil.getPlayer(record?.userSteamId!);
|
||||
|
||||
res.render("stations/details.ejs", {
|
||||
record,
|
||||
dayjs,
|
||||
player,
|
||||
msToTime,
|
||||
...GitUtil.getData()
|
||||
});
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
@ -56,78 +56,8 @@ export class TrainsRoute
|
||||
.setData({ records: records.map(x => removeProperties<Omit<ITrainLog, "_id" | "__v">>(x, [ "_id", "__v" ])) })
|
||||
.toJSON(),
|
||||
);
|
||||
|
||||
// res.render('trains/index.ejs', {
|
||||
// records,
|
||||
// dayjs,
|
||||
// q: req.query.q,
|
||||
// msToTime,
|
||||
// ...GitUtil.getData()
|
||||
// });
|
||||
});
|
||||
|
||||
app.get("/details/:id", async (req, res) =>
|
||||
{
|
||||
if (!req.params.id)
|
||||
{
|
||||
return res.redirect("/trains/");
|
||||
}
|
||||
const record = await MTrainLog.findOne({ id: req.params.id });
|
||||
const player = await SteamUtil.getPlayer(record?.userSteamId!);
|
||||
const blacklist = await MBlacklist.findOne({ steam: record?.userSteamId! });
|
||||
if (blacklist && blacklist.status)
|
||||
{
|
||||
return res.redirect("/trains/");
|
||||
}
|
||||
|
||||
res.render("trains/details.ejs", {
|
||||
record,
|
||||
dayjs,
|
||||
player,
|
||||
msToTime,
|
||||
...GitUtil.getData(),
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/leaderboard/", async (req, res) =>
|
||||
{
|
||||
const s = req.query.q?.toString().split(",").map(x => new RegExp(x, "i"));
|
||||
|
||||
const data = Object.keys(raw_schema)
|
||||
.reduce((o, key) => ({ ...o, [ key ]: `$${ key }` }), {});
|
||||
|
||||
const filter: PipelineStage[] = [
|
||||
{
|
||||
$project: {
|
||||
// record.leftDate - record.joinedDate
|
||||
result: { $subtract: [ "$leftDate", "$joinedDate" ] },
|
||||
...data,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
s && filter.unshift(
|
||||
{
|
||||
$match: {
|
||||
$and: [
|
||||
...s.map(x => ({ $or: generateSearch(x) })),
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
const records = await MTrainLog.aggregate(filter)
|
||||
.sort({ result: -1 })
|
||||
.limit(30);
|
||||
res.render("trains/leaderboard.ejs", {
|
||||
records,
|
||||
dayjs,
|
||||
q: req.query.q,
|
||||
msToTime
|
||||
});
|
||||
})
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
@ -1,39 +1,30 @@
|
||||
import express from "express";
|
||||
import express, { Router } from "express";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
import { StationsRoute } from "./routes/stations.js";
|
||||
import { TrainsRoute } from "./routes/trains.js";
|
||||
import { ProfilesRoute } from "./routes/profile.js";
|
||||
import { LeaderboardRoute } from "./routes/leaderboard.js";
|
||||
import { MProfile } from "../mongo/profile.js";
|
||||
import { GitUtil } from "../util/git.js";
|
||||
import cors from "cors";
|
||||
import { StatsRoute } from "./routes/stats.js";
|
||||
import { LogRoute } from "./routes/log.js";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
|
||||
export class ApiModule
|
||||
{
|
||||
public static load()
|
||||
{
|
||||
const app = express();
|
||||
|
||||
app.set("view engine", "ejs");
|
||||
app.set("views", __dirname + "/views");
|
||||
app.get("/", (_, res) => res.render("home", GitUtil.getData()));
|
||||
app.use(cors());
|
||||
// backward compatible
|
||||
app.get("/details/:id", (req, res) => res.redirect("/stations/details/" + req.params.id));
|
||||
|
||||
app.use("/stations/", StationsRoute.load());
|
||||
app.use("/trains/", TrainsRoute.load());
|
||||
app.use("/profiles/", ProfilesRoute.load());
|
||||
app.use("/leaderboard/", LeaderboardRoute.load());
|
||||
app.use("/stats/", StatsRoute.load());
|
||||
app.use("/log/", LogRoute.load());
|
||||
const router = Router();
|
||||
router.use("/stations/", StationsRoute.load());
|
||||
router.use("/trains/", TrainsRoute.load());
|
||||
router.use("/profiles/", ProfilesRoute.load());
|
||||
router.use("/leaderboard/", LeaderboardRoute.load());
|
||||
router.use("/stats/", StatsRoute.load());
|
||||
router.use("/log/", LogRoute.load());
|
||||
|
||||
app.use("/api/v1", router);
|
||||
|
||||
app.listen(2005);
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
<div style="font-size: 13.5px;">
|
||||
<p>Made with <span style="color: red;">❤️</span> by <a href="https://www.alekswilc.dev/">alekswilc</a> for SimRail
|
||||
Community</p>
|
||||
<p><a href="https://git.alekswilc.dev/alekswilc/">Open Source</a></p>
|
||||
<p><% if (version) { %>
|
||||
Wersja: <a href="https://git.alekswilc.dev/alekswilc/simrail-logs/releases/tag/<%= version %>"><%= version %></a>
|
||||
<% } %>
|
||||
Commit: <a href="https://git.alekswilc.dev/alekswilc/simrail-logs/commit/<%= commit %>"><%= commit %></a>
|
||||
</p>
|
||||
<% if (thanks) { %>
|
||||
<p>Podziękowania dla społeczności discorda <a href="https://discord.gg/yDhy3pDrVr">Simrail24</a>, <a
|
||||
href="https://discord.com/users/1079005960653254656">AQUALYTH</a>, osób lajkujących <a
|
||||
href="https://forum.simrail.eu/topic/9142-logowanie-wyj%C5%9B%C4%87-z-posterunk%C3%B3w/">posta</a>, osób
|
||||
użytkujących strone i społeczności Simrail <span style="color: red;">❤️</span></p>
|
||||
<% } %>
|
||||
</div>
|
@ -1,14 +0,0 @@
|
||||
<header>
|
||||
<h1><a style="color: white; text-decoration: none;" href="/">SimRail Logs</a></h1>
|
||||
|
||||
<a href="/stations/">Logi posterunków</a> /
|
||||
<a href="/trains/">Logi pociągów</a> /
|
||||
<a href="/leaderboard/train">Tablica pociągow</a> /
|
||||
<a href="/leaderboard/station">Tablica posterunków</a>
|
||||
|
||||
<br/>
|
||||
<p style="color: darkorange; font-size: 14px;">Hej! Podoba Ci się projekt? Polajkuj post na <a
|
||||
href="https://forum.simrail.eu/topic/9142-logowanie-wyj%C5%9B%C4%87-z-posterunk%C3%B3w/">forum</a>, a
|
||||
będzie
|
||||
mi miło! Dla Ciebie to jedno kliknięcie, a dla mnie motywacja do rozwijania projektu.</p>
|
||||
</header>
|
@ -1,125 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description" content="Simrail Utils">
|
||||
<meta property="og:title" content="simrail.alekswilc.dev">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev">
|
||||
<meta property="og:description" content="Simrail Utils">
|
||||
<meta property="og:type" content="website">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 1%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%- include('_modules/header.ejs', { section:'home' }) %>
|
||||
|
||||
<p>Prosty projekt, logujący wyjścia z posterunków.</p>
|
||||
<h3>Cele projektu</h3>
|
||||
<p>Główne założenia</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Ułatwienie zgłaszania graczy, którzy robią "Hit and Run" (psuje i wychodze z posterunku)</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Statystyki</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Rozwój aplikacji</h3>
|
||||
<p>Planowane funkcjonalności</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Nowy wygląd aplikacji</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Podziękowania dla</h3>
|
||||
<ul>
|
||||
<li>Społeczności discorda <a href="https://discord.gg/yDhy3pDrVr">Simrail24</a></li>
|
||||
<li><a href="https://discord.com/users/1079005960653254656">AQUALYTH</a></li>
|
||||
<li>osób lajkujących <a href="https://forum.simrail.eu/topic/9142-logowanie-wyj%C5%9B%C4%87-z-posterunk%C3%B3w/">posta</a>
|
||||
</li>
|
||||
<li>osób użytkujących strone</li>
|
||||
<li>Społeczności SimRail <span style="color: red;">❤️</span></li>
|
||||
</ul>
|
||||
|
||||
<h3>Informacje dodatkowe</h3>
|
||||
<details>
|
||||
<summary>
|
||||
Zgłaszanie błędów i propozycji
|
||||
</summary>
|
||||
|
||||
<h6>Zgłaszanie błedów</h6>
|
||||
<ul>
|
||||
<li>Otwórz <a
|
||||
href="https://git.alekswilc.dev/alekswilc/simrail-logs/issues">https://git.alekswilc.dev/alekswilc/simrail-logs/issues</a>
|
||||
</li>
|
||||
<li>Zaloguj się (np poprzez Discorda)</li>
|
||||
<li>Naciśnij przycisk "New issue" ("Nowe zgłoszenie")</li>
|
||||
<li>W tytule napisz krótki opis (np. Problem z wyświetleniem strony)</li>
|
||||
<li>Opisz problem (kiedy występuje, podaj linki, postaraj sie napisać jak moge odtworzyć ten błąd, jak
|
||||
powinna zachowywać sie aplikacja bez tego błędu)
|
||||
</li>
|
||||
<li>Poczekaj na informacje z mojej strony</li>
|
||||
<li>Dziekuje :)</li>
|
||||
</ul>
|
||||
|
||||
<img src="https://git.alekswilc.dev/alekswilc/simrail-logs/raw/branch/main/.gitea/assets/image-1.png">
|
||||
|
||||
|
||||
<h6>Zgłaszanie propozycji</h6>
|
||||
<ul>
|
||||
<li>Otwórz <a
|
||||
href="https://git.alekswilc.dev/alekswilc/simrail-logs/issues">https://git.alekswilc.dev/alekswilc/simrail-logs/issues</a>
|
||||
</li>
|
||||
<li>Zaloguj się (np poprzez Discorda)</li>
|
||||
<li>Naciśnij przycisk "New issue" ("Nowe zgłoszenie")</li>
|
||||
<li>W tytule napisz krótki opis (np. Logi wejścia i wyjścia z pociągów)</li>
|
||||
<li>Opisz propozycje (dokładnie co z dyżurkami ale dla pociągów)</li>
|
||||
<li>Poczekaj na informacje z mojej strony</li>
|
||||
<li>Dziekuje :)</li>
|
||||
</ul>
|
||||
|
||||
<img src="https://git.alekswilc.dev/alekswilc/simrail-logs/raw/branch/main/.gitea/assets/image-2.png">
|
||||
</details>
|
||||
|
||||
|
||||
<h2>Licencja</h2>
|
||||
<details>
|
||||
<summary>
|
||||
Copyright (C) 2024 Aleksander
|
||||
<alekswilc> Wilczyński
|
||||
</summary>
|
||||
|
||||
|
||||
<code style="white-space: pre-line">This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see https://www.gnu.org/licenses/.</code>
|
||||
</details>
|
||||
|
||||
<hr>
|
||||
<%- include('_modules/footer.ejs', { thanks: true, version, commit }) %>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,86 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description" content="Simrail Utils">
|
||||
<meta property="og:title" content="simrail.alekswilc.dev">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev/leaderboard/">
|
||||
<meta property="og:description" content="Simrail Utils">
|
||||
<meta property="og:type" content="website">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 1%;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%- include('../_modules/header.ejs', { section: 'leaderboard' }) %>
|
||||
|
||||
<h2 id="but">Tablica wyników</h2>
|
||||
<div class="container">
|
||||
<input type="text" id="search" value="<%- q %>">
|
||||
|
||||
<button onclick="search()">Szukaj</button>
|
||||
<button onclick="clearSearch()">Wyczyść</button>
|
||||
|
||||
<p>Użyj przecinka, aby wyszukać wiele wartości: pl2,Łazy</p>
|
||||
|
||||
</div>
|
||||
<br/>
|
||||
<ul>
|
||||
<% records.forEach(record=> { %>
|
||||
<li>
|
||||
<%- type === 'train' ? include('train.ejs', { record, msToTime }) : include('station.ejs', { record, msToTime }) %>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
||||
<% if (!records.length) { %>
|
||||
<h4>Nie znaleziono wyników dla twojego zapytania.</h4>
|
||||
<% } %>
|
||||
|
||||
<script>
|
||||
function select()
|
||||
{
|
||||
const isTrain = "<%- type %>" === "train";
|
||||
location.href = "/leaderboard/" + (isTrain ? "station" : "train");
|
||||
}
|
||||
|
||||
document.getElementById("but").textContent = ("<%- type %>" === "train") ? "Tablica pociągów" : "Tablica posterunków";
|
||||
|
||||
function search()
|
||||
{
|
||||
location.href = '/leaderboard/<%- type %>/?q=' + document.getElementById("search").value;
|
||||
}
|
||||
|
||||
function clearSearch()
|
||||
{
|
||||
location.href = '/leaderboard/<%- type %>';
|
||||
}
|
||||
|
||||
document.getElementById("search").addEventListener("keyup", (event) =>
|
||||
{
|
||||
if (event.key === "Enter")
|
||||
{
|
||||
search();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<hr>
|
||||
|
||||
<p style="color: orange;">Dane do rankingu zbierane są od dnia 19.08.2024.</p>
|
||||
|
||||
<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,9 +0,0 @@
|
||||
<details>
|
||||
<summary><span style="color:hotpink">
|
||||
<%= record.steamName %>
|
||||
</span> <span style="color: lightskyblue">
|
||||
<%= msToTime(record.dispatcherTime) %>
|
||||
</span> </summary>
|
||||
<p>Spędzona liczba godzin: <%= msToTime(record.dispatcherTime, true) || 'Brak' %></p>
|
||||
<button onclick="location.href = '/profiles/<%= record.steam %>'">Więcej</button>
|
||||
</details>
|
@ -1,11 +0,0 @@
|
||||
<details>
|
||||
<summary><span style="color:hotpink">
|
||||
<%= record.steamName %>
|
||||
</span> - <span style="color:lightskyblue">
|
||||
<%= record.trainPoints %> pkt.
|
||||
</span></summary>
|
||||
<p>Spędzona liczba godzin: <%= msToTime(record.trainTime, true) %></p>
|
||||
<p>Przejechane kilometry: <%= record.trainDistance / 1000 %>km</p>
|
||||
<p>Zdobyte punkty: <%= record.trainPoints %></p>
|
||||
<button onclick="location.href = '/profiles/<%= record.steam %>'">Więcej</button>
|
||||
</details>
|
@ -1,123 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description"
|
||||
content="<%- steam.personaname %>">
|
||||
<meta property="og:title" content="Simrail Log">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev/profiles/<%- player.steam %>/">
|
||||
<meta property="og:description"
|
||||
content="<%- steam.personaname %>">
|
||||
<meta property=" og:type" content="website">
|
||||
<meta property="og:image" content="<%- steam.avatarfull %>"/>
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function copylink()
|
||||
{
|
||||
navigator.clipboard.writeText("https://simrail.alekswilc.dev/players/details/<%- player.steam %>/");
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<%- include('../_modules/header.ejs', { section: 'profiles' }) %>
|
||||
|
||||
<div class="details">
|
||||
<h1><a href="<%- steam.profileurl %>"><%- steam.personaname %></a></h1>
|
||||
|
||||
<% if (steamStats.stats) { %>
|
||||
<details open>
|
||||
<summary>Statystyki Steam</summary>
|
||||
<p>Zdobyte punkty: <%- steamStats.stats.find(x => x.name === 'SCORE')?.value ?? "0" %></p>
|
||||
<p>Przejechane
|
||||
kilometry: <%- (steamStats.stats.find(x => x.name === 'DISTANCE_M')?.value / 1000) ?? "0" %></p>
|
||||
<p>Czas spędzony jako dyżurny
|
||||
ruchu: <%- msToTime((steamStats.stats.find(x => x.name === 'DISPATCHER_TIME')?.value ?? 0) * 1_000_000, true) || 'Nigdy nie wszedł w tryb dyżurnego ruchu.' %></p>
|
||||
<br/>
|
||||
<p style="font-size: smaller;">UWAGA: powyższe statystyki udostępnia platforma STEAM, mogą one być z
|
||||
łatwością manipulowane.</p>
|
||||
|
||||
</details>
|
||||
<% } %>
|
||||
|
||||
<h1>Statystyki pociągów</h1>
|
||||
<% if (player.trainTime) { %>
|
||||
<p>Spędzony czas: <%- msToTime(player.trainTime) %></p>
|
||||
<p>Przejechane kilometry: <%- player.trainDistance / 1000 %>km</p>
|
||||
<p>Zdobyte punkty: <%- player.trainPoints %></p>
|
||||
<p>Średnia prędkość: <%- ((player.trainDistance / (player.trainTime / 1000)) * 3.6).toFixed(2) %> km/h</p>
|
||||
<% } %>
|
||||
<% if (player.trainStats && Object.keys(player.trainStats).length) { %>
|
||||
<ul>
|
||||
<% Object.keys(player.trainStats).forEach(name => { %>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><%- name %></summary>
|
||||
<p>Przejechany dystans: <%- player.trainStats[ name ].distance / 1000 %>km</p>
|
||||
<p>Spędzony czas: <%- msToTime(player.trainStats[ name ].time, true) %></p>
|
||||
<p>Zdobyte punkty: <%- player.trainStats[ name ].score %></p>
|
||||
<p>Średnia
|
||||
prędkość: <%- ((player.trainStats[ name ].distance / (player.trainStats[ name ].time / 1000)) * 3.6).toFixed(2) %>
|
||||
km/h</p>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
<% }) %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
<p>Brak danych</p>
|
||||
<% } %>
|
||||
|
||||
<h1>Statystyki posterunków</h1>
|
||||
<% if (player.dispatcherTime) { %>
|
||||
<p>Spędzony czas: <%- msToTime(player.dispatcherTime) %></p>
|
||||
<% } %>
|
||||
<% if (player.dispatcherStats && Object.keys(player.dispatcherStats).length) { %>
|
||||
<ul>
|
||||
<% Object.keys(player.dispatcherStats).forEach(name => { %>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><%- name %></summary>
|
||||
<p>Spędzony czas: <%- msToTime(player.dispatcherStats[ name ].time, true) %></p>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
<% }) %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
<p>Brak danych</p>
|
||||
<% } %>
|
||||
|
||||
<br/>
|
||||
<p>
|
||||
<button onclick="copylink()">Kopiuj link</button>
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<p style="color: orange;">Dane do rankingu zbierane są od dnia 19.08.2024.</p>
|
||||
<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,47 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description"
|
||||
content="Profil prywatny">
|
||||
<meta property="og:title" content="Simrail Log">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev/">
|
||||
<meta property="og:description"
|
||||
content="Profil prywatny">
|
||||
<meta property=" og:type" content="website">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%- include('../_modules/header.ejs', { section: 'profiles' }) %>
|
||||
|
||||
<div class="details">
|
||||
<p>Profil gracza jest prywatny.</p>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,91 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description"
|
||||
content="<%- record.stationName %> | <%- record.userUsername %> | <%- dayjs(record.leftDate).format('hh:mm DD/MM/YYYY') %>">
|
||||
<meta property="og:title" content="Simrail Log">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev/details/<%- record.id %>/">
|
||||
<meta property="og:description"
|
||||
content="<%- record.stationName %> | <%- record.userUsername %> | <%- dayjs(record.leftDate).format('hh:mm DD/MM/YYYY') %>"
|
||||
">
|
||||
<meta property=" og:type" content="website">
|
||||
<meta property="og:image" content="<%- record.userAvatar %>"/>
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function copydata()
|
||||
{
|
||||
navigator.clipboard.writeText(document.getElementById("data").textContent.replace(/ /g, "").split("\n").filter(x => x).join(""));
|
||||
|
||||
}
|
||||
|
||||
function copylink()
|
||||
{
|
||||
navigator.clipboard.writeText("https://simrail.alekswilc.dev/stations/details/<%- record.id %>/");
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<%- include('../_modules/header.ejs', { section: 'stations' }) %>
|
||||
|
||||
<div class="details">
|
||||
|
||||
<p>Użytkownik: <a href="/profiles/<%- record.userSteamId %>">
|
||||
<%- record.userUsername %>
|
||||
</a></p>
|
||||
<p>Stacja: <%- record.stationName %>
|
||||
</p>
|
||||
<p>Serwer: <%- record.server.toUpperCase() %>
|
||||
</p>
|
||||
<p>Data wejścia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY') : '--:-- --/--/--'
|
||||
%> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)</p>
|
||||
<p>Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%- dayjs(record.leftDate).fromNow()
|
||||
%>)</p>
|
||||
<p>Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate, true) : '--' %>
|
||||
</p>
|
||||
|
||||
<br/>
|
||||
<code class="clickable" style="white-space: pre-line" onclick="copydata()"
|
||||
id="data">;station: <%- record.stationName %>
|
||||
;steam: <%- record.userSteamId %>
|
||||
;server: <%- record.server %>
|
||||
;name: <%- record.userUsername %>
|
||||
;joined: <%- record.joinedDate ? dayjs(record.joinedDate).format() : 'no-data' %>
|
||||
;left: <%- dayjs(record.leftDate).format() %>
|
||||
;url: https://simrail.alekswilc.dev/stations/details/<%- record.id %>/
|
||||
</code>
|
||||
<br/>
|
||||
<p>
|
||||
<button onclick="copylink()">Kopiuj link</button>
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,98 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description" content="Simrail Utils">
|
||||
<meta property="og:title" content="simrail.alekswilc.dev">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev">
|
||||
<meta property="og:description" content="Simrail Utils">
|
||||
<meta property="og:type" content="website">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 1%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%- include('../_modules/header.ejs', { section: 'stations' }) %>
|
||||
|
||||
<h2>Wyszukaj posterunek, osobe lub serwer</h2>
|
||||
|
||||
<div class="container">
|
||||
<input type="text" id="search" value="<%- q %>">
|
||||
<button onclick="search()">Szukaj</button>
|
||||
<button onclick="clearSearch()">Wyczyść</button>
|
||||
|
||||
<p>Użyj przecinka, aby wyszukać wiele wartości: pl2,Łazy</p>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<% records.forEach(record=> { %>
|
||||
<li>
|
||||
<details>
|
||||
<summary>[<span style="color:lightskyblue">
|
||||
<%- record.server.toUpperCase() %>
|
||||
</span>] <span style="color: lightskyblue">
|
||||
<%- record.stationName %>
|
||||
</span> - <span style="color:hotpink">
|
||||
<%- record.userUsername %>
|
||||
</span>
|
||||
<p style="margin-bottom: 0; opacity: 0.5;">
|
||||
<%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %>
|
||||
</p>
|
||||
</summary>
|
||||
<p>Data dołączenia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY')
|
||||
: '--:-- --/--/--' %> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)
|
||||
</p>
|
||||
<p>Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%-
|
||||
dayjs(record.leftDate).fromNow() %>)</p>
|
||||
<p>Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate) : '--' %>
|
||||
</p>
|
||||
|
||||
<a href="/stations/details/<%- record.id %>">
|
||||
<button>Więcej</button>
|
||||
</a>
|
||||
</details>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
||||
<% if (!records.length) { %>
|
||||
<h4>Nie znaleziono wyników dla twojego zapytania.</h4>
|
||||
<% } %>
|
||||
|
||||
<hr>
|
||||
<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
|
||||
|
||||
<script>
|
||||
function search()
|
||||
{
|
||||
location.href = "/stations/?q=" + document.getElementById("search").value;
|
||||
}
|
||||
|
||||
function clearSearch()
|
||||
{
|
||||
console.log("test");
|
||||
location.href = "/stations/";
|
||||
}
|
||||
|
||||
document.getElementById("search").addEventListener("keyup", (event) =>
|
||||
{
|
||||
if (event.key === "Enter")
|
||||
{
|
||||
search();
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,102 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description"
|
||||
content="<%- record.stationName %> | <%- record.userUsername %> | <%- dayjs(record.leftDate).format('hh:mm DD/MM/YYYY') %>">
|
||||
<meta property="og:title" content="Simrail Log">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev/details/<%- record.id %>/">
|
||||
<meta property="og:description"
|
||||
content="<%- record.stationName %> | <%- record.userUsername %> | <%- dayjs(record.leftDate).format('hh:mm DD/MM/YYYY') %>"
|
||||
">
|
||||
<meta property=" og:type" content="website">
|
||||
<meta property="og:image" content="<%- record.userAvatar %>"/>
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function copydata()
|
||||
{
|
||||
navigator.clipboard.writeText(document.getElementById("data").textContent.replace(/ /g, "").split("\n").filter(x => x).join(""));
|
||||
|
||||
}
|
||||
|
||||
function copylink()
|
||||
{
|
||||
navigator.clipboard.writeText("https://simrail.alekswilc.dev/trains/details/<%- record.id %>/");
|
||||
}
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<%- include('../_modules/header.ejs', { section: 'trains' }) %>
|
||||
|
||||
<div class="details">
|
||||
|
||||
<p>Użytkownik: <a href="/profiles/<%- record.userSteamId %>">
|
||||
<%- record.userUsername %>
|
||||
</a></p>
|
||||
|
||||
<p>Pociąg: <%- record.trainName %> <%- record.trainNumber %>
|
||||
</p>
|
||||
<p>Data wejścia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY') : '--:-- --/--/--'
|
||||
%> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)</p>
|
||||
<p>Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%- dayjs(record.leftDate).fromNow()
|
||||
%>)</p>
|
||||
<p>Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate, true) : '--' %>
|
||||
</p>
|
||||
<% if (record.distance) { %>
|
||||
<p>Przejechane kilometry: <%- record.distance / 1000 %></p>
|
||||
<p>Zdobyte punkty: <%- record.points %></p>
|
||||
<p>Średnia
|
||||
prędkość: <%- ((record.distance / ((record.leftDate - record.joinedDate) / 1000)) * 3.6).toFixed(2) %>
|
||||
km/h</p>
|
||||
<% } %>
|
||||
</p>
|
||||
|
||||
<br/>
|
||||
<code class="clickable" style="white-space: pre-line" onclick="copydata()"
|
||||
id="data">;train: <%- record.trainNumber %>
|
||||
;steam: <%- record.userSteamId %>
|
||||
;server: <%- record.server %>
|
||||
;name: <%- record.userUsername %>
|
||||
;joined: <%- record.joinedDate ? dayjs(record.joinedDate).format() : 'no-data' %>
|
||||
;left: <%- dayjs(record.leftDate).format() %>
|
||||
<% if (record.distance) { %>
|
||||
;distance: <%- record.distance / 1000 %>
|
||||
;points: <%- record.points %>
|
||||
<% } %>
|
||||
;url: https://simrail.alekswilc.dev/trains/details/<%- record.id %>/
|
||||
</code>
|
||||
<br/>
|
||||
<p>
|
||||
<button onclick="copylink()">Kopiuj link</button>
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,104 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>simrail.alekswilc.dev</title>
|
||||
<meta name="description" content="Simrail Utils">
|
||||
<meta property="og:title" content="simrail.alekswilc.dev">
|
||||
<meta property="og:url" content="https://simrail.alekswilc.dev">
|
||||
<meta property="og:description" content="Simrail Utils">
|
||||
<meta property="og:type" content="website">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/open-fonts@1.1.1/fonts/inter.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css">
|
||||
|
||||
<style>
|
||||
p {
|
||||
margin: 1%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%- include('../_modules/header.ejs', { section: 'trains' }) %>
|
||||
|
||||
<h2>Wyszukaj pociąg, osobe lub serwer</h2>
|
||||
|
||||
<div class="container">
|
||||
<input type="text" id="search" value="<%- q %>">
|
||||
<button onclick="search()">Szukaj</button>
|
||||
<button onclick="clearSearch()">Wyczyść</button>
|
||||
|
||||
<p>Użyj przecinka, aby wyszukać wiele wartości: pl2,1413</p>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<% records.forEach(record=> { %>
|
||||
<li>
|
||||
<details>
|
||||
<summary>[<span style="color:lightskyblue">
|
||||
<%- record.server.toUpperCase() %>
|
||||
</span>] <span style="color: lightskyblue">
|
||||
<%- record.trainName %>
|
||||
</span> - <span style="color: lightskyblue">
|
||||
<%- record.trainNumber %>
|
||||
</span> - <span style="color:hotpink">
|
||||
<%- record.userUsername %>
|
||||
</span>
|
||||
<p style="margin-bottom: 0; opacity: 0.5;">
|
||||
<%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %>
|
||||
</p>
|
||||
</summary>
|
||||
<p>Data dołączenia: <%- record.joinedDate ? dayjs(record.joinedDate).format('HH:mm DD/MM/YYYY')
|
||||
: '--:-- --/--/--' %> (<%- record.joinedDate ? dayjs(record.joinedDate).fromNow() : '--' %>)
|
||||
</p>
|
||||
<p>Data wyjścia: <%- dayjs(record.leftDate).format('HH:mm DD/MM/YYYY') %> (<%-
|
||||
dayjs(record.leftDate).fromNow() %>)</p>
|
||||
<p>Spędzony czas: <%- record.joinedDate ? msToTime(record.leftDate - record.joinedDate) : '--' %>
|
||||
<% if (record.distance) { %>
|
||||
<p>Przejechane kilometry: <%- record.distance / 1000 %></p>
|
||||
<p>Zdobyte punkty: <%- record.points %></p>
|
||||
<% } %>
|
||||
</p>
|
||||
|
||||
<a href="/trains/details/<%- record.id %>">
|
||||
<button>Więcej</button>
|
||||
</a>
|
||||
</details>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
||||
<% if (!records.length) { %>
|
||||
<h4>Nie znaleziono wyników dla twojego zapytania.</h4>
|
||||
<% } %>
|
||||
|
||||
<hr>
|
||||
<%- include('../_modules/footer.ejs', { thanks: false, version, commit }) %>
|
||||
|
||||
<script>
|
||||
function search()
|
||||
{
|
||||
location.href = "/trains/?q=" + document.getElementById("search").value;
|
||||
}
|
||||
|
||||
function clearSearch()
|
||||
{
|
||||
console.log("test");
|
||||
location.href = "/trains/";
|
||||
}
|
||||
|
||||
document.getElementById("search").addEventListener("keyup", (event) =>
|
||||
{
|
||||
if (event.key === "Enter")
|
||||
{
|
||||
search();
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -29,7 +29,7 @@ import dayjs from "dayjs";
|
||||
StationsModule.load();
|
||||
TrainsModule.load();
|
||||
}
|
||||
|
||||
|
||||
ApiModule.load(); // TODO: use fastify
|
||||
|
||||
if (process.env.NODE_ENV === "development")
|
||||
|
@ -51,7 +51,7 @@ export class StationsModule
|
||||
await MProfile.findOneAndUpdate({ id: userProfile.id }, { dispatcherStats: userProfile.dispatcherStats, dispatcherTime: userProfile.dispatcherTime });
|
||||
}
|
||||
|
||||
MLog.create({
|
||||
await MLog.create({
|
||||
id: v4(),
|
||||
userSteamId: player.steamid,
|
||||
userAvatar: player.avatarfull,
|
||||
@ -60,8 +60,8 @@ export class StationsModule
|
||||
leftDate: date.getTime(),
|
||||
stationName: station.Name,
|
||||
stationShort: station.Prefix,
|
||||
server: server.ServerCode
|
||||
server: server.ServerCode,
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import { Server, Station, Train } from "@simrail/types";
|
||||
import { MLog } from "../mongo/logs.js";
|
||||
import { Server, Train } from "@simrail/types";
|
||||
import { IPlayer } from "../types/player.js";
|
||||
import { SimrailClientEvents } from "../util/SimrailClient.js";
|
||||
import { v4 } from "uuid";
|
||||
@ -63,7 +62,7 @@ export class TrainsModule
|
||||
await MProfile.findOneAndUpdate({ id: userProfile.id }, { trainStats: userProfile.trainStats, trainTime: userProfile.trainTime, trainPoints: userProfile.trainPoints, trainDistance: userProfile.trainDistance });
|
||||
}
|
||||
|
||||
MTrainLog.create({
|
||||
await MTrainLog.create({
|
||||
id: v4(),
|
||||
userSteamId: player.steamid,
|
||||
userAvatar: player.avatarfull,
|
||||
@ -73,8 +72,8 @@ export class TrainsModule
|
||||
trainNumber: train.TrainNoLocal,
|
||||
server: server.ServerCode,
|
||||
distance, points,
|
||||
trainName: train.TrainName
|
||||
trainName: train.TrainName,
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
1
packages/backend/src/types/typings.d.ts
vendored
1
packages/backend/src/types/typings.d.ts
vendored
@ -5,5 +5,4 @@ declare global
|
||||
{
|
||||
declare var redis: RedisClientType,
|
||||
client: SimrailClient;
|
||||
|
||||
}
|
@ -19,4 +19,4 @@ export const msToTime = (duration: number, long = false) =>
|
||||
}
|
||||
|
||||
return time.humanize();
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user