From dfc6aab9402f3a4bfa3cbaba3ae817407d8504e0 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 9 Aug 2021 12:38:37 +0200
Subject: [PATCH] admin

---
 app/assets/stylesheets/admin.sass             |  2 +-
 app/assets/stylesheets/admin/styles.sass      |  6 ++++
 app/views/admin/application/_footer.html.erb  |  2 +-
 app/views/admin/application/_nav.html.erb     |  3 +-
 app/views/admin/application/_top.html.erb     |  6 ++--
 app/views/admin/dashboard/index.html.erb      | 20 ++---------
 app/views/admin/layouts/application.html.erb  |  2 +-
 app/views/devise/confirmations/new.html.erb   | 20 +++++++++++
 .../mailer/confirmation_instructions.html.erb |  5 +++
 .../devise/mailer/email_changed.html.erb      |  7 ++++
 .../devise/mailer/password_change.html.erb    |  3 ++
 .../reset_password_instructions.html.erb      |  8 +++++
 .../mailer/unlock_instructions.html.erb       |  7 ++++
 app/views/devise/passwords/edit.html.erb      | 27 ++++++++++++++
 app/views/devise/passwords/new.html.erb       | 18 ++++++++++
 app/views/devise/registrations/edit.html.erb  | 35 +++++++++++++++++++
 app/views/devise/registrations/new.html.erb   | 25 +++++++++++++
 app/views/devise/sessions/new.html.erb        | 20 +++++++++++
 .../devise/shared/_error_messages.html.erb    | 15 ++++++++
 app/views/devise/shared/_links.html.erb       | 25 +++++++++++++
 app/views/devise/unlocks/new.html.erb         | 19 ++++++++++
 app/views/layouts/devise.html.erb             | 33 +++++++++++++++++
 22 files changed, 282 insertions(+), 26 deletions(-)
 create mode 100644 app/views/devise/confirmations/new.html.erb
 create mode 100644 app/views/devise/mailer/confirmation_instructions.html.erb
 create mode 100644 app/views/devise/mailer/email_changed.html.erb
 create mode 100644 app/views/devise/mailer/password_change.html.erb
 create mode 100644 app/views/devise/mailer/reset_password_instructions.html.erb
 create mode 100644 app/views/devise/mailer/unlock_instructions.html.erb
 create mode 100644 app/views/devise/passwords/edit.html.erb
 create mode 100644 app/views/devise/passwords/new.html.erb
 create mode 100644 app/views/devise/registrations/edit.html.erb
 create mode 100644 app/views/devise/registrations/new.html.erb
 create mode 100644 app/views/devise/sessions/new.html.erb
 create mode 100644 app/views/devise/shared/_error_messages.html.erb
 create mode 100644 app/views/devise/shared/_links.html.erb
 create mode 100644 app/views/devise/unlocks/new.html.erb
 create mode 100644 app/views/layouts/devise.html.erb

diff --git a/app/assets/stylesheets/admin.sass b/app/assets/stylesheets/admin.sass
index d484bedaa..0ae531030 100644
--- a/app/assets/stylesheets/admin.sass
+++ b/app/assets/stylesheets/admin.sass
@@ -1,2 +1,2 @@
-@import 'appstack/light'
+@import 'appstack/dark'
 @import 'admin/*'
diff --git a/app/assets/stylesheets/admin/styles.sass b/app/assets/stylesheets/admin/styles.sass
index cd6160dcb..d94ee86ef 100644
--- a/app/assets/stylesheets/admin/styles.sass
+++ b/app/assets/stylesheets/admin/styles.sass
@@ -3,3 +3,9 @@ h1
 
 .sidebar-nav .fas
   min-width: 20px
+
+#topbar
+    padding-left: 2.5rem
+    padding-right: 2.5rem
+    .nav-link.avatar
+        padding-right: 0
diff --git a/app/views/admin/application/_footer.html.erb b/app/views/admin/application/_footer.html.erb
index c8f2fe951..34e022a16 100644
--- a/app/views/admin/application/_footer.html.erb
+++ b/app/views/admin/application/_footer.html.erb
@@ -20,7 +20,7 @@
       <div class="col-6 text-end">
         <p class="mb-0">
           <a href="https://www.osuny.org" target="_blank" rel="noreferrer">
-            <%= image_tag 'osuny-black.svg', width: 65 %>
+            <%= image_tag 'osuny-white.svg', width: 65 %>
           </a>
         </p>
       </div>
