Реализация Page и DataCardWidget
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
module Api
|
||||
module V1
|
||||
module Channels
|
||||
class ApplicationController < ApplicationController
|
||||
def resource_channel
|
||||
@resource_channel ||= Channel.find(params[:channel_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
module Api
|
||||
module V1
|
||||
module Channels
|
||||
class HistoriesController < ApplicationController
|
||||
before_action :resource_channel
|
||||
|
||||
def index
|
||||
@history = @resource_channel.histories.last(100)
|
||||
|
||||
render json: @history
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
module Api
|
||||
module V1
|
||||
class ChannelsController < ApplicationController
|
||||
def index
|
||||
@channels = Channel.all
|
||||
render json: @channels
|
||||
end
|
||||
|
||||
def show
|
||||
@channel = Channel.find(params[:id])
|
||||
render json: @channel
|
||||
end
|
||||
|
||||
def selected_index
|
||||
ids = params[:ids]
|
||||
|
||||
if ids.present? && ids.is_a?(Array)
|
||||
@channels = Channel.where(id: ids)
|
||||
@channels = @channels.sort_by(&:id)
|
||||
render json: @channels
|
||||
else
|
||||
render json: { error: "Invalid or missing ids" }, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class ApplicationController < ActionController::API
|
||||
# TODO: auth. users before exec request
|
||||
# TODO: implement middleware for IP trottling
|
||||
# TODO: implement request rate limit
|
||||
end
|
||||
Reference in New Issue
Block a user