mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 02:04:57 +00:00
Create device model and setup devise, activeadmin and rspec!
- with attributes: model, imei_number, unique_id and access_token - access_token is automatically generated on create
This commit is contained in:
28
app/admin/admin_user.rb
Normal file
28
app/admin/admin_user.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
ActiveAdmin.register AdminUser do
|
||||
permit_params :email, :password, :password_confirmation
|
||||
|
||||
index do
|
||||
selectable_column
|
||||
id_column
|
||||
column :email
|
||||
column :current_sign_in_at
|
||||
column :sign_in_count
|
||||
column :created_at
|
||||
actions
|
||||
end
|
||||
|
||||
filter :email
|
||||
filter :current_sign_in_at
|
||||
filter :sign_in_count
|
||||
filter :created_at
|
||||
|
||||
form do |f|
|
||||
f.inputs "Admin Details" do
|
||||
f.input :email
|
||||
f.input :password
|
||||
f.input :password_confirmation
|
||||
end
|
||||
f.actions
|
||||
end
|
||||
|
||||
end
|
||||
33
app/admin/dashboard.rb
Normal file
33
app/admin/dashboard.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
ActiveAdmin.register_page "Dashboard" do
|
||||
|
||||
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
|
||||
|
||||
content title: proc{ I18n.t("active_admin.dashboard") } do
|
||||
div class: "blank_slate_container", id: "dashboard_default_message" do
|
||||
span class: "blank_slate" do
|
||||
span I18n.t("active_admin.dashboard_welcome.welcome")
|
||||
small I18n.t("active_admin.dashboard_welcome.call_to_action")
|
||||
end
|
||||
end
|
||||
|
||||
# Here is an example of a simple dashboard with columns and panels.
|
||||
#
|
||||
# columns do
|
||||
# column do
|
||||
# panel "Recent Posts" do
|
||||
# ul do
|
||||
# Post.recent(5).map do |post|
|
||||
# li link_to(post.title, admin_post_path(post))
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# column do
|
||||
# panel "Info" do
|
||||
# para "Welcome to ActiveAdmin."
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end # content
|
||||
end
|
||||
1
app/assets/javascripts/active_admin.js.coffee
Normal file
1
app/assets/javascripts/active_admin.js.coffee
Normal file
@@ -0,0 +1 @@
|
||||
#= require active_admin/base
|
||||
17
app/assets/stylesheets/active_admin.scss
Normal file
17
app/assets/stylesheets/active_admin.scss
Normal file
@@ -0,0 +1,17 @@
|
||||
// SASS variable overrides must be declared before loading up Active Admin's styles.
|
||||
//
|
||||
// To view the variables that Active Admin provides, take a look at
|
||||
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
|
||||
// Active Admin source.
|
||||
//
|
||||
// For example, to change the sidebar width:
|
||||
// $sidebar-width: 242px;
|
||||
|
||||
// Active Admin's got SASS!
|
||||
@import "active_admin/mixins";
|
||||
@import "active_admin/base";
|
||||
|
||||
// Overriding any non-variable SASS must be done after the fact.
|
||||
// For example, to change the default status-tag color:
|
||||
//
|
||||
// .status_tag { background: #6090DB; }
|
||||
6
app/models/admin_user.rb
Normal file
6
app/models/admin_user.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class AdminUser < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
end
|
||||
9
app/models/device.rb
Normal file
9
app/models/device.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Device < ActiveRecord::Base
|
||||
validates :unique_id, :model, presence: true
|
||||
validates :unique_id, uniqueness: true
|
||||
before_create :generate_access_token
|
||||
|
||||
def generate_access_token
|
||||
self.access_token = SecureRandom.uuid
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user