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