diff --git a/app/views/admin/application/_nav.html.erb b/app/views/admin/application/_nav.html.erb
index df7afefc6..5016cfd06 100644
--- a/app/views/admin/application/_nav.html.erb
+++ b/app/views/admin/application/_nav.html.erb
@@ -1,8 +1,7 @@
-
 <nav id="sidebar" class="sidebar">
   <div class="sidebar-content js-simplebar">
     <%= link_to admin_root_path, class: 'sidebar-brand' do %>
-      <%= image_tag 'osuny-black.svg', class: 'img-fluid pe-5 py-3' %>
+      <%= image_tag 'osuny-white.svg', class: 'img-fluid pe-5 py-3' %>
     <% end %>
     <%= render_navigation context: :admin %>
   </div>
diff --git a/app/views/admin/application/_top.html.erb b/app/views/admin/application/_top.html.erb
index b79946dcf..7c6ab401b 100644
--- a/app/views/admin/application/_top.html.erb
+++ b/app/views/admin/application/_top.html.erb
@@ -1,4 +1,4 @@
-<nav class="navbar navbar-expand navbar-light navbar-bg">
+<nav id="topbar" class="navbar navbar-expand navbar-light navbar-bg">
   <div class="navbar-collapse collapse">
     <%= render_breadcrumbs builder: Appstack::BreadcrumbsOnRailsBuilder %>
     <ul class="navbar-nav navbar-align">
@@ -14,11 +14,11 @@
           <div class="dropdown-divider"></div>
           <a class="dropdown-item" href="#">Settings & Privacy</a>
           <a class="dropdown-item" href="#">Help</a>
-          <a class="dropdown-item" href="#">Sign out</a>
+          <%= link_to 'DĆ©connexion', destroy_user_session_path, method: :delete, class: 'dropdown-item' %>
         </div>
       </li>
       <li>
-        <a class="nav-link" href="#">
+        <a class="nav-link avatar" href="#">
           <%= image_tag 'avatar.jpg', class: 'avatar img-fluid rounded-circle' %>
         </a>
       </li>
diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb
index 7d508ae2a..1d3d05832 100644
--- a/app/views/admin/dashboard/index.html.erb
+++ b/app/views/admin/dashboard/index.html.erb
@@ -49,24 +49,8 @@
         <div class="col-sm-6 col-lg-12 col-xxl-6 d-flex">
           <div class="card illustration flex-fill">
             <div class="card-body p-0 d-flex flex-fill">
-              <div class="row g-0 w-100">
-                <div class="col-6">
-                  <div class="illustration-text p-3 m-1">
-                    <h4 class="illustration-text">
-                      <font style="vertical-align: inherit;">
-                        <font style="vertical-align: inherit;">Bon retour, Chris&nbsp;!</font>
-                      </font>
-                    </h4>
-                    <p class="mb-0">
-                      <font style="vertical-align: inherit;">
-                        <font style="vertical-align: inherit;">Tableau de bord AppStack</font>
-                      </font>
-                    </p>
-                  </div>
-                </div>
-                <div class="col-6 align-self-end text-end">
-                  <img src="img/illustrations/searching.png" alt="Recherche" class="img-fluid illustration-img">
-                </div>
+              <div class="p-3">
+                <h4>Bonjour <%= current_user.first_name %>&nbsp;!</h4>
               </div>
             </div>
           </div>
diff --git a/app/views/admin/layouts/application.html.erb b/app/views/admin/layouts/application.html.erb
index c5ed8061f..a4c9b6ee1 100644
--- a/app/views/admin/layouts/application.html.erb
+++ b/app/views/admin/layouts/application.html.erb
@@ -13,7 +13,7 @@
     <%= favicon_link_tag 'favicon.ico' %>
   </head>
 
-  <body data-theme="light" data-layout="fluid" data-sidebar-position="left" data-sidebar-behavior="sticky">
+  <body data-theme="dark" data-layout="fluid" data-sidebar-position="left" data-sidebar-behavior="sticky">
     <div class="wrapper">
       <%= render 'admin/application/nav' %>
       <div class="main">
diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb
new file mode 100644
index 000000000..f7b4a65c5
--- /dev/null
+++ b/app/views/devise/confirmations/new.html.erb
@@ -0,0 +1,20 @@
+<h2>Resend confirmation instructions</h2>
+
+<%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
+  <%= f.error_notification %>
+  <%= f.full_error :confirmation_token %>
+
+  <div class="form-inputs">
+    <%= f.input :email,
+                required: true,
+                autofocus: true,
+                value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
+                input_html: { autocomplete: "email" } %>
+  </div>
+
+  <div class="form-actions">
+    <%= f.button :submit, "Resend confirmation instructions" %>
+  </div>
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb
new file mode 100644
index 000000000..dc55f64f6
--- /dev/null
+++ b/app/views/devise/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+<p>Welcome <%= @email %>!</p>
+
+<p>You can confirm your account email through the link below:</p>
+
+<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
diff --git a/app/views/devise/mailer/email_changed.html.erb b/app/views/devise/mailer/email_changed.html.erb
new file mode 100644
index 000000000..32f4ba803
--- /dev/null
+++ b/app/views/devise/mailer/email_changed.html.erb
@@ -0,0 +1,7 @@
+<p>Hello <%= @email %>!</p>
+
+<% if @resource.try(:unconfirmed_email?) %>
+  <p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
+<% else %>
+  <p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
+<% end %>
diff --git a/app/views/devise/mailer/password_change.html.erb b/app/views/devise/mailer/password_change.html.erb
new file mode 100644
index 000000000..b41daf476
--- /dev/null
+++ b/app/views/devise/mailer/password_change.html.erb
@@ -0,0 +1,3 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>We're contacting you to notify you that your password has been changed.</p>
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb
new file mode 100644
index 000000000..f667dc12f
--- /dev/null
+++ b/app/views/devise/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Someone has requested a link to change your password. You can do this through the link below.</p>
+
+<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
+
+<p>If you didn't request this, please ignore this email.</p>
+<p>Your password won't change until you access the link above and create a new one.</p>
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb
new file mode 100644
index 000000000..41e148bf2
--- /dev/null
+++ b/app/views/devise/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
+
+<p>Click the link below to unlock your account:</p>
+
+<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb
new file mode 100644
index 000000000..591cd8c85
--- /dev/null
+++ b/app/views/devise/passwords/edit.html.erb
@@ -0,0 +1,27 @@
+<h2>Change your password</h2>
+
+<%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
+  <%= f.error_notification %>
+
+  <%= f.input :reset_password_token, as: :hidden %>
+  <%= f.full_error :reset_password_token %>
+
+  <div class="form-inputs">
+    <%= f.input :password,
+                label: "New password",
+                required: true,
+                autofocus: true,
+                hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
+                input_html: { autocomplete: "new-password" } %>
+    <%= f.input :password_confirmation,
+                label: "Confirm your new password",
+                required: true,
+                input_html: { autocomplete: "new-password" } %>
+  </div>
+
+  <div class="form-actions">
+    <%= f.button :submit, "Change my password" %>
+  </div>
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb
new file mode 100644
index 000000000..01ce0b8b9
--- /dev/null
+++ b/app/views/devise/passwords/new.html.erb
@@ -0,0 +1,18 @@
+<h2>Forgot your password?</h2>
+
+<%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
+  <%= f.error_notification %>
+
+  <div class="form-inputs">
+    <%= f.input :email,
+                required: true,
+                autofocus: true,
+                input_html: { autocomplete: "email" } %>
+  </div>
+
+  <div class="form-actions">
+    <%= f.button :submit, "Send me reset password instructions" %>
+  </div>
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb
new file mode 100644
index 000000000..dfb7eb94e
--- /dev/null
+++ b/app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,35 @@
+<h2>Edit <%= resource_name.to_s.humanize %></h2>
+
+<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
+  <%= f.error_notification %>
+
+  <div class="form-inputs">
+    <%= f.input :email, required: true, autofocus: true %>
+
+    <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
+      <p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
+    <% end %>
+
+    <%= f.input :password,
+                hint: "leave it blank if you don't want to change it",
+                required: false,
+                input_html: { autocomplete: "new-password" } %>
+    <%= f.input :password_confirmation,
+                required: false,
+                input_html: { autocomplete: "new-password" } %>
+    <%= f.input :current_password,
+                hint: "we need your current password to confirm your changes",
+                required: true,
+                input_html: { autocomplete: "current-password" } %>
+  </div>
+
+  <div class="form-actions">
+    <%= f.button :submit, "Update" %>
+  </div>
+<% end %>
+
+<h3>Cancel my account</h3>
+
+<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
+
+<%= link_to "Back", :back %>
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
new file mode 100644
index 000000000..cf520eccd
--- /dev/null
+++ b/app/views/devise/registrations/new.html.erb
@@ -0,0 +1,25 @@
+<h2>Sign up</h2>
+
+<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
+  <%= f.error_notification %>
+
+  <div class="form-inputs">
+    <%= f.input :email,
+                required: true,
+                autofocus: true,
+                input_html: { autocomplete: "email" }%>
+    <%= f.input :password,
+                required: true,
+                hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
+                input_html: { autocomplete: "new-password" } %>
+    <%= f.input :password_confirmation,
+                required: true,
+                input_html: { autocomplete: "new-password" } %>
+  </div>
+
+  <div class="form-actions">
+    <%= f.button :submit, "Sign up", class: 'btn btn-lg btn-primary' %>
+  </div>
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
new file mode 100644
index 000000000..c2f4b30df
--- /dev/null
+++ b/app/views/devise/sessions/new.html.erb
@@ -0,0 +1,20 @@
+<h2>Log in</h2>
+
+<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
+  <div class="form-inputs">
+    <%= f.input :email,
+                required: false,
+                autofocus: true,
+                input_html: { autocomplete: "email" } %>
+    <%= f.input :password,
+                required: false,
+                input_html: { autocomplete: "current-password" } %>
+    <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
+  </div>
+
+  <div class="form-actions">
+    <%= f.button :submit, "Log in", class: 'btn btn-lg btn-primary' %>
+  </div>
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/devise/shared/_error_messages.html.erb b/app/views/devise/shared/_error_messages.html.erb
new file mode 100644
index 000000000..ba7ab8870
--- /dev/null
+++ b/app/views/devise/shared/_error_messages.html.erb
@@ -0,0 +1,15 @@
+<% if resource.errors.any? %>
+  <div id="error_explanation">
+    <h2>
+      <%= I18n.t("errors.messages.not_saved",
+                 count: resource.errors.count,
+                 resource: resource.class.model_name.human.downcase)
+       %>
+    </h2>
+    <ul>
+      <% resource.errors.full_messages.each do |message| %>
+        <li><%= message %></li>
+      <% end %>
+    </ul>
+  </div>
+<% end %>
diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb
new file mode 100644
index 000000000..96a941241
--- /dev/null
+++ b/app/views/devise/shared/_links.html.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+  <%= link_to "Log in", new_session_path(resource_name) %><br />
+<% end %>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+  <%= link_to "Sign up", new_registration_path(resource_name) %><br />
+<% end %>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
+  <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
+<% end %>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+  <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
+<% end %>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+  <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
+<% end %>
+
+<%- if devise_mapping.omniauthable? %>
+  <%- resource_class.omniauth_providers.each do |provider| %>
+    <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %><br />
+  <% end %>
+<% end %>
diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb
new file mode 100644
index 000000000..c42de1738
--- /dev/null
+++ b/app/views/devise/unlocks/new.html.erb
@@ -0,0 +1,19 @@
+<h2>Resend unlock instructions</h2>
+
+<%= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
+  <%= f.error_notification %>
+  <%= f.full_error :unlock_token %>
+
+  <div class="form-inputs">
+    <%= f.input :email,
+                required: true,
+                autofocus: true,
+                input_html: { autocomplete: "email" } %>
+  </div>
+
+  <div class="form-actions">
+    <%= f.button :submit, "Resend unlock instructions" %>
+  </div>
+<% end %>
+
+<%= render "devise/shared/links" %>
diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb
new file mode 100644
index 000000000..f7b594e8c
--- /dev/null
+++ b/app/views/layouts/devise.html.erb
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+    <title><%= yield :title %></title>
+    <%= csrf_meta_tags %>
+    <%= csp_meta_tag %>
+    <%= stylesheet_link_tag 'admin', media: 'all' %>
+    <%= javascript_include_tag 'admin' %>
+  </head>
+  <body data-theme="default" data-layout="fluid">
+    <div class="main d-flex justify-content-center w-100">
+      <main class="content d-flex p-0">
+        <div class="container d-flex flex-column">
+          <div class="row h-100">
+            <div class="col-sm-10 col-md-8 col-lg-6 mx-auto d-table h-100">
+              <div class="d-table-cell align-middle">
+                <h1 class="mb-5 text-center"><%= current_university %></h1>
+                <div class="card">
+                  <div class="card-body text-start">
+                    <div class="m-sm-4">
+                      <%= yield %>
+                    </div>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+        </main>
+      </div>
+    </body>
+  </html>
-- 
GitLab