mirror of
https://github.com/czhu12/canine.git
synced 2025-12-20 10:19:50 -06:00
added login as feature
This commit is contained in:
5
app/avo/config.rb
Normal file
5
app/avo/config.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class Avo::Config
|
||||||
|
def self.button_css
|
||||||
|
"button-component inline-flex flex-grow-0 items-center font-semibold leading-6 fill-current whitespace-nowrap transition duration-100 transform transition duration-100 cursor-pointer disabled:cursor-not-allowed disabled:opacity-60 data-[disabled='true']:opacity-60 justify-center border active:outline active:outline-1 rounded bg-primary-500 text-white border-primary-500 hover:bg-primary-600 hover:border-primary-600 active:border-primary-600 active:outline-primary-600 active:bg-primary-600 px-3 py-1.5 text-sm"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -8,7 +8,7 @@ class Avo::Resources::Cluster < Avo::BaseResource
|
|||||||
def fields
|
def fields
|
||||||
field :id, as: :id
|
field :id, as: :id
|
||||||
field :name, as: :text
|
field :name, as: :text
|
||||||
field :status, as: :select, options: Cluster.statuses.keys.map { |status| [status.humanize, status] }
|
field :status, as: :select, options: Cluster.statuses.keys.map { |status| [ status.humanize, status ] }
|
||||||
field :account, as: :belongs_to
|
field :account, as: :belongs_to
|
||||||
field :add_ons, as: :has_many
|
field :add_ons, as: :has_many
|
||||||
field :projects, as: :has_many
|
field :projects, as: :has_many
|
||||||
|
|||||||
@@ -3,4 +3,10 @@ class Avo::ToolsController < Avo::ApplicationController
|
|||||||
@page_title = "Dashboard"
|
@page_title = "Dashboard"
|
||||||
add_breadcrumb "Dashboard"
|
add_breadcrumb "Dashboard"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def login_as
|
||||||
|
user = User.find(params[:id])
|
||||||
|
sign_in(user)
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,15 +10,9 @@
|
|||||||
<div class="flex flex-col p-4 min-h-24">
|
<div class="flex flex-col p-4 min-h-24">
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<h3>Manage User</h3>
|
<h3>Manage User</h3>
|
||||||
|
<%= form_with url: login_as_path(@resource.record.id), method: :post, data: { turbo: false } do |f| %>
|
||||||
<p>
|
<%= f.submit "Login As", class: Avo::Config.button_css %>
|
||||||
You can edit this file here <code class='p-1 rounded bg-gray-500 text-white text-sm'>app/views/avo/resource_tools/_user.html.erb</code>.
|
<% end %>
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The resource tool configuration file should be here <code class='p-1 rounded bg-gray-500 text-white text-sm'>app/avo/resource_tools/user.rb</code>.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<%
|
<%
|
||||||
# In this partial you have access to the following variables:
|
# In this partial you have access to the following variables:
|
||||||
# tool
|
# tool
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
|||||||
Avo::Engine.routes.draw do
|
Avo::Engine.routes.draw do
|
||||||
# This route is not protected, secure it with authentication if needed.
|
# This route is not protected, secure it with authentication if needed.
|
||||||
get "dashboard", to: "tools#dashboard", as: :dashboard
|
get "dashboard", to: "tools#dashboard", as: :dashboard
|
||||||
|
post "login_as/:id", to: "tools#login_as", as: :login_as
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :accounts, only: [ :create ] do
|
resources :accounts, only: [ :create ] do
|
||||||
|
|||||||
Reference in New Issue
Block a user