diff --git a/src/app.rb b/src/app.rb index 2e44fcc..a25d324 100755 --- a/src/app.rb +++ b/src/app.rb @@ -220,7 +220,6 @@ get "/auctions/:id" do end end - # Admin panel get "/admin" do flags = get_current_user.flags @@ -238,7 +237,7 @@ end def role_check(id) no_go_away if ROLE_IDS.include? id - auth_denied if get_current_user.permitted? :roleman + auth_denied unless get_current_user.permitted? :roleman end get "/admin/roles/:id/delete" do @@ -274,7 +273,7 @@ end post "/admin/roles/:id/update" do id = params[:id].to_i user = get_current_user - auth_denied if user.permitted? :roleman + auth_denied unless user.permitted? :roleman flags = params[:flags].to_i flags = verify_flags(flags, user.flags) diff --git a/src/views/admin/index.slim b/src/views/admin/index.slim index 2dc526d..461e49a 100644 --- a/src/views/admin/index.slim +++ b/src/views/admin/index.slim @@ -1,52 +1,70 @@ -h1 Admin Panel +header + h1 Admin Panel + nav + ul.button-container + li + a.button href="#users" = "Manage Users" + li + a.button href="#roles" = "Roles" + li + a.button href="#auctions" = "Auctions" + li + a.button href="#categories" = "Category Settings" + #admin-panel - article.card.border - h2 Create Role - - .form-container - form action="/admin/roles" method="post" - label Role name - input type="text" name="name" pattern="#{NAME_REGEX_STR}" maxlength="#{MAX_NAME_LEN}" oninput="this.reportValidity()" title="#{REGISTER_ERRORS[:name_desc]}" - - label Role color - input type="color" name="color" value="#fa0f01" - - label Role flags int - input type="number" name="flags" value="0" - - input type="submit" value="Create role" - - article.card.border - h2 Manage Roles - ul.list-container - - data[:roles].each do |role| - li - | #{role.name} - a.inlbutton href="/admin/roles/#{role.id}/edit" - | [EDIT] - a.inlbutton href="/admin/roles/#{role.id}/delete" - | [DELETE] - - article.card.border - h2 Add User to Role - - .form-container - form action="/admin/roles/give" method="post" - label Select User - select name="user_id" - - User.get_all.each do |seluser| - option value="#{seluser.id}" - | #{seluser.name} (id=#{seluser.id}) - - label Select Role - select name="role_id" - - if session_user.admin? - - Role.get_all.each do |selrole| - option value="#{selrole.id}" - | #{selrole.name} (id=#{selrole.id}) - - else - - session_user.roles.each do |selrole| - option value="#{selrole.id}" - | #{selrole.name} (id=#{selrole.id}) - - input type="submit" value="Add User" + + h2#users User Management + .management-container + article.card.border + h2 Add User to Role + + .form-container + form action="/admin/roles/give" method="post" + label Select User + select name="user_id" + - User.get_all.each do |seluser| + option value="#{seluser.id}" + | #{seluser.name} (id=#{seluser.id}) + + label Select Role + select name="role_id" + - if session_user.admin? + - Role.get_all.each do |selrole| + option value="#{selrole.id}" + | #{selrole.name} (id=#{selrole.id}) + - else + - session_user.roles.each do |selrole| + option value="#{selrole.id}" + | #{selrole.name} (id=#{selrole.id}) + + input type="submit" value="Add User" + + h2#roles Role Management + .management-container + article.card.border + h2 Create Role + + .form-container + form action="/admin/roles" method="post" + label Role name + input type="text" name="name" pattern="#{NAME_REGEX_STR}" maxlength="#{MAX_NAME_LEN}" oninput="this.reportValidity()" title="#{REGISTER_ERRORS[:name_desc]}" + + label Role color + input type="color" name="color" value="#fa0f01" + + label Role flags int + input type="number" name="flags" value="0" + + input type="submit" value="Create role" + + + article.card.border + h2 Manage Roles + ul.list-container + - data[:roles].each do |role| + li + | #{role.name} + a.inlbutton href="/admin/roles/#{role.id}/edit" + | [EDIT] + a.inlbutton href="/admin/roles/#{role.id}/delete" + | [DELETE] diff --git a/src/views/stylesheets/style.sass b/src/views/stylesheets/style.sass index f7f216d..ebb17fe 100644 --- a/src/views/stylesheets/style.sass +++ b/src/views/stylesheets/style.sass @@ -42,6 +42,13 @@ html width: auto height: 100% + header + background: $bg_clr + margin-bottom: 2rem + + h1 + text-align: center + .fade-in animation: fade-in .5s ease-in alternate @@ -51,7 +58,6 @@ body height: 100% header - height: 48px background-color: $bg_clr padding: .1rem .8rem white-space: nowrap @@ -421,6 +427,11 @@ ul.list-container border: $border_size solid $border_clr #admin-panel + h2 + text-align: center + border-bottom: $border_size solid $shadow_clr + +.management-container display: flex flex-wrap: wrap justify-content: center