-
Notifications
You must be signed in to change notification settings - Fork 6
User management interface #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d4933a9
condition in file mazer for login page, new route for connexion, desi…
967e809
add design for password, add route for reset password, add layout for…
f3f9cb5
view user and method crud, not finished
dalyl0x0 413e1c2
removed local config, removed layout, fix design user list
dalyl0x0 b34134c
add user crud action
dalyl0x0 c1bee51
add faker, add faker email, add test users
dalyl0x0 4c57f48
fix design button edit and delete
dalyl0x0 7279012
fix rubocop
dalyl0x0 d5a0b87
fix rubocop
dalyl0x0 6105117
remove AuthHelper
dalyl0x0 488517e
fix rubocop
dalyl0x0 0251abc
Implement style changes
Oli0li d7374fd
Add "session" layout
Oli0li c2b6925
Fix link and indentation in user index
Oli0li File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,54 @@ | ||
| class UsersController < ApplicationController | ||
| before_action :set_user, only: %i[ edit update destroy ] | ||
|
|
||
| def index | ||
| @users = User.all | ||
| end | ||
|
|
||
| def new | ||
| @user = User.new | ||
| end | ||
|
|
||
| def create | ||
| @user = User.new(user_params) | ||
|
|
||
| respond_to do |format| | ||
| if @user.save | ||
| format.html { redirect_to users_path, notice: "User was successfully created." } | ||
| else | ||
| format.html { render :new, status: :unprocessable_entity } | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add space before this method |
||
| end | ||
|
|
||
| def update | ||
| respond_to do |format| | ||
| if @user.update(user_params) | ||
| format.html { redirect_to users_path, notice: "User was successfully updated." } | ||
| else | ||
| format.html { render :edit, status: :unprocessable_entity } | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| @user.destroy! | ||
|
|
||
| respond_to do |format| | ||
| format.html { redirect_to users_path, status: :see_other, notice: "User was successfully destroyed." } | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def set_user | ||
| @user = User.find(params.expect(:id)) | ||
| end | ||
|
|
||
| def user_params | ||
| params.expect(user: [ :email, :password, :is_admin ]) | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title><%= content_for(:title) || "Skillrx" %></title> | ||
|
|
||
| <meta name="viewport" content="width=device-width,initial-scale=1"> | ||
| <meta name="apple-mobile-web-app-capable" content="yes"> | ||
| <meta name="mobile-web-app-capable" content="yes"> | ||
| <%= csrf_meta_tags %> | ||
| <%= csp_meta_tag %> | ||
|
|
||
| <%= yield :head %> | ||
|
|
||
| <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> | ||
| <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> | ||
|
|
||
|
|
||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/app.css"> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/app-dark.css"> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/iconly.css"> | ||
|
|
||
| <%# Includes all stylesheet files in app/assets/stylesheets %> | ||
| <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> | ||
| <%= javascript_importmap_tags %> | ||
| </head> | ||
|
|
||
| <body> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/initTheme.js"></script> | ||
|
|
||
| <!-- Start content here --> | ||
| <%= render "layouts/sidebar" %> | ||
|
|
||
| <%= yield %> | ||
| <!-- End content --> | ||
|
|
||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/components/dark.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/extensions/perfect-scrollbar/perfect-scrollbar.min.js"></script> | ||
|
|
||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/js/app.js"></script> | ||
|
|
||
| <!-- Need: Apexcharts --> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/extensions/apexcharts/apexcharts.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/pages/dashboard.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title><%= content_for(:title) || "Skillrx" %></title> | ||
|
|
||
| <meta name="viewport" content="width=device-width,initial-scale=1"> | ||
| <meta name="apple-mobile-web-app-capable" content="yes"> | ||
| <meta name="mobile-web-app-capable" content="yes"> | ||
| <%= csrf_meta_tags %> | ||
| <%= csp_meta_tag %> | ||
|
|
||
| <%= yield :head %> | ||
|
|
||
| <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> | ||
| <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> | ||
|
|
||
|
|
||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/app.css"> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/app-dark.css"> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/css/iconly.css"> | ||
|
|
||
| <%# Includes all stylesheet files in app/assets/stylesheets %> | ||
| <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> | ||
| <%= javascript_importmap_tags %> | ||
| </head> | ||
|
|
||
| <body> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/initTheme.js"></script> | ||
|
|
||
| <!-- Start content here --> | ||
| <%= yield %> | ||
| <!-- End content --> | ||
|
|
||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/components/dark.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/extensions/perfect-scrollbar/perfect-scrollbar.min.js"></script> | ||
|
|
||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/compiled/js/app.js"></script> | ||
|
|
||
| <!-- Need: Apexcharts --> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/extensions/apexcharts/apexcharts.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/gh/zuramai/mazer@docs/demo/assets/static/js/pages/dashboard.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,32 @@ | ||
| <h1>Forgot your password?</h1> | ||
|
|
||
| <%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %> | ||
|
|
||
| <%= form_with url: passwords_path do |form| %> | ||
| <%= form.email_field :email, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email] %><br> | ||
| <%= form.submit "Email reset instructions" %> | ||
| <% end %> | ||
| <div class="row h-100 p-4"> | ||
| <div class="col-lg-5 col-12"> | ||
| <div id="auth-left"> | ||
| <div class="auth-logo"> | ||
|
|
||
| </div> | ||
| <h1 class="auth-title">Forgot Password</h1> | ||
| <p class="auth-subtitle mb-5">Input your email and we will send you reset password link.</p> | ||
|
|
||
| <%= form_with url: passwords_path do |form| %> | ||
| <div class="form-group position-relative has-icon-left mb-4"> | ||
| <%= form.email_field :email, required: true, class:"form-control form-control-xl", autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email] %><br> | ||
| <div class="form-control-icon"> | ||
| <i class="bi bi-envelope"></i> | ||
| </div> | ||
| </div> | ||
|
|
||
| <%= form.submit "Email reset instructions", class:"btn btn-primary btn-block btn-lg shadow-lg mt-5" %> | ||
| <% end %> | ||
|
|
||
| <div class="text-center mt-5 text-lg fs-4"> | ||
| <p class="text-gray-600">Remember your account? <%= link_to "Login", new_session_path, class:"font-bold" %></p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="col-lg-7 d-none d-lg-block"> | ||
| <div id="auth-right"> | ||
| </div> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,29 @@ | ||
| <%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %> | ||
| <%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %> | ||
|
|
||
| <%= form_with url: session_path do |form| %> | ||
| <%= form.email_field :email, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email] %><br> | ||
| <%= form.password_field :password, required: true, autocomplete: "current-password", placeholder: "Enter your password", maxlength: 72 %><br> | ||
| <%= form.submit "Sign in" %> | ||
| <% end %> | ||
| <br> | ||
|
|
||
| <%= link_to "Forgot password?", new_password_path %> | ||
| <div class="row h-100 p-4"> | ||
| <div class="col-lg-5 col-12"> | ||
| <div id="auth-left"> | ||
| <div class="auth-logo"> | ||
| </div> | ||
| <h1 class="auth-title">Log in</h1> | ||
| <p class="auth-subtitle mb-5">Log in with your data that you entered during registration.</p> | ||
| <%= form_with url: session_path do |form| %> | ||
| <div class="form-group position-relative has-icon-left mb-4"> | ||
| <%= form.email_field :email, required: true, class:"form-control form-control-xl", autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email] %><br> | ||
| <div class="form-control-icon"> | ||
| <i class="bi bi-person"></i> | ||
| </div> | ||
| </div> | ||
| <div class="form-group position-relative has-icon-left mb-4"> | ||
| <%= form.password_field :password, required: true, class:"form-control form-control-xl", autocomplete: "current-password", placeholder: "Enter your password", maxlength: 72 %><br> | ||
| <div class="form-control-icon"> | ||
| <i class="bi bi-shield-lock"></i> | ||
| </div> | ||
| </div> | ||
| <%= form.submit "Sign in", class:"btn btn-primary btn-block btn-lg shadow-lg mt-5" %> | ||
| <% end %> | ||
| <div class="text-center mt-5 text-lg fs-4"> | ||
| <p><%= link_to "Forgot password?", new_password_path, class:"font-bold" %></p> | ||
| </div> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <%= form_with(model: user) do |form| %> | ||
| <% if user.errors.any? %> | ||
| <div style="color: red"> | ||
| <h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2> | ||
|
|
||
| <ul> | ||
| <% user.errors.each do |error| %> | ||
| <li><%= error.full_message %></li> | ||
| <% end %> | ||
| </ul> | ||
| </div> | ||
| <% end %> | ||
|
|
||
| <div class="col-md-4"> | ||
| <div class="form-group"> | ||
| <%= form.label :email, style: "display: block" %> | ||
| <%= form.text_field :email, id: "basicInput", class: "form-control", autofocus: true %> | ||
| </div> | ||
| </div> | ||
| <div class="col-md-4"> | ||
| <div class="form-group"> | ||
| <%= form.label :password, style: "display: block" %> | ||
| <%= form.text_field :password, id: "basicInput", class: "form-control", autofocus: true %> | ||
| </div> | ||
| </div> | ||
| <div class="col-md-4"> | ||
| <div class="form-group"> | ||
| <%= form.label :is_admin, style: "display: block" %> | ||
| <%= form.check_box :is_admin, autofocus: true %> | ||
| </div> | ||
| </div> | ||
| <div class="mt-4"> | ||
| <div class="col-12 d-flex justify-content-end"> | ||
| <%= form.submit "Save User", class: "btn btn-primary me-1 mb-1" %> | ||
| <%= link_to "Cancel", users_path, class: "btn btn-light-secondary me-1 mb-1" %> | ||
| </div> | ||
| </div> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <% content_for :title, "Editing user" %> | ||
|
|
||
| <h1>Editing user</h1> | ||
|
|
||
| <%= render "form", user: @user %> | ||
|
|
||
| <div class="mt-4"> | ||
| <%= link_to "Show this user", @user %> | | ||
| <%= link_to "Back to users", users_path %> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <h1>User list </h1> | ||
|
|
||
| <div class="page-heading"> | ||
| <section class="section"> | ||
| <div class="card"> | ||
| <div class="card-body"> | ||
| <%= link_to new_region_path, class: "btn btn-primary" do %> | ||
| <i class="bi bi-plus"></i> Add New User | ||
| <% end %> | ||
| <table class="table table-striped" id="table1"> | ||
| <thead> | ||
| <tr> | ||
| <th>Email</th> | ||
| <th>Administrator</th> | ||
| <th>User actions</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @users.each do |user| %> | ||
| <tr> | ||
| <td><%= user.email %></td> | ||
| <td><%= user.is_admin %></td> | ||
| <td class="text-end"> | ||
| <%= link_to edit_user_path(user), class: "btn btn-secondary btn-sm pr-2" do %> | ||
| <i class="bi bi-pencil"></i> Edit | ||
| <% end %> | ||
| <%= button_to user, data: { confirm: "Are you sure?" }, method: :delete,form_class:"d-inline", class: "btn btn-danger btn-sm " do %> | ||
| <i class="bi bi-trash"></i> Delete | ||
| <% end %> | ||
| </td> | ||
| </tr> | ||
| <% end %> | ||
| <tbody> | ||
| </table> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| </div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space here can be removed