mirror of
https://github.com/morbalint/kemkas.git
synced 2026-07-18 03:13:46 +00:00
add local run and save button
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kemkas.Web.Db.Models;
|
||||
using Kemkas.Web.Services;
|
||||
using Kemkas.Web.Services.Character;
|
||||
using Kemkas.Web.ViewModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Kemkas.Web.Controllers;
|
||||
@@ -20,6 +18,10 @@ public class CharacterController(
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<Guid>> StoreNewCharacter([FromBody] CharacterDto dto)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var errors = validationService.Validate(dto);
|
||||
if (errors != null)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Unicode;
|
||||
using Kemkas.Web.Config;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Kemkas.Web.Db;
|
||||
@@ -30,7 +32,11 @@ builder.Services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.R
|
||||
|
||||
builder.Services.AddAuthentication();
|
||||
|
||||
builder.Services.AddControllersWithViews();
|
||||
builder.Services.AddControllersWithViews().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.AllowTrailingCommas = true;
|
||||
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
|
||||
});
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
builder.Services.AddCharacterServices();
|
||||
@@ -54,6 +60,8 @@ await using (var scope = app.Services.CreateAsyncScope())
|
||||
await db.Database.MigrateAsync();
|
||||
}
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
"Kemkas.Web": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7251;http://localhost:5174",
|
||||
"applicationUrl": "https://*:7251;http://*:5174",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
|
||||
}
|
||||
},
|
||||
"launchUrl": "https://localhost:8000"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Support for ASP.NET Core Identity was added to your project.
|
||||
|
||||
For setup and configuration information, see https://go.microsoft.com/fwlink/?linkid=2116645.
|
||||
@@ -8,3 +8,12 @@ services:
|
||||
environment:
|
||||
POSTGRES_USER: "kemkas"
|
||||
POSTGRES_PASSWORD: "kemkas-dev42"
|
||||
|
||||
proxy:
|
||||
image: nginx:latest
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- $HOME/.aspnet/https/kemkas.pem:/etc/nginx/kemkas.pem
|
||||
- $HOME/.aspnet/https/kemkas.key:/etc/nginx/kemkas.key
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node as builder
|
||||
FROM node:21.4-bookworm as builder
|
||||
|
||||
WORKDIR "/src"
|
||||
|
||||
@@ -11,7 +11,7 @@ COPY . .
|
||||
RUN ./compile-less.sh
|
||||
RUN yarn build
|
||||
|
||||
FROM nginx as proxy
|
||||
FROM nginx:latest as proxy
|
||||
|
||||
# COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=builder "/src/build" "/usr/share/nginx/html"
|
||||
@@ -12,13 +12,14 @@
|
||||
"@types/node": "^20.8.9",
|
||||
"@types/react": "^18.2.33",
|
||||
"@types/react-dom": "^18.2.13",
|
||||
"axios": "^1.6.2",
|
||||
"bootstrap": "^5.3.2",
|
||||
"downloadjs": "^1.4.7",
|
||||
"pdf-lib": "^1.17.1",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"jquery": "^3.6.0",
|
||||
"merge": "^2.1.1",
|
||||
"oidc-client": "^1.11.5",
|
||||
"pdf-lib": "^1.17.1",
|
||||
"react": "^18.2.0",
|
||||
"react-bootstrap": "^2.9.1",
|
||||
"react-dom": "^18.2.0",
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import {KarakterInputs} from "../domain-models/karakter";
|
||||
import * as axios from "axios";
|
||||
|
||||
export async function StoreNewCharacter(karakter: KarakterInputs) {
|
||||
let response = await axios.default.post(`${window.location.origin}/Character/`, karakter, {
|
||||
withCredentials: true,
|
||||
})
|
||||
if (response.status < 300){
|
||||
return response.data as string
|
||||
}
|
||||
else {
|
||||
return Error(response.statusText)
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import HarcosFegyverSpecializacio from "../components/HarcosFegyverSpecializacio
|
||||
import Felszereles from '../components/Felszereles';
|
||||
import { KarakterFelszereles } from '../domain-models/felszereles';
|
||||
import {Faro} from "@grafana/faro-web-sdk";
|
||||
import {StoreNewCharacter} from "../api/character.api";
|
||||
|
||||
function CreateCharacterPage(props: {faro?: Faro}) {
|
||||
const {faro} = props
|
||||
@@ -56,33 +57,34 @@ function CreateCharacterPage(props: {faro?: Faro}) {
|
||||
<h1>Karakter létrehozása</h1>
|
||||
</div>
|
||||
<div className='p-3'>
|
||||
<form onSubmit={ async (event) => event.preventDefault() }>
|
||||
<form onSubmit={async (event) => event.preventDefault()}>
|
||||
<div className='row'>
|
||||
<h5 className='col align-self-center'>Származás</h5>
|
||||
</div>
|
||||
<div className='row m-2'>
|
||||
<label className='col-md-2 col-sm-3 col-form-label' >Név</label>
|
||||
<label className='col-md-2 col-sm-3 col-form-label'>Név</label>
|
||||
<input className='col form-control'
|
||||
value={karakter.name}
|
||||
onChange={(e) => changeKarakter({...karakter, name: e.target.value})}/>
|
||||
{!karakter.name && <span className='form-field-error'>A karaktered nem mászkálhat névtelenül a világban!</span>}
|
||||
</div>
|
||||
<div className='row m-2'>
|
||||
<label className='col-md-2 col-sm-3 col-form-label' >Nem</label>
|
||||
<label className='col-md-2 col-sm-3 col-form-label'>Nem</label>
|
||||
<input className='col form-control'
|
||||
value={karakter.nem}
|
||||
onChange={(e) => changeKarakter({...karakter, nem: e.target.value})}/>
|
||||
</div>
|
||||
<div className='row m-2'>
|
||||
<label className='col-md-2 col-sm-3 col-form-label' >Kor</label>
|
||||
<label className='col-md-2 col-sm-3 col-form-label'>Kor</label>
|
||||
<input className='col form-control'
|
||||
value={karakter.kor}
|
||||
type={"number"}
|
||||
onChange={(e) => changeKarakter({...karakter, kor: Number(e.target.value)})}/>
|
||||
</div>
|
||||
<JellemSelector selected={karakter.jellem} changeJellem={(val) => changeKarakter({...karakter, jellem: val})} />
|
||||
<JellemSelector selected={karakter.jellem}
|
||||
changeJellem={(val) => changeKarakter({...karakter, jellem: val})}/>
|
||||
<div className='row m-2'>
|
||||
<label className='col-md-2 col-sm-3 col-form-label' >Választott istenség</label>
|
||||
<label className='col-md-2 col-sm-3 col-form-label'>Választott istenség</label>
|
||||
<input className='col form-control'
|
||||
value={karakter.isten}
|
||||
onChange={(e) => changeKarakter({...karakter, isten: e.target.value})}/>
|
||||
@@ -95,9 +97,12 @@ function CreateCharacterPage(props: {faro?: Faro}) {
|
||||
<Tulajdonsagok
|
||||
currentFaj={karakter.faj}
|
||||
tulajdonsagok={karakter.tulajdonsagok}
|
||||
changeTulajdonsagok={(tul: KarakterTulajdonsagok) => changeKarakter({...karakter, tulajdonsagok: tul})}
|
||||
changeTulajdonsagok={(tul: KarakterTulajdonsagok) => changeKarakter({
|
||||
...karakter,
|
||||
tulajdonsagok: tul
|
||||
})}
|
||||
/>
|
||||
<hr />
|
||||
<hr/>
|
||||
<div className='row'>
|
||||
<h5 className='col align-self-center'>Tanult</h5>
|
||||
</div>
|
||||
@@ -116,7 +121,10 @@ function CreateCharacterPage(props: {faro?: Faro}) {
|
||||
<HarcosFegyverSpecializacio
|
||||
specialization={karakter.harcosSpecializaciok[0]}
|
||||
existingSpecializations={karakter.harcosSpecializaciok}
|
||||
changeSpecialization={(spec: string) => changeKarakter({...karakter, harcosSpecializaciok: [spec, ...karakter.harcosSpecializaciok.slice(1)]})}
|
||||
changeSpecialization={(spec: string) => changeKarakter({
|
||||
...karakter,
|
||||
harcosSpecializaciok: [spec, ...karakter.harcosSpecializaciok.slice(1)]
|
||||
})}
|
||||
szint={1}
|
||||
/>
|
||||
</div>}
|
||||
@@ -129,34 +137,49 @@ function CreateCharacterPage(props: {faro?: Faro}) {
|
||||
changeTolvajKepzettsegek={changeTolvajKepzettseg}
|
||||
/>
|
||||
|
||||
<hr />
|
||||
<MasodlagosErtekek {...CalculateMasodlagosErtekek({...karakter, tulajdonsagok: tulajdonsagokFajjal, szint: 1, hpRolls: []})} />
|
||||
<hr/>
|
||||
<MasodlagosErtekek {...CalculateMasodlagosErtekek({
|
||||
...karakter,
|
||||
tulajdonsagok: tulajdonsagokFajjal,
|
||||
szint: 1,
|
||||
hpRolls: []
|
||||
})} />
|
||||
|
||||
<hr />
|
||||
<hr/>
|
||||
|
||||
<LevelUps key={'level-ups'} karakter={karakter} changeKarakter={changeKarakter} />
|
||||
<LevelUps key={'level-ups'} karakter={karakter} changeKarakter={changeKarakter}/>
|
||||
|
||||
{karakter.szint > 1 && <hr />}
|
||||
{karakter.szint > 1 && <hr/>}
|
||||
<div className='d-grid gap-2 m-5'>
|
||||
{canLevelUp && <button className='btn btn-dark btn-lg' type='button' onClick={levelUp}>Szintlépés! ⇧</button> }
|
||||
{canLevelUp &&
|
||||
<button className='btn btn-dark btn-lg' type='button' onClick={levelUp}>Szintlépés!
|
||||
⇧</button>}
|
||||
{!canLevelUp && karakter.szint < 10 &&
|
||||
<Card className='col text-center p-3'>Elérted a fajod szint limitjét</Card>}
|
||||
{karakter.szint > 1 && <button className='btn btn-dark btn-lg' type='button' onClick={levelDown}>Visszalépés! ⇩</button> }
|
||||
{karakter.szint > 1 &&
|
||||
<button className='btn btn-dark btn-lg' type='button' onClick={levelDown}>Visszalépés!
|
||||
⇩</button>}
|
||||
</div>
|
||||
|
||||
|
||||
<hr />
|
||||
<hr/>
|
||||
|
||||
<Felszereles osztaly={karakter.osztaly} felszereles={karakter.felszereles} changeFelszereles={setFelszereles} harcosSpec={karakter.harcosSpecializaciok} />
|
||||
<Felszereles osztaly={karakter.osztaly} felszereles={karakter.felszereles}
|
||||
changeFelszereles={setFelszereles} harcosSpec={karakter.harcosSpecializaciok}/>
|
||||
|
||||
<div className='d-grid gap-2 m-5'>
|
||||
<button className='btn btn-danger btn-lg' type='button' onClick={async () => {
|
||||
await StoreNewCharacter(karakter)
|
||||
}}>Mentés
|
||||
</button>
|
||||
<button className='btn btn-danger btn-lg' type='button' onClick={async () => {
|
||||
faro?.api.pushEvent('character_created', {
|
||||
osztaly: karakter.osztaly,
|
||||
szint: karakter.szint.toString()
|
||||
})
|
||||
await CreatePDF(KarakterInputToPdfView(karakter))
|
||||
}}>Létrehozás</button>
|
||||
}}>PDF
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -3036,6 +3036,15 @@ axe-core@^4.6.2:
|
||||
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.7.2.tgz#040a7342b20765cb18bb50b628394c21bccc17a0"
|
||||
integrity sha512-zIURGIS1E1Q4pcrMjp+nnEh+16G56eG/MUllJH8yEvw7asDo7Ac9uhC9KIH5jzpITueEZolfYglnCGIuSBz39g==
|
||||
|
||||
axios@^1.6.2:
|
||||
version "1.6.2"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2"
|
||||
integrity sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==
|
||||
dependencies:
|
||||
follow-redirects "^1.15.0"
|
||||
form-data "^4.0.0"
|
||||
proxy-from-env "^1.1.0"
|
||||
|
||||
axobject-query@^3.1.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.2.1.tgz#39c378a6e3b06ca679f29138151e45b2b32da62a"
|
||||
@@ -4907,6 +4916,11 @@ follow-redirects@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
|
||||
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
|
||||
|
||||
follow-redirects@^1.15.0:
|
||||
version "1.15.3"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a"
|
||||
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==
|
||||
|
||||
for-each@^0.3.3:
|
||||
version "0.3.3"
|
||||
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
|
||||
@@ -4942,6 +4956,15 @@ form-data@^3.0.0:
|
||||
combined-stream "^1.0.8"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
form-data@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||
dependencies:
|
||||
asynckit "^0.4.0"
|
||||
combined-stream "^1.0.8"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
forwarded@0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
|
||||
@@ -7907,6 +7930,11 @@ proxy-addr@~2.0.7:
|
||||
forwarded "0.2.0"
|
||||
ipaddr.js "1.9.1"
|
||||
|
||||
proxy-from-env@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
|
||||
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
|
||||
|
||||
prr@~1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
#gzip on;
|
||||
upstream frontend {
|
||||
server 172.17.0.1:44478;
|
||||
}
|
||||
|
||||
upstream backend {
|
||||
server 172.17.0.1:7251;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8000 ssl;
|
||||
server_name localhost;
|
||||
|
||||
ssl_certificate kemkas.pem;
|
||||
ssl_certificate_key kemkas.key;
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
proxy_pass https://frontend;
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
location /Identity/ {
|
||||
|
||||
proxy_pass https://backend;
|
||||
proxy_pass_request_headers on;
|
||||
}
|
||||
|
||||
location /Character/ {
|
||||
proxy_pass https://backend;
|
||||
proxy_pass_request_headers on;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user