Add more data routes
This commit is contained in:
@ -60,7 +60,7 @@ $(document).ready(function () {
|
||||
if (! ($.isController('statistics') && $('#user-activity').isPresent())) {
|
||||
clearInterval(refreshInterval);
|
||||
} else {
|
||||
var jqxhr = $.ajax({
|
||||
var jqxhr = $.ajax('graphs/user-activity', {
|
||||
dataType: 'json',
|
||||
method: 'GET'
|
||||
});
|
||||
|
@ -1,12 +1,13 @@
|
||||
class StatisticsController < ApplicationController
|
||||
include StatisticsHelper
|
||||
|
||||
before_action :authorize!, only: [:graphs, :user_activity, :rfc_activity]
|
||||
|
||||
def policy_class
|
||||
StatisticsPolicy
|
||||
end
|
||||
|
||||
def show
|
||||
authorize self
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render(json: statistics_data) }
|
||||
@ -14,11 +15,23 @@ class StatisticsController < ApplicationController
|
||||
end
|
||||
|
||||
def graphs
|
||||
authorize self
|
||||
end
|
||||
|
||||
def user_activity
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render(json: graph_live_data) }
|
||||
format.json { render(json: user_activity_live_data) }
|
||||
end
|
||||
end
|
||||
|
||||
def rfc_activity
|
||||
respond_to do |format|
|
||||
format.json { render(json: rfc_activity_live_data) }
|
||||
end
|
||||
end
|
||||
|
||||
def authorize!
|
||||
authorize self
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
end
|
||||
|
@ -122,7 +122,7 @@ module StatisticsHelper
|
||||
]
|
||||
end
|
||||
|
||||
def graph_live_data
|
||||
def user_activity_live_data
|
||||
[
|
||||
{
|
||||
key: 'active_in_last_hour',
|
||||
@ -140,4 +140,8 @@ module StatisticsHelper
|
||||
]
|
||||
end
|
||||
|
||||
def rfc_activity_live_data
|
||||
[]
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -4,4 +4,12 @@ class StatisticsPolicy < AdminOnlyPolicy
|
||||
admin?
|
||||
end
|
||||
|
||||
def user_activity?
|
||||
admin?
|
||||
end
|
||||
|
||||
def rfc_activity?
|
||||
admin?
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -44,6 +44,8 @@ Rails.application.routes.draw do
|
||||
|
||||
get 'statistics/', to: 'statistics#show'
|
||||
get 'statistics/graphs', to: 'statistics#graphs'
|
||||
get 'statistics/graphs/user-activity', to: 'statistics#user_activity'
|
||||
get 'statistics/graphs/rfc-activity', to: 'statistics#rfc_activity'
|
||||
|
||||
concern :statistics do
|
||||
member do
|
||||
|
Reference in New Issue
Block a user