Реализация 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
|
||||
@@ -0,0 +1,7 @@
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
# Automatically retry jobs that encountered a deadlock
|
||||
# retry_on ActiveRecord::Deadlocked
|
||||
|
||||
# Most jobs are safe to ignore if the underlying records are no longer available
|
||||
# discard_on ActiveJob::DeserializationError
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: "from@example.com"
|
||||
layout "mailer"
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
primary_abstract_class
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class Channel < ApplicationRecord
|
||||
self.table_name = "channels"
|
||||
self.inheritance_column = nil
|
||||
|
||||
has_many :histories, -> { order(event_date: :asc) }
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class History < ApplicationRecord
|
||||
self.table_name = "histories"
|
||||
|
||||
belongs_to :channel
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
<%= yield %>
|
||||
Reference in New Issue
Block a user