Merge pull request #19 from Bardioc26/small_fixes_aside
Small fixes aside
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
* API endpunkte für Export/Import aus Commit 2dcb4e00faaf316b98eb28e83cc5137bf0d1385d
|
||||
* wouldn't it be a good idea to remove the GameSystem from all the records and define it in a kind of manifest. The values in the manifest could be applied to all records (where needed) during the import session. export_import.go
|
||||
* maintanance view for gsm_cc_class_category_points
|
||||
* Todo: calculate poison tolerance based on character data (frontend/src/components/DatasheetView.vue)
|
||||
|
||||
## Refaktor
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ func TestImportVTT2Char(t *testing.T) {
|
||||
database.SetupTestDB()
|
||||
defer database.ResetTestDB()
|
||||
fileName := fmt.Sprintf("../testdata/%s", "VTT_Import1.json")
|
||||
char, err := ImportVTTJSON(fileName)
|
||||
char, err := ImportVTTJSON(fileName, 1)
|
||||
assert.NoError(t, err, "expected no error when saving imported Char")
|
||||
var chr2 models.Char
|
||||
chr2.First(char.Name)
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestExportChar2VTT(t *testing.T) {
|
||||
|
||||
// Import a test character first
|
||||
fileName := fmt.Sprintf("../testdata/%s", "VTT_Import1.json")
|
||||
char, err := ImportVTTJSON(fileName)
|
||||
char, err := ImportVTTJSON(fileName, 1)
|
||||
assert.NoError(t, err, "Expected no error when importing char")
|
||||
|
||||
// Export the character back to VTT format
|
||||
@@ -25,6 +25,7 @@ func TestExportChar2VTT(t *testing.T) {
|
||||
assert.NoError(t, err, "Expected no error when exporting char")
|
||||
|
||||
// Basic validations
|
||||
assert.Equal(t, char.UserID, 1)
|
||||
assert.Equal(t, char.Name, exportedChar.Name)
|
||||
assert.Equal(t, char.Rasse, exportedChar.Rasse)
|
||||
assert.Equal(t, char.Typ, exportedChar.Typ)
|
||||
@@ -68,7 +69,7 @@ func TestExportChar2VTTRoundTrip(t *testing.T) {
|
||||
|
||||
// Import original
|
||||
fileName := fmt.Sprintf("../testdata/%s", "VTT_Import1.json")
|
||||
char1, err := ImportVTTJSON(fileName)
|
||||
char1, err := ImportVTTJSON(fileName, 1)
|
||||
assert.NoError(t, err, "Expected no error when importing char")
|
||||
|
||||
// Export to VTT
|
||||
@@ -87,10 +88,12 @@ func TestExportChar2VTTRoundTrip(t *testing.T) {
|
||||
tempFile.Close()
|
||||
|
||||
// Re-import the exported file
|
||||
char2, err := ImportVTTJSON(tempFile.Name())
|
||||
char2, err := ImportVTTJSON(tempFile.Name(), 6)
|
||||
assert.NoError(t, err, "Expected no error when re-importing char")
|
||||
|
||||
// Compare key fields
|
||||
assert.Equal(t, char1.UserID, uint(1), "UserID should match 1 as set in first import")
|
||||
assert.Equal(t, char2.UserID, uint(6), "UserID should match 6 as set in re-import")
|
||||
assert.Equal(t, char1.Name, char2.Name)
|
||||
assert.Equal(t, char1.Rasse, char2.Rasse)
|
||||
assert.Equal(t, char1.Typ, char2.Typ)
|
||||
@@ -148,7 +151,7 @@ func TestExportCharToCSV(t *testing.T) {
|
||||
|
||||
// Import a test character first
|
||||
fileName := fmt.Sprintf("../testdata/%s", "VTT_Import1.json")
|
||||
char, err := ImportVTTJSON(fileName)
|
||||
char, err := ImportVTTJSON(fileName, 1)
|
||||
assert.NoError(t, err, "Expected no error when importing char")
|
||||
|
||||
// Export to CSV
|
||||
@@ -180,7 +183,7 @@ func TestExportImportWithoutMasterData(t *testing.T) {
|
||||
|
||||
// Import a test character first
|
||||
fileName := fmt.Sprintf("../testdata/%s", "VTT_Import1.json")
|
||||
char1, err := ImportVTTJSON(fileName)
|
||||
char1, err := ImportVTTJSON(fileName, 1)
|
||||
assert.NoError(t, err, "Expected no error when importing char")
|
||||
|
||||
// Export to VTT
|
||||
@@ -210,7 +213,7 @@ func TestExportImportWithoutMasterData(t *testing.T) {
|
||||
database.DB.Exec("DELETE FROM sqlite_sequence WHERE name LIKE 'gsm_%'")
|
||||
|
||||
// Re-import without master data
|
||||
char2, err := ImportVTTJSON(tempFile.Name())
|
||||
char2, err := ImportVTTJSON(tempFile.Name(), 1)
|
||||
assert.NoError(t, err, "Expected no error when re-importing without master data")
|
||||
assert.NotNil(t, char2, "Character should be imported")
|
||||
|
||||
@@ -248,7 +251,7 @@ func TestExportImportPreservesCharacterData(t *testing.T) {
|
||||
|
||||
// Import a test character
|
||||
fileName := fmt.Sprintf("../testdata/%s", "VTT_Import1.json")
|
||||
char1, err := ImportVTTJSON(fileName)
|
||||
char1, err := ImportVTTJSON(fileName, 1)
|
||||
assert.NoError(t, err, "Expected no error when importing char")
|
||||
|
||||
// Store original counts and values
|
||||
@@ -306,7 +309,7 @@ func TestExportImportPreservesCharacterData(t *testing.T) {
|
||||
database.DB.Exec("DELETE FROM gsm_transportations")
|
||||
|
||||
// Re-import
|
||||
char2, err := ImportVTTJSON(tempFile.Name())
|
||||
char2, err := ImportVTTJSON(tempFile.Name(), 1)
|
||||
assert.NoError(t, err, "Expected no error when re-importing")
|
||||
|
||||
// Verify all data was preserved
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -58,8 +59,13 @@ func UploadFiles(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
character, err3 := ImportVTTJSON(vttFileName)
|
||||
userIDStr := c.GetString("userID")
|
||||
userID, err := strconv.Atoi(userIDStr)
|
||||
if err != nil {
|
||||
respondWithError(c, http.StatusInternalServerError, "Invalid user ID")
|
||||
return
|
||||
}
|
||||
character, err3 := ImportVTTJSON(vttFileName, uint(userID))
|
||||
if err3 != nil {
|
||||
respondWithError(c, http.StatusInternalServerError, fmt.Sprintf("Failed to Import Character from file %s", err3.Error()))
|
||||
return
|
||||
|
||||
@@ -17,7 +17,7 @@ func readImportChar(fileName string) (*CharacterImport, error) {
|
||||
return &character, err
|
||||
}
|
||||
|
||||
func ImportVTTJSON(fileName string) (*models.Char, error) {
|
||||
func ImportVTTJSON(fileName string, userID uint) (*models.Char, error) {
|
||||
//fileName = fmt.Sprintf("../testdata/%s", "VTT_Import1.json")
|
||||
imp, err := readImportChar(fileName)
|
||||
if err != nil {
|
||||
@@ -57,6 +57,7 @@ func ImportVTTJSON(fileName string) (*models.Char, error) {
|
||||
}
|
||||
|
||||
char := models.Char{}
|
||||
char.UserID = userID
|
||||
char.Name = imp.Name
|
||||
char.Rasse = imp.Rasse
|
||||
char.Typ = imp.Typ
|
||||
|
||||
@@ -32,7 +32,8 @@ FROM nginx:alpine
|
||||
# Adjust /usr/src/app/build -> /usr/src/app/dist if you’re using Angular/Vue
|
||||
#COPY --from=build /usr/src/app/build /usr/share/nginx/html
|
||||
COPY --from=build /usr/src/app/dist /usr/share/nginx/html
|
||||
|
||||
# Copy custom nginx configuration for SPA routing
|
||||
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
# Expose HTTP port
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
# SPA routing: try files, fallback to index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
||||
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# proxy_pass http://127.0.0.1;
|
||||
#}
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# root html;
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
||||
# include fastcgi_params;
|
||||
#}
|
||||
|
||||
# deny access to .htaccess files, if Apache's document root
|
||||
# concurs with nginx's one
|
||||
#
|
||||
#location ~ /\.ht {
|
||||
# deny all;
|
||||
#}
|
||||
}
|
||||
@@ -260,6 +260,7 @@ export default {
|
||||
},
|
||||
getStat(path) {
|
||||
if (path === 'git') {
|
||||
// Todo: calculate poison tolerance based on character data
|
||||
return '64!'
|
||||
}
|
||||
return path.split('.').reduce((obj, key) => obj?.[key], this.character) ?? '-'
|
||||
|
||||
Reference in New Issue
Block a user