mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 10:14:59 +00:00
Add GCM push for pushing OneMDM app to devices
This commit is contained in:
@@ -3,31 +3,41 @@ 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")
|
||||
|
||||
panel "Recent Pushes" do
|
||||
table_for BatchInstallation.order('id desc').limit(10) do
|
||||
column "Pushed on" do |batch|
|
||||
batch.created_at
|
||||
end
|
||||
column "App Name" do |batch|
|
||||
batch.app.name
|
||||
end
|
||||
column "# Devices" do |batch|
|
||||
link_to batch.installations.count,
|
||||
admin_devices_path(q: {installations_batch_installation_id_eq: batch.id})
|
||||
end
|
||||
column "# Installed" do |batch|
|
||||
link_to batch.installations.installed.count,
|
||||
admin_devices_path(q: {installations_batch_installation_id_eq: batch.id,
|
||||
installations_status_eq: Installation.statuses[:installed]})
|
||||
end
|
||||
column "# Cancelled" do |batch|
|
||||
link_to batch.installations.cancelled.count,
|
||||
admin_devices_path(q: {installations_batch_installation_id_eq: batch.id,
|
||||
installations_status_eq: Installation.statuses[:cancelled]})
|
||||
end
|
||||
column "# Pending" do |batch|
|
||||
link_to batch.installations.pushed.count + batch.installations.downloaded.count,
|
||||
admin_devices_path(q: {installations_batch_installation_id_eq: batch.id,
|
||||
installations_status_in: [Installation.statuses[:pushed],
|
||||
Installation.statuses[:downloaded]]})
|
||||
end
|
||||
column "% Success" do |batch|
|
||||
total = batch.installations.count
|
||||
installed = batch.installations.installed.count
|
||||
percentage_success = (installed/total) * 100 if total > 0
|
||||
end
|
||||
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
|
||||
end # content
|
||||
end
|
||||
|
||||
@@ -2,18 +2,21 @@ ActiveAdmin.register Device do
|
||||
|
||||
actions :all, except: [:edit,:new]
|
||||
|
||||
# See permitted parameters documentation:
|
||||
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
||||
#
|
||||
# permit_params :list, :of, :attributes, :on, :model
|
||||
#
|
||||
# or
|
||||
#
|
||||
# permit_params do
|
||||
# permitted = [:permitted, :attributes]
|
||||
# permitted << :other if resource.something?
|
||||
# permitted
|
||||
# end
|
||||
app_data = lambda do
|
||||
apps = App.order('name').reload.pluck(:name,:id)
|
||||
{"App Name" => apps}
|
||||
end
|
||||
|
||||
batch_action :push, confirm: "Select apps to push",form: app_data do |ids,inputs|
|
||||
app = App.find(inputs["App Name"])
|
||||
batch = BatchInstallation.create(:app => app)
|
||||
ids.each do | id |
|
||||
install = Installation.new(device: Device.find(id),batch_installation: batch)
|
||||
install.pushed!
|
||||
end
|
||||
redirect_to admin_dashboard_path, notice: "Successfully pushed app to device(s)"
|
||||
end
|
||||
|
||||
index do
|
||||
selectable_column
|
||||
id_column
|
||||
|
||||
Reference in New Issue
Block a user