From 48b3f972985da94ab2f73950a6507e36d915bee4 Mon Sep 17 00:00:00 2001 From: tsindt Date: Wed, 9 Sep 2026 19:37:55 +0200 Subject: [PATCH] Templates --- .../xcpq_editor/cmd/server/httpServer.go | 38 +++++- xcpq/buildtime/xcpq_editor/static/index.html | 123 ------------------ .../xcpq_editor/templates/layouts/.ignore | 0 .../xcpq_editor/templates/layouts/footer.html | 4 + .../xcpq_editor/templates/layouts/navbar.html | 16 +++ .../templates/layouts/properties.html | 82 ++++++++++++ .../xcpq_editor/templates/pages/.ignore | 0 .../xcpq_editor/templates/pages/index.html | 34 +++++ 8 files changed, 173 insertions(+), 124 deletions(-) delete mode 100644 xcpq/buildtime/xcpq_editor/static/index.html delete mode 100644 xcpq/buildtime/xcpq_editor/templates/layouts/.ignore create mode 100644 xcpq/buildtime/xcpq_editor/templates/layouts/footer.html create mode 100644 xcpq/buildtime/xcpq_editor/templates/layouts/navbar.html create mode 100644 xcpq/buildtime/xcpq_editor/templates/layouts/properties.html delete mode 100644 xcpq/buildtime/xcpq_editor/templates/pages/.ignore create mode 100644 xcpq/buildtime/xcpq_editor/templates/pages/index.html diff --git a/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go b/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go index fe86d40b8..3dbb553c8 100644 --- a/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go +++ b/xcpq/buildtime/xcpq_editor/cmd/server/httpServer.go @@ -2,6 +2,7 @@ package server import ( "database/sql" + "html/template" "log" "net/http" @@ -30,7 +31,7 @@ func InitHttpServer(config *viper.Viper, dbHandler *sql.DB) HttpServer { // static content router.Static("/static", "../static") - router.StaticFile("/", "../static/index.html") + router.GET("/", home) router.GET("/test", Test) @@ -54,3 +55,38 @@ func Test(ctx *gin.Context) { "message": "Test", }) } + +func home(ctx *gin.Context) { + + /* load templates */ + + tmpl, err := template.ParseFiles( + "../templates/pages/index.html", + "../templates/layouts/navbar.html", + "../templates/layouts/properties.html", + "../templates/layouts/footer.html") + + if err != nil { + ctx.JSON(http.StatusInternalServerError, gin.H{ + "error": err.Error(), + }) + return + } + + renderTemplate(ctx, tmpl, nil) +} + +func renderTemplate(ctx *gin.Context, tmpl *template.Template, data interface{}) { + if tmpl == nil { + ctx.JSON(http.StatusInternalServerError, gin.H{ + "error": "template is nil", + }) + return + } + err := tmpl.Execute(ctx.Writer, data) + if err != nil { + ctx.JSON(http.StatusInternalServerError, gin.H{ + "error": err.Error(), + }) + } +} diff --git a/xcpq/buildtime/xcpq_editor/static/index.html b/xcpq/buildtime/xcpq_editor/static/index.html deleted file mode 100644 index 88b965533..000000000 --- a/xcpq/buildtime/xcpq_editor/static/index.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - X-CPQ by Simply CPQ - - - - - - - - - -
- Simply CPQ Logo -

X-CPQ Material Editor

-

by Simply CPQ

- -
-
-
-

X-CPQ Material Editor: Eigenschaften

- -

Der Eigenschaftspool dient der globalen Definition von Eigenschaften.

-
-
-

Property Type Groups

-
    -
    - - X-CPQ-Eigenschaften - -
      -
      - - Systemeigenschaften - -
        -
      • - Eigenschaft 1 -
      • -
      • - Eigenschaft 2 -
      • -
      -
      -
      - - Catalog Eigenschaften - -
        -
      • - Eigenschaft 1 -
      • -
      • - Eigenschaft 2 -
      • -
      -
      -
    • - Eigenschaft 1 -
    • -
    • - Eigenschaft 2 -
    • -
    -
    -
-
-
-
-

Property-Type Group {PropertyTypeGroupName}

-
- - - - -
- - - -
-
-
-
-

Property-Type {PropertyTypeName}

-

Hier können die Details der ausgewählten Eigenschaft bearbeitet werden.

- -
-
-
-
-

Values für {PropertyTypeName}

-

Hier können die Werte der ausgewählten Eigenschaft bearbeitet werden.

- -
-
-
-
-
- - - - - - \ No newline at end of file diff --git a/xcpq/buildtime/xcpq_editor/templates/layouts/.ignore b/xcpq/buildtime/xcpq_editor/templates/layouts/.ignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/xcpq/buildtime/xcpq_editor/templates/layouts/footer.html b/xcpq/buildtime/xcpq_editor/templates/layouts/footer.html new file mode 100644 index 000000000..6621db6a9 --- /dev/null +++ b/xcpq/buildtime/xcpq_editor/templates/layouts/footer.html @@ -0,0 +1,4 @@ +{{define "footer"}} + +

© 2026 Simply CPQ

+{{end}} \ No newline at end of file diff --git a/xcpq/buildtime/xcpq_editor/templates/layouts/navbar.html b/xcpq/buildtime/xcpq_editor/templates/layouts/navbar.html new file mode 100644 index 000000000..cfa09094f --- /dev/null +++ b/xcpq/buildtime/xcpq_editor/templates/layouts/navbar.html @@ -0,0 +1,16 @@ +{{define "navbar"}} + +Simply CPQ Logo +

X-CPQ Material Editor

+

by Simply CPQ

+ +{{end}} \ No newline at end of file diff --git a/xcpq/buildtime/xcpq_editor/templates/layouts/properties.html b/xcpq/buildtime/xcpq_editor/templates/layouts/properties.html new file mode 100644 index 000000000..036a9392f --- /dev/null +++ b/xcpq/buildtime/xcpq_editor/templates/layouts/properties.html @@ -0,0 +1,82 @@ +{{define "properties"}} + +

X-CPQ Material Editor: Eigenschaften

+ +

Der Eigenschaftspool dient der globalen Definition von Eigenschaften.

+
+
+

Property Type Groups

+
    +
    + + X-CPQ-Eigenschaften + +
      +
      + + Systemeigenschaften + +
        +
      • + Eigenschaft 1 +
      • +
      • + Eigenschaft 2 +
      • +
      +
      +
      + + Catalog Eigenschaften + +
        +
      • + Eigenschaft 1 +
      • +
      • + Eigenschaft 2 +
      • +
      +
      +
    • + Eigenschaft 1 +
    • +
    • + Eigenschaft 2 +
    • +
    +
    +
+
+
+
+

Property-Type Group {PropertyTypeGroupName}

+
+ + + + +
+ + + +
+
+
+
+

Property-Type {PropertyTypeName}

+

Hier können die Details der ausgewählten Eigenschaft bearbeitet werden.

+ +
+
+
+
+

Values für {PropertyTypeName}

+

Hier können die Werte der ausgewählten Eigenschaft bearbeitet werden.

+ +
+
+
+ + +{{end}} \ No newline at end of file diff --git a/xcpq/buildtime/xcpq_editor/templates/pages/.ignore b/xcpq/buildtime/xcpq_editor/templates/pages/.ignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/xcpq/buildtime/xcpq_editor/templates/pages/index.html b/xcpq/buildtime/xcpq_editor/templates/pages/index.html new file mode 100644 index 000000000..1bbf55f0c --- /dev/null +++ b/xcpq/buildtime/xcpq_editor/templates/pages/index.html @@ -0,0 +1,34 @@ + + + + + + + + + X-CPQ by Simply CPQ + + + + + + + + + +
+ {{ template "navbar" . }} +
+
+
+ {{ template "properties" . }} +
+
+ + + + + +