summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-02-11 20:47:15 +0000
committerMatthew Lemon <y@yulqen.org>2024-02-11 20:47:15 +0000
commit47c2880467d1906c9a40746da4bf7c212634db79 (patch)
treedd897564eb6dfd0fd1e878bcf9029d3f8464318f
parent21ec508717ecd6112984b56ca376ebac11477a2a (diff)
Adds an operations html template
Does not contain any dynamic data at this point, i.e. does not actually list the operations from the database - just dummy data at this point.
-rw-r--r--cmd/web/handlers.go21
-rw-r--r--internal/models/operation.go4
-rw-r--r--ui/html/pages/operations/list.tmpl.html36
-rw-r--r--ui/html/partials/nav.tmpl.html1
4 files changed, 57 insertions, 5 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go
index 78d4029..49f52ca 100644
--- a/cmd/web/handlers.go
+++ b/cmd/web/handlers.go
@@ -12,14 +12,27 @@ import (
func (app *application) listOperations(w http.ResponseWriter, r *http.Request) {
- ops, err := app.operations.ListAll()
+ // ops, err := app.operations.ListAll()
+
+ // if err != nil {
+ // app.serverError(w, r, err)
+ // return
+ // }
+ files := []string{
+ "./ui/html/base.tmpl.html",
+ "./ui/html/pages/operations/list.tmpl.html",
+ "./ui/html/partials/nav.tmpl.html",
+ }
+
+ ts, err := template.ParseFiles(files...)
if err != nil {
- app.serverError(w, r, err)
+ app.serverError(w, r, err) // Use the serverError() helper
return
}
- for _, op := range ops {
- fmt.Fprintf(w, "%+v\n", op)
+ err = ts.ExecuteTemplate(w, "base", nil)
+ if err != nil {
+ app.serverError(w, r, err) // Use the serverError() helper
}
}
diff --git a/internal/models/operation.go b/internal/models/operation.go
index abb874c..4c5d67f 100644
--- a/internal/models/operation.go
+++ b/internal/models/operation.go
@@ -19,7 +19,9 @@ type OperationModel struct {
func (m *OperationModel) ListAll() ([]Operation, error) {
- stmt := `SELECT op.id, op.name, op.description, op.created, org.name FROM operations op INNER JOIN organisations org ON op.organisation_id=org.id`
+ stmt := `SELECT op.id, op.name, op.description, op.created, org.name
+ FROM operations op
+ INNER JOIN organisations org ON op.organisation_id=org.id`
// stmt := `SELECT * FROM operations`
diff --git a/ui/html/pages/operations/list.tmpl.html b/ui/html/pages/operations/list.tmpl.html
new file mode 100644
index 0000000..c377129
--- /dev/null
+++ b/ui/html/pages/operations/list.tmpl.html
@@ -0,0 +1,36 @@
+{{ define "title" }}Operations{{end}}
+
+{{ define "main" }}
+<h3>Operations <span><a href="#" class="admin-link">[Admin]</a></span></h3>
+<p>There is nothing to see here yet.</p>
+<table id="home-summary-table">
+ <thead>
+ <tr id="header-row">
+ <th>Operation</th>
+ <th>RP</th>
+ <th>Lead Inspector[s]</th>
+ <th>Another attribute</th>
+ <th>Another attribute</th>
+ <th>SharePoint</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="#">First operation</a></td>
+ <td>Tim Gudgeon</td>
+ <td>Tina McKinchey / Barbara Snelland</td>
+ <td>Bobbins</td>
+ <td>Bobbins</td>
+ <td><a href="#">Link</a></td>
+ </tr>
+ <tr>
+ <td>Second organisation</td>
+ <td>Seth Pring</td>
+ <td>Barbara Snelland</td>
+ <td>Bobbins</td>
+ <td>Bobbins</td>
+ <td><a href="#">Link</a></td>
+ </tr>
+ </tbody>
+</table>
+{{ end }}
diff --git a/ui/html/partials/nav.tmpl.html b/ui/html/partials/nav.tmpl.html
index 1e43d8c..ed3a355 100644
--- a/ui/html/partials/nav.tmpl.html
+++ b/ui/html/partials/nav.tmpl.html
@@ -3,6 +3,7 @@
<h1>DefNucSyR Engagement Database</h1>
<a href="/">Home</a>
<a href="/organisation/list">Organisations</a>
+ <a href="/operation/list">Operations</a>
<a href="#">Engagement Planning</a>
</nav>
{{ end }}