Skip to content

Commit

Permalink
Adding more features
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Jun 30, 2024
1 parent 2ea106f commit 8c056a7
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 77 deletions.
44 changes: 32 additions & 12 deletions templates/officershipTeam.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,30 @@
{{with .OfficershipTeam}}
<p>Team ID: {{.TeamID}}<br>
Name: {{.Name}}<br>
Email alias: {{.EmailAlias}}<br>
Short description: {{.ShortDescription}}<br>
Email alias: {{.EmailAlias}}<br><br>
Short description: {{.ShortDescription}}<br><br>
Full description: {{.FullDescription}}
{{if gt (len .TeamMembers) 0}}<br><br>
Officership team members: <ol>
Officership team members:
<ol>
{{range .TeamMembers}}
<li style='list-style-type: none;'><span class='tab'></span>
<a href="/internal/officership/officer/{{.OfficerID}}">{{.OfficerName}}</a>{{if .IsLeader}} - Leader{{else if .IsDeputy}} - Deputy{{end}}
</li>
{{if .IsCurrent}}
<li style='list-style-type: none;'><span class='tab'></span>
<a href="/internal/officership/{{.OfficerID}}">{{.OfficerName}}</a>{{if .IsLeader}} - Leader{{else if .IsDeputy}} - Deputy{{end}}
</li>
{{end}}
{{end}}
</ol>
</ol><br>
Retired officership team members:
<ol>
{{range .TeamMembers}}
{{if not .IsCurrent}}
<li style='list-style-type: none;'><span class='tab'></span>
<a href="/internal/officership/{{.OfficerID}}">{{.OfficerName}}</a>{{if .IsLeader}} - was leader{{else if .IsDeputy}} - was deputy{{end}}
</li>
{{end}}
{{end}}
</ol>
{{end}}
</p>
{{end}}
Expand All @@ -54,9 +67,11 @@
<div class="content">
<p class="title">Are you sure you want to edit this officership team?</p>
<p><strong>This action can be undone by changing them back but be careful</strong><br>
Use the fields below to modify your details, to not change a field, either leave it as
Use the fields below to modify your details, to not change a field, either leave it
as
is or blank.<br>If you change the SuperUser name then many things will break</p>
<form action="/internal/officership/team/{{.OfficershipTeam.TeamID}}/edit" method="post">
<form action="/internal/officership/team/{{.OfficershipTeam.TeamID}}/edit"
method="post">
<div class="field">
<label class="label" for="name">Name</label>
<div class="control">
Expand Down Expand Up @@ -105,7 +120,9 @@
>{{.OfficershipTeam.FullDescription}}</textarea>
</div>
</div>
<button class="button is-danger"><span class="mdi mdi-pencil"></span>&ensp;Edit officership team</button>
<button class="button is-danger"><span class="mdi mdi-pencil"></span>&ensp;Edit
officership team
</button>
</form>
</div>
</div>
Expand All @@ -122,8 +139,11 @@
<div class="media-content">
<div class="content">
<p class="title">Are you sure you want to delete this officership team?</p>
<p>Be careful! Officers and the public site use this and will have to set back up manually.</p>
<form action="/internal/officership/team/{{.OfficershipTeam.TeamID}}/delete" method="post">
<p>Be careful! Officers and the public site use this and will have to set back up
manually.</p>
<p>All officers will be removed from this team and will not have a team assigned!</p>
<form action="/internal/officership/team/{{.OfficershipTeam.TeamID}}/delete"
method="post">
<button class="button is-danger">Delete officership team</button>
</form>
</div>
Expand Down
142 changes: 77 additions & 65 deletions templates/user.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
height="128px"/>
</figure>
{{if not .User.DeletedAt.Valid}}
<div class="buttons" style="display: block">
<a class="button is-info is-outlined" onclick="resetPasswordModal()">
<span class="mdi mdi-account-key"></span>&ensp;Reset password
</a>
<a class="button is-info is-outlined" onclick="editUserModal()">
<span class="mdi mdi-account-edit"></span>&ensp;Edit
</a>
{{if .User.Enabled}}
<a class="button is-warning is-outlined" onclick="disableUserModal()">
<span class="mdi mdi-account-lock"></span>&ensp;Disable
<div class="buttons" style="display: block">
<a class="button is-info is-outlined" onclick="resetPasswordModal()">
<span class="mdi mdi-account-key"></span>&ensp;Reset password
</a>
{{if and (checkPermission .UserPermissions "SuperUser") (not .Assumed)}}
<a class="button is-warning is-outlined" onclick="assumeUserModal()">
<span class="mdi mdi-account-child"></span>&ensp;Assume user
<a class="button is-info is-outlined" onclick="editUserModal()">
<span class="mdi mdi-account-edit"></span>&ensp;Edit
</a>
{{if .User.Enabled}}
<a class="button is-warning is-outlined" onclick="disableUserModal()">
<span class="mdi mdi-account-lock"></span>&ensp;Disable
</a>
{{if and (checkPermission .UserPermissions "SuperUser") (not .Assumed)}}
<a class="button is-warning is-outlined" onclick="assumeUserModal()">
<span class="mdi mdi-account-child"></span>&ensp;Assume user
</a>
{{end}}
{{else}}
<a class="button is-warning is-outlined" onclick="enableUserModal()">
<span class="mdi mdi-account-lock-open"></span>&ensp;Enable
</a>
{{end}}
{{else}}
<a class="button is-warning is-outlined" onclick="enableUserModal()">
<span class="mdi mdi-account-lock-open"></span>&ensp;Enable
<a class="button is-danger is-outlined" onclick="deleteUserModal()">
<span class="mdi mdi-account-remove"></span>&ensp;Delete
</a>
{{end}}
<a class="button is-danger is-outlined" onclick="deleteUserModal()">
<span class="mdi mdi-account-remove"></span>&ensp;Delete
</a>
</div>
</div>
{{end}}
</div>
<div class="column">
Expand Down Expand Up @@ -68,30 +68,30 @@
{{end}}
Avatar source: {{if .UseGravatar}}Using gravatar{{else}}Using local file{{end}}<br><br>
{{if gt (len .Permissions) 0}}
Permissions: <ol>
{{range .Permissions}}
<li style='list-style-type: none;'><span class='tab'></span>
{{if $permissionAdmin}}
<a href="/internal/permission/{{.PermissionID}}">{{.Name}}</a>
{{else}}
{{.Name}}
{{end}}
</li>
{{end}}
</ol><br>
Permissions: <ol>
{{range .Permissions}}
<li style='list-style-type: none;'><span class='tab'></span>
{{if $permissionAdmin}}
<a href="/internal/permission/{{.PermissionID}}">{{.Name}}</a>
{{else}}
{{.Name}}
{{end}}
</li>
{{end}}
</ol><br>
{{end}}
{{if gt (len .Roles) 0}}
Roles: <ol>
{{range .Roles}}
<li style='list-style-type: none;'><span class='tab'></span>
{{if $roleAdmin}}
<a href="/internal/role/{{.RoleID}}">{{.Name}}</a>
{{else}}
{{.Name}}
{{end}}
</li>
{{end}}
</ol><br>
Roles: <ol>
{{range .Roles}}
<li style='list-style-type: none;'><span class='tab'></span>
{{if $roleAdmin}}
<a href="/internal/role/{{.RoleID}}">{{.Name}}</a>
{{else}}
{{.Name}}
{{end}}
</li>
{{end}}
</ol><br>
{{end}}
{{if .LastLogin.Valid}}
Last login at {{.LastLogin.String}}<br>
Expand Down Expand Up @@ -162,7 +162,8 @@
<p class="title">Are you sure you want to reset the password?</p>
<p>An email will be sent to the user for
them to reset their password</p>
<a class="button is-danger" onclick="resetPassword()"><span class="mdi mdi-account-key"></span>&ensp;Reset password</a>
<a class="button is-danger" onclick="resetPassword()"><span
class="mdi mdi-account-key"></span>&ensp;Reset password</a>
</div>
</div>
</article>
Expand Down Expand Up @@ -287,7 +288,9 @@
/>
</div>
</div>
<button class="button is-danger"><span class="mdi mdi-account-edit"></span>&ensp;Edit user</button>
<button class="button is-danger"><span class="mdi mdi-account-edit"></span>&ensp;Edit
user
</button>
</form>
</div>
</div>
Expand All @@ -307,7 +310,9 @@
<p class="title">Are you sure you want to disable this account?</p>
<p>This user won't be able to log in until it is re-enabled</p>
<form action="/internal/user/{{.User.UserID}}/toggle" method="post">
<button class="button is-danger"><span class="mdi mdi-account-lock"></span>&ensp;Disable user</button>
<button class="button is-danger"><span class="mdi mdi-account-lock"></span>&ensp;Disable
user
</button>
</form>
</div>
</div>
Expand All @@ -327,7 +332,9 @@
<p class="title">Are you sure you want to enable this account?</p>
<p>This user will be able to log in again</p>
<form action="/internal/user/{{.User.UserID}}/toggle" method="post">
<button class="button is-danger"><span class="mdi mdi-account-lock-open"></span>&ensp;Enable user</button>
<button class="button is-danger"><span class="mdi mdi-account-lock-open"></span>&ensp;Enable
user
</button>
</form>
</div>
</div>
Expand All @@ -347,7 +354,9 @@
<p class="title">Are you sure you want to delete this account?</p>
<p>This user won't be able to log in or access any functions forever</p>
<form action="/internal/user/{{.User.UserID}}/delete" method="post">
<button class="button is-danger"><span class="mdi mdi-account-remove"></span>&ensp;Delete user</button>
<button class="button is-danger"><span class="mdi mdi-account-remove"></span>&ensp;Delete
user
</button>
</form>
</div>
</div>
Expand All @@ -365,9 +374,12 @@
<div class="media-content">
<div class="content">
<p class="title">Are you sure you want to assume this user?</p>
<p>Your current permissions may not work and your actions will appear as though it was from this user</p>
<p>Your current permissions may not work and your actions will appear as though it was
from this user</p>
<form action="/internal/user/{{.User.UserID}}/assume" method="post">
<button class="button is-danger"><span class="mdi mdi-account-child"></span>&ensp;Assume user</button>
<button class="button is-danger"><span class="mdi mdi-account-child"></span>&ensp;Assume
user
</button>
</form>
</div>
</div>
Expand All @@ -392,18 +404,18 @@
}

