diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec312a9..142805d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,13 +47,13 @@ jobs: run: dotnet test --no-restore --verbosity normal - name: dotnet publish - run: dotnet publish ./src/REG.Angular/REG.Angular.csproj -c Release -o ${{env.DOTNET_ROOT}}/REG + run: dotnet publish ./src/REG.WebApi/REG.WebApi.csproj -c Release -o ${{env.DOTNET_ROOT}}/webapi - name: Upload artifact for deployment job uses: actions/upload-artifact@v7 with: name: .net-app - path: ${{env.DOTNET_ROOT}}/REG + path: ${{env.DOTNET_ROOT}}/webapi github-release: needs: build diff --git a/README.md b/README.md index f744f27..50e4990 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![Build status](https://github.com/Externius/RandomEncounterGenerator/actions/workflows/main.yml/badge.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) -This is a ASP.NET Core 10.0 Angular project for generating random encounters using D&D5th Edition SRD monsters. +This is an ASP.NET Core 10.0 + Angular project for generating random encounters using D&D5th Edition SRD monsters. ## Prerequisites @@ -13,21 +13,29 @@ You have Node.js and npm installed, also .NET 10 SDK. Use `git clone` to clone the repository. -## Build +## Build and run -In your preferred IDe run the REG.Angular project. +In your preferred IDE run the REG.WebApi project. Or manually in the project root folder you must run the following commands in a terminal: ``` bash dotnet build ``` -Than in the REG.Angular folder: +Then in the REG.WebApi folder: ``` bash dotnet run ``` +Also, you need to run the following commands in the REG.Angular folder + +``` bash +npm ci +npm run build +npm run start +``` + ## Usage -Open the address in a browser. +Open the address in a browser. diff --git a/REG.slnx b/REG.slnx index efc6aea..4da10e9 100644 --- a/REG.slnx +++ b/REG.slnx @@ -11,9 +11,9 @@ - + diff --git a/src/REG.Angular/ClientApp/.browserslistrc b/src/REG.Angular/.browserslistrc similarity index 97% rename from src/REG.Angular/ClientApp/.browserslistrc rename to src/REG.Angular/.browserslistrc index b44a58d..427441d 100644 --- a/src/REG.Angular/ClientApp/.browserslistrc +++ b/src/REG.Angular/.browserslistrc @@ -1,17 +1,17 @@ -# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. -# For additional information regarding the format and rule options, please see: -# https://github.com/browserslist/browserslist#queries - -# For the full list of supported browsers by the Angular framework, please see: -# https://angular.io/guide/browser-support - -# You can see what browsers were selected by your queries by running: -# npx browserslist - -last 1 Chrome version -last 1 Firefox version -last 2 Edge major versions -last 2 Safari major versions -last 2 iOS major versions -Firefox ESR -not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. +# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. +# For additional information regarding the format and rule options, please see: +# https://github.com/browserslist/browserslist#queries + +# For the full list of supported browsers by the Angular framework, please see: +# https://angular.io/guide/browser-support + +# You can see what browsers were selected by your queries by running: +# npx browserslist + +last 1 Chrome version +last 1 Firefox version +last 2 Edge major versions +last 2 Safari major versions +last 2 iOS major versions +Firefox ESR +not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. diff --git a/src/REG.Angular/ClientApp/.editorconfig b/src/REG.Angular/.editorconfig similarity index 94% rename from src/REG.Angular/ClientApp/.editorconfig rename to src/REG.Angular/.editorconfig index 6aac73a..5fc7188 100644 --- a/src/REG.Angular/ClientApp/.editorconfig +++ b/src/REG.Angular/.editorconfig @@ -1,19 +1,19 @@ -# Editor configuration, see http://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -quote_type = single - -[*.md] -max_line_length = off -trim_trailing_whitespace = false - -[*.{razor,cshtml}] -charset = utf-8-bom +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.ts] +quote_type = single + +[*.md] +max_line_length = off +trim_trailing_whitespace = false + +[*.{razor,cshtml}] +charset = utf-8-bom diff --git a/src/REG.Angular/.gitignore b/src/REG.Angular/.gitignore index 3255fe7..5bc630a 100644 --- a/src/REG.Angular/.gitignore +++ b/src/REG.Angular/.gitignore @@ -1,231 +1,42 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. +# See http://help.github.com/ignore-files/ for more about ignoring files. -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -bin/ -Bin/ -obj/ -Obj/ - -# Visual Studio 2015 cache/options directory -.vs/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Microsoft Azure ApplicationInsights config file -ApplicationInsights.config - -# Windows Store app package directory -AppPackages/ -BundleArtifacts/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -orleans.codegen.cs +# compiled output +/dist +/dist-server +/tmp +/out-tsc +# dependencies /node_modules -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe - -# FAKE - F# Make -.fake/ +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +yarn-error.log +testem.log +/typings + +# System Files +.DS_Store +Thumbs.db + +/.angular diff --git a/src/REG.Angular/ClientApp/.prettierrc b/src/REG.Angular/.prettierrc similarity index 95% rename from src/REG.Angular/ClientApp/.prettierrc rename to src/REG.Angular/.prettierrc index 168745e..81e1b02 100644 --- a/src/REG.Angular/ClientApp/.prettierrc +++ b/src/REG.Angular/.prettierrc @@ -1,11 +1,11 @@ -{ - "semi": true, - "trailingComma": "none", - "singleQuote": true, - "printWidth": 120, - "endOfLine": "auto", - "bracketSpacing": true, - "arrowParens": "avoid", - "tabWidth": 2, - "bracketSameLine": false -} +{ + "semi": true, + "trailingComma": "none", + "singleQuote": true, + "printWidth": 120, + "endOfLine": "auto", + "bracketSpacing": true, + "arrowParens": "avoid", + "tabWidth": 2, + "bracketSameLine": false +} diff --git a/src/REG.Angular/ClientApp/.gitignore b/src/REG.Angular/ClientApp/.gitignore deleted file mode 100644 index 5bc630a..0000000 --- a/src/REG.Angular/ClientApp/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# compiled output -/dist -/dist-server -/tmp -/out-tsc - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# misc -/.sass-cache -/connect.lock -/coverage -/libpeerconnection.log -npm-debug.log -yarn-error.log -testem.log -/typings - -# System Files -.DS_Store -Thumbs.db - -/.angular diff --git a/src/REG.Angular/Properties/launchSettings.json b/src/REG.Angular/Properties/launchSettings.json deleted file mode 100644 index daa509a..0000000 --- a/src/REG.Angular/Properties/launchSettings.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:61938", - "sslPort": 44332 - } - }, - "profiles": { - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development", - "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" - } - } - } -} diff --git a/src/REG.Angular/ClientApp/README.md b/src/REG.Angular/README.md similarity index 97% rename from src/REG.Angular/ClientApp/README.md rename to src/REG.Angular/README.md index c0b890b..471f09b 100644 --- a/src/REG.Angular/ClientApp/README.md +++ b/src/REG.Angular/README.md @@ -1,27 +1,27 @@ -# REG.Angular - -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.0. - -## Development server - -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. - -## Code scaffolding - -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. - -## Build - -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. - -## Running unit tests - -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Running end-to-end tests - -Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). +# REG.Angular + +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.0. + +## Development server + +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. + +## Build + +Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. + +## Running unit tests + +Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/src/REG.Angular/REG.Angular.csproj b/src/REG.Angular/REG.Angular.csproj deleted file mode 100644 index 3ec0b0d..0000000 --- a/src/REG.Angular/REG.Angular.csproj +++ /dev/null @@ -1,77 +0,0 @@ - - - false - ClientApp\ - https://localhost:4200 - npm start - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Never - - - - - - - - - - - - - - - - - - - - wwwroot\%(RecursiveDir)%(FileName)%(Extension) - PreserveNewest - true - - - - diff --git a/src/REG.Angular/ClientApp/angular.json b/src/REG.Angular/angular.json similarity index 96% rename from src/REG.Angular/ClientApp/angular.json rename to src/REG.Angular/angular.json index 92d5f38..28cae12 100644 --- a/src/REG.Angular/ClientApp/angular.json +++ b/src/REG.Angular/angular.json @@ -1,122 +1,122 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "REG.Angular": { - "projectType": "application", - "schematics": { - "@schematics/angular:application": { - "strict": true - }, - "@schematics/angular:component": { - "style": "scss", - "skipTests": true - } - }, - "root": "", - "sourceRoot": "src", - "prefix": "app", - "architect": { - "build": { - "builder": "@angular/build:application", - "options": { - "progress": false, - "outputPath": { - "base": "dist" - }, - "index": "src/index.html", - "polyfills": [], - "tsConfig": "tsconfig.app.json", - "assets": [ - "src/assets" - ], - "styles": [ - "node_modules/bootstrap/dist/css/bootstrap.min.css", - "src/styles.css", - "node_modules/@ng-select/ng-select/themes/default.theme.css" - ], - "scripts": [], - "browser": "src/main.ts", - "server": "src/server.ts", - "ssr": true, - "security": { - "allowedHosts": [] - } - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "initial", - "maximumWarning": "2mb", - "maximumError": "5mb" - }, - { - "type": "anyComponentStyle", - "maximumWarning": "2kb", - "maximumError": "4kb" - } - ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ], - "outputHashing": "all" - }, - "development": { - "optimization": false, - "extractLicenses": false, - "sourceMap": true, - "namedChunks": true - } - }, - "defaultConfiguration": "production" - }, - "serve": { - "builder": "@angular/build:dev-server", - "configurations": { - "production": { - "buildTarget": "REG.Angular:build:production" - }, - "development": { - "buildTarget": "REG.Angular:build:development", - "proxyConfig": "proxy.conf.json" - } - }, - "defaultConfiguration": "development" - }, - "extract-i18n": { - "builder": "@angular/build:extract-i18n", - "options": { - "buildTarget": "REG.Angular:build" - } - }, - "test": { - "builder": "@angular/build:karma", - "options": { - "main": "src/test.ts", - "polyfills": [], - "tsConfig": "tsconfig.spec.json", - "karmaConfig": "karma.conf.js", - "assets": [ - "src/assets" - ], - "styles": [ - "src/styles.scss" - ], - "scripts": [] - } - } - } - } - }, - "cli": { - "analytics": false, - "cache": { - "enabled": false - } - } -} +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "newProjectRoot": "projects", + "projects": { + "REG.Angular": { + "projectType": "application", + "schematics": { + "@schematics/angular:application": { + "strict": true + }, + "@schematics/angular:component": { + "style": "scss", + "skipTests": true + } + }, + "root": "", + "sourceRoot": "src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular/build:application", + "options": { + "progress": false, + "outputPath": { + "base": "dist" + }, + "index": "src/index.html", + "polyfills": [], + "tsConfig": "tsconfig.app.json", + "assets": [ + "src/assets" + ], + "styles": [ + "node_modules/bootstrap/dist/css/bootstrap.min.css", + "src/styles.css", + "node_modules/@ng-select/ng-select/themes/default.theme.css" + ], + "scripts": [], + "browser": "src/main.ts", + "server": "src/server.ts", + "ssr": true, + "security": { + "allowedHosts": [] + } + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "2kb", + "maximumError": "4kb" + } + ], + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ], + "outputHashing": "all" + }, + "development": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "builder": "@angular/build:dev-server", + "configurations": { + "production": { + "buildTarget": "REG.Angular:build:production" + }, + "development": { + "buildTarget": "REG.Angular:build:development", + "proxyConfig": "proxy.conf.json" + } + }, + "defaultConfiguration": "development" + }, + "extract-i18n": { + "builder": "@angular/build:extract-i18n", + "options": { + "buildTarget": "REG.Angular:build" + } + }, + "test": { + "builder": "@angular/build:karma", + "options": { + "main": "src/test.ts", + "polyfills": [], + "tsConfig": "tsconfig.spec.json", + "karmaConfig": "karma.conf.js", + "assets": [ + "src/assets" + ], + "styles": [ + "src/styles.scss" + ], + "scripts": [] + } + } + } + } + }, + "cli": { + "analytics": false, + "cache": { + "enabled": false + } + } +} diff --git a/src/REG.Angular/ClientApp/aspnetcore-https.js b/src/REG.Angular/aspnetcore-https.js similarity index 97% rename from src/REG.Angular/ClientApp/aspnetcore-https.js rename to src/REG.Angular/aspnetcore-https.js index 328ccb6..2bde928 100644 --- a/src/REG.Angular/ClientApp/aspnetcore-https.js +++ b/src/REG.Angular/aspnetcore-https.js @@ -1,33 +1,33 @@ -// This script sets up HTTPS for the application using the ASP.NET Core HTTPS certificate -const fs = require('fs'); -const spawn = require('child_process').spawn; -const path = require('path'); - -const baseFolder = - process.env.APPDATA !== undefined && process.env.APPDATA !== '' - ? `${process.env.APPDATA}/ASP.NET/https` - : `${process.env.HOME}/.aspnet/https`; - -const certificateArg = process.argv.map(arg => arg.match(/--name=(?.+)/i)).filter(Boolean)[0]; -const certificateName = certificateArg ? certificateArg.groups.value : process.env.npm_package_name; - -if (!certificateName) { - console.error('Invalid certificate name. Run this script in the context of an npm/yarn script or pass --name=<> explicitly.') - process.exit(-1); -} - -const certFilePath = path.join(baseFolder, `${certificateName}.pem`); -const keyFilePath = path.join(baseFolder, `${certificateName}.key`); - -if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) { - spawn('dotnet', [ - 'dev-certs', - 'https', - '--export-path', - certFilePath, - '--format', - 'Pem', - '--no-password', - ], { stdio: 'inherit', }) - .on('exit', (code) => process.exit(code)); -} +// This script sets up HTTPS for the application using the ASP.NET Core HTTPS certificate +const fs = require('fs'); +const spawn = require('child_process').spawn; +const path = require('path'); + +const baseFolder = + process.env.APPDATA !== undefined && process.env.APPDATA !== '' + ? `${process.env.APPDATA}/ASP.NET/https` + : `${process.env.HOME}/.aspnet/https`; + +const certificateArg = process.argv.map(arg => arg.match(/--name=(?.+)/i)).filter(Boolean)[0]; +const certificateName = certificateArg ? certificateArg.groups.value : process.env.npm_package_name; + +if (!certificateName) { + console.error('Invalid certificate name. Run this script in the context of an npm/yarn script or pass --name=<> explicitly.') + process.exit(-1); +} + +const certFilePath = path.join(baseFolder, `${certificateName}.pem`); +const keyFilePath = path.join(baseFolder, `${certificateName}.key`); + +if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) { + spawn('dotnet', [ + 'dev-certs', + 'https', + '--export-path', + certFilePath, + '--format', + 'Pem', + '--no-password', + ], { stdio: 'inherit', }) + .on('exit', (code) => process.exit(code)); +} diff --git a/src/REG.Angular/ClientApp/e2e/protractor.conf.js b/src/REG.Angular/e2e/protractor.conf.js similarity index 96% rename from src/REG.Angular/ClientApp/e2e/protractor.conf.js rename to src/REG.Angular/e2e/protractor.conf.js index 6639854..d60eff0 100644 --- a/src/REG.Angular/ClientApp/e2e/protractor.conf.js +++ b/src/REG.Angular/e2e/protractor.conf.js @@ -1,28 +1,28 @@ -// Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/lib/config.ts - -const { SpecReporter } = require("jasmine-spec-reporter"); - -exports.config = { - allScriptsTimeout: 11000, - specs: ["./src/**/*.e2e-spec.ts"], - capabilities: { - browserName: "chrome" - }, - directConnect: true, - baseUrl: "http://localhost:4200/", - framework: "jasmine", - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 30000, - print: function() {} - }, - onPrepare() { - require("ts-node").register({ - project: require("path").join(__dirname, "./tsconfig.e2e.json") - }); - jasmine - .getEnv() - .addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); - } -}; +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require("jasmine-spec-reporter"); + +exports.config = { + allScriptsTimeout: 11000, + specs: ["./src/**/*.e2e-spec.ts"], + capabilities: { + browserName: "chrome" + }, + directConnect: true, + baseUrl: "http://localhost:4200/", + framework: "jasmine", + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require("ts-node").register({ + project: require("path").join(__dirname, "./tsconfig.e2e.json") + }); + jasmine + .getEnv() + .addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; diff --git a/src/REG.Angular/ClientApp/e2e/src/app.e2e-spec.ts b/src/REG.Angular/e2e/src/app.e2e-spec.ts similarity index 95% rename from src/REG.Angular/ClientApp/e2e/src/app.e2e-spec.ts rename to src/REG.Angular/e2e/src/app.e2e-spec.ts index dc99225..5b3b4b2 100644 --- a/src/REG.Angular/ClientApp/e2e/src/app.e2e-spec.ts +++ b/src/REG.Angular/e2e/src/app.e2e-spec.ts @@ -1,14 +1,14 @@ -import { AppPage } from './app.po'; - -describe('App', () => { - let page: AppPage; - - beforeEach(() => { - page = new AppPage(); - }); - - it('should display welcome message', () => { - page.navigateTo(); - expect(page.getMainHeading()).toEqual('Hello, world!'); - }); -}); +import { AppPage } from './app.po'; + +describe('App', () => { + let page: AppPage; + + beforeEach(() => { + page = new AppPage(); + }); + + it('should display welcome message', () => { + page.navigateTo(); + expect(page.getMainHeading()).toEqual('Hello, world!'); + }); +}); diff --git a/src/REG.Angular/ClientApp/e2e/src/app.po.ts b/src/REG.Angular/e2e/src/app.po.ts similarity index 94% rename from src/REG.Angular/ClientApp/e2e/src/app.po.ts rename to src/REG.Angular/e2e/src/app.po.ts index 09a89fa..24bc8b3 100644 --- a/src/REG.Angular/ClientApp/e2e/src/app.po.ts +++ b/src/REG.Angular/e2e/src/app.po.ts @@ -1,11 +1,11 @@ -import { browser, by, element } from 'protractor'; - -export class AppPage { - navigateTo() { - return browser.get('/'); - } - - getMainHeading() { - return element(by.css('app-root h1')).getText(); - } -} +import { browser, by, element } from 'protractor'; + +export class AppPage { + navigateTo() { + return browser.get('/'); + } + + getMainHeading() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/src/REG.Angular/ClientApp/e2e/tsconfig.e2e.json b/src/REG.Angular/e2e/tsconfig.e2e.json similarity index 94% rename from src/REG.Angular/ClientApp/e2e/tsconfig.e2e.json rename to src/REG.Angular/e2e/tsconfig.e2e.json index 43d5b30..a6dd622 100644 --- a/src/REG.Angular/ClientApp/e2e/tsconfig.e2e.json +++ b/src/REG.Angular/e2e/tsconfig.e2e.json @@ -1,13 +1,13 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/app", - "module": "commonjs", - "target": "es5", - "types": [ - "jasmine", - "jasminewd2", - "node" - ] - } +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } } \ No newline at end of file diff --git a/src/REG.Angular/ClientApp/eslint.config.mjs b/src/REG.Angular/eslint.config.mjs similarity index 100% rename from src/REG.Angular/ClientApp/eslint.config.mjs rename to src/REG.Angular/eslint.config.mjs diff --git a/src/REG.Angular/ClientApp/karma.conf.js b/src/REG.Angular/karma.conf.js similarity index 97% rename from src/REG.Angular/ClientApp/karma.conf.js rename to src/REG.Angular/karma.conf.js index e6f9add..78590dd 100644 --- a/src/REG.Angular/ClientApp/karma.conf.js +++ b/src/REG.Angular/karma.conf.js @@ -1,39 +1,39 @@ -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage') - ], - client: { - jasmine: { - // you can add configuration options for Jasmine here - // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html - // for example, you can disable the random execution with `random: false` - // or set a specific seed with `seed: 4321` - }, - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - jasmineHtmlReporter: { - suppressAll: true // removes the duplicated traces - }, - coverageReporter: { - dir: require('path').join(__dirname, './coverage/'), - subdir: '.', - reporters: [{ type: 'html' }, { type: 'text-summary' }] - }, - reporters: ['progress', 'kjhtml'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false, - restartOnFileChange: true, - listenAddress: 'localhost', - hostname: 'localhost' - }); -}; +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage') + ], + client: { + jasmine: { + // you can add configuration options for Jasmine here + // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html + // for example, you can disable the random execution with `random: false` + // or set a specific seed with `seed: 4321` + }, + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + jasmineHtmlReporter: { + suppressAll: true // removes the duplicated traces + }, + coverageReporter: { + dir: require('path').join(__dirname, './coverage/'), + subdir: '.', + reporters: [{ type: 'html' }, { type: 'text-summary' }] + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true, + listenAddress: 'localhost', + hostname: 'localhost' + }); +}; diff --git a/src/REG.Angular/ClientApp/package-lock.json b/src/REG.Angular/package-lock.json similarity index 100% rename from src/REG.Angular/ClientApp/package-lock.json rename to src/REG.Angular/package-lock.json diff --git a/src/REG.Angular/ClientApp/package.json b/src/REG.Angular/package.json similarity index 96% rename from src/REG.Angular/ClientApp/package.json rename to src/REG.Angular/package.json index 8928881..f4bc8cf 100644 --- a/src/REG.Angular/ClientApp/package.json +++ b/src/REG.Angular/package.json @@ -1,73 +1,73 @@ -{ - "name": "reg.angular", - "version": "0.4.22", - "scripts": { - "ng": "ng", - "lint": "eslint . --ext .ts", - "lint-and-fix": "eslint . --ext .ts --fix", - "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write", - "prestart": "node aspnetcore-https", - "start": "run-script-os", - "start:windows": "ng serve --ssl --ssl-cert \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem\" --ssl-key \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.key\" --host=127.0.0.1", - "start:default": "ng serve --ssl --ssl-cert \"$HOME/.aspnet/https/${npm_package_name}.pem\" --ssl-key \"$HOME/.aspnet/https/${npm_package_name}.key\" --host=127.0.0.1", - "build": "ng build", - "watch": "ng build --watch --configuration development", - "test": "ng test", - "serve:ssr:REG.Angular": "node dist/server/server.mjs" - }, - "private": true, - "dependencies": { - "@angular/animations": "22.1.3", - "@angular/cdk": "22.1.3", - "@angular/common": "22.1.3", - "@angular/compiler": "22.1.3", - "@angular/core": "22.1.3", - "@angular/forms": "22.1.3", - "@angular/material": "22.1.3", - "@angular/platform-browser": "22.1.3", - "@angular/platform-browser-dynamic": "22.1.3", - "@angular/platform-server": "22.1.3", - "@angular/router": "22.1.3", - "@angular/ssr": "22.1.5", - "@fortawesome/angular-fontawesome": "5.1.0", - "@fortawesome/fontawesome-svg-core": "7.3.1", - "@fortawesome/free-solid-svg-icons": "7.3.1", - "@ng-bootstrap/ng-bootstrap": "21.0.0", - "@ng-select/ng-select": "24.0.2", - "@ngx-translate/core": "18.0.0", - "@ngx-translate/http-loader": "18.0.0", - "@popperjs/core": "2.11.8", - "@types/bootstrap": "5.2.11", - "bootstrap": "5.3.8", - "express": "5.2.1", - "ngx-cookie-service": "22.0.0", - "oidc-client": "1.11.5", - "run-script-os": "1.1.6", - "rxjs": "7.8.2", - "tslib": "2.8.1" - }, - "devDependencies": { - "@angular/build": "22.1.5", - "@angular/cli": "22.1.5", - "@angular/compiler-cli": "22.1.3", - "@angular/language-service": "22.1.3", - "@eslint/eslintrc": "3.3.6", - "@eslint/js": "10.0.1", - "@types/express": "5.0.6", - "@types/jasmine": "6.0.0", - "@types/node": "26.2.0", - "@typescript-eslint/eslint-plugin": "8.67.0", - "@typescript-eslint/parser": "8.67.0", - "eslint": "10.9.0", - "eslint-config-prettier": "10.1.8", - "eslint-plugin-prettier": "5.5.6", - "jasmine-core": "7.0.2", - "karma": "6.4.4", - "karma-chrome-launcher": "3.2.0", - "karma-coverage": "2.2.1", - "karma-jasmine": "5.1.0", - "karma-jasmine-html-reporter": "2.3.0", - "prettier": "3.9.6", - "typescript": "6.0.3" - } -} +{ + "name": "reg.angular", + "version": "0.4.22", + "scripts": { + "ng": "ng", + "lint": "eslint . --ext .ts", + "lint-and-fix": "eslint . --ext .ts --fix", + "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write", + "prestart": "node aspnetcore-https", + "start": "run-script-os", + "start:windows": "ng serve --ssl --ssl-cert \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem\" --ssl-key \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.key\" --host=127.0.0.1", + "start:default": "ng serve --ssl --ssl-cert \"$HOME/.aspnet/https/${npm_package_name}.pem\" --ssl-key \"$HOME/.aspnet/https/${npm_package_name}.key\" --host=127.0.0.1", + "build": "ng build --configuration production", + "watch": "ng build --watch --configuration development", + "test": "ng test", + "serve:ssr:REG.Angular": "node dist/server/server.mjs" + }, + "private": true, + "dependencies": { + "@angular/animations": "22.1.3", + "@angular/cdk": "22.1.3", + "@angular/common": "22.1.3", + "@angular/compiler": "22.1.3", + "@angular/core": "22.1.3", + "@angular/forms": "22.1.3", + "@angular/material": "22.1.3", + "@angular/platform-browser": "22.1.3", + "@angular/platform-browser-dynamic": "22.1.3", + "@angular/platform-server": "22.1.3", + "@angular/router": "22.1.3", + "@angular/ssr": "22.1.5", + "@fortawesome/angular-fontawesome": "5.1.0", + "@fortawesome/fontawesome-svg-core": "7.3.1", + "@fortawesome/free-solid-svg-icons": "7.3.1", + "@ng-bootstrap/ng-bootstrap": "21.0.0", + "@ng-select/ng-select": "24.0.2", + "@ngx-translate/core": "18.0.0", + "@ngx-translate/http-loader": "18.0.0", + "@popperjs/core": "2.11.8", + "@types/bootstrap": "5.2.11", + "bootstrap": "5.3.8", + "express": "5.2.1", + "ngx-cookie-service": "22.0.0", + "oidc-client": "1.11.5", + "run-script-os": "1.1.6", + "rxjs": "7.8.2", + "tslib": "2.8.1" + }, + "devDependencies": { + "@angular/build": "22.1.5", + "@angular/cli": "22.1.5", + "@angular/compiler-cli": "22.1.3", + "@angular/language-service": "22.1.3", + "@eslint/eslintrc": "3.3.6", + "@eslint/js": "10.0.1", + "@types/express": "5.0.6", + "@types/jasmine": "6.0.0", + "@types/node": "26.2.0", + "@typescript-eslint/eslint-plugin": "8.67.0", + "@typescript-eslint/parser": "8.67.0", + "eslint": "10.9.0", + "eslint-config-prettier": "10.1.8", + "eslint-plugin-prettier": "5.5.6", + "jasmine-core": "7.0.2", + "karma": "6.4.4", + "karma-chrome-launcher": "3.2.0", + "karma-coverage": "2.2.1", + "karma-jasmine": "5.1.0", + "karma-jasmine-html-reporter": "2.3.0", + "prettier": "3.9.6", + "typescript": "6.0.3" + } +} diff --git a/src/REG.Angular/ClientApp/proxy.conf.json b/src/REG.Angular/proxy.conf.json similarity index 92% rename from src/REG.Angular/ClientApp/proxy.conf.json rename to src/REG.Angular/proxy.conf.json index 6560a75..b65b5da 100644 --- a/src/REG.Angular/ClientApp/proxy.conf.json +++ b/src/REG.Angular/proxy.conf.json @@ -1,6 +1,6 @@ -{ - "/api": { - "target": "https://localhost:5001", - "secure": true - } -} +{ + "/api": { + "target": "https://localhost:5001", + "secure": true + } +} diff --git a/src/REG.Angular/ClientApp/src/app/app.component.html b/src/REG.Angular/src/app/app.component.html similarity index 96% rename from src/REG.Angular/ClientApp/src/app/app.component.html rename to src/REG.Angular/src/app/app.component.html index 4838423..83ef2ed 100644 --- a/src/REG.Angular/ClientApp/src/app/app.component.html +++ b/src/REG.Angular/src/app/app.component.html @@ -1,3 +1,3 @@ - - - + + + diff --git a/src/REG.Angular/ClientApp/src/app/app.component.ts b/src/REG.Angular/src/app/app.component.ts similarity index 97% rename from src/REG.Angular/ClientApp/src/app/app.component.ts rename to src/REG.Angular/src/app/app.component.ts index 461bcfa..b87df4b 100644 --- a/src/REG.Angular/ClientApp/src/app/app.component.ts +++ b/src/REG.Angular/src/app/app.component.ts @@ -1,18 +1,18 @@ -import { Component } from '@angular/core'; -import { TranslateService } from '@ngx-translate/core'; -import { AppHeaderComponent } from './shared/components/app.header.component'; -import { AppBodyComponent } from './shared/components/app.body.component'; -import { AppFooterComponent } from './shared/components/app.footer.component'; - -@Component({ - selector: 'app-root', - imports: [AppHeaderComponent, AppBodyComponent, AppFooterComponent], - templateUrl: './app.component.html' -}) -export class AppComponent { - constructor(translate: TranslateService) { - translate.addLangs(['en', 'hu']); - translate.setFallbackLang('en'); - translate.use('en'); - } -} +import { Component } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { AppHeaderComponent } from './shared/components/app.header.component'; +import { AppBodyComponent } from './shared/components/app.body.component'; +import { AppFooterComponent } from './shared/components/app.footer.component'; + +@Component({ + selector: 'app-root', + imports: [AppHeaderComponent, AppBodyComponent, AppFooterComponent], + templateUrl: './app.component.html' +}) +export class AppComponent { + constructor(translate: TranslateService) { + translate.addLangs(['en', 'hu']); + translate.setFallbackLang('en'); + translate.use('en'); + } +} diff --git a/src/REG.Angular/ClientApp/src/app/app.routing.ts b/src/REG.Angular/src/app/app.routing.ts similarity index 100% rename from src/REG.Angular/ClientApp/src/app/app.routing.ts rename to src/REG.Angular/src/app/app.routing.ts diff --git a/src/REG.Angular/ClientApp/src/app/core/alertdialog/alertdialog.component.html b/src/REG.Angular/src/app/core/alertdialog/alertdialog.component.html similarity index 97% rename from src/REG.Angular/ClientApp/src/app/core/alertdialog/alertdialog.component.html rename to src/REG.Angular/src/app/core/alertdialog/alertdialog.component.html index aa1e720..e4bafc5 100644 --- a/src/REG.Angular/ClientApp/src/app/core/alertdialog/alertdialog.component.html +++ b/src/REG.Angular/src/app/core/alertdialog/alertdialog.component.html @@ -1,16 +1,16 @@ - - - + + + diff --git a/src/REG.Angular/ClientApp/src/app/core/alertdialog/alertdialog.component.ts b/src/REG.Angular/src/app/core/alertdialog/alertdialog.component.ts similarity index 96% rename from src/REG.Angular/ClientApp/src/app/core/alertdialog/alertdialog.component.ts rename to src/REG.Angular/src/app/core/alertdialog/alertdialog.component.ts index 553a125..24f518a 100644 --- a/src/REG.Angular/ClientApp/src/app/core/alertdialog/alertdialog.component.ts +++ b/src/REG.Angular/src/app/core/alertdialog/alertdialog.component.ts @@ -1,24 +1,24 @@ -import { Component, Input } from '@angular/core'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { TranslatePipe } from '@ngx-translate/core'; - -@Component({ - selector: 'app-alert-dialog', - imports: [TranslatePipe], - templateUrl: './alertdialog.component.html' -}) -export class AlertDialogComponent { - @Input() title = ''; - @Input() message = ''; - @Input() stackTrace = ''; - - constructor(public activeModal: NgbActiveModal) {} - - onConfirm(): void { - this.activeModal.close(true); - } - - onDismiss(): void { - this.activeModal.dismiss(true); - } -} +import { Component, Input } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { TranslatePipe } from '@ngx-translate/core'; + +@Component({ + selector: 'app-alert-dialog', + imports: [TranslatePipe], + templateUrl: './alertdialog.component.html' +}) +export class AlertDialogComponent { + @Input() title = ''; + @Input() message = ''; + @Input() stackTrace = ''; + + constructor(public activeModal: NgbActiveModal) {} + + onConfirm(): void { + this.activeModal.close(true); + } + + onDismiss(): void { + this.activeModal.dismiss(true); + } +} diff --git a/src/REG.Angular/ClientApp/src/app/core/http/encounter.service.ts b/src/REG.Angular/src/app/core/http/encounter.service.ts similarity index 96% rename from src/REG.Angular/ClientApp/src/app/core/http/encounter.service.ts rename to src/REG.Angular/src/app/core/http/encounter.service.ts index 8192018..0219ec1 100644 --- a/src/REG.Angular/ClientApp/src/app/core/http/encounter.service.ts +++ b/src/REG.Angular/src/app/core/http/encounter.service.ts @@ -1,28 +1,28 @@ -import { Injectable, Inject } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; -import { RequestHttpOption } from './http.option'; - -@Injectable({ providedIn: 'root' }) -export class EncounterService { - constructor( - private httpClient: HttpClient, - private rho: RequestHttpOption, - @Inject('API_URL') private apiUrl: string - ) {} - - public getMonsterTypes() { - return this.httpClient.get(this.apiUrl + '/Encounter/monstertypes', this.rho.httpOptions); - } - - public getDifficulties() { - return this.httpClient.get(this.apiUrl + '/Encounter/difficulties', this.rho.httpOptions); - } - - public getSizes() { - return this.httpClient.get(this.apiUrl + '/Encounter/sizes', this.rho.httpOptions); - } - - public generate(data: string) { - return this.httpClient.post(`${this.apiUrl}/Encounter`, data, this.rho.httpOptions); - } -} +import { Injectable, Inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { RequestHttpOption } from './http.option'; + +@Injectable({ providedIn: 'root' }) +export class EncounterService { + constructor( + private httpClient: HttpClient, + private rho: RequestHttpOption, + @Inject('API_URL') private apiUrl: string + ) {} + + public getMonsterTypes() { + return this.httpClient.get(this.apiUrl + '/Encounter/monstertypes', this.rho.httpOptions); + } + + public getDifficulties() { + return this.httpClient.get(this.apiUrl + '/Encounter/difficulties', this.rho.httpOptions); + } + + public getSizes() { + return this.httpClient.get(this.apiUrl + '/Encounter/sizes', this.rho.httpOptions); + } + + public generate(data: string) { + return this.httpClient.post(`${this.apiUrl}/Encounter`, data, this.rho.httpOptions); + } +} diff --git a/src/REG.Angular/ClientApp/src/app/core/http/http.option.ts b/src/REG.Angular/src/app/core/http/http.option.ts similarity index 96% rename from src/REG.Angular/ClientApp/src/app/core/http/http.option.ts rename to src/REG.Angular/src/app/core/http/http.option.ts index 5f8cb2c..09b7aaa 100644 --- a/src/REG.Angular/ClientApp/src/app/core/http/http.option.ts +++ b/src/REG.Angular/src/app/core/http/http.option.ts @@ -1,14 +1,14 @@ -import { Injectable } from '@angular/core'; -import { HttpHeaders } from '@angular/common/http'; - -@Injectable({ - providedIn: 'root' -}) -export class RequestHttpOption { - httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json', - 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS, PUT, PATCH, DELETE' - }) - }; -} +import { Injectable } from '@angular/core'; +import { HttpHeaders } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class RequestHttpOption { + httpOptions = { + headers: new HttpHeaders({ + 'Content-Type': 'application/json', + 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS, PUT, PATCH, DELETE' + }) + }; +} diff --git a/src/REG.Angular/ClientApp/src/app/core/interceptors/server.error.interceptor.ts b/src/REG.Angular/src/app/core/interceptors/server.error.interceptor.ts similarity index 97% rename from src/REG.Angular/ClientApp/src/app/core/interceptors/server.error.interceptor.ts rename to src/REG.Angular/src/app/core/interceptors/server.error.interceptor.ts index 329b883..e7d6b10 100644 --- a/src/REG.Angular/ClientApp/src/app/core/interceptors/server.error.interceptor.ts +++ b/src/REG.Angular/src/app/core/interceptors/server.error.interceptor.ts @@ -1,34 +1,34 @@ -import { Injectable, inject, Injector } from '@angular/core'; -import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; -import { Observable, EMPTY, throwError } from 'rxjs'; -import { catchError } from 'rxjs/operators'; -import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { AlertDialogComponent } from '../alertdialog/alertdialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import { PLATFORM_ID } from '@angular/core'; -import { isPlatformBrowser } from '@angular/common'; - -@Injectable() -export class ServerErrorInterceptor implements HttpInterceptor { - private readonly modalService = inject(NgbModal); - private readonly injector = inject(Injector); - private readonly platformId = inject(PLATFORM_ID); - - intercept(req: HttpRequest, next: HttpHandler): Observable> { - const request = req.clone({ withCredentials: true }); - return next.handle(request).pipe( - catchError(err => { - const isBrowser = isPlatformBrowser(this.platformId); - if (isBrowser && (err.status === 400 || err.status === 500)) { - const translate = this.injector.get(TranslateService); - const dialogRef = this.modalService.open(AlertDialogComponent); - dialogRef.componentInstance.title = translate.instant('error.title'); - dialogRef.componentInstance.message = err.error?.Message; - dialogRef.componentInstance.stackTrace = err.error?.StackTrace; - return EMPTY; - } - return throwError(() => err); - }) - ); - } -} +import { Injectable, inject, Injector } from '@angular/core'; +import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; +import { Observable, EMPTY, throwError } from 'rxjs'; +import { catchError } from 'rxjs/operators'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { AlertDialogComponent } from '../alertdialog/alertdialog.component'; +import { TranslateService } from '@ngx-translate/core'; +import { PLATFORM_ID } from '@angular/core'; +import { isPlatformBrowser } from '@angular/common'; + +@Injectable() +export class ServerErrorInterceptor implements HttpInterceptor { + private readonly modalService = inject(NgbModal); + private readonly injector = inject(Injector); + private readonly platformId = inject(PLATFORM_ID); + + intercept(req: HttpRequest, next: HttpHandler): Observable> { + const request = req.clone({ withCredentials: true }); + return next.handle(request).pipe( + catchError(err => { + const isBrowser = isPlatformBrowser(this.platformId); + if (isBrowser && (err.status === 400 || err.status === 500)) { + const translate = this.injector.get(TranslateService); + const dialogRef = this.modalService.open(AlertDialogComponent); + dialogRef.componentInstance.title = translate.instant('error.title'); + dialogRef.componentInstance.message = err.error?.Message; + dialogRef.componentInstance.stackTrace = err.error?.StackTrace; + return EMPTY; + } + return throwError(() => err); + }) + ); + } +} diff --git a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.detail.component.html b/src/REG.Angular/src/app/modules/encounter/encounter.detail.component.html similarity index 97% rename from src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.detail.component.html rename to src/REG.Angular/src/app/modules/encounter/encounter.detail.component.html index 8b02645..0de7c1a 100644 --- a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.detail.component.html +++ b/src/REG.Angular/src/app/modules/encounter/encounter.detail.component.html @@ -1,238 +1,238 @@ - - - + + + diff --git a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.detail.component.ts b/src/REG.Angular/src/app/modules/encounter/encounter.detail.component.ts similarity index 96% rename from src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.detail.component.ts rename to src/REG.Angular/src/app/modules/encounter/encounter.detail.component.ts index d67e3f0..edf8ef2 100644 --- a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.detail.component.ts +++ b/src/REG.Angular/src/app/modules/encounter/encounter.detail.component.ts @@ -1,35 +1,35 @@ -import { Component, Input } from '@angular/core'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { EncounterDetailModel } from '../../shared/models/encounter.model'; -import { EncounterService } from '../../core/http/encounter.service'; -import { TranslatePipe } from '@ngx-translate/core'; -import { DecimalPipe } from '@angular/common'; -import { SavingThrowPipe } from '../../shared/pipes/saving.throw.pipe'; - -@Component({ - selector: 'app-encounter-detail', - templateUrl: './encounter.detail.component.html', - imports: [TranslatePipe, DecimalPipe, SavingThrowPipe], - providers: [EncounterService] -}) -export class EncounterDetailComponent { - @Input() detail!: EncounterDetailModel; - - constructor(public activeModal: NgbActiveModal) {} - - calcMod(ability: number): string { - const result = -5 + Math.floor(ability / 2); - if (result > 0) { - return '+' + result; - } - return result.toString(); - } - - onConfirm(): void { - this.activeModal.close(true); - } - - onDismiss(): void { - this.activeModal.close(true); - } -} +import { Component, Input } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { EncounterDetailModel } from '../../shared/models/encounter.model'; +import { EncounterService } from '../../core/http/encounter.service'; +import { TranslatePipe } from '@ngx-translate/core'; +import { DecimalPipe } from '@angular/common'; +import { SavingThrowPipe } from '../../shared/pipes/saving.throw.pipe'; + +@Component({ + selector: 'app-encounter-detail', + templateUrl: './encounter.detail.component.html', + imports: [TranslatePipe, DecimalPipe, SavingThrowPipe], + providers: [EncounterService] +}) +export class EncounterDetailComponent { + @Input() detail!: EncounterDetailModel; + + constructor(public activeModal: NgbActiveModal) {} + + calcMod(ability: number): string { + const result = -5 + Math.floor(ability / 2); + if (result > 0) { + return '+' + result; + } + return result.toString(); + } + + onConfirm(): void { + this.activeModal.close(true); + } + + onDismiss(): void { + this.activeModal.close(true); + } +} diff --git a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.component.html b/src/REG.Angular/src/app/modules/encounter/encounter.list.component.html similarity index 97% rename from src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.component.html rename to src/REG.Angular/src/app/modules/encounter/encounter.list.component.html index 01e1f0c..afea196 100644 --- a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.component.html +++ b/src/REG.Angular/src/app/modules/encounter/encounter.list.component.html @@ -1,83 +1,83 @@ -
-
-
- - - -
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
-
- -
-
-
- - - - - - - - - - - - - -
{{ 'encounter.monsterName' | translate }}{{ 'encounter.count' | translate }}{{ 'encounter.type' | translate }}{{ 'encounter.size' | translate }}{{ 'encounter.xp' | translate }}{{ 'encounter.difficulty' | translate }}
-
-
- @for (monster of encounterModel.encounters; track monster.name) { -
-
-
- -
-
-
-
- {{ monster.count | number }}x {{ monster.name }} -
-
{{ monster.type }} ({{ monster.size }})
-

{{ 'encounter.difficulty' | translate }}: {{ monster.difficulty }} - ({{ monster.xp | number }} {{ 'encounter.xp' | translate }}) -

-
-
-
-
- } -
+
+
+
+ + + +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + +
{{ 'encounter.monsterName' | translate }}{{ 'encounter.count' | translate }}{{ 'encounter.type' | translate }}{{ 'encounter.size' | translate }}{{ 'encounter.xp' | translate }}{{ 'encounter.difficulty' | translate }}
+
+
+ @for (monster of encounterModel.encounters; track monster.name) { +
+
+
+ +
+
+
+
+ {{ monster.count | number }}x {{ monster.name }} +
+
{{ monster.type }} ({{ monster.size }})
+

{{ 'encounter.difficulty' | translate }}: {{ monster.difficulty }} + ({{ monster.xp | number }} {{ 'encounter.xp' | translate }}) +

+
+
+
+
+ } +
diff --git a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.component.ts b/src/REG.Angular/src/app/modules/encounter/encounter.list.component.ts similarity index 97% rename from src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.component.ts rename to src/REG.Angular/src/app/modules/encounter/encounter.list.component.ts index b7618a1..2be80c0 100644 --- a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.component.ts +++ b/src/REG.Angular/src/app/modules/encounter/encounter.list.component.ts @@ -1,128 +1,128 @@ -import { Component, OnInit, ViewChildren, QueryList, ChangeDetectorRef } from '@angular/core'; -import { EncounterListService } from './encounter.list.service'; -import { - EncounterOptionModel, - EncounterModel, - EncounterDetailModel, - SpecialAbility, - Action, - Reaction, - LegendaryAction -} from '../../shared/models/encounter.model'; -import { FormGroup, FormBuilder, ReactiveFormsModule } from '@angular/forms'; -import { SortEvent, SortableHeaderDirective } from '../../shared/directive/sortable.directive'; -import { faDiceD20 } from '@fortawesome/free-solid-svg-icons'; -import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { EncounterDetailComponent } from './encounter.detail.component'; -import { TranslatePipe } from '@ngx-translate/core'; -import { NgSelectComponent } from '@ng-select/ng-select'; -import { FaIconComponent } from '@fortawesome/angular-fontawesome'; -import { DecimalPipe } from '@angular/common'; - -const compare = ( - v1: string | number | SpecialAbility[] | Action[] | Reaction[] | LegendaryAction[], - v2: string | number | SpecialAbility[] | Action[] | Reaction[] | LegendaryAction[] -) => (v1 < v2 ? -1 : v1 > v2 ? 1 : 0); - -@Component({ - selector: 'app-encounter', - templateUrl: './encounter.list.component.html', - imports: [ - TranslatePipe, - NgSelectComponent, - FaIconComponent, - DecimalPipe, - ReactiveFormsModule, - SortableHeaderDirective - ], - providers: [EncounterListService] -}) -export class EncounterListComponent implements OnInit { - _monsterTypes!: []; - _sizes!: []; - difficulties!: []; - partyLevels: number[] = []; - partySizes: number[] = []; - _originalDetails: EncounterDetailModel[] = []; - serverError = ''; - encounterOptionsForm!: FormGroup; - encounterModel: EncounterModel = new EncounterModel(); - @ViewChildren(SortableHeaderDirective) headers!: QueryList; - faDiceD20 = faDiceD20; - - constructor( - private formBuilder: FormBuilder, - private modalService: NgbModal, - private ref: ChangeDetectorRef, - public encounterListService: EncounterListService - ) { - for (let level = 1; level < 21; level++) { - this.partyLevels.push(level); - } - for (let i = 1; i < 11; i++) { - this.partySizes.push(i); - } - } - - ngOnInit() { - this.encounterListService.getMonsterTypes().subscribe(data => { - this._monsterTypes = data as []; - }); - this.encounterListService.getDifficulties().subscribe(data => { - this.difficulties = data as []; - }); - this.encounterListService.getSizes().subscribe(data => { - this._sizes = data as []; - }); - this.encounterOptionsForm = this.formBuilder.group(new EncounterOptionModel()); - } - - onSubmit() { - // workaround for first empty select - if (this.encounterOptionsForm.value.monsterTypes === null) { - this.encounterOptionsForm.value.monsterTypes = []; - } - if (this.encounterOptionsForm.value.sizes === null) { - this.encounterOptionsForm.value.sizes = []; - } - - this.encounterListService.generate(JSON.stringify(this.encounterOptionsForm.value)).subscribe({ - next: data => { - Object.assign(this.encounterModel, data); - this._originalDetails = []; - Object.assign(this._originalDetails, this.encounterModel.encounters); - }, - error: error => { - this.serverError = error.error.Message; - }, - complete: () => { - this.ref.detectChanges(); - } - }); - } - - onSort({ column, direction }: SortEvent) { - this.headers.forEach(header => { - if (header.sortable !== column) { - header.direction = ''; - } - }); - - if (direction === '' || column === '') { - this.encounterModel.encounters = this._originalDetails; - } else { - this.encounterModel.encounters = [...this._originalDetails].sort((a, b) => { - const res = compare(a[column], b[column]); - return direction === 'asc' ? res : -res; - }); - } - } - - monsterDetailDialog(detail: EncounterDetailModel) { - const modalRef = this.modalService.open(EncounterDetailComponent, { - size: 'xl', - scrollable: true - }); - modalRef.componentInstance.detail = detail; - } -} +import { Component, OnInit, ViewChildren, QueryList, ChangeDetectorRef } from '@angular/core'; +import { EncounterListService } from './encounter.list.service'; +import { + EncounterOptionModel, + EncounterModel, + EncounterDetailModel, + SpecialAbility, + Action, + Reaction, + LegendaryAction +} from '../../shared/models/encounter.model'; +import { FormGroup, FormBuilder, ReactiveFormsModule } from '@angular/forms'; +import { SortEvent, SortableHeaderDirective } from '../../shared/directive/sortable.directive'; +import { faDiceD20 } from '@fortawesome/free-solid-svg-icons'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { EncounterDetailComponent } from './encounter.detail.component'; +import { TranslatePipe } from '@ngx-translate/core'; +import { NgSelectComponent } from '@ng-select/ng-select'; +import { FaIconComponent } from '@fortawesome/angular-fontawesome'; +import { DecimalPipe } from '@angular/common'; + +const compare = ( + v1: string | number | SpecialAbility[] | Action[] | Reaction[] | LegendaryAction[], + v2: string | number | SpecialAbility[] | Action[] | Reaction[] | LegendaryAction[] +) => (v1 < v2 ? -1 : v1 > v2 ? 1 : 0); + +@Component({ + selector: 'app-encounter', + templateUrl: './encounter.list.component.html', + imports: [ + TranslatePipe, + NgSelectComponent, + FaIconComponent, + DecimalPipe, + ReactiveFormsModule, + SortableHeaderDirective + ], + providers: [EncounterListService] +}) +export class EncounterListComponent implements OnInit { + _monsterTypes!: []; + _sizes!: []; + difficulties!: []; + partyLevels: number[] = []; + partySizes: number[] = []; + _originalDetails: EncounterDetailModel[] = []; + serverError = ''; + encounterOptionsForm!: FormGroup; + encounterModel: EncounterModel = new EncounterModel(); + @ViewChildren(SortableHeaderDirective) headers!: QueryList; + faDiceD20 = faDiceD20; + + constructor( + private formBuilder: FormBuilder, + private modalService: NgbModal, + private ref: ChangeDetectorRef, + public encounterListService: EncounterListService + ) { + for (let level = 1; level < 21; level++) { + this.partyLevels.push(level); + } + for (let i = 1; i < 11; i++) { + this.partySizes.push(i); + } + } + + ngOnInit() { + this.encounterListService.getMonsterTypes().subscribe(data => { + this._monsterTypes = data as []; + }); + this.encounterListService.getDifficulties().subscribe(data => { + this.difficulties = data as []; + }); + this.encounterListService.getSizes().subscribe(data => { + this._sizes = data as []; + }); + this.encounterOptionsForm = this.formBuilder.group(new EncounterOptionModel()); + } + + onSubmit() { + // workaround for first empty select + if (this.encounterOptionsForm.value.monsterTypes === null) { + this.encounterOptionsForm.value.monsterTypes = []; + } + if (this.encounterOptionsForm.value.sizes === null) { + this.encounterOptionsForm.value.sizes = []; + } + + this.encounterListService.generate(JSON.stringify(this.encounterOptionsForm.value)).subscribe({ + next: data => { + Object.assign(this.encounterModel, data); + this._originalDetails = []; + Object.assign(this._originalDetails, this.encounterModel.encounters); + }, + error: error => { + this.serverError = error.error.Message; + }, + complete: () => { + this.ref.detectChanges(); + } + }); + } + + onSort({ column, direction }: SortEvent) { + this.headers.forEach(header => { + if (header.sortable !== column) { + header.direction = ''; + } + }); + + if (direction === '' || column === '') { + this.encounterModel.encounters = this._originalDetails; + } else { + this.encounterModel.encounters = [...this._originalDetails].sort((a, b) => { + const res = compare(a[column], b[column]); + return direction === 'asc' ? res : -res; + }); + } + } + + monsterDetailDialog(detail: EncounterDetailModel) { + const modalRef = this.modalService.open(EncounterDetailComponent, { + size: 'xl', + scrollable: true + }); + modalRef.componentInstance.detail = detail; + } +} diff --git a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.service.ts b/src/REG.Angular/src/app/modules/encounter/encounter.list.service.ts similarity index 95% rename from src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.service.ts rename to src/REG.Angular/src/app/modules/encounter/encounter.list.service.ts index e69fbf4..a746d52 100644 --- a/src/REG.Angular/ClientApp/src/app/modules/encounter/encounter.list.service.ts +++ b/src/REG.Angular/src/app/modules/encounter/encounter.list.service.ts @@ -1,53 +1,53 @@ -import { Injectable } from '@angular/core'; -import { EncounterService } from '../../core/http/encounter.service'; -import { Subject } from 'rxjs'; -import { SortDirection } from '../../shared/directive/sortable.directive'; - -interface State { - sortColumn: string; - sortDirection: SortDirection; -} - -@Injectable({ providedIn: 'root' }) -export class EncounterListService { - private _search$ = new Subject(); - private _state: State = { - sortColumn: 'name', - sortDirection: 'asc' - }; - - constructor(private service: EncounterService) {} - - set sortColumn(sortColumn: string) { - this._set({ sortColumn }); - } - - set sortDirection(sortDirection: SortDirection) { - this._set({ sortDirection }); - } - - private _set(patch: Partial) { - Object.assign(this._state, patch); - this._search$.next(); - } - - public getMonsterTypes() { - return this.service.getMonsterTypes(); - } - - public getDifficulties() { - return this.service.getDifficulties(); - } - - public getSizes() { - return this.service.getSizes(); - } - - public generate(data: string) { - return this.service.generate(data); - } - - refresh() { - this._search$.next(); - } -} +import { Injectable } from '@angular/core'; +import { EncounterService } from '../../core/http/encounter.service'; +import { Subject } from 'rxjs'; +import { SortDirection } from '../../shared/directive/sortable.directive'; + +interface State { + sortColumn: string; + sortDirection: SortDirection; +} + +@Injectable({ providedIn: 'root' }) +export class EncounterListService { + private _search$ = new Subject(); + private _state: State = { + sortColumn: 'name', + sortDirection: 'asc' + }; + + constructor(private service: EncounterService) {} + + set sortColumn(sortColumn: string) { + this._set({ sortColumn }); + } + + set sortDirection(sortDirection: SortDirection) { + this._set({ sortDirection }); + } + + private _set(patch: Partial) { + Object.assign(this._state, patch); + this._search$.next(); + } + + public getMonsterTypes() { + return this.service.getMonsterTypes(); + } + + public getDifficulties() { + return this.service.getDifficulties(); + } + + public getSizes() { + return this.service.getSizes(); + } + + public generate(data: string) { + return this.service.generate(data); + } + + refresh() { + this._search$.next(); + } +} diff --git a/src/REG.Angular/ClientApp/src/app/modules/home/home.component.html b/src/REG.Angular/src/app/modules/home/home.component.html similarity index 97% rename from src/REG.Angular/ClientApp/src/app/modules/home/home.component.html rename to src/REG.Angular/src/app/modules/home/home.component.html index f2a2f98..1a91018 100644 --- a/src/REG.Angular/ClientApp/src/app/modules/home/home.component.html +++ b/src/REG.Angular/src/app/modules/home/home.component.html @@ -1,5 +1,5 @@ -
-
-

{{ 'home.welcome' | translate }}

-
+
+
+

{{ 'home.welcome' | translate }}

+
\ No newline at end of file diff --git a/src/REG.Angular/ClientApp/src/app/modules/home/home.component.ts b/src/REG.Angular/src/app/modules/home/home.component.ts similarity index 96% rename from src/REG.Angular/ClientApp/src/app/modules/home/home.component.ts rename to src/REG.Angular/src/app/modules/home/home.component.ts index 811e847..bbf6845 100644 --- a/src/REG.Angular/ClientApp/src/app/modules/home/home.component.ts +++ b/src/REG.Angular/src/app/modules/home/home.component.ts @@ -1,9 +1,9 @@ -import { Component } from '@angular/core'; -import { TranslatePipe } from '@ngx-translate/core'; - -@Component({ - selector: 'app-home', - imports: [TranslatePipe], - templateUrl: './home.component.html' -}) -export class HomeComponent {} +import { Component } from '@angular/core'; +import { TranslatePipe } from '@ngx-translate/core'; + +@Component({ + selector: 'app-home', + imports: [TranslatePipe], + templateUrl: './home.component.html' +}) +export class HomeComponent {} diff --git a/src/REG.Angular/ClientApp/src/app/shared/components/app.body.component.html b/src/REG.Angular/src/app/shared/components/app.body.component.html similarity index 95% rename from src/REG.Angular/ClientApp/src/app/shared/components/app.body.component.html rename to src/REG.Angular/src/app/shared/components/app.body.component.html index 8b32be6..3626a22 100644 --- a/src/REG.Angular/ClientApp/src/app/shared/components/app.body.component.html +++ b/src/REG.Angular/src/app/shared/components/app.body.component.html @@ -1,5 +1,5 @@ -
-
- -
-
+
+
+ +
+
diff --git a/src/REG.Angular/ClientApp/src/app/shared/components/app.body.component.ts b/src/REG.Angular/src/app/shared/components/app.body.component.ts similarity index 100% rename from src/REG.Angular/ClientApp/src/app/shared/components/app.body.component.ts rename to src/REG.Angular/src/app/shared/components/app.body.component.ts diff --git a/src/REG.Angular/ClientApp/src/app/shared/components/app.footer.component.html b/src/REG.Angular/src/app/shared/components/app.footer.component.html similarity index 97% rename from src/REG.Angular/ClientApp/src/app/shared/components/app.footer.component.html rename to src/REG.Angular/src/app/shared/components/app.footer.component.html index 610f2e4..859ccfa 100644 --- a/src/REG.Angular/ClientApp/src/app/shared/components/app.footer.component.html +++ b/src/REG.Angular/src/app/shared/components/app.footer.component.html @@ -1,5 +1,5 @@ -