From cf15c8dddcfee50cba0321cd51c3b2afb20cb86b Mon Sep 17 00:00:00 2001 From: xoy Date: Tue, 4 Mar 2025 20:18:55 +0100 Subject: [PATCH] [Zwischencommit] --- .gitignore | 1 + data/database.sql | 0 data/fisch.db | Bin 0 -> 16384 bytes db.go | 203 ++++++++++++++++++++++++++++++++ go.mod | 1 + go.sum | 2 + main.go | 50 +++++++- misc.go | 14 +++ static/css/admin.css | 0 static/css/colors.css | 0 static/css/main.css | 0 static/css/overview.css | 38 ++++++ static/css/search.css | 0 static/css/tables.css | 15 +++ types.go | 77 +++++++++++- views/admin/edit.html | 0 views/admin/overview.html | 20 ++-- views/admin/tables.html | 2 +- views/alert.html | 0 views/partials/base-bottom.html | 2 +- views/partials/base-top.html | 2 +- views/search.html | 0 22 files changed, 409 insertions(+), 18 deletions(-) create mode 100644 .gitignore mode change 100644 => 100755 data/database.sql create mode 100755 data/fisch.db create mode 100755 db.go mode change 100644 => 100755 go.mod mode change 100644 => 100755 go.sum mode change 100644 => 100755 main.go create mode 100755 misc.go delete mode 100644 static/css/admin.css mode change 100644 => 100755 static/css/colors.css mode change 100644 => 100755 static/css/main.css create mode 100755 static/css/overview.css mode change 100644 => 100755 static/css/search.css create mode 100755 static/css/tables.css mode change 100644 => 100755 types.go mode change 100644 => 100755 views/admin/edit.html mode change 100644 => 100755 views/admin/overview.html mode change 100644 => 100755 views/admin/tables.html mode change 100644 => 100755 views/alert.html mode change 100644 => 100755 views/partials/base-bottom.html mode change 100644 => 100755 views/partials/base-top.html mode change 100644 => 100755 views/search.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a3e68d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/.DS_Store \ No newline at end of file diff --git a/data/database.sql b/data/database.sql old mode 100644 new mode 100755 diff --git a/data/fisch.db b/data/fisch.db new file mode 100755 index 0000000000000000000000000000000000000000..6e68a8264eed25f655e6f1a9e6825c1f14e0c53f GIT binary patch literal 16384 zcmeI3O>g5w7{|wPY}e_MK|&(X6^escK~@Q?C9F_o5Tr?(qHb4hQg-)(#KfLWhWI6n z$AMOR2@(fB2Oj`&L|nM=B{*<_8wW02k$CL9Y>TQDCnVq*$?<=l`9IH$f47-Yh9`H0 z;?AR3hDc!Ew9mH{8wGsEq)PIiVrS56pZ1*7_TJr|lZTww zO1AJF5h*_A(wRvSGI{1q`B|f6M=a!y;-4wdij9-C4q}ff5l5S}C{|9C1_AiII8sbR zP-|UtJy@!LRIn0opT1sbvJr(#6Kujy ztq-7hq}Jc_7cM?eJSk>5jto_)p6$)Am47AlXZk(;f*#YGv_@Z`l$zx~%D=+^HY9)q zkN^@u0!RP}AOR$R1dsp{Kmz|R0@k)cG)fA6tF#pRmc0}`YilXGmbDZe%Up^*%UFu` zD@B8l7vCMQG<5D9vBaCe!9gUm?k(p5m(xTsrCNIC`Y?CB*_rTAa2USFM?4Bxc4%?S zX?2@jnR-)@$3d(Vm%D{5N#seb1D4Lz+S`^RE>vp%zM1P>)(QlxG z4GACtB!C2v01`j~NB{{S0VIF~kN^_+rwLp$bW$C9lXMg?pKld)QaKfH1hA!p8t^d- zDg~X~IgGuB<+r7e=yu@9;BnB z;WP&vHlPwjSHL}Uk|rY;o|X$+Qx`6pVa#Pdo578?@p8!|&%KjpZ)~CPWbB3_5?PvO z+_p{f(urnwkDG^V!~=ik`XZSH>}(cGy8nKbc3 zai#TD%Oq7-v+wuYOXqydt~Q!WWB2~5q(8s9;!VROZ`Cz>kEIFY>Ky(ypTc$fp@`ti zM_EvvyVJa9REkja`UUT5+}PJma?;oA2XOnI@L&{(XbMG+W&AOps*4prz2sOGcGq?4 z1(V#^)$G+~z86g6WSnj68ysX~8pEO@SP?+m(EwUivxi6B<{%CNh=;x_GiCe div.action-container { + display: flex; + align-items: baseline; + justify-content: space-around; +} + +table tr td:last-child form { + display: flex; + flex-direction: row; + align-items: center; + height: max-content; +} + +table tr td:last-child form button { + background-color: transparent; + border: none; + cursor: pointer; + color: var(--fg); +} \ No newline at end of file diff --git a/static/css/search.css b/static/css/search.css old mode 100644 new mode 100755 diff --git a/static/css/tables.css b/static/css/tables.css new file mode 100755 index 0000000..bdd5a93 --- /dev/null +++ b/static/css/tables.css @@ -0,0 +1,15 @@ +main { + display: flex; + justify-content: center; + align-items: start; + gap: 1em; + padding: 1em; +} + +main > a { + display: inline-block; + padding: 2em; + background-color: var(--bg-light); + border-radius: 50px; + font-size: 3em; +} \ No newline at end of file diff --git a/types.go b/types.go old mode 100644 new mode 100755 index a5ba263..c0dd8d4 --- a/types.go +++ b/types.go @@ -1,5 +1,10 @@ package main +import ( + "database/sql" + "fmt" +) + // Web type NavItem struct { @@ -17,15 +22,79 @@ func NewStyleItemList(stylenames ...Stylename) []Stylename { return stylenames } +type TableColumns []string + +type TableRow struct { + Columns TableColumns + Id int +} + +type Table struct { + Collumns TableColumns + Rows []TableRow +} + // Database type Location struct { - id int - parent int - Name string - Description string + Id sql.NullInt64 + Parent sql.NullInt64 + Name sql.NullString + Description sql.NullString +} + +func (l *Location) ToTableRow() TableRow { + columns := make(TableColumns, 4) + + tr := TableRow{} + + if l.Id.Valid { + columns[0] = fmt.Sprintf("%d", l.Id.Int64) + tr.Id = int(l.Id.Int64) + } else { + columns[0] = "NULL" + tr.Id = -1 + } + if l.Parent.Valid { + columns[1] = fmt.Sprintf("%d", l.Parent.Int64) + } else { + columns[1] = "NULL" + } + if l.Name.Valid { + columns[2] = l.Name.String + } else { + columns[2] = "NULL" + } + if l.Description.Valid { + columns[3] = l.Description.String + } else { + columns[3] = "NULL" + } + + tr.Columns = columns + + return tr } func (l *Location) GetParent() *Location { return nil } + +type Container struct { + Id sql.NullInt64 + Name sql.NullString +} + +type Part struct { + Id sql.NullInt64 + Name sql.NullString + Tags sql.NullString + Location Location + Container Container +} + +// Interfaces + +type DatabaseType interface { + ToTableRow() TableRow +} diff --git a/views/admin/edit.html b/views/admin/edit.html old mode 100644 new mode 100755 diff --git a/views/admin/overview.html b/views/admin/overview.html old mode 100644 new mode 100755 index 409ca63..34477fd --- a/views/admin/overview.html +++ b/views/admin/overview.html @@ -5,21 +5,25 @@ {{ range .Columns }} {{ . }} {{ end }} + Aktionen + {{ $Table := .Table }} {{ range .Rows }} {{ range .Columns }} {{ . }} {{ end }} -
- - -
-
- - -
+
+
+ + +
+
+ + +
+
{{ end }} diff --git a/views/admin/tables.html b/views/admin/tables.html old mode 100644 new mode 100755 index f46f18c..4ca86bc --- a/views/admin/tables.html +++ b/views/admin/tables.html @@ -1,7 +1,7 @@ {{template "partials/base-top" .}} {{ range .Tables }} -{{ .Caption }} +{{ .Caption }} {{ end }} {{template "partials/base-bottom" .}} \ No newline at end of file diff --git a/views/alert.html b/views/alert.html old mode 100644 new mode 100755 diff --git a/views/partials/base-bottom.html b/views/partials/base-bottom.html old mode 100644 new mode 100755 index d3dcfd8..7f5a489 --- a/views/partials/base-bottom.html +++ b/views/partials/base-bottom.html @@ -1,7 +1,7 @@ diff --git a/views/partials/base-top.html b/views/partials/base-top.html old mode 100644 new mode 100755 index 1e5d351..b9f6036 --- a/views/partials/base-top.html +++ b/views/partials/base-top.html @@ -5,7 +5,7 @@ fisch - {{ .Title }} {{ range .Stylenames }} - + {{ end }} diff --git a/views/search.html b/views/search.html old mode 100644 new mode 100755