{{if .User.Enabled}}
function disableUserModal() {
document.getElementById("disableUserModal").classList.add("is-active");
}
{{if and (checkPermission .UserPermissions "SuperUser") (not .Assumed)}}
function assumeUserModal() {
document.getElementById("assumeUserModal").classList.add("is-active");
}
{{end}}
function disableUserModal() {
document.getElementById("disableUserModal").classList.add("is-active");
}
{{if and (checkPermission .UserPermissions "SuperUser") (not .Assumed)}}
function assumeUserModal() {
document.getElementById("assumeUserModal").classList.add("is-active");
}
{{end}}
{{else}}
function enableUserModal() {
document.getElementById("enableUserModal").classList.add("is-active");
}
function enableUserModal() {
document.getElementById("enableUserModal").classList.add("is-active");
}
{{end}}
function editUserModal() {
document.getElementById("editUserModal").classList.add("is-active");
Expand All @@ -416,15 +428,15 @@
function resetPassword() {
$.ajax({
url: '/internal/user/{{.User.UserID}}/reset',
type: 'post',
dataType: 'json',
contentType: 'application/x-www-form-urlencoded',
type: "post",
dataType: "json",
contentType: "application/x-www-form-urlencoded",
success: function (data) {
document.getElementById("resetPasswordModal").classList.remove("is-active");
$("#message").html(data.message);
$("#error").html(data.error);
},
})
});
}
</script>
{{end}}

0 comments on commit 8c056a7

Please sign in to comment.