memberships: modal for errors (#133)
* unpolished version of error modal rendering
* rework of html files. template implemented
* new html files
* minor fixes.
* minor fixes
* title changes
diff --git a/core/auth/memberships/memberships-tmpl/base.html b/core/auth/memberships/memberships-tmpl/base.html
new file mode 100644
index 0000000..39a7755
--- /dev/null
+++ b/core/auth/memberships/memberships-tmpl/base.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en" data-theme="light">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>{{ block "title" . }}{{ end }}</title>
+ <link rel="stylesheet" href="/static/pico.2.0.6.min.css">
+ <link rel="stylesheet" href="/static/main.css">
+</head>
+<body class="container">
+ {{- block "content" . }}
+ {{- end }}
+ {{ if ne .ErrorMessage "" }}
+ <dialog id="error-message" open>
+ <article>
+ <h2>Error</h2>
+ <p id="error-message-content">{{ .ErrorMessage }}</p>
+ <footer>
+ <button id="error-cancel-button" class="secondary error-cancel-button">Close</button>
+ </footer>
+ </article>
+ </dialog>
+ {{ end }}
+ <script src="/static/main.js"></script>
+</body>
+</html>
diff --git a/core/auth/memberships/memberships-tmpl/group.html b/core/auth/memberships/memberships-tmpl/group.html
new file mode 100644
index 0000000..2f5c89a
--- /dev/null
+++ b/core/auth/memberships/memberships-tmpl/group.html
@@ -0,0 +1,107 @@
+{{ define "title" }}
+ Group - {{ .GroupName }}
+{{ end }}
+{{ define "content" }}
+{{- $parentGroupName := .GroupName }}
+ <div>
+ <h2 class="headline">{{ .GroupName }} Group Management</h2>
+ <p class="description">{{ .Description }}</p>
+ </div>
+ <hr class="divider">
+ <form action="/group/{{ .GroupName }}/add-user/" method="post">
+ <label>Username:</label>
+ <input type="text" id="username" name="username" required>
+ <label for="status">Status:</label>
+ <select id="status" name="status" required>
+ <option value="Member" selected>Member</option>
+ <option value="Owner">Owner</option>
+ </select>
+ <button type="submit">Add Member</button>
+ </form>
+ <hr class="divider">
+ <form action="/group/{{ .GroupName }}/add-child-group" method="post">
+ <label for="child-group">Select Child Group:</label>
+ <select id="child-group" aria-label="Select" name="child-group" required>
+ {{- range .AvailableGroups }}
+ <option value="{{ . }}">{{ . }}</option>
+ {{- end }}
+ </select>
+ <button type="submit">Create Child Group</button>
+ </form>
+ <h4>Owners</h4>
+ <table>
+ <tr>
+ <th>Username</th>
+ <th>Action</th>
+ </tr>
+ {{- range .Owners }}
+ <tr>
+ <td><a href="/user/{{ . }}">{{ . }}</a></td>
+ <td>
+ <form action="/group/{{ $parentGroupName }}/remove-owner/{{ . }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to revoke user <strong>{{ . }}</strong>'s ownership of the <strong>{{ $parentGroupName }}</strong> group?">
+ <button type="submit">Remove</button>
+ </form>
+ </td>
+ </tr>
+ {{- end }}
+ </table>
+ <h4>Members</h4>
+ <table>
+ <tr>
+ <th>Username</th>
+ <th>Action</th>
+ </tr>
+ {{- range .Members }}
+ <tr>
+ <td><a href="/user/{{ . }}">{{ . }}</a></td>
+ <td>
+ <form action="/group/{{ $parentGroupName }}/remove-member/{{ . }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove user <strong>{{ . }}</strong> user from <strong>{{ $parentGroupName }}</strong> group?">
+ <button type="submit" class="button">Remove</button>
+ </form>
+ </td>
+ </tr>
+ {{- end }}
+ </table>
+ <h4>Transitive Groups</h4>
+ <table>
+ <tr>
+ <th>Group Name</th>
+ <th>Description</th>
+ </tr>
+ {{- range .TransitiveGroups }}
+ <tr>
+ <td><a href="/group/{{ .Name }}">{{ .Name }}</a></td>
+ <td>{{ .Description }}</td>
+ </tr>
+ {{- end }}
+ </table>
+ <h3>Child Groups</h3>
+ <table>
+ <tr>
+ <th>Group Name</th>
+ <th>Description</th>
+ <th>Action</th>
+ </tr>
+ {{- range .ChildGroups }}
+ <tr>
+ <td><a href="/group/{{ .Name }}">{{ .Name }}</a></td>
+ <td>{{ .Description }}</td>
+ <td>
+ <form action="/group/{{ $parentGroupName }}/remove-child-group/{{ .Name }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove group <strong>{{ .Name }}</strong> as a child of the group <strong>{{ $parentGroupName }}</strong>?">
+ <button type="submit" class="button">Remove</button>
+ </form>
+ </td>
+ </tr>
+ {{- end }}
+ </table>
+ <dialog id="confirmation" close>
+ <article>
+ <h2>Confirm Your Action</h2>
+ <p id="confirmation-message">Are you sure?</p>
+ <footer>
+ <button id="cancel-button" class="secondary cancel-button">Cancel</button>
+ <button id="confirm-button">Confirm</button>
+ </footer>
+ </article>
+ </dialog>
+{{ end }}
diff --git a/core/auth/memberships/memberships-tmpl/user.html b/core/auth/memberships/memberships-tmpl/user.html
new file mode 100644
index 0000000..53a89be
--- /dev/null
+++ b/core/auth/memberships/memberships-tmpl/user.html
@@ -0,0 +1,54 @@
+{{ define "title" }}
+ User - {{ .CurrentUser }}
+{{ end }}
+{{- define "content" -}}
+ <h1>User: {{ .CurrentUser }}</h1>
+ {{ if .LoggedInUserPage }}
+ <form action="/create-group" method="post">
+ <label for="group-name">Group Name:</label>
+ <input type="text" id="group-name" name="group-name" required>
+ <label for="description">Group Description:</label>
+ <input type="text" id="description" name="description">
+ <button type="submit">Create Group</button>
+ </form>
+ {{ end }}
+ <h4>Owner</h4>
+ <table>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ </tr>
+ {{- range .OwnerGroups -}}
+ <tr>
+ <td><a href="/group/{{ .Name }}">{{ .Name }}</a></td>
+ <td>{{ .Description }}</td>
+ </tr>
+ {{- end -}}
+ </table>
+ <h4>Member</h4>
+ <table>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ </tr>
+ {{- range .MembershipGroups -}}
+ <tr>
+ <td><a href="/group/{{ .Name }}">{{ .Name }}</a></td>
+ <td>{{ .Description }}</td>
+ </tr>
+ {{- end -}}
+ </table>
+ <h4>Transitive Groups</h4>
+ <table>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ </tr>
+ {{- range .TransitiveGroups -}}
+ <tr>
+ <td><a href="/group/{{ .Name }}">{{ .Name }}</a></td>
+ <td>{{ .Description }}</td>
+ </tr>
+ {{- end -}}
+ </table>
+{{- end }}