diff --git a/app/controllers/admin/channel_controller.rb b/app/controllers/admin/channel_controller.rb new file mode 100644 index 0000000..118473f --- /dev/null +++ b/app/controllers/admin/channel_controller.rb @@ -0,0 +1,26 @@ +class Admin::ChannelController < ApplicationController + include ChannelConcern + load_and_authorize_resource + before_action :set_channel, only: [:show, :edit, :update, :destroy] + + def index + channel_index + end + + def new + @channel = Channel.new + end + + def create + channel_create + end + + def update + channel_update + end + + def destroy + authorize!(:destroy, :channel_admin) + channel_destroy + end +end diff --git a/app/controllers/admin/control_point_controller.rb b/app/controllers/admin/control_point_controller.rb index 2ea2021..5d43457 100644 --- a/app/controllers/admin/control_point_controller.rb +++ b/app/controllers/admin/control_point_controller.rb @@ -29,8 +29,6 @@ def update def destroy assigned_models_count = - Room.where(control_point_id: params[:id]).count + - Device.where(control_point_id: params[:id]).count + Channel.where(control_point_id: params[:id]).count if assigned_models_count.zero? diff --git a/app/controllers/admin/server_controller.rb b/app/controllers/admin/server_controller.rb new file mode 100644 index 0000000..d30362c --- /dev/null +++ b/app/controllers/admin/server_controller.rb @@ -0,0 +1,26 @@ +class Admin::ServerController < ApplicationController + include ServerConcern + + load_and_authorize_resource + # before_action :set_server, only: [:show, :edit, :update, :destroy] + + def index + server_index + end + + def new + @server = Server.new + end + + def create + server_create + end + + def update + server_update + end + + def destroy + server_destroy + end +end diff --git a/app/controllers/concerns/channel_concern.rb b/app/controllers/concerns/channel_concern.rb new file mode 100644 index 0000000..8dbe3c3 --- /dev/null +++ b/app/controllers/concerns/channel_concern.rb @@ -0,0 +1,64 @@ +module ChannelConcern + extend ActiveSupport::Concern + + included do # rubocop:disable Metrics/BlockLength + def channel_index + @query = Channel.ransack(params[:q]) + @pagy, @channels = pagy(@query.result.order(:id)) + end + + def channel_create + @channel = Channel.new(channel_params) + + if @channel.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def channel_update + if @channel.update(channel_params) + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def channel_destroy + assigned_histories = History.where(channel_id: @channel.id).count + + if assigned_histories.zero? + if @channel.destroy + flash[:success] = t('message.admin.channel.delete.success') + else + flash[:error] = t('message.admin.channel.delete.error') + end + else + flash[:error] = t('message.admin.channel.delete.error') + end + redirect_to(admin_channel_index_path) + end + + private + + def set_channel + @channel = Channel.find(params[:id]) + end + + def channel_params + params.require(:channel).permit( + :channel_id, + :server_id, + :control_point_id, + :location_description, + :self_background, + :pre_emergency_limit, + :emergency_limit, + :consumption, + :conversion_coefficient, + :service_id, + ) + end + end +end diff --git a/app/controllers/concerns/device_concern.rb b/app/controllers/concerns/device_concern.rb index ee3f035..ef7d611 100644 --- a/app/controllers/concerns/device_concern.rb +++ b/app/controllers/concerns/device_concern.rb @@ -44,7 +44,7 @@ def device_update(device) def device_destroy(device, path_success, path_failure) assigned_inspections_count = Inspection.where(device_id: device.id).count - if assigned_inspections_count.zero? && device.control_point_id? + if assigned_inspections_count.zero? && device.control_point.nil? device.destroy redirect_to(path_success) else @@ -87,7 +87,7 @@ def device_params :year_of_production, :year_of_commissioning, :supplementary_kit_id, - :control_point_id, + :control_point_ids, :service_id) end end diff --git a/app/controllers/concerns/organization_concern.rb b/app/controllers/concerns/organization_concern.rb index 68b0b22..6abbc74 100644 --- a/app/controllers/concerns/organization_concern.rb +++ b/app/controllers/concerns/organization_concern.rb @@ -53,7 +53,7 @@ def organization_params :zip_code, :phone, :fax, - :email + :email, ) end end diff --git a/app/controllers/concerns/server_concern.rb b/app/controllers/concerns/server_concern.rb new file mode 100644 index 0000000..ad9f783 --- /dev/null +++ b/app/controllers/concerns/server_concern.rb @@ -0,0 +1,55 @@ +module ServerConcern + extend ActiveSupport::Concern + + included do # rubocop:disable Metrics/BlockLength + def server_index + @query = Server.ransack(params[:q]) + @pagy, @servers = pagy(@query.result.order(:name)) + end + + def server_create + @server = Server.new(server_params) + + if @server.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def server_update + if @server.update(server_params) + redirect_back(fallback_location: root_path) + else + render(:edit, status: :unprocessable_entity) + end + end + + def server_destroy + assigned_models_count = Channel.where(server_id: params[:id]).count + + if assigned_models_count.zero? + @server.destroy + else + flash[:error] = t('message.admin.server.delete.error') + end + redirect_to(admin_server_index_path) + end + + private + + def set_server + @server = Server.find(params[:id]) + end + + def server_params + params.require(:server).permit( + :name, + :ip_address, + :inventory_id, + :service_id, + :room_id, + ) + end + end +end diff --git a/app/javascript/Components/Armstrong/Armstrong.jsx b/app/javascript/Components/Armstrong/Armstrong.jsx index 1fc6287..75bd926 100644 --- a/app/javascript/Components/Armstrong/Armstrong.jsx +++ b/app/javascript/Components/Armstrong/Armstrong.jsx @@ -26,7 +26,7 @@ export default function Armstrong() { case 'normal': return ; case 'warning': - return ; + return ; case 'danger': return ; default: @@ -96,7 +96,7 @@ export default function Armstrong() { return (
- + {isModalOpen && ( - + ); } diff --git a/app/javascript/Components/Armstrong/Table/TableBody.jsx b/app/javascript/Components/Armstrong/Table/TableBody.jsx index 06aca78..96bee36 100644 --- a/app/javascript/Components/Armstrong/Table/TableBody.jsx +++ b/app/javascript/Components/Armstrong/Table/TableBody.jsx @@ -13,7 +13,13 @@ export default function TableBody({ columns, data, openModal }) { let tData = row[accessor] ? row[accessor] : '——'; if (accessor === 'chart') { tData = ( - ); diff --git a/app/models/channel.rb b/app/models/channel.rb index 4f57cc2..54477c8 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -4,4 +4,17 @@ class Channel < ApplicationRecord has_many :history belongs_to :control_point + + channel_id_msg = 'должен быть в диапозоне от 1 до 48' + + validates :channel_id, presence: true, numericality: { in: 1..48, message: channel_id_msg } + + def self.ransackable_associations(_auth_object = nil) + ['control_point', 'history', 'server', 'service'] + end + + def self.ransackable_attributes(_auth_object = nil) + ['channel_id', 'consumption', 'control_point_id', 'conversion_coefficient', 'created_at', 'emergency_limit', 'event_count', + 'event_datetime', 'event_error_count', 'event_impulse_value', 'event_not_system_value', 'event_system_value', 'id', 'is_online', 'is_special_control', 'location_description', 'pre_emergency_limit', 'self_background', 'server_id', 'service_id', 'state', 'updated_at'] + end end diff --git a/app/models/control_point.rb b/app/models/control_point.rb index d091bae..7bf8344 100644 --- a/app/models/control_point.rb +++ b/app/models/control_point.rb @@ -3,7 +3,7 @@ class ControlPoint < ApplicationRecord belongs_to :service has_one :channel - has_one :device + belongs_to :device, optional: true validates :name, presence: true diff --git a/app/models/device.rb b/app/models/device.rb index e4bddfd..f2b2c14 100644 --- a/app/models/device.rb +++ b/app/models/device.rb @@ -5,20 +5,22 @@ class Device < ApplicationRecord current_year = Date.today.year year_error_msg = "должен быть больше 1900 и меньше или равен #{current_year}" + inspection_interval_msg = 'должен быть от 0.1 (раз в месяц) до 10.0 (раз в 10 лет)' belongs_to :device_model belongs_to :device_reg_group belongs_to :supplementary_kit, optional: true belongs_to :room, optional: true belongs_to :service - belongs_to :control_point, optional: true + has_many :control_point has_many :inspections validates :inventory_id, numericality: { less_than_or_equal_to: 2147483647 }, uniqueness: true, allow_nil: true validates :serial_id, :tabel_id, presence: true, uniqueness: true validates :year_of_commissioning, :year_of_production, numericality: { in: 1900..current_year, message: year_error_msg }, allow_nil: true validates :year_of_production, presence: true + validates :inspection_interval, presence: true, numericality: { in: 0.1..10.0, message: inspection_interval_msg } STATUS = { verified: 'verified', diff --git a/app/models/organization.rb b/app/models/organization.rb index 304b1c8..3dfcd03 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -5,7 +5,7 @@ class Organization < ApplicationRecord validates :name, presence: true - def self.ransackable_attributes(auth_object = nil) - ["created_at", "email", "fax", "full_address", "id", "name", "phone", "updated_at", "zip_code"] + def self.ransackable_attributes(_auth_object = nil) + ['created_at', 'email', 'fax', 'full_address', 'id', 'name', 'phone', 'updated_at', 'zip_code'] end end diff --git a/app/models/server.rb b/app/models/server.rb index 73e12cf..092bce0 100644 --- a/app/models/server.rb +++ b/app/models/server.rb @@ -6,8 +6,17 @@ class Server < ApplicationRecord has_many :channels - validates :ip_adress, + validates :name, :service, :room, presence: true + validates :ip_address, presence: true, uniqueness: true, format: { with: Resolv::IPv4::Regex } + + def self.ransackable_attributes(_auth_object = nil) + ['created_at', 'id', 'inventory_id', 'ip_address', 'name', 'room_id', 'service_id', 'updated_at'] + end + + def self.ransackable_associations(_auth_object = nil) + ['channels', 'room', 'service'] + end end diff --git a/app/views/admin/building/index.html.erb b/app/views/admin/building/index.html.erb index ee80518..5553e11 100644 --- a/app/views/admin/building/index.html.erb +++ b/app/views/admin/building/index.html.erb @@ -30,47 +30,46 @@ <%= render 'shared/modal_button_add', path: new_admin_building_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
-
- - - - - - - - - - - <% @buildings.each do |building| %> - - - - <% if building.organization.nil? %> - - <% else %> - - <% end %> - <% if building.description.nil? %> - - <% else %> - - <% end %> - +
+
+
+
<%= t('activerecord.attributes.building.id') %><%= t('activerecord.attributes.building.name') %><%= t('activerecord.attributes.building.organization') %><%= t('activerecord.attributes.building.description') %><%= t('action') %>
<%= building.id %><%= building.name %><%= "——" %><%= building.organization.name %><%= "——" %><%= building.description %> -
- <%= link_to edit_admin_building_path(building.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_building_path(building.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: Building.count %> + + + + + + + + <%= render 'shared/ui/table/header/action'%> - <% end %> - -
<%= t('activerecord.attributes.building.id') %><%= t('activerecord.attributes.building.name') %><%= t('activerecord.attributes.building.organization') %><%= t('activerecord.attributes.building.description') %>
+ + + <% @buildings.each do |building| %> + + <%= building.id %> + <%= building.name %> + <% if building.organization.nil? %> + <%= "——" %> + <% else %> + <%= building.organization.name %> + <% end %> + <% if building.description.nil? %> + <%= "——" %> + <% else %> + <%= building.description %> + <% end %> + + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_building_path(building.id), + destroy_path: admin_building_path(building.id) %> + + <% end %> + + +
diff --git a/app/views/admin/channel/create.turbo_stream.erb b/app/views/admin/channel/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/channel/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/channel/edit.turbo_stream.erb b/app/views/admin/channel/edit.turbo_stream.erb new file mode 100644 index 0000000..fd44313 --- /dev/null +++ b/app/views/admin/channel/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('.edit_channel') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/channel", + locals: { path: admin_channel_path(@channel), channel: @channel } %> diff --git a/app/views/admin/channel/index.html.erb b/app/views/admin/channel/index.html.erb new file mode 100644 index 0000000..3de3133 --- /dev/null +++ b/app/views/admin/channel/index.html.erb @@ -0,0 +1,124 @@ +<% provide :page_title, "Точки контроля" %> +<%= render 'shared/admin/navbar/admin', selected: "asrc" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/asrc_navbar', selected: "channel" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_channel_index_path, method: :get, class: "rounded accordion-body") do |f| %> +
+ <%= f.label :id, class: "mb-1" %> + <%= f.search_field :id_eq, class:"form-control mb-2", placeholder:"ID" %> + + <%= f.label :channel_id, class: "mb-1" %> + <%= f.search_field :channel_id_eq, class:"form-control mb-2", placeholder:"25" %> + + <%= f.label :server_id, class: "mb-1" %> + <%= f.collection_select(:server_id_eq, Server.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select mb-2'}) %> + + <%= f.label :control_point_id, class: "mb-1" %> + <%= f.collection_select(:control_point_id_eq, ControlPoint.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select mb-2'}) %> + + <%= f.label :service_id, class: "mb-1" %> + <%= f.collection_select(:service_id_eq, Service.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select mb-2'}) %> +
+ <%= f.submit t('b_accept'), class: 'btn btn-primary w-100 my-2'%> +
+ <%= t("b_clear")%> +
+ <% end %> +
+
+
+ <%= render 'shared/modal_button_add', path: new_admin_channel_path, classes: "btn btn-primary w-100", text: t("b_add") %> +
+
+
+
+ + <%= render 'shared/ui/table/caption/all_items', + count: Channel.count %> + + + + + + + + + + + + + + + <%= render 'shared/ui/table/header/action'%> + + + + <% @channels.each do |channel| %> + + + + + <% if channel.control_point.nil? %> + + <% else %> + + + + + + + + + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_channel_path(channel.id), + destroy_path: admin_channel_path(channel.id) %> + + <% end %> + +
<%= t('activerecord.attributes.channel.id') %><%= t('activerecord.attributes.channel.channel_id')%><%= t('activerecord.attributes.channel.server')%><%= t('activerecord.attributes.channel.control_point.name')%><%= t('activerecord.attributes.channel.location_description')%><%= t('activerecord.attributes.channel.self_background')%><%= t('activerecord.attributes.channel.pre_emergency_limit')%><%= t('activerecord.attributes.channel.emergency_limit')%><%= t('activerecord.attributes.channel.consumption')%><%= t('activerecord.attributes.channel.conversion_coefficient')%><%= t('activerecord.attributes.channel.service')%>
<%= channel.id %><%= channel.channel_id %><%= channel.server.name %><%= "——" %><%= channel.control_point.name %> + <% end %> + <%= channel.location_description %><%= channel.self_background %><%= channel.pre_emergency_limit %><%= channel.emergency_limit %><%= channel.consumption %><%= channel.conversion_coefficient %><%= channel.service.name %>
+
+
+
+
+ +
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/channel/new.turbo_stream.erb b/app/views/admin/channel/new.turbo_stream.erb new file mode 100644 index 0000000..2cf090d --- /dev/null +++ b/app/views/admin/channel/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.channel.new.add_channel') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/channel", + locals: {path: admin_channel_index_path, channel: @channel } %> diff --git a/app/views/admin/channel/update.turbo_stream.erb b/app/views/admin/channel/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/channel/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/control_point/index.html.erb b/app/views/admin/control_point/index.html.erb index 2ae22b5..508fe67 100644 --- a/app/views/admin/control_point/index.html.erb +++ b/app/views/admin/control_point/index.html.erb @@ -17,8 +17,8 @@ <%= f.label :name, class: "mb-2" %> <%= f.search_field :name_cont, class:"form-control", placeholder:"Название" %> <%= f.label :room_id, class:"mb-1" %> - <%= f.collection_select(:room_id_eq, Room.all, - :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select'}) %> + <%= f.collection_select(:room_id_eq, Room.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select'}) %> <%= f.submit t('b_accept'), class: 'btn btn-primary w-100 my-2'%>
@@ -30,53 +30,51 @@
<%= render 'shared/modal_button_add', path: new_admin_control_point_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
- - - - - - - - - - - - <% @control_points.each do |control_point| %> - - - <% if control_point.room.nil? %> - - <% else %> - - <% end %> - <% if control_point.device.nil? %> - - <% else %> - - <% end %> - <% if control_point.description.nil? %> - - <% else %> - - <% end %> - +
+
+
+
<%= t('activerecord.attributes.control_point.name') %><%= t('activerecord.attributes.control_point.room') %><%= t('activerecord.attributes.control_point.device') %><%= t('activerecord.attributes.control_point.description') %><%= t('action') %>
<%= control_point.name %><%= "——" %><%= control_point.room.name %><%= "——" %> - <%= button_to "(#{sprintf("%05d", control_point.device.tabel_id)}) #{control_point.device.device_model.name}", admin_device_path(control_point.device.id), method: :get, class: "btn btn-light btn-sm" %> - <%= "——" %><%= control_point.description %> -
- <%= link_to edit_admin_control_point_path(control_point.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_control_point_path(control_point.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: ControlPoint.count %> + + + + + + + <%= render 'shared/ui/table/header/action'%> - <% end %> - -
<%= t('activerecord.attributes.control_point.name') %><%= t('activerecord.attributes.control_point.room') %><%= t('activerecord.attributes.control_point.device') %><%= t('activerecord.attributes.control_point.description') %>
+ + + <% @control_points.each do |control_point| %> + + <%= control_point.name %> + <% if control_point.room.nil? %> + <%= "——" %> + <% else %> + <%= control_point.room.name %> + <% end %> + <% if control_point.device.nil? %> + <%= "——" %> + <% else %> + + <%= button_to "(#{sprintf("%05d", control_point.device.tabel_id)}) #{control_point.device.device_model.name}", admin_device_path(control_point.device.id), method: :get, class: "btn btn-light btn-sm" %> + + <% end %> + <% if control_point.description.nil? %> + <%= "——" %> + <% else %> + <%= control_point.description %> + <% end %> + + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_control_point_path(control_point.id), + destroy_path: admin_control_point_path(control_point.id) %> + + <% end %> + + +
diff --git a/app/views/admin/device_component/index.html.erb b/app/views/admin/device_component/index.html.erb index 6494867..3e01fe1 100644 --- a/app/views/admin/device_component/index.html.erb +++ b/app/views/admin/device_component/index.html.erb @@ -36,49 +36,47 @@ <%= render 'shared/modal_button_add', path: new_admin_device_component_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %> -
-
- - - - - - - - - - - - - - - <% @device_components.each do |device_component| %> - - - - <% if device_component.supplementary_kit.nil? %> - - <% else %> - - <% end %> - - - - - +
+
+
+
<%= t('activerecord.attributes.device_component.serial_id')%><%= t('activerecord.attributes.device_component.name')%><%= t('activerecord.attributes.device_component.supplementary_kit')%><%= t('activerecord.attributes.device_component.measurement_min')%><%= t('activerecord.attributes.device_component.measurement_max')%><%= t('activerecord.attributes.device_component.measuring_unit')%><%= t('activerecord.attributes.device_component.description')%><%= t('action')%>
<%= device_component.serial_id %><%= device_component.name %><%= device_component.supplementary_kit.name %><%= device_component.measurement_min %><%= device_component.measurement_max %><%= device_component.measuring_unit %><%= device_component.description %> -
- <%= link_to edit_admin_device_component_path(device_component.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_device_component_path(device_component.id), method: :delete, form: { data: { turbo_confirm: t('delete_confirm') } }, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: DeviceComponent.count %> + + + + + + + + + + <%= render 'shared/ui/table/header/action'%> - <% end %> - -
<%= t('activerecord.attributes.device_component.serial_id')%><%= t('activerecord.attributes.device_component.name')%><%= t('activerecord.attributes.device_component.supplementary_kit')%><%= t('activerecord.attributes.device_component.measurement_min')%><%= t('activerecord.attributes.device_component.measurement_max')%><%= t('activerecord.attributes.device_component.measuring_unit')%><%= t('activerecord.attributes.device_component.description')%>
+ + + <% @device_components.each do |device_component| %> + + <%= device_component.serial_id %> + <%= device_component.name %> + <% if device_component.supplementary_kit.nil? %> + + <% else %> + <%= device_component.supplementary_kit.name %> + <% end %> + <%= device_component.measurement_min %> + <%= device_component.measurement_max %> + <%= device_component.measuring_unit %> + <%= device_component.description %> + + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_device_component_path(device_component.id), + destroy_path: admin_device_component_path(device_component.id) %> + + <% end %> + + +
diff --git a/app/views/admin/device_model/index.html.erb b/app/views/admin/device_model/index.html.erb index 1dbb858..64fe22b 100644 --- a/app/views/admin/device_model/index.html.erb +++ b/app/views/admin/device_model/index.html.erb @@ -55,9 +55,12 @@ <%= render 'shared/modal_button_add', path: new_admin_device_model_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %> -
+
+
+ <%= render 'shared/ui/table/caption/all_items', + count: DeviceModel.count %> @@ -94,6 +97,7 @@
<%= t('activerecord.attributes.device_model.name')%>
+
diff --git a/app/views/admin/device_reg_group/index.html.erb b/app/views/admin/device_reg_group/index.html.erb index b713ec5..3925556 100644 --- a/app/views/admin/device_reg_group/index.html.erb +++ b/app/views/admin/device_reg_group/index.html.erb @@ -29,33 +29,31 @@ <%= render 'shared/modal_button_add', path: new_admin_device_reg_group_path, classes: "btn btn-primary w-100", text: t("b_add") %>
-
-
- - - - - - - - - <% @device_reg_groups.each do |device_reg_group| %> +
+
+
+
<%= t('activerecord.attributes.device_reg_group.name') %><%= t('action')%>
+ <%= render 'shared/ui/table/caption/all_items', + count: @device_reg_groups.count %> + - - + + + <%= render 'shared/ui/table/header/action' %> - <% end %> - -
<%= device_reg_group.name %> -
- <%= link_to edit_admin_device_reg_group_path(device_reg_group.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_device_reg_group_path(device_reg_group.id), method: :delete, class: "btn" do %> - - <% end %> -
-
<%= t('activerecord.attributes.device_reg_group.name') %>
+ + + <% @device_reg_groups.each do |device_reg_group| %> + + <%= device_reg_group.name %> + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_device_reg_group_path(device_reg_group.id), + destroy_path: admin_device_reg_group_index_path(device_reg_group.id) %> + + <% end %> + + +
diff --git a/app/views/admin/division/index.html.erb b/app/views/admin/division/index.html.erb index 503b954..51f2182 100644 --- a/app/views/admin/division/index.html.erb +++ b/app/views/admin/division/index.html.erb @@ -30,41 +30,38 @@ <%= render 'shared/modal_button_add', path: new_admin_division_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
- - - - - - - - - - - <% @divisions.each do |division| %> - - - - <% if division.organization.nil? %> - - <% else %> - - <% end %> - +
+
+
+
<%= t('activerecord.attributes.division.id') %><%= t('activerecord.attributes.division.name') %><%= t('activerecord.attributes.division.organization') %><%= t('action') %>
<%= division.id %><%= division.name %><%= "——" %><%= division.organization.name %> -
- <%= link_to edit_admin_division_path(division.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_division_path(division.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: Division.count %> + + + + + + <%= render 'shared/ui/table/header/action' %> - <% end %> - -
<%= t('activerecord.attributes.division.id') %><%= t('activerecord.attributes.division.name') %><%= t('activerecord.attributes.division.organization') %>
+ + + <% @divisions.each do |division| %> + + <%= division.id %> + <%= division.name %> + <% if division.organization.nil? %> + <%= "——" %> + <% else %> + <%= division.organization.name %> + <% end %> + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_division_path(division.id), + destroy_path: admin_division_path(division.id) %> + + <% end %> + + +
diff --git a/app/views/admin/manufacturer/index.html.erb b/app/views/admin/manufacturer/index.html.erb index fc946f3..2bd9711 100644 --- a/app/views/admin/manufacturer/index.html.erb +++ b/app/views/admin/manufacturer/index.html.erb @@ -35,41 +35,40 @@ <%= render 'shared/modal_button_add', path: new_admin_manufacturer_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %> -
-
- - - - - - - - - - - - - <% @manufacturers.each do |manufacturer| %> - - - - - - - +
+
+
+
<%= t('activerecord.attributes.manufacturer.name') %><%= t('activerecord.attributes.manufacturer.adress') %><%= t('activerecord.attributes.manufacturer.phone') %><%= t('activerecord.attributes.manufacturer.email') %><%= t('activerecord.attributes.manufacturer.site_url') %><%= t('action') %>
<%= manufacturer.name %><%= manufacturer.adress %><%= manufacturer.phone %><%= manufacturer.email %><%= manufacturer.site_url %> -
- <%= link_to edit_admin_manufacturer_path(manufacturer.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_manufacturer_path(manufacturer.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: Manufacturer.count %> + + + + + + + + + <%= render 'shared/ui/table/header/action' %> - <% end %> - -
<%= t('activerecord.attributes.manufacturer.name') %><%= t('activerecord.attributes.manufacturer.adress') %><%= t('activerecord.attributes.manufacturer.phone') %><%= t('activerecord.attributes.manufacturer.email') %><%= t('activerecord.attributes.manufacturer.site_url') %>
+ + + <% @manufacturers.each do |manufacturer| %> + + <%= manufacturer.name %> + <%= manufacturer.adress %> + <%= manufacturer.phone %> + <%= manufacturer.email %> + <%= manufacturer.site_url %> + + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_manufacturer_path(manufacturer.id), + destroy_path: admin_manufacturer_path(manufacturer.id) %> + + <% end %> + + +
diff --git a/app/views/admin/measurement_class/index.html.erb b/app/views/admin/measurement_class/index.html.erb index 6364567..538a202 100644 --- a/app/views/admin/measurement_class/index.html.erb +++ b/app/views/admin/measurement_class/index.html.erb @@ -32,37 +32,36 @@ <%= render 'shared/modal_button_add', path: new_admin_measurement_class_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
- - - - - - - - - - - <% @measurement_classes.each do |measurement_class| %> - - - - - + +
+
+
+
<%= t('activerecord.attributes.measurement_class.name') %><%= t('activerecord.attributes.measurement_class.arms_device_type') %><%= t('activerecord.attributes.measurement_class.measurement_group') %><%= t('action') %>
<%= measurement_class.name %><%= measurement_class.arms_device_type %><%= measurement_class.measurement_group.name %> -
- <%= link_to edit_admin_measurement_class_path(measurement_class.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_measurement_class_path(measurement_class.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: MeasurementClass.count %> + + + + + + + <%= render 'shared/ui/table/header/action' %> - <% end %> - -
<%= t('activerecord.attributes.measurement_class.name') %><%= t('activerecord.attributes.measurement_class.arms_device_type') %><%= t('activerecord.attributes.measurement_class.measurement_group') %>
+ + + <% @measurement_classes.each do |measurement_class| %> + + <%= measurement_class.name %> + <%= measurement_class.arms_device_type %> + <%= measurement_class.measurement_group.name %> + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_measurement_class_path(measurement_class.id), + destroy_path: admin_measurement_class_path(measurement_class.id) %> + + <% end %> + + +
diff --git a/app/views/admin/measurement_group/index.html.erb b/app/views/admin/measurement_group/index.html.erb index 7869bed..3c99a79 100644 --- a/app/views/admin/measurement_group/index.html.erb +++ b/app/views/admin/measurement_group/index.html.erb @@ -27,33 +27,30 @@ <%= render 'shared/modal_button_add', path: new_admin_measurement_group_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
- - - - - - - - - <% @measurement_groupes.each do |measurement_group| %> - - - +
+
+
+
<%= t('activerecord.attributes.measurement_group.name') %><%= t('action') %>
<%= measurement_group.name %> -
- <%= link_to edit_admin_measurement_group_path(measurement_group.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_measurement_group_path(measurement_group.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: MeasurementGroup.count %> + + + + <%= render 'shared/ui/table/header/action' %> - <% end %> - -
<%= t('activerecord.attributes.measurement_group.name') %>
+ + + <% @measurement_groupes.each do |measurement_group| %> + + <%= measurement_group.name %> + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_measurement_group_path(measurement_group.id), + destroy_path: admin_measurement_group_path(measurement_group.id) %> + + <% end %> + + +
diff --git a/app/views/admin/organization/index.html.erb b/app/views/admin/organization/index.html.erb index 45d93c2..07ae7fb 100644 --- a/app/views/admin/organization/index.html.erb +++ b/app/views/admin/organization/index.html.erb @@ -37,65 +37,69 @@ <%= render 'shared/modal_button_add', path: new_admin_organization_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
- - - - - - - - - - - - - - - <% @organizations.each do |organization| %> - - - - <% if organization.full_address.nil? %> - - <% else %> - - <% end %> - <% if organization.zip_code.nil? %> - - <% else %> - - <% end %> - <% if organization.phone.nil? %> - - <% else %> - - <% end %> - <% if organization.fax.nil? %> - - <% else %> - - <% end %> - <% if organization.email.nil? %> - - <% else %> - - <% end %> - +
+
+
+
<%= t('activerecord.attributes.organization.id') %><%= t('activerecord.attributes.organization.name') %><%= t('activerecord.attributes.organization.full_address') %><%= t('activerecord.attributes.organization.zip_code') %><%= t('activerecord.attributes.organization.phone') %><%= t('activerecord.attributes.organization.fax') %><%= t('activerecord.attributes.organization.email') %><%= t('action') %>
<%= organization.id %><%= organization.name %><%= "——" %><%= organization.full_address %><%= "——" %><%= organization.zip_code %><%= "——" %><%= organization.phone %><%= "——" %><%= organization.fax %><%= "——" %><%= organization.email %> -
- <%= link_to edit_admin_organization_path(organization.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_organization_path(organization.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: Organization.count %> + + + + + + + + + + - <% end %> - -
<%= t('activerecord.attributes.organization.id') %><%= t('activerecord.attributes.organization.name') %><%= t('activerecord.attributes.organization.full_address') %><%= t('activerecord.attributes.organization.zip_code') %><%= t('activerecord.attributes.organization.phone') %><%= t('activerecord.attributes.organization.fax') %><%= t('activerecord.attributes.organization.email') %><%= t('action') %>
+ + + <% @organizations.each do |organization| %> + + <%= organization.id %> + <%= organization.name %> + <% if organization.full_address.nil? %> + <%= "——" %> + <% else %> + <%= organization.full_address %> + <% end %> + <% if organization.zip_code.nil? %> + <%= "——" %> + <% else %> + <%= organization.zip_code %> + <% end %> + <% if organization.phone.nil? %> + <%= "——" %> + <% else %> + <%= organization.phone %> + <% end %> + <% if organization.fax.nil? %> + <%= "——" %> + <% else %> + <%= organization.fax %> + <% end %> + <% if organization.email.nil? %> + <%= "——" %> + <% else %> + <%= organization.email %> + <% end %> + +
+ <%= link_to edit_admin_organization_path(organization.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> + + <% end %> + <%= button_to admin_organization_path(organization.id), method: :delete, class: "btn" do %> + + <% end %> +
+ + + <% end %> + + +
diff --git a/app/views/admin/room/index.html.erb b/app/views/admin/room/index.html.erb index 351440e..797bcb9 100644 --- a/app/views/admin/room/index.html.erb +++ b/app/views/admin/room/index.html.erb @@ -32,49 +32,46 @@ <%= render 'shared/modal_button_add', path: new_admin_room_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
- - - - - - - - - - - - - <% @rooms.each do |room| %> - - - - - <% if room.level.nil? %> - - <% else %> - - <% end %> - <% if room.description.nil? %> - - <% else %> - - <% end %> - +
+
+
+
<%= t('activerecord.attributes.room.id') %><%= t('activerecord.attributes.room.name') %><%= t('activerecord.attributes.room.building') %><%= t('activerecord.attributes.room.level') %><%= t('activerecord.attributes.room.description') %><%= t('action') %>
<%= room.id %><%= room.name %><%= room.building.name %><%= "——" %><%= room.level %><%= "——" %><%= room.description %> -
- <%= link_to edit_admin_room_path(room.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_room_path(room.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: Room.count %> + + + + + + + + <%= render 'shared/ui/table/header/action'%> - <% end %> - -
<%= t('activerecord.attributes.room.id') %><%= t('activerecord.attributes.room.name') %><%= t('activerecord.attributes.room.building') %><%= t('activerecord.attributes.room.level') %><%= t('activerecord.attributes.room.description') %>
+ + + <% @rooms.each do |room| %> + + <%= room.id %> + <%= room.name %> + <%= room.building.name %> + <% if room.level.nil? %> + <%= "——" %> + <% else %> + <%= room.level %> + <% end %> + <% if room.description.nil? %> + <%= "——" %> + <% else %> + <%= room.description %> + <% end %> + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_room_path(room.id), + destroy_path: admin_room_path(room.id) %> + + <% end %> + + +
diff --git a/app/views/admin/server/create.turbo_stream.erb b/app/views/admin/server/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/server/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/server/edit.turbo_stream.erb b/app/views/admin/server/edit.turbo_stream.erb new file mode 100644 index 0000000..3874fd9 --- /dev/null +++ b/app/views/admin/server/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.server.edit') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/server", + locals: { path: admin_server_path(@server), server: @server } %> diff --git a/app/views/admin/server/index.html.erb b/app/views/admin/server/index.html.erb new file mode 100644 index 0000000..16d3282 --- /dev/null +++ b/app/views/admin/server/index.html.erb @@ -0,0 +1,125 @@ +<% provide :page_title, "Службы" %> +<%= render 'shared/admin/navbar/admin', selected: "asrc" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/asrc_navbar', selected: "server" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_server_index_path, method: :get, class: "rounded accordion-body") do |f| %> +
+ <%= f.label :name, class: "mb-1" %> + <%= f.search_field :name_cont, class:"form-control mb-2", placeholder:"Название" %> + <%= f.label :ip_address, class: "mb-1" %> + <%= f.search_field :ip_address_cont, class:"form-control mb-2", placeholder:"192.168.1.101" %> + <%= f.label :inventory_id, class: "mb-1"%> + <%= f.search_field :inventory_id_cont, class:"form-control mb-2", placeholder:"4321" %> + + <%= f.label :service_id, class: "mb-1" %> + <%= f.collection_select(:service_id_eq, Service.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class =>'form-select mb-2'}) %> + <%= f.label :room_id, class: "mb-1" %> + <%= f.collection_select(:room_id_eq, Service.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class =>'form-select mb-2'}) %> +
+ <%= f.submit t('b_accept'), class: 'btn btn-primary w-100 my-2'%> +
+ <%= t("b_clear")%> +
+ <% end %> +
+
+
+ <%= render 'shared/modal_button_add', path: new_admin_server_path, classes: "btn btn-primary w-100", text: t("b_add") %> +
+
+
+
+ + <%= render 'shared/ui/table/caption/all_items', + count: Server.count %> + + + + + + + + + <%= render 'shared/ui/table/header/action' %> + + + + <% @servers.each do |server| %> + + + + + <% if server.ip_address.nil? %> + + <% else %> + + <% end %> + + <% if server.inventory_id.nil? %> + + <% else %> + + <% end %> + + <% if server.service.nil? %> + + <% else %> + + <% end %> + + <% if server.room.nil? %> + + <% else %> + + <% end %> + + <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_server_path(server.id), + destroy_path: admin_server_path(server.id) %> + + <% end %> + +
<%= t('activerecord.attributes.server.id') %><%= t('activerecord.attributes.server.name') %><%= t('activerecord.attributes.server.ip_address') %><%= t('activerecord.attributes.server.inventory_id') %><%= t('activerecord.attributes.server.service') %><%= t('activerecord.attributes.server.room') %>
<%= server.id %><%= server.name %><%= "——" %><%= server.ip_address %><%= "——" %><%= server.inventory_id %><%= "——" %><%= server.service.name %><%= "——" %><%= server.room.name %>
+
+
+
+
+ +
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/server/new.turbo_stream.erb b/app/views/admin/server/new.turbo_stream.erb new file mode 100644 index 0000000..c4ce362 --- /dev/null +++ b/app/views/admin/server/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.server.new') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/server", + locals: { path: admin_server_index_path, server: @server } %> diff --git a/app/views/admin/server/update.turbo_stream.erb b/app/views/admin/server/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/server/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/service/index.html.erb b/app/views/admin/service/index.html.erb index 7c2cc5d..c32eab3 100644 --- a/app/views/admin/service/index.html.erb +++ b/app/views/admin/service/index.html.erb @@ -34,57 +34,54 @@ <%= render 'shared/modal_button_add', path: new_admin_service_path, classes: "btn btn-primary w-100", text: t("b_add") %> -
-
- - - - - - - - - - - - - <% @services.each do |service| %> - - - +
+
+
+
<%= t('activerecord.attributes.service.id') %><%= t('activerecord.attributes.service.name') %><%= t('activerecord.attributes.service.division') %><%= t('activerecord.attributes.service.organization') %><%= t('activerecord.attributes.service.building') %><%= t('action') %>
<%= service.id %><%= service.name %>
+ <%= render 'shared/ui/table/caption/all_items', + count: Service.count %> + + + + + + + + <%= render 'shared/ui/table/header/action' %> + + + + <% @services.each do |service| %> + + + - <% if service.division.nil? %> - - <% else %> - - <% end %> + <% if service.division.nil? %> + + <% else %> + + <% end %> - <% if service.organization.nil? %> - - <% else %> - - <% end %> + <% if service.organization.nil? %> + + <% else %> + + <% end %> - <% if service.building.nil? %> - - <% else %> - - <% end %> + <% if service.building.nil? %> + + <% else %> + + <% end %> - - - <% end %> - -
<%= t('activerecord.attributes.service.id') %><%= t('activerecord.attributes.service.name') %><%= t('activerecord.attributes.service.division') %><%= t('activerecord.attributes.service.organization') %><%= t('activerecord.attributes.service.building') %>
<%= service.id %><%= service.name %><%= "——" %><%= service.division.name %><%= "——" %><%= service.division.name %><%= "——" %><%= service.organization.name %><%= "——" %><%= service.organization.name %><%= "——" %><%= service.building.name %><%= "——" %><%= service.building.name %> -
- <%= link_to edit_admin_service_path(service.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %> - - <% end %> - <%= button_to admin_service_path(service.id), method: :delete, class: "btn" do %> - - <% end %> -
-
+ <%= render 'shared/ui/table/cell/action', + edit_path: edit_admin_service_path(service.id), + destroy_path: admin_service_path(service.id) %> + + <% end %> + + +
diff --git a/app/views/admin/supplementary_kit/index.html.erb b/app/views/admin/supplementary_kit/index.html.erb index f3dd2df..e58ff17 100644 --- a/app/views/admin/supplementary_kit/index.html.erb +++ b/app/views/admin/supplementary_kit/index.html.erb @@ -32,40 +32,42 @@ <%= render 'shared/modal_button_add', path: new_admin_supplementary_kit_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %> -
-
- <% @supplementary_kits.each do |supplementary_kit| %> - <% sk_text = "Kit#{supplementary_kit.id}" %> -
-
-

- -

-
-
- <% device_components_in_this_sk = supplementary_kit.device_components %> - <% if device_components_in_this_sk.length > 0 %> -

<%= t('activerecord.models.device_component')%>:

- <%= render 'shared/show/supplementary_kit', device_components: device_components_in_this_sk %> - <% end %> -

- <%= t('activerecord.attributes.supplementary_kit.description')%>: <%= supplementary_kit.description %> -

-
-
- <%= link_to t('b_change'), edit_admin_supplementary_kit_path(supplementary_kit), class: "btn btn-primary", data: { action: "click->modal#open", turbo_stream: "" }%> -
-
- <%= button_to t('b_delete'), admin_supplementary_kit_path(supplementary_kit), method: :delete, class: "btn btn-danger"%> +
+
+
+ <% @supplementary_kits.each do |supplementary_kit| %> + <% sk_text = "Kit#{supplementary_kit.id}" %> +
+
+

+ +

+
+
+ <% device_components_in_this_sk = supplementary_kit.device_components %> + <% if device_components_in_this_sk.length > 0 %> +

<%= t('activerecord.models.device_component')%>:

+ <%= render 'shared/show/supplementary_kit', device_components: device_components_in_this_sk %> + <% end %> +

+ <%= t('activerecord.attributes.supplementary_kit.description')%>: <%= supplementary_kit.description %> +

+
+
+ <%= link_to t('b_change'), edit_admin_supplementary_kit_path(supplementary_kit), class: "btn btn-primary", data: { action: "click->modal#open", turbo_stream: "" }%> +
+
+ <%= button_to t('b_delete'), admin_supplementary_kit_path(supplementary_kit), method: :delete, class: "btn btn-danger"%> +
+ <% end %>
- <% end %>
diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index b537902..7c11093 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -62,53 +62,57 @@ <%= t('b_add')%> <% end %>
-
-
- - - - - - - - - - - - - - - - - - <% @users.each do |user| %> - - - - - - - - - - - - +
+
+
+
<%=t('activerecord.attributes.user.tabel_id')%><%=t('activerecord.attributes.user.last_name')%><%=t('activerecord.attributes.user.first_name')%><%=t('activerecord.attributes.user.second_name')%><%=t('activerecord.attributes.user.role')%><%=t('activerecord.attributes.user.email')%><%=t('activerecord.attributes.user.phone')%><%=t('activerecord.attributes.user.service')%><%=t('created_at')%><%=t('updated_at')%><%=t('action')%>
<%= user.tabel_id %><%= user.last_name %><%= user.first_name %><%= user.second_name %><%= user.role %><%= user.email %><%= user.phone %><%= user.service.name %><%= formatted_date(user.created_at, :short_full) %><%= formatted_date(user.updated_at, :short_full) %> -
- <%= link_to edit_admin_user_path(user), class: "btn" do %> - - <% end %> - <% unless user.id == current_user.id %> - <%= button_to admin_user_path(user), method: :delete, class: "btn" do %> - - <% end %> - <% end %> -
-
+ <%= render 'shared/ui/table/caption/all_items', + count: User.count %> + + + + + + + + + + + + + <%= render 'shared/ui/table/header/action' %> - <% end %> - -
<%=t('activerecord.attributes.user.tabel_id')%><%=t('activerecord.attributes.user.last_name')%><%=t('activerecord.attributes.user.first_name')%><%=t('activerecord.attributes.user.second_name')%><%=t('activerecord.attributes.user.role')%><%=t('activerecord.attributes.user.email')%><%=t('activerecord.attributes.user.phone')%><%=t('activerecord.attributes.user.service')%><%=t('created_at')%><%=t('updated_at')%>
+ + + <% @users.each do |user| %> + + <%= user.tabel_id %> + <%= user.last_name %> + <%= user.first_name %> + <%= user.second_name %> + <%= user.role %> + <%= user.email %> + <%= user.phone %> + <%= user.service.name %> + <%= formatted_date(user.created_at, :short_full) %> + <%= formatted_date(user.updated_at, :short_full) %> + +
+ <%= link_to edit_admin_user_path(user), class: "btn btn-sm" do %> + + <% end %> + <% unless user.id == current_user.id %> + <%= button_to admin_user_path(user), method: :delete, class: "btn btn-sm" do %> + + <% end %> + <% end %> +
+ + + <% end %> + + +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ce2fb7b..621e5f1 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -26,7 +26,7 @@ <% if can? :read, :armstrong %> <%= link_to armstrong_index_path, class: "nav-link px-2 link-secondary position-relative" do %> <%= t(".ARMS") %> - + β Этот раздел в разработке @@ -35,8 +35,14 @@
  • <% if can? :read, Device %> - <%= link_to t(".devices"), device_index_path, class: "nav-link px-2 link-secondary" %> - <%end%> + <%= link_to device_index_path, class: "nav-link px-2 link-secondary position-relative" do %> + <%= t(".devices") %> + + β + Этот раздел в разработке + + <% end %> + <% end %>
  • <% if can? :read, Inspection %> diff --git a/app/views/shared/admin/form/_channel.html.erb b/app/views/shared/admin/form/_channel.html.erb new file mode 100644 index 0000000..e496f02 --- /dev/null +++ b/app/views/shared/admin/form/_channel.html.erb @@ -0,0 +1,91 @@ +<%= simple_form_for channel, as: :channel, url: path, + class: "form-group row" do |f| %> + + + +
    +
    +
    + <%= f.label :channel_id %> +
    +
    + <%= f.input :channel_id, label: false, placeholder: t('.placeholders.channel_id'), input_html: {:tabindex => 1} %> +
    +
    +
    +
    + <%= f.label :server%> +
    +
    +
    + <%= f.association :server, label: false, input_html: {:tabindex => 2}, include_blank: false %> +
    +
    + <%= render 'shared/modal_button_add', path: new_admin_server_path, classes: "btn btn-ligth", text: nil %> +
    +
    +
    +
    + +
    +
    +
    + <%= f.label :location_description %> +
    +
    + <%= f.input :location_description, as: :string, label: false, placeholder: t('.placeholders.location_description'), input_html: {:tabindex => 3} %> +
    +
    +
    +
    + <%= f.label :control_point, label_method: :name %> +
    +
    +
    + <%= f.association :control_point, label: false, input_html: {:tabindex => 4}, include_blank: false %> +
    +
    + <%= render 'shared/modal_button_add', path: new_admin_control_point_path, classes: "btn btn-ligth", text: nil %> +
    +
    +
    +
    + +
    +
    + <%= f.input :self_background, placeholder: t('.placeholders.self_background'), input_html: {:tabindex => 5} %> +
    +
    + <%= f.input :consumption, placeholder: t('.placeholders.consumption'), input_html: {:tabindex => 6} %> +
    +
    + <%= f.input :conversion_coefficient, placeholder: t('.placeholders.conversion_coefficient'), input_html: {:tabindex => 7} %> +
    +
    + +
    +
    + <%= f.input :pre_emergency_limit, placeholder: t('.placeholders.pre_emergency_limit'), input_html: {:tabindex => 8} %> +
    +
    + <%= f.input :emergency_limit, placeholder: t('.placeholders.emergency_limit'), input_html: {:tabindex => 9} %> +
    +
    + + <% if current_user.admin? %> +
    + <%= f.association :service, input_html: { :tabindex => 10 }, include_blank: false %> +
    + <% end %> + + <%= render 'shared/form/actions', f:f %> +<% end %> diff --git a/app/views/shared/admin/form/_control_point.html.erb b/app/views/shared/admin/form/_control_point.html.erb index 495c456..888a422 100644 --- a/app/views/shared/admin/form/_control_point.html.erb +++ b/app/views/shared/admin/form/_control_point.html.erb @@ -13,9 +13,10 @@
  • <%= f.input :description, placeholder: 'Описание точки контроля', input_html: {:tabindex => 4}%> + <%= f.association :device, label_method: :tabel_id, input_html: {:tabindex => 3} %> <% if current_user.admin? %>
    - <%= f.association :service, input_html: {:tabindex => 9}, include_blank: false %> + <%= f.association :service, input_html: {:tabindex => 4}, include_blank: false %>
    <% else %> <%= f.input :service_id, label: false, input_html: {hidden: true, value: current_user.service_id} %> diff --git a/app/views/shared/admin/form/_server.html.erb b/app/views/shared/admin/form/_server.html.erb new file mode 100644 index 0000000..69d3663 --- /dev/null +++ b/app/views/shared/admin/form/_server.html.erb @@ -0,0 +1,12 @@ +<%= simple_form_for server, as: :server, url: path, + class: "form-group row" do |f| %> +
    + <%= f.input :name, placeholder: 'Название службы', input_html: {:tabindex => 1}%> + <%= f.input :ip_address, input_html: { :tabindex => 2}, include_blank: false %> + <%= f.input :inventory_id, input_html: { :tabindex => 3 }, include_blank: false %> + <%= f.association :service, input_html: { :tabindex => 4}, include_blank: false %> + <%= f.association :room, input_html: { :tabindex => 5}, include_blank: false %> +
    + + <%= render 'shared/form/actions', f:f %> +<% end %> diff --git a/app/views/shared/admin/navbar/_admin.html.erb b/app/views/shared/admin/navbar/_admin.html.erb index c4b4588..35550ed 100644 --- a/app/views/shared/admin/navbar/_admin.html.erb +++ b/app/views/shared/admin/navbar/_admin.html.erb @@ -9,4 +9,7 @@ + diff --git a/app/views/shared/admin/navbar/_asrc_navbar.html.erb b/app/views/shared/admin/navbar/_asrc_navbar.html.erb new file mode 100644 index 0000000..60a4ff7 --- /dev/null +++ b/app/views/shared/admin/navbar/_asrc_navbar.html.erb @@ -0,0 +1,13 @@ +
    + <% selected = local_assigns[:selected] %> +
    + <%= link_to admin_channel_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'channel' } text-start" do %> + <%= 'Каналы' %> + <% end %> +
    +
    + <%= link_to admin_server_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'server' } text-start" do %> + <%= 'Серверы' %> + <% end %> +
    +
    diff --git a/app/views/shared/form/_device.html.erb b/app/views/shared/form/_device.html.erb index 83afc6e..6bf8161 100644 --- a/app/views/shared/form/_device.html.erb +++ b/app/views/shared/form/_device.html.erb @@ -49,7 +49,7 @@
    -
    +
    <% if current_user.admin? %>
    <%= f.association :service, input_html: {:tabindex => 9}, include_blank: false %> @@ -57,9 +57,7 @@ <% else %> <%= f.input :service_id, label: false, input_html: {hidden: true, value: current_user.service_id} %> <% end %> -
    - <%= f.association :control_point, input_html: {:tabindex => 10}, include_blank: t('combobox_blank')%> -
    +
    <%= render 'shared/form/actions', f:f %> diff --git a/app/views/shared/index/_device.html.erb b/app/views/shared/index/_device.html.erb index 795cfaa..d73cc3d 100644 --- a/app/views/shared/index/_device.html.erb +++ b/app/views/shared/index/_device.html.erb @@ -73,66 +73,87 @@ <%=t('b_download_pdf')%> <% end %>
    -
    -
    - - - - - - - - - - - <% if current_user.admin? %> - - <% end %> - - - - - - <% @devices.each do |device| %> - <% path = "#{show_path}#{device.id}" %> - - - - - - - <% if device.control_point_id? %> - - - <% else %> - - - <% end %> +
    +
    +
    +
    <%=t('activerecord.attributes.device.tabel_id')%><%=t('activerecord.attributes.device.serial_id')%><%=t('activerecord.attributes.device.device_model')%><%=t('activerecord.attributes.device.year_of_production')%><%=t('activerecord.attributes.device.year_of_commissioning')%><%=t('activerecord.attributes.device.room')%><%=t('activerecord.attributes.device.control_point')%><%=t('activerecord.attributes.device.service')%><%=t('activerecord.attributes.device.date_of_inspection')%>
    <%= device.tabel_id %><%= device.serial_id %><%= device.device_model.name %><%= device.year_of_production %><%= device.year_of_commissioning %><%= device.control_point.room.name %><%= device.control_point.name %><%= "——" %><%= "——" %>
    + <%= render 'shared/ui/table/caption/all_items', + count: Device.count %> + + + + + + + + + + <% if current_user.admin? %> - - <% end %> - <% if device.inspection_expiration_status == Device::INSPECTION_EXPIRATION_STATUS[:verified] %> - - <% elsif device.inspection_expiration_status == Device::INSPECTION_EXPIRATION_STATUS[:prepare_to_inspection] %> - - <% else %> - - <% end %> - <% if device.last_successful_inspection.present? %> - - <% else %> - + <% end %> + - <% end %> - -
    <%=t('activerecord.attributes.device.tabel_id')%><%=t('activerecord.attributes.device.serial_id')%><%=t('activerecord.attributes.device.device_model')%><%=t('activerecord.attributes.device.year_of_production')%><%=t('activerecord.attributes.device.year_of_commissioning')%><%=t('activerecord.attributes.device.room')%><%=t('activerecord.attributes.device.control_point')%><%= device.service.name %> - <%= device.last_successful_inspection %> - - <%= device.last_successful_inspection %> - - <%= device.last_successful_inspection %> - <%=t('activerecord.attributes.device.service')%><%=t('activerecord.attributes.device.date_of_inspection')%>
    + + + <% @devices.each do |device| %> + <% path = "#{show_path}#{device.id}" %> + + <% if device.status == Device::STATUS[:in_storage] %> + + <% elsif device.status == Device::STATUS[:expired] %> + + <% elsif device.status == Device::STATUS[:on_repair] %> + + <% elsif device.status == Device::STATUS[:in_stock] %> + + <% elsif device.status == Device::STATUS[:sended_to_inspection] %> + + <% end %> + + <%= device.tabel_id %> + <%= device.serial_id %> + <%= device.device_model.name %> + <%= device.year_of_production %> + <%= device.year_of_commissioning %> + <% if device.control_point.nil? %> + <%= "——" %> + <%= "——" %> + <% else %> + + + <% device.control_point.each do |e| %> + <%= content_tag(:span, e.room.name, class: "btn btn-light btn-sm") %> + <% end %> + + + + <% device.control_point.each do |e| %> + <%= content_tag(:span, e.name, class: "btn btn-light btn-sm") %> + <% end %> + + <% end %> + <% if current_user.admin? %> + <%= device.service.name %> + <% end %> + <% if device.inspection_expiration_status == Device::INSPECTION_EXPIRATION_STATUS[:verified] %> + + <%= device.last_successful_inspection %> + + <% elsif device.inspection_expiration_status == Device::INSPECTION_EXPIRATION_STATUS[:prepare_to_inspection] %> + + <%= device.last_successful_inspection %> + + <% else %> + + <%= device.last_successful_inspection %> + + <% end %> + + <% end %> + + +
    diff --git a/app/views/shared/index/_inspection.html.erb b/app/views/shared/index/_inspection.html.erb index 5b6932c..d0a2a61 100644 --- a/app/views/shared/index/_inspection.html.erb +++ b/app/views/shared/index/_inspection.html.erb @@ -59,121 +59,105 @@ <% if @inspections.count > 0 %> -
    -
    - - - - - - <% unless is_new_tasks %> - - <% end %> - - - <% if is_completed_tasks %> - - - <% end %> - - - - - - <% @inspections.each do |inspection| %> +
    +
    +
    +
    <%= t('.device_serial_id') %><%= t('.device_tabel_id') %><%= t('.assigned_user') %><%= t('.target') %><%= t('.state') %><%= t('.conclusion') %><%= t('.conclusion_date') %><%= t('.creator') %><%= t('action') %>
    + - - + + <% unless is_new_tasks %> - <% if inspection.performer.present? %> - - <% else %> - - <% end %> + <% end %> - - + + <% if is_completed_tasks %> - - <% if inspection.conclusion_date.present? %> - - <% else %> + + + <% end %> + + <%= render 'shared/ui/table/header/action'%> + + + + <% @inspections.each do |inspection| %> + + + + <% unless is_new_tasks %> + <% if inspection.performer.present? %> + + <% else %> + <% end %> <% end %> - <% end %> - - + + <% if is_completed_tasks %> + + <% if inspection.conclusion_date.present? %> + + <% else %> + + <% end %> + <% end %> + + - - <% end %> - -
    <%= inspection.device.serial_id %><%= inspection.device.tabel_id %><%= t('.device_serial_id') %><%= t('.device_tabel_id') %><%= inspection.performer.last_name + " " + inspection.performer.first_name %><%= t('.assigned_user') %><%= t("activerecord.attributes.inspection.#{inspection.type_target}") %><%= t("activerecord.attributes.inspection.#{inspection.state}") %><%= t('.target') %><%= t('.state') %><%= inspection.conclusion %><%= formatted_date(inspection.conclusion_date, :short_full) %><%= t('.conclusion') %><%= t('.conclusion_date') %><%= t('.creator') %>
    <%= inspection.device.serial_id %><%= inspection.device.tabel_id %><%= inspection.performer.last_name + " " + inspection.performer.first_name %><%= inspection.creator.last_name + " " + inspection.creator.first_name %> -
    -
    - <%= link_to inspection_path(id: inspection.id, previous_action: @previous_action), class: 'btn p-0' do %> +
    <%= t("activerecord.attributes.inspection.#{inspection.type_target}") %><%= t("activerecord.attributes.inspection.#{inspection.state}") %><%= inspection.conclusion %><%= formatted_date(inspection.conclusion_date, :short_full) %><%= inspection.creator.last_name + " " + inspection.creator.first_name %> +
    + <%= link_to inspection_path(id: inspection.id, previous_action: @previous_action), class: 'btn btn-sm' do %> - <% end %> -
    - <% if can? :accept_task, Inspection %> - <% unless path == all_tasks_inspection_index_path %> - <% case inspection.state %> - <% when "task_created"%> -
    + <% end %> + <% if can? :accept_task, Inspection %> + <% unless path == all_tasks_inspection_index_path %> + <% case inspection.state %> + <% when "task_created"%> <%= button_to accept_task_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end%> -
    - <% when "task_accepted"%> -
    + <% when "task_accepted"%> <%= button_to complete_verification_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end %> -
    -
    <%= button_to fail_verification_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end %> -
    - <% when "verification_failed"%> -
    + <% when "verification_failed"%> <%= button_to send_to_repair_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end %> -
    -
    <%= button_to close_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end %> -
    - <% when "sent_to_repair"%> -
    + <% when "sent_to_repair"%> <%= button_to return_from_repair_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end %> -
    - <% when "returned_from_repair"%> -
    + <% when "returned_from_repair"%> <%= button_to send_from_repair_to_verification_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end %> -
    -
    <%= button_to send_from_repair_to_close_inspection_path(inspection), - method: :post, class: 'btn p-0' do %> + method: :post, class: 'btn btn-sm' do %> <% end %> -
    + <% end %> <% end %> <% end %> - <% end %> - -
    +
    + + + <% end %> + + +
    diff --git a/app/views/shared/ui/table/caption/_all_items.erb b/app/views/shared/ui/table/caption/_all_items.erb new file mode 100644 index 0000000..f79e974 --- /dev/null +++ b/app/views/shared/ui/table/caption/_all_items.erb @@ -0,0 +1,3 @@ + + <%= "#{t('.')} #{count}" %> + diff --git a/app/views/shared/ui/table/cell/_action.erb b/app/views/shared/ui/table/cell/_action.erb new file mode 100644 index 0000000..4630562 --- /dev/null +++ b/app/views/shared/ui/table/cell/_action.erb @@ -0,0 +1,10 @@ + +
    + <%= link_to edit_path, class: "btn btn-sm", data: { action: "click->modal#open", turbo_stream: "" } do %> + + <% end %> + <%= button_to destroy_path, method: :delete, class: "btn btn-sm" do %> + + <% end %> +
    + diff --git a/app/views/shared/ui/table/header/_action.erb b/app/views/shared/ui/table/header/_action.erb new file mode 100644 index 0000000..4dc4658 --- /dev/null +++ b/app/views/shared/ui/table/header/_action.erb @@ -0,0 +1,5 @@ + + <%= t('action')%> + diff --git a/config/locales/en.yml b/config/locales/en.yml index 9a4abfb..b449d95 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -81,6 +81,11 @@ en: body: Eat some more of these... category: Public or URB-106 shared: + shared: + ui: + table: + caption: + all_items: "All: " show: device: send_to_inspection: Send to inspection diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 5c709d9..0b0bf7a 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -211,6 +211,18 @@ ru: room_id: Помещение description: Описание device: Устройство + channel: + id: ID + channel_id: № кнл. + server: № срв. + control_point: Точка контроля + location_description: Описание располож. + self_background: Собств. фон + pre_emergency_limit: Пред.-ав. уст. + emergency_limit: Ав. уст. + consumption: Расход + conversion_coefficient: Коэфф. конв. + service: Служба device: inventory_id: Инв. № control_point: Точка контроля @@ -313,6 +325,15 @@ ru: organization_id: Организация building: Здание building_id: Здание + server: + id: ID + name: Название + ip_address: IPv4 + inventory_id: № инв. + service: Служба + service_id: Служба + room: Расположение + room_id: Расположение user: tabel_id: Таб. № first_name: Имя @@ -359,8 +380,24 @@ ru: title: Страница редактирования %{resource} we_need_your_current_password_to_confirm_your_changes: введите текущий пароль для подтверждения изменений shared: + ui: + table: + caption: + all_items: "Всего: " admin: form: + channel: + placeholders: + channel_id: ID канала (1...48) + server_id: ID сервера + server: Название сервера + location_description: Описание канала + self_background: Собственный фон (12.34) + pre_emergency_limit: Предаварийная уставка (123.45) + emergency_limit: Аварийная уставка (1234.56) + consumption: Расход (123.45) + conversion_coefficient: Коэфф. преобразования (0.0009) + service: Служба division: labels: name: Название diff --git a/config/routes.rb b/config/routes.rb index 843d6db..1b8afcd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,7 @@ post :create_inspection, :to => 'device#create_inspection' end resources :device_model, :measurement_class - resources :room, :building, :organization, :division, :service, :control_point, :manufacturer, :measurement_group, :device_reg_group, + resources :server, :channel, :room, :building, :organization, :division, :service, :control_point, :manufacturer, :measurement_group, :device_reg_group, :supplementary_kit, :device_component, except: [:show] end @@ -33,7 +33,7 @@ resources :device do post :create_inspection, :to => 'device#create_inspection' end - resources :room, :building, :organization, :division, :service, :control_point, :device_model, :measurement_class, + resources :server, :channel, :room, :building, :organization, :division, :service, :control_point, :device_model, :measurement_class, :manufacturer, :measurement_group, :device_reg_group, :supplementary_kit, :device_component, only: [:create, :new] resources :inspection, except: [:index] do diff --git a/db/migrate/20240214043200_revert_last_migration.rb b/db/migrate/20240214043200_revert_last_migration.rb new file mode 100644 index 0000000..b9c32d2 --- /dev/null +++ b/db/migrate/20240214043200_revert_last_migration.rb @@ -0,0 +1,8 @@ +class RevertLastMigration < ActiveRecord::Migration[7.0] + def change + remove_reference :devices, :control_point, index: true, foreign_key: :true + add_reference :control_points, :device, foreign_key: true + add_column :devices, :inspection_interval, :float, default: 1.0, null: false + add_column :control_points, :control_point_type, :string + end +end diff --git a/db/migrate/20240214111919_rename_consumption_column_for_channel.rb b/db/migrate/20240214111919_rename_consumption_column_for_channel.rb new file mode 100644 index 0000000..a4db4e7 --- /dev/null +++ b/db/migrate/20240214111919_rename_consumption_column_for_channel.rb @@ -0,0 +1,5 @@ +class RenameConsumptionColumnForChannel < ActiveRecord::Migration[7.0] + def change + rename_column :channels, :consumptiom, :consumption + end +end diff --git a/db/migrate/20240219101812_server_ip_address_rename.rb b/db/migrate/20240219101812_server_ip_address_rename.rb new file mode 100644 index 0000000..1d61fd3 --- /dev/null +++ b/db/migrate/20240219101812_server_ip_address_rename.rb @@ -0,0 +1,5 @@ +class ServerIpAddressRename < ActiveRecord::Migration[7.0] + def change + rename_column :servers, :ip_adress, :ip_address + end +end diff --git a/db/schema.rb b/db/schema.rb index f3e6734..c294e57 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_02_02_104526) do +ActiveRecord::Schema[7.0].define(version: 2024_02_19_101812) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -31,7 +31,7 @@ t.float "self_background", default: 0.0 t.float "pre_emergency_limit", default: 1.0 t.float "emergency_limit", default: 2.0 - t.float "consumptiom", default: 1.0 + t.float "consumption", default: 1.0 t.float "conversion_coefficient", default: 0.0 t.float "event_system_value", default: 0.0 t.float "event_not_system_value", default: 0.0 @@ -57,6 +57,9 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.bigint "service_id" + t.bigint "device_id" + t.string "control_point_type" + t.index ["device_id"], name: "index_control_points_on_device_id" t.index ["room_id"], name: "index_control_points_on_room_id" t.index ["service_id"], name: "index_control_points_on_service_id" end @@ -119,8 +122,7 @@ t.bigint "room_id" t.string "inspection_expiration_status", default: "prepare_to_inspection", null: false t.string "status", default: "in_stock", null: false - t.bigint "control_point_id" - t.index ["control_point_id"], name: "index_devices_on_control_point_id" + t.float "inspection_interval", default: 1.0, null: false t.index ["device_model_id"], name: "index_devices_on_device_model_id" t.index ["device_reg_group_id"], name: "index_devices_on_device_reg_group_id" t.index ["inventory_id"], name: "index_devices_on_inventory_id", unique: true @@ -223,7 +225,7 @@ create_table "servers", force: :cascade do |t| t.string "name" - t.string "ip_adress" + t.string "ip_address" t.integer "inventory_id" t.bigint "service_id", null: false t.bigint "room_id", null: false @@ -279,13 +281,13 @@ add_foreign_key "channels", "control_points" add_foreign_key "channels", "servers" add_foreign_key "channels", "services" + add_foreign_key "control_points", "devices" add_foreign_key "control_points", "rooms" add_foreign_key "control_points", "services" add_foreign_key "device_components", "supplementary_kits" add_foreign_key "device_models", "manufacturers" add_foreign_key "device_models", "measurement_classes" add_foreign_key "device_models", "measurement_groups" - add_foreign_key "devices", "control_points" add_foreign_key "devices", "device_models" add_foreign_key "devices", "device_reg_groups" add_foreign_key "devices", "rooms" diff --git a/db/seeds.rb b/db/seeds.rb index 9bfb22d..4c30485 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -293,21 +293,9 @@ ) end - -# seed ControlPoints -200.times do |i| - ControlPoint.create( - name: "Точка контроля #{i}", - description: "Возможное описание", - room: Room.find_by(id: rand(1..99)), - service: Service.find_by(id: rand(1..10)), - ) -end - # seed Device 100.times do |i| - puts ControlPoint.find_by(id: i + 1).name Device.create( inventory_id: i, serial_id: "#{i}-123-N", @@ -318,7 +306,18 @@ year_of_commissioning: 1991, supplementary_kit: SupplementaryKit.find_by(id: rand(1..20)), service: Service.find_by(id: rand(1..10)), - control_point: ControlPoint.find_by(id: i + 1), + inspection_interval: rand(0.1..9.9) + ) +end + +# seed ControlPoints +200.times do |i| + ControlPoint.create( + name: "Точка контроля #{i}", + description: "Возможное описание", + room: Room.find_by(id: rand(1..99)), + service: Service.find_by(id: rand(1..10)), + device: Device.find_by(id: rand(1..100)), ) end @@ -398,4 +397,12 @@ event_not_system_value: rand(0.0..100.0), event_datetime: Time.now, ) + + History.create( + channel_id: Channel.last, + event_impulse_value: rand(0.0..100.0), + event_system_value: Time.now, + event_not_system_value: rand(0.0..100.0), + event_datetime: Time.now, + ) end diff --git a/test/controllers/admin/building_controller_test.rb b/test/controllers/admin/building_controller_test.rb index ddc78ea..21b56bb 100644 --- a/test/controllers/admin/building_controller_test.rb +++ b/test/controllers/admin/building_controller_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class Admin::BuildingControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/admin/channel_controller_test.rb b/test/controllers/admin/channel_controller_test.rb new file mode 100644 index 0000000..3699ee7 --- /dev/null +++ b/test/controllers/admin/channel_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class Admin::ChannelControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/admin/organization_controller_test.rb b/test/controllers/admin/organization_controller_test.rb index 8dd03d8..4d1c564 100644 --- a/test/controllers/admin/organization_controller_test.rb +++ b/test/controllers/admin/organization_controller_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class Admin::OrganizationControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/admin/room_controller_test.rb b/test/controllers/admin/room_controller_test.rb index b49c04b..4ef8898 100644 --- a/test/controllers/admin/room_controller_test.rb +++ b/test/controllers/admin/room_controller_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class Admin::RoomControllerTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/controllers/admin/server_controller_test.rb b/test/controllers/admin/server_controller_test.rb new file mode 100644 index 0000000..6c276b7 --- /dev/null +++ b/test/controllers/admin/server_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class Admin::ServerControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/factories/channels.rb b/test/factories/channels.rb index 6b4c8f5..255b392 100644 --- a/test/factories/channels.rb +++ b/test/factories/channels.rb @@ -8,7 +8,7 @@ self_background { 1.5 } pre_emergency_limit { 1.5 } emergency_limit { 1.5 } - consumptiom { 1.5 } + consumption { 1.5 } conversion_coefficient { 1.5 } event_system_value { 1.5 } event_not_system_value { 1.5 } diff --git a/test/factories/control_points.rb b/test/factories/control_points.rb index 9b4e4c3..e0476f8 100644 --- a/test/factories/control_points.rb +++ b/test/factories/control_points.rb @@ -6,5 +6,6 @@ channel { nil } device { nil } service { association :service } + device_id { association :device } end end diff --git a/test/factories/servers.rb b/test/factories/servers.rb index 6e23ccd..55f5548 100644 --- a/test/factories/servers.rb +++ b/test/factories/servers.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :server do name { 'MyString' } - ip_adress + ip_address { '127.0.0.1' } inventory_id { 1 } service { association :service } room { association :room }