diff --git a/Gemfile.lock b/Gemfile.lock index 867fffd..8ae3b86 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -302,6 +302,7 @@ GEM zeitwerk (2.6.7) PLATFORMS + x86_64-linux x86_64-linux-musl DEPENDENCIES diff --git a/app/controllers/admin/admin_controller.rb b/app/controllers/admin/admin_controller.rb index 6bb9848..321e676 100644 --- a/app/controllers/admin/admin_controller.rb +++ b/app/controllers/admin/admin_controller.rb @@ -1,4 +1,6 @@ class Admin::AdminController < ApplicationController load_and_authorize_resource - def index; end + def index + redirect_to(admin_users_path) + end end diff --git a/app/controllers/admin/building_controller.rb b/app/controllers/admin/building_controller.rb new file mode 100644 index 0000000..ab90369 --- /dev/null +++ b/app/controllers/admin/building_controller.rb @@ -0,0 +1,30 @@ +class Admin::BuildingController < ApplicationController + include BuildingConcern + + load_and_authorize_resource + before_action :set_building, only: [:show, :edit, :update, :destroy] + + def index + building_index + end + + def new + authorize!(:new, :building_admin) + @building = Building.new + end + + def create + authorize!(:create, :building_admin) + building_create + end + + def update + authorize!(:update, :building_admin) + building_update + end + + def destroy + authorize!(:destroy, :building_admin) + building_destroy + end +end diff --git a/app/controllers/admin/control_point_controller.rb b/app/controllers/admin/control_point_controller.rb new file mode 100644 index 0000000..2ea2021 --- /dev/null +++ b/app/controllers/admin/control_point_controller.rb @@ -0,0 +1,60 @@ +class Admin::ControlPointController < ApplicationController + include ControlPointConcern + load_and_authorize_resource + before_action :set_control_point, only: [:show, :edit, :update, :destroy] + + def index + @query = ControlPoint.ransack(params[:q]) + @pagy, @control_points = pagy(@query.result. + order(:name)) + end + + def new + authorize!(:new, :control_point_admin) + @control_point = ControlPoint.new + end + + def create + authorize!(:create, :control_point_admin) + control_point_create + end + + def update + if @control_point.update(control_point_params) + redirect_back(fallback_location: root_path) + else + render(:edit, status: :unprocessable_entity) + end + end + + 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? + @control_point.destroy + else + flash[:error] = t('message.control_point.delete.error') + end + redirect_to(admin_control_point_index_path) + end + + private + + def set_control_point + @control_point = ControlPoint.find(params[:id]) + end + + def control_point_params + params.require(:control_point).permit( + :name, + :room_id, + :device_id, + :channel_id, + :description, + :service_id, + ) + end +end diff --git a/app/controllers/admin/division_controller.rb b/app/controllers/admin/division_controller.rb new file mode 100644 index 0000000..2dd1459 --- /dev/null +++ b/app/controllers/admin/division_controller.rb @@ -0,0 +1,29 @@ +class Admin::DivisionController < ApplicationController + include DivisionConcern + load_and_authorize_resource + before_action :set_division, only: [:show, :edit, :update, :destroy] + + def index + division_index + end + + def new + authorize!(:new, :division_admin) + @division = Division.new + end + + def create + authorize!(:create, :division_admin) + division_create + end + + def update + authorize!(:update, :division_admin) + division_update + end + + def destroy + authorize!(:destroy, :division_admin) + division_destroy + end +end diff --git a/app/controllers/admin/organization_controller.rb b/app/controllers/admin/organization_controller.rb new file mode 100644 index 0000000..a6e21fa --- /dev/null +++ b/app/controllers/admin/organization_controller.rb @@ -0,0 +1,30 @@ +class Admin::OrganizationController < ApplicationController + include OrganizationConcern + + load_and_authorize_resource + before_action :set_organization, only: [:show, :edit, :update, :destroy] + + def index + organization_index + end + + def new + authorize!(:new, :organization_admin) + @organization = Organization.new + end + + def create + authorize!(:create, :organization_admin) + organization_create + end + + def update + authorize!(:update, :organization_admin) + organization_update + end + + def destroy + authorize!(:destroy, :organization_admin) + organization_destroy + end +end diff --git a/app/controllers/admin/room_controller.rb b/app/controllers/admin/room_controller.rb new file mode 100644 index 0000000..80d39eb --- /dev/null +++ b/app/controllers/admin/room_controller.rb @@ -0,0 +1,30 @@ +class Admin::RoomController < ApplicationController + include RoomConsern + + load_and_authorize_resource + before_action :set_room, only: [:show, :edit, :update, :destroy] + + def index + room_index + end + + def new + authorize!(:new, :room_admin) + @room = Room.new + end + + def create + authorize!(:create, :room_admin) + room_create + end + + def update + authorize!(:update, :room_admin) + room_update + end + + def destroy + authorize!(:destroy, :room_admin) + room_destroy + end +end diff --git a/app/controllers/admin/service_controller.rb b/app/controllers/admin/service_controller.rb new file mode 100644 index 0000000..2f18ec7 --- /dev/null +++ b/app/controllers/admin/service_controller.rb @@ -0,0 +1,63 @@ +class Admin::ServiceController < ApplicationController + include ServiceConcern + + load_and_authorize_resource + before_action :set_service, only: [:show, :edit, :update, :destroy] + + def index + @query = Service.ransack(params[:q]) + @pagy, @services = pagy(@query.result.order(:name)) + end + + def new + authorize!(:new, :service_admin) + @service = Service.new + end + + def create + authorize!(:create, :service_admin) + service_create + end + + def update + authorize!(:update, :service_admin) + + if @service.update(service_params) + redirect_back(fallback_location: root_path) + else + render(:edit, status: :unprocessable_entity) + end + end + + def destroy + authorize!(:destroy, :service_admin) + + assigned_models_count = + Device.where(service_id: params[:id]).count + + User.where(service_id: params[:id]).count + + Server.where(service_id: params[:id]).count + + ControlPoint.where(service_id: params[:id]).count + + if assigned_models_count.zero? + @service.destroy + else + flash[:error] = t('message.service.delete.error') + end + redirect_to(admin_service_index_path) + end + + private + + def set_service + @service = Service.find(params[:id]) + end + + def service_params + params.require(:service).permit( + :name, + :division_id, + :organization_id, + :building_id, + ) + end +end diff --git a/app/controllers/api/v1/armstrong_controller.rb b/app/controllers/api/v1/armstrong_controller.rb index e0dcc39..1aeb466 100644 --- a/app/controllers/api/v1/armstrong_controller.rb +++ b/app/controllers/api/v1/armstrong_controller.rb @@ -3,13 +3,19 @@ class V1::ArmstrongController < ApplicationController after_action :set_csp_header def index - channels = Channel.all + channels = Channel.joins(:control_point, :server, :service) result = channels.sort { |a, b| a[:server_id] <=> b[:server_id] } render(json: result, include: [ - device: { include: [device_model: { only: [:name] }] }, - room: { only: [:name] }, + :server, + :service, + { control_point: { + include: [ + :room, + { device: { include: :device_model } }, + ], + } }, ]) end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 67f7da5..b0cb009 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ def set_time_zone(&block) protected def configure_permitted_parameters - attributes_sign_up = [:first_name, :last_name, :tabel_id, :role, :email,:service_id, :timezone] + attributes_sign_up = [:first_name, :last_name, :tabel_id, :role, :email, :service_id, :timezone] attributes_update = [*attributes_sign_up.excluding(:service_id), :second_name, :email, :phone] devise_parameter_sanitizer.permit(:sign_up, keys: attributes_sign_up) devise_parameter_sanitizer.permit(:account_update, keys: attributes_update) diff --git a/app/controllers/concerns/building_concern.rb b/app/controllers/concerns/building_concern.rb new file mode 100644 index 0000000..2a1b1ec --- /dev/null +++ b/app/controllers/concerns/building_concern.rb @@ -0,0 +1,55 @@ +module BuildingConcern + extend ActiveSupport::Concern + + included do # rubocop:disable Metrics/BlockLength + def building_index + @query = Building.ransack(params[:q]) + @pagy, @buildings = pagy(@query.result.order(:name)) + end + + def building_create + @building = Building.new(building_params) + + if @building.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def building_update + if @building.update(building_params) + redirect_back(fallback_location: root_path) + else + render(:edit, status: :unprocessable_entity) + end + end + + def building_destroy + assigned_models_count = + Room.where(building_id: params[:id]).count + + Service.where(building_id: params[:id]).count + + if assigned_models_count.zero? + @building.destroy + else + flash[:error] = t('message.admin.building.delete.error') + end + redirect_to(admin_building_index_path) + end + + private + + def set_building + @building = Building.find(params[:id]) + end + + def building_params + params.require(:building).permit( + :name, + :organization_id, + :description, + ) + end + end +end diff --git a/app/controllers/concerns/control_point_concern.rb b/app/controllers/concerns/control_point_concern.rb new file mode 100644 index 0000000..17d551f --- /dev/null +++ b/app/controllers/concerns/control_point_concern.rb @@ -0,0 +1,26 @@ +module ControlPointConcern + extend ActiveSupport::Concern + + included do + def control_point_create + @control_point = ControlPoint.new(control_point_params) + + if @control_point.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def control_point_params + params.require(:control_point).permit( + :name, + :device_id, + :room_id, + :channel_id, + :description, + :service_id, + ) + end + end +end diff --git a/app/controllers/concerns/device_concern.rb b/app/controllers/concerns/device_concern.rb index fc2bfce..b0fdb72 100644 --- a/app/controllers/concerns/device_concern.rb +++ b/app/controllers/concerns/device_concern.rb @@ -2,7 +2,7 @@ module DeviceConcern extend ActiveSupport::Concern include DeviceHelper - included do + included do # rubocop:disable Metrics/BlockLength def device_index params[:q] ||= {} @query = Device.ransack(params[:q]) @@ -43,9 +43,8 @@ def device_update(device) def device_destroy(device, path_success, path_failure) assigned_inspections_count = Inspection.where(device_id: device.id).count - assigned_channels_count = Channel.where(device_id: device.id).count - if assigned_inspections_count.zero? && assigned_channels_count.zero? + if assigned_inspections_count.zero? && device.control_point_id? device.destroy redirect_to(path_success) else @@ -55,17 +54,16 @@ def device_destroy(device, path_success, path_failure) end def create_inspection_for_device(device) - if inspection_params[:is_admin] - inspection = device.inspections.build(creator_id: current_user.id, + inspection = if inspection_params[:is_admin] + device.inspections.build(creator_id: current_user.id, performer_id: current_user.id, type_target: inspection_params[:type_target], conclusion_date: inspection_params[:conclusion_date].to_datetime + 12.hours, conclusion: t('message.inspection.create_from_device.generated'), - state: Inspection::STATES[:verification_successful] - ) - else - inspection = device.inspections.build(creator_id: current_user.id, type_target: inspection_params[:type_target]) - end + state: Inspection::STATES[:verification_successful]) + else + device.inspections.build(creator_id: current_user.id, type_target: inspection_params[:type_target]) + end if inspection.save set_inspection_status(device) flash[:success] = t('message.inspection.create_from_device.success') diff --git a/app/controllers/concerns/division_concern.rb b/app/controllers/concerns/division_concern.rb new file mode 100644 index 0000000..fa08c4f --- /dev/null +++ b/app/controllers/concerns/division_concern.rb @@ -0,0 +1,52 @@ +module DivisionConcern + extend ActiveSupport::Concern + + included do + def division_index + @query = Division.ransack(params[:q]) + @pagy, @divisions = pagy(@query.result.order(:name)) + end + + def division_create + @division = Division.new(division_params) + + if @division.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def division_update + if @division.update(division_params) + redirect_back(fallback_location: root_path) + else + render(:edit, status: :unprocessable_entity) + end + end + + def division_destroy + assigned_models_count = Service.where(division_id: params[:id]).count + + if assigned_models_count.zero? + @division.destroy + else + flash[:error] = t('message.admin.division.delete.error') + end + redirect_to(admin_division_index_path) + end + + private + + def set_division + @division = Division.find(params[:id]) + end + + def division_params + params.require(:division).permit( + :name, + :organization_id, + ) + end + end +end diff --git a/app/controllers/concerns/organization_concern.rb b/app/controllers/concerns/organization_concern.rb new file mode 100644 index 0000000..68b0b22 --- /dev/null +++ b/app/controllers/concerns/organization_concern.rb @@ -0,0 +1,60 @@ +module OrganizationConcern + extend ActiveSupport::Concern + + included do + def organization_index + @query = Organization.ransack(params[:q]) + @pagy, @organizations = pagy(@query.result.order(:name)) + end + + def organization_create + @organization = Organization.new(organization_params) + + if @organization.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def organization_update + if @organization.update(organization_params) + redirect_back(fallback_location: root_path) + else + render(:edit, status: :unprocessable_entity) + end + end + + def organization_destroy + assigned_models_count = + Division.where(organization_id: params[:id]).count + + Service.where(organization_id: params[:id]).count + + Building.where(organization_id: params[:id]).count + + if assigned_models_count.zero? + @organization.destroy + else + flash[:error] = t('message.admin.organization.delete.error') + end + + redirect_to(admin_organization_index_path) + end + + private + + def set_organization + @organization = Organization.find(params[:id]) + end + + def organization_params + params.require(:organization).permit( + :name, + :full_address, + :zip_code, + :phone, + :fax, + :email + ) + end + end +end diff --git a/app/controllers/concerns/room_consern.rb b/app/controllers/concerns/room_consern.rb new file mode 100644 index 0000000..8636930 --- /dev/null +++ b/app/controllers/concerns/room_consern.rb @@ -0,0 +1,54 @@ +module RoomConsern + extend ActiveSupport::Concern + + included do # rubocop:disable Metrics/BlockLength + def room_index + @query = Room.ransack(params[:q]) + @pagy, @rooms = pagy(@query.result.order(:name)) + end + + def room_create + @room = Room.new(room_params) + + if @room.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def room_update + if @room.update(room_params) + redirect_back(fallback_location: root_path) + else + render(:edit, status: :unprocessable_entity) + end + end + + def room_destroy + assigned_models_count = ControlPoint.where(room_id: params[:id]).count + + if assigned_models_count.zero? + @room.destroy + else + flash[:error] = t('message.admin.room.delete.error') + end + redirect_to(admin_room_index_path) + end + + private + + def set_room + @room = Room.find(params[:id]) + end + + def room_params + params.require(:room).permit( + :name, + :building_id, + :level, + :description, + ) + end + end +end diff --git a/app/controllers/concerns/service_concern.rb b/app/controllers/concerns/service_concern.rb new file mode 100644 index 0000000..42c5528 --- /dev/null +++ b/app/controllers/concerns/service_concern.rb @@ -0,0 +1,24 @@ +module ServiceConcern + extend ActiveSupport::Concern + + included do + def service_create + @service = Service.new(service_params) + + if @service.save + redirect_back(fallback_location: root_path) + else + render(:new, status: :unprocessable_entity) + end + end + + def service_params + params.require(:service).permit( + :name, + :division_id, + :organization_id, + :building_id, + ) + end + end +end diff --git a/app/controllers/control_point_controller.rb b/app/controllers/control_point_controller.rb new file mode 100644 index 0000000..861cf6d --- /dev/null +++ b/app/controllers/control_point_controller.rb @@ -0,0 +1,19 @@ +class ControlPointController < ApplicationController + include ControlPointConcern + + load_and_authorize_resource + + def index + @query = ControlPoint.ransack(params[:q]) + @query.sorts = ['name asc'] + @pagy, @control_points = pagy(@query.result) + end + + def new + @control_point = ControlPoint.new + end + + def create + control_point_create + end +end diff --git a/app/helpers/device_helper.rb b/app/helpers/device_helper.rb index 4d8d90f..63fcea7 100644 --- a/app/helpers/device_helper.rb +++ b/app/helpers/device_helper.rb @@ -6,17 +6,17 @@ def set_inspection_status(device) unless device.last_successful_inspection_raw.nil? next_inspection_date = device.last_successful_inspection_raw + 1.year status = if next_inspection_date > separator - Device::INSPECTION_EXPIRATION_STATUS[:verified] - elsif next_inspection_date <= separator && next_inspection_date > current_date - Device::INSPECTION_EXPIRATION_STATUS[:prepare_to_inspection] - else - Device::INSPECTION_EXPIRATION_STATUS[:expired] - end + Device::INSPECTION_EXPIRATION_STATUS[:verified] + elsif next_inspection_date <= separator && next_inspection_date > current_date + Device::INSPECTION_EXPIRATION_STATUS[:prepare_to_inspection] + else + Device::INSPECTION_EXPIRATION_STATUS[:expired] + end begin device.update(inspection_expiration_status: status) - rescue ActiveRecord::ActiveRecordError => error - puts error.to_s + rescue ActiveRecord::ActiveRecordError => e + puts(e.to_s) end end end diff --git a/app/javascript/Components/Armstrong/Armstrong.jsx b/app/javascript/Components/Armstrong/Armstrong.jsx index 846eb02..1fc6287 100644 --- a/app/javascript/Components/Armstrong/Armstrong.jsx +++ b/app/javascript/Components/Armstrong/Armstrong.jsx @@ -42,12 +42,12 @@ export default function Armstrong() { state: setChannelColor(channel.state), specialControl: , id: channel.id, - serverId: channel.server_id, + serverId: channel.server.id, channelId: channel.channel_id, - name: channel.name, - deviceModel: channel.device.device_model.name, - location: channel.room.name, - locationDescription: channel.location_description, + name: channel.control_point.name, + deviceModel: channel.control_point.device ? channel.control_point.device.device_model.name : '——', + location: channel.control_point.room.name, + locationDescription: channel.control_point.description, eventSystemValue: channel.event_system_value.toExponential(3), eventNotSystemValue: channel.event_not_system_value.toExponential(3), eventDatetime: moment.tz(channel.event_datetime, timeZone).format('HH:mm:SS'), diff --git a/app/models/building.rb b/app/models/building.rb index 5cc3a87..6cd5c8b 100644 --- a/app/models/building.rb +++ b/app/models/building.rb @@ -6,4 +6,8 @@ class Building < ApplicationRecord has_many :servers validates :name, presence: true + + def self.ransackable_attributes(_auth_object = nil) + ['created_at', 'description', 'id', 'name', 'organization_id', 'updated_at'] + end end diff --git a/app/models/channel.rb b/app/models/channel.rb index fb89b7e..4f57cc2 100644 --- a/app/models/channel.rb +++ b/app/models/channel.rb @@ -1,7 +1,7 @@ class Channel < ApplicationRecord - belongs_to :device - belongs_to :room belongs_to :server belongs_to :service + has_many :history + belongs_to :control_point end diff --git a/app/models/control_point.rb b/app/models/control_point.rb new file mode 100644 index 0000000..d091bae --- /dev/null +++ b/app/models/control_point.rb @@ -0,0 +1,17 @@ +class ControlPoint < ApplicationRecord + belongs_to :room, optional: true + belongs_to :service + + has_one :channel + has_one :device + + validates :name, presence: true + + def self.ransackable_attributes(_auth_object = nil) + ['channel_id', 'created_at', 'description', 'device_id', 'id', 'name', 'room_id', 'service_id', 'updated_at'] + end + + def self.ransackable_associations(_auth_object = nil) + ['channel', 'device', 'room', 'service'] + end +end diff --git a/app/models/device.rb b/app/models/device.rb index 52d9e39..e4bddfd 100644 --- a/app/models/device.rb +++ b/app/models/device.rb @@ -11,9 +11,9 @@ class Device < ApplicationRecord belongs_to :supplementary_kit, optional: true belongs_to :room, optional: true belongs_to :service + belongs_to :control_point, optional: true has_many :inspections - has_one :channel validates :inventory_id, numericality: { less_than_or_equal_to: 2147483647 }, uniqueness: true, allow_nil: true validates :serial_id, :tabel_id, presence: true, uniqueness: true diff --git a/app/models/division.rb b/app/models/division.rb index 336c209..abcf7cd 100644 --- a/app/models/division.rb +++ b/app/models/division.rb @@ -4,4 +4,8 @@ class Division < ApplicationRecord has_many :services validates :name, presence: true + + def self.ransackable_attributes(_auth_object = nil) + ['created_at', 'id', 'name', 'organization_id', 'updated_at'] + end end diff --git a/app/models/organization.rb b/app/models/organization.rb index 666c369..304b1c8 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -4,4 +4,8 @@ class Organization < ApplicationRecord has_many :services validates :name, presence: true + + 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/room.rb b/app/models/room.rb index 4c36553..a15cea3 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,8 +1,12 @@ class Room < ApplicationRecord belongs_to :building - has_many :channels has_many :devices + has_many :control_point - validates :name, presence: true + validates :name, :building, presence: true + + def self.ransackable_attributes(_auth_object = nil) + ['building_id', 'created_at', 'description', 'id', 'level', 'name', 'updated_at'] + end end diff --git a/app/models/service.rb b/app/models/service.rb index 6a3daf8..b58df8c 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -6,4 +6,16 @@ class Service < ApplicationRecord has_many :devices has_many :users has_many :servers + has_many :control_points + + validates :name, :organization, :division, :building, presence: true + validates :name, uniqueness: true + + def self.ransackable_attributes(_auth_object = nil) + ['building_id', 'created_at', 'division_id', 'id', 'name', 'organization_id', 'updated_at'] + end + + def self.ransackable_associations(_auth_object = nil) + ['building', 'control_points', 'devices', 'division', 'organization', 'servers', 'users'] + end end diff --git a/app/models/user.rb b/app/models/user.rb index 522dbe2..676bea8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -45,7 +45,8 @@ def self.ransackable_attributes(_auth_object = nil) 'second_name', 'tabel_id', 'updated_at', - 'service_id'] + 'service_id', + ] end def self.ransackable_associations(_auth_object = nil) diff --git a/app/views/admin/building/create.turbo_stream.erb b/app/views/admin/building/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/building/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/building/edit.turbo_stream.erb b/app/views/admin/building/edit.turbo_stream.erb new file mode 100644 index 0000000..d662b90 --- /dev/null +++ b/app/views/admin/building/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.building.edit') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/building", + locals: { path: admin_building_path(@building), building: @building } %> diff --git a/app/views/admin/building/index.html.erb b/app/views/admin/building/index.html.erb new file mode 100644 index 0000000..ee80518 --- /dev/null +++ b/app/views/admin/building/index.html.erb @@ -0,0 +1,103 @@ +<% provide :page_title, "Здания" %> +<%= render 'shared/admin/navbar/admin', selected: "location" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/location_navbar', selected: "building" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_building_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 :organization_id, class: "mb-1" %> + <%= f.collection_select(:organization_id_eq, Organization.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_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 %> + + + <% 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 %> +
+
+
+
+
+ +
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/building/new.turbo_stream.erb b/app/views/admin/building/new.turbo_stream.erb new file mode 100644 index 0000000..f2f0499 --- /dev/null +++ b/app/views/admin/building/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.building.new') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/building", + locals: {path: admin_building_index_path, building: @building } %> diff --git a/app/views/admin/building/update.turbo_stream.erb b/app/views/admin/building/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/building/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/control_point/create.turbo_stream.erb b/app/views/admin/control_point/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/control_point/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/control_point/edit.turbo_stream.erb b/app/views/admin/control_point/edit.turbo_stream.erb new file mode 100644 index 0000000..000bc6f --- /dev/null +++ b/app/views/admin/control_point/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('.edit_control_point') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/control_point", + locals: { path: admin_control_point_path(@control_point), control_point: @control_point } %> diff --git a/app/views/admin/control_point/index.html.erb b/app/views/admin/control_point/index.html.erb new file mode 100644 index 0000000..2ae22b5 --- /dev/null +++ b/app/views/admin/control_point/index.html.erb @@ -0,0 +1,109 @@ +<% provide :page_title, "Точки контроля" %> +<%= render 'shared/admin/navbar/admin', selected: "location" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/location_navbar', selected: "control_point" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_control_point_index_path, method: :get, class: "rounded accordion-body") do |f| %> +
+ <%= 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.submit t('b_accept'), class: 'btn btn-primary w-100 my-2'%> +
+ <%= t("b_clear")%> +
+ <% end %> +
+
+
+ <%= 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 %> + + + <% 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 %> +
+
+
+
+
+ +
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/control_point/new.turbo_stream.erb b/app/views/admin/control_point/new.turbo_stream.erb new file mode 100644 index 0000000..1c12ae4 --- /dev/null +++ b/app/views/admin/control_point/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.control_points.new.add_control_point') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/control_point", + locals: {path: admin_control_point_index_path, control_point: @control_point } %> diff --git a/app/views/admin/control_point/update.turbo_stream.erb b/app/views/admin/control_point/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/control_point/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/device/index.html.erb b/app/views/admin/device/index.html.erb index 48f6dc4..c2bf60f 100644 --- a/app/views/admin/device/index.html.erb +++ b/app/views/admin/device/index.html.erb @@ -1,3 +1,2 @@ <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "device" %> <%= render 'shared/index/device', search_path: admin_device_index_path, show_path: admin_device_path(0), new_path: new_admin_device_path %> diff --git a/app/views/admin/device_component/index.html.erb b/app/views/admin/device_component/index.html.erb index cb918c3..6494867 100644 --- a/app/views/admin/device_component/index.html.erb +++ b/app/views/admin/device_component/index.html.erb @@ -1,9 +1,9 @@ <% provide :page_title, "Компоненты" %> <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "device_component" %> <%= render 'shared/flash_alert' %> -
-
+
+
+ <%= render 'shared/admin/navbar/device_bread', selected: "device_component" %>

@@ -14,33 +14,18 @@
<%= search_form_for(@query, url:admin_device_component_index_path, method: :get, class: "rounded accordion-body") do |f| %>
-
-
- <%= f.label :serial_id %> - <%= f.search_field :serial_id_cont, class:"form-control", placeholder:"0-123-N" %> -
-
- <%= f.label :name %> - <%= f.search_field :name_cont, class:"form-control", placeholder:"БДЗБ" %> -
-
- <%= f.label :measurement_min %> - <%= f.search_field :measurement_min_eq, class:"form-control", placeholder:"1.0" %> -
-
- <%= f.label :measurement_max %> - <%= f.search_field :measurement_max_eq, class:"form-control", placeholder:"2.0" %> -
-
- <%= f.label :measuring_unit %> - <%= f.search_field :measuring_unit_cont, class:"form-control", placeholder:"мЗв/ч" %> -
-
-
-
-
- <%= f.submit t('b_accept'), class: 'col btn btn-primary w-100'%> -
+ <%= f.label :serial_id %> + <%= f.search_field :serial_id_cont, class:"form-control mb-2", placeholder:"0-123-N" %> + <%= f.label :name %> + <%= f.search_field :name_cont, class:"form-control mb-2", placeholder:"БДЗБ" %> + <%= f.label :measurement_min %> + <%= f.search_field :measurement_min_eq, class:"form-control mb-2", placeholder:"1.0" %> + <%= f.label :measurement_max %> + <%= f.search_field :measurement_max_eq, class:"form-control mb-2", placeholder:"2.0" %> + <%= f.label :measuring_unit %> + <%= f.search_field :measuring_unit_cont, class:"form-control mb-2", placeholder:"мЗв/ч" %> + <%= f.submit t('b_accept'), class: 'my-2 btn btn-primary w-100'%> +
<%= t("b_clear")%>
@@ -51,19 +36,17 @@
<%= render 'shared/modal_button_add', path: new_admin_device_component_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %>
-
-
-
+
- + - + @@ -99,7 +82,6 @@ -
diff --git a/app/views/admin/device_model/index.html.erb b/app/views/admin/device_model/index.html.erb index 7902a0b..1dbb858 100644 --- a/app/views/admin/device_model/index.html.erb +++ b/app/views/admin/device_model/index.html.erb @@ -1,8 +1,8 @@ <% provide :page_title, "Модели" %> <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "device_model" %> -
-
+
+
+ <%= render 'shared/admin/navbar/device_bread', selected: "device_model" %>

@@ -14,73 +14,40 @@ <%= search_form_for(@query, url:admin_device_model_index_path, method: :get, data:{controller: "filter", 'filtrator_class': 'filtrator-class-index'}, class: "rounded accordion-body") do |f| %>
-
-
- <%= f.label :name, class:"mb-1"%> - <%= f.search_field :name_cont, class: 'form-control', placeholder: 'Название' %> -
-
- <%= f.label :manufacturer_id, class:"mb-1" %> - <%= f.collection_select(:manufacturer_id_eq, Manufacturer.all, - :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select'}) %> -
-
- <%= f.label :measurement_group_id, class:"mb-1" %> - <%= f.collection_select(:measurement_group_id_eq, MeasurementGroup.all, - :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select', id:"filtrator-class-index", data: {'action': 'onchange -> filter#filter', 'to_filter_class': 'filter-class-index', 'filtrator_class': 'filtrator-class-index'}}) %> -
-
- <%= f.label :measurement_class_id, class:"mb-1" %> - <%= f.collection_select(:measurement_class_id_eq, MeasurementClass.all, - :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select', id: "filter-class-index"}) %> -
-
- <%= f.label :measuring_unit, class:"mb-1" %> - <%= f.search_field :measuring_unit_cont, class: 'form-control', placeholder: 'мЗв/ч' %> -
-
-
-
- <%= f.label :measurement_sensitivity, class:"mb-1" %> - <%= f.search_field :measurement_sensitivity_eq, class: 'form-control', placeholder: '1.0' %> -
-
- <%= f.label :measurement_min, class:"mb-1" %> - <%= f.search_field :measurement_min_eq, class: 'form-control', placeholder: '1.0' %> -
-
- <%= f.label :measurement_max, class:"mb-1" %> - <%= f.search_field :measurement_max_eq, class: 'form-control', placeholder: '1.0' %> -
-
- <%= f.label :safety_class, class:"mb-1" %> - <%= f.search_field :safety_class_cont, class: 'form-control', placeholder: '3Н' %> -
-
-
-
- <%= f.label :accuracy_class, class:"mb-1" %> - <%= f.search_field :accuracy_class_eq, class: 'form-control', placeholder: '1.0' %> -
-
- <%= f.label :is_complete_device, class:"mb-1" %> - <%= f.select(:is_complete_device_eq, [['Да', true], ['Нет', false]], + <%= f.label :name, class:"mb-2"%> + <%= f.search_field :name_cont, class: 'form-control', placeholder: 'Название' %> + <%= f.label :manufacturer_id, class:"mb-2" %> + <%= f.collection_select(:manufacturer_id_eq, Manufacturer.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select'}) %> + <%= f.label :measurement_group_id, class:"mb-2" %> + <%= f.collection_select(:measurement_group_id_eq, MeasurementGroup.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select', id:"filtrator-class-index", data: {'action': 'onchange -> filter#filter', 'to_filter_class': 'filter-class-index', 'filtrator_class': 'filtrator-class-index'}}) %> + <%= f.label :measurement_class_id, class:"mb-2" %> + <%= f.collection_select(:measurement_class_id_eq, MeasurementClass.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select', id: "filter-class-index"}) %> + <%= f.label :measuring_unit, class:"mb-2" %> + <%= f.search_field :measuring_unit_cont, class: 'form-control', placeholder: 'мЗв/ч' %> + <%= f.label :measurement_sensitivity, class:"mb-2" %> + <%= f.search_field :measurement_sensitivity_eq, class: 'form-control', placeholder: '1.0' %> + <%= f.label :measurement_min, class:"mb-2" %> + <%= f.search_field :measurement_min_eq, class: 'form-control', placeholder: '1.0' %> + <%= f.label :measurement_max, class:"mb-2" %> + <%= f.search_field :measurement_max_eq, class: 'form-control', placeholder: '1.0' %> + <%= f.label :safety_class, class:"mb-2" %> + <%= f.search_field :safety_class_cont, class: 'form-control', placeholder: '3Н' %> + <%= f.label :accuracy_class, class:"mb-2" %> + <%= f.search_field :accuracy_class_eq, class: 'form-control', placeholder: '1.0' %> + <%= f.label :is_complete_device, class:"mb-2" %> + <%= f.select(:is_complete_device_eq, [['Да', true], ['Нет', false]], {:include_blank => t('combobox_blank')}, {:class =>'form-select form-select'})%> -
-
- <%= f.label :is_tape_rolling_mechanism, class:"mb-1" %> + <%= f.label :is_tape_rolling_mechanism, class:"mb-2" %> <%= f.select(:is_tape_rolling_mechanism_eq, [['Да', true], ['Нет', false]], - {:include_blank => t('combobox_blank')}, {:class =>'form-select form-select'})%> -
-
-
-
-
- <%= f.submit "Применить", class: 'col btn btn-primary w-100'%> -
+ {:include_blank => t('combobox_blank')}, {:class =>'form-select form-select mb-2'})%> + + <%= f.submit t('b_accept'), class: 'col btn btn-primary w-100 my-2'%> +
<%= t("b_clear")%>
-
<% end %>
@@ -88,47 +55,45 @@

<%= render 'shared/modal_button_add', path: new_admin_device_model_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %>
-
-
-
-
-
<%= 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.measurement_unit')%><%= t('activerecord.attributes.device_component.measuring_unit')%> <%= t('activerecord.attributes.device_component.description')%> <%= t('action')%>
- - - - - - - - - - - - - - - - - - <% @device_models.each do |device_model| %> - - - - - - - - - - - - - +
+
+
<%= t('activerecord.attributes.device_model.name')%><%= t('activerecord.attributes.device_model.manufacturer')%><%= t('activerecord.attributes.device_model.measurement_group')%><%= t('activerecord.attributes.device_model.measurement_class')%><%= t('activerecord.attributes.device_model.measuring_unit')%><%= t('activerecord.attributes.device_model.measurement_sensitivity')%>.<%= t('activerecord.attributes.device_model.measurement_min')%><%= t('activerecord.attributes.device_model.measurement_max')%><%= t('activerecord.attributes.device_model.calibration_min')%><%= t('activerecord.attributes.device_model.calibration_max')%><%= t('activerecord.attributes.device_model.safety_class')%><%= t('activerecord.attributes.device_model.accuracy_class')%>
<%= device_model.name %><%= device_model.manufacturer.name %><%= device_model.measurement_group.name %><%= device_model.measurement_class.name %><%= device_model.measuring_unit %><%= device_model.measurement_sensitivity %><%= device_model.measurement_min %><%= device_model.measurement_max %><%= device_model.calibration_min %><%= device_model.calibration_max %><%= device_model.safety_class %><%= device_model.accuracy_class %>
+ + + + + + + + + + + + + + - <% end %> - -
<%= t('activerecord.attributes.device_model.name')%><%= t('activerecord.attributes.device_model.manufacturer')%><%= t('activerecord.attributes.device_model.measurement_group')%><%= t('activerecord.attributes.device_model.measurement_class')%><%= t('activerecord.attributes.device_model.measuring_unit')%><%= t('activerecord.attributes.device_model.measurement_sensitivity')%>.<%= t('activerecord.attributes.device_model.measurement_min')%><%= t('activerecord.attributes.device_model.measurement_max')%><%= t('activerecord.attributes.device_model.calibration_min')%><%= t('activerecord.attributes.device_model.calibration_max')%><%= t('activerecord.attributes.device_model.safety_class')%><%= t('activerecord.attributes.device_model.accuracy_class')%>
-
+ + + <% @device_models.each do |device_model| %> + + <%= device_model.name %> + <%= device_model.manufacturer.name %> + <%= device_model.measurement_group.name %> + <%= device_model.measurement_class.name %> + <%= device_model.measuring_unit %> + <%= device_model.measurement_sensitivity %> + <%= device_model.measurement_min %> + <%= device_model.measurement_max %> + <%= device_model.calibration_min %> + <%= device_model.calibration_max %> + <%= device_model.safety_class %> + <%= device_model.accuracy_class %> + + <% end %> + + +
diff --git a/app/views/admin/device_reg_group/index.html.erb b/app/views/admin/device_reg_group/index.html.erb index ccc283a..b713ec5 100644 --- a/app/views/admin/device_reg_group/index.html.erb +++ b/app/views/admin/device_reg_group/index.html.erb @@ -1,9 +1,9 @@ <% provide :page_title, "Рег.группы" %> <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "device_reg_group" %> <%= render 'shared/flash_alert' %>
-
+
+ <%= render 'shared/admin/navbar/device_bread', selected: "device_reg_group" %>

@@ -14,10 +14,10 @@
<%= search_form_for(@query, url:admin_device_reg_group_index_path, method: :get, class: "rounded accordion-body") do |f| %>
- <%= f.label :name, class: "mb-2" %> - <%= f.search_field :name_cont, class:"form-control", placeholder:"Название" %> + <%= f.label :name %> + <%= f.search_field :name_cont, class:"form-control mb-2", placeholder:"Название" %>
- <%= f.submit t('b_accept'), class: 'btn btn-primary w-100 my-2'%> + <%= f.submit t('b_accept'), class: 'my-2 btn btn-primary w-100 my-2'%>
<%= t("b_clear")%>
@@ -29,7 +29,7 @@ <%= render 'shared/modal_button_add', path: new_admin_device_reg_group_path, classes: "btn btn-primary w-100", text: t("b_add") %>

-
+
diff --git a/app/views/admin/division/create.turbo_stream.erb b/app/views/admin/division/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/division/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/division/edit.turbo_stream.erb b/app/views/admin/division/edit.turbo_stream.erb new file mode 100644 index 0000000..5f6aea4 --- /dev/null +++ b/app/views/admin/division/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.division.edit.edit_division') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/division", + locals: { path: admin_division_path(@division), division: @division } %> diff --git a/app/views/admin/division/index.html.erb b/app/views/admin/division/index.html.erb new file mode 100644 index 0000000..503b954 --- /dev/null +++ b/app/views/admin/division/index.html.erb @@ -0,0 +1,97 @@ +<% provide :page_title, "Подразделения" %> +<%= render 'shared/admin/navbar/admin', selected: "user" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/user_navbar', selected: "division" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_division_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 :organization_id, class:"mb-1" %> + <%= f.collection_select(:organization_id_eq, Organization.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_division_path, classes: "btn btn-primary w-100", text: t("b_add") %> +
+
+
+
+ + + + + + + + + + <% @divisions.each do |division| %> + + + + <% if division.organization.nil? %> + + <% else %> + + <% end %> + + + <% 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 %> +
+
+
+
+
+
+
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/division/new.turbo_stream.erb b/app/views/admin/division/new.turbo_stream.erb new file mode 100644 index 0000000..f4ecaa8 --- /dev/null +++ b/app/views/admin/division/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.division.new.add_division') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/division", + locals: { path: admin_division_index_path, division: @division } %> diff --git a/app/views/admin/division/update.turbo_stream.erb b/app/views/admin/division/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/division/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/manufacturer/index.html.erb b/app/views/admin/manufacturer/index.html.erb index 6400a25..fc946f3 100644 --- a/app/views/admin/manufacturer/index.html.erb +++ b/app/views/admin/manufacturer/index.html.erb @@ -1,9 +1,9 @@ <% provide :page_title, "Производители" %> <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "manufacturer" %> <%= render 'shared/flash_alert' %> -
-
+
+
+ <%= render 'shared/admin/navbar/device_bread', selected: "manufacturer" %>

@@ -14,36 +14,20 @@
<%= search_form_for(@query, url:admin_manufacturer_index_path, method: :get, class: "rounded accordion-body") do |f| %>
-
-
- <%= f.label :name, class: "mb-2" %> - <%= f.search_field :name_cont, class:"form-control", placeholder:"Название" %> -
-
- <%= f.label :adress, class: "my-2" %> - <%= f.search_field :adress_cont, class:"form-control", placeholder:"г. Димитровград, Победы 12" %> -
-
- <%= f.label :phone, class: "my-2" %> - <%= f.search_field :phone_cont, class:"form-control", placeholder:"+7 (999) 123-01-02" %> -
-
- <%= f.label :email, class: "my-2" %> - <%= f.search_field :email_cont, class:"form-control", placeholder:"niiar@example.ru" %> -
-
- <%= f.label :site_url, class: "my-2" %> - <%= f.search_field :site_url_cont, class:"form-control", placeholder:"example.ru" %> -
-
-
-
-
- <%= f.submit "Применить", class: 'col btn btn-primary w-100'%> -
+ <%= f.label :name %> + <%= f.search_field :name_cont, class:"form-control mb-2", placeholder:"Название" %> + <%= f.label :adress %> + <%= f.search_field :adress_cont, class:"form-control mb-2", placeholder:"г. Димитровград, Победы 12" %> + <%= f.label :phone %> + <%= f.search_field :phone_cont, class:"form-control mb-2", placeholder:"+7 (999) 123-01-02" %> + <%= f.label :email %> + <%= f.search_field :email_cont, class:"form-control mb-2", placeholder:"niiar@example.ru" %> + <%= f.label :site_url %> + <%= f.search_field :site_url_cont, class:"form-control mb-2", placeholder:"example.ru" %> + <%= f.submit "Применить", class: 'my-2 btn btn-primary w-100'%> +
<%= t("b_clear")%>
-
<% end %>
@@ -51,9 +35,7 @@
<%= render 'shared/modal_button_add', path: new_admin_manufacturer_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %>

-
-
-
+
@@ -71,8 +53,8 @@ - - + +
<%= manufacturer.name %> <%= manufacturer.adress %><%= manufacturer.phone %><%= manufacturer.email %><%= manufacturer.phone %><%= manufacturer.email %> <%= manufacturer.site_url %>
diff --git a/app/views/admin/measurement_class/index.html.erb b/app/views/admin/measurement_class/index.html.erb index a7ec6ab..6364567 100644 --- a/app/views/admin/measurement_class/index.html.erb +++ b/app/views/admin/measurement_class/index.html.erb @@ -1,9 +1,9 @@ <% provide :page_title, "Классы измерения" %> <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "measurement_class" %> <%= render 'shared/flash_alert' %>
-
+
+ <%= render 'shared/admin/navbar/device_bread', selected: "measurement_class" %>

@@ -14,13 +14,13 @@
<%= search_form_for(@query, url: admin_measurement_class_index_path, method: :get, class: "rounded accordion-body") do |f| %>
- <%= f.label :name, class: "mb-2" %> - <%= f.search_field :name_cont, class:"form-control", placeholder:"Название" %> - <%= f.label :measurement_group_id, class:"mb-1" %> - <%= f.collection_select(:measurement_group_id_eq, MeasurementGroup.all, - :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select'}) %> - <%= f.label :arms_device_type, class: "my-2" %> - <%= f.search_field :arms_device_type_eq, class:"form-control", placeholder:"1" %> + <%= f.label :name %> + <%= f.search_field :name_cont, class:"form-control mb-2", placeholder:"Название" %> + <%= f.label :measurement_group_id %> + <%= f.collection_select(:measurement_group_id_eq, MeasurementGroup.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select mb-2'}) %> + <%= f.label :arms_device_type %> + <%= f.search_field :arms_device_type_eq, class:"form-control mb-2", placeholder:"1" %>
<%= f.submit t('b_accept'), class: 'btn btn-primary w-100 my-2'%>
@@ -32,14 +32,14 @@
<%= render 'shared/modal_button_add', path: new_admin_measurement_class_path, classes: "btn btn-primary w-100", text: t("b_add") %>
-
+
- + diff --git a/app/views/admin/measurement_group/index.html.erb b/app/views/admin/measurement_group/index.html.erb index 16af796..7869bed 100644 --- a/app/views/admin/measurement_group/index.html.erb +++ b/app/views/admin/measurement_group/index.html.erb @@ -1,9 +1,9 @@ <% provide :page_title, "Группы измерения" %> <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "measurement_group" %> <%= render 'shared/flash_alert' %>
-
+
+ <%= render 'shared/admin/navbar/device_bread', selected: "measurement_group" %>

@@ -27,7 +27,7 @@

<%= render 'shared/modal_button_add', path: new_admin_measurement_group_path, classes: "btn btn-primary w-100", text: t("b_add") %>
-
+
<%= t('activerecord.attributes.measurement_class.name') %> <%= t('activerecord.attributes.measurement_class.arms_device_type') %><%= t('activerecord.attributes.measurement_class.measuremnt_group') %><%= t('activerecord.attributes.measurement_class.measurement_group') %> <%= t('action') %>
diff --git a/app/views/admin/organization/create.turbo_stream.erb b/app/views/admin/organization/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/organization/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/organization/edit.turbo_stream.erb b/app/views/admin/organization/edit.turbo_stream.erb new file mode 100644 index 0000000..e3e741d --- /dev/null +++ b/app/views/admin/organization/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.organization.edit') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/organization", + locals: { path: admin_organization_path(@organization), organization: @organization } %> diff --git a/app/views/admin/organization/index.html.erb b/app/views/admin/organization/index.html.erb new file mode 100644 index 0000000..45d93c2 --- /dev/null +++ b/app/views/admin/organization/index.html.erb @@ -0,0 +1,128 @@ +<% provide :page_title, "Организации" %> +<%= render 'shared/admin/navbar/admin', selected: "user" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/user_navbar', selected: "organization" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_organization_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 :full_address, class: "mb-1" %> + <%= f.search_field :full_address_cont, class:"form-control mb-2", placeholder:"Западное шоссе" %> + <%= f.label :zip_code, class: "mb-1" %> + <%= f.search_field :zip_code_cont, class:"form-control mb-2", placeholder:"433019" %> + <%= f.label :phone, class: "mb-1" %> + <%= f.search_field :phone_cont, class:"form-control mb-2", placeholder:"7-55-35" %> + <%= f.label :fax, class: "mb-1" %> + <%= f.search_field :fax_cont, class:"form-control mb-2", placeholder:"7-55-35" %> + <%= f.label :email, class: "mb-1" %> + <%= f.search_field :email_cont, class:"form-control mb-2", placeholder:"example@mail.com" %> +
+ <%= 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_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 %> + + + <% 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 %> +
+
+
+
+
+

+
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/organization/new.turbo_stream.erb b/app/views/admin/organization/new.turbo_stream.erb new file mode 100644 index 0000000..3ee8927 --- /dev/null +++ b/app/views/admin/organization/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.organization.new') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/organization", + locals: { path: admin_organization_index_path, organization: @organization } %> diff --git a/app/views/admin/organization/update.turbo_stream.erb b/app/views/admin/organization/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/organization/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/room/create.turbo_stream.erb b/app/views/admin/room/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/room/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/room/edit.turbo_stream.erb b/app/views/admin/room/edit.turbo_stream.erb new file mode 100644 index 0000000..aec72af --- /dev/null +++ b/app/views/admin/room/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.room.edit') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/room", + locals: { path: admin_room_path(@room), room: @room } %> diff --git a/app/views/admin/room/index.html.erb b/app/views/admin/room/index.html.erb new file mode 100644 index 0000000..351440e --- /dev/null +++ b/app/views/admin/room/index.html.erb @@ -0,0 +1,107 @@ +<% provide :page_title, "Помещения" %> +<%= render 'shared/admin/navbar/admin', selected: "location" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/location_navbar', selected: "room" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_room_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 :building_id, class: "mb-1" %> + <%= f.collection_select(:building_id_eq, Building.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select mb-2'}) %> + <%= f.label :level, class: "mb-1" %> + <%= f.search_field :level_cont, class: "form-control mb-2", placeholder:"Уровень"%> +
+ <%= 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_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 %> + + + <% 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 %> +
+
+
+
+
+
+
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/room/new.turbo_stream.erb b/app/views/admin/room/new.turbo_stream.erb new file mode 100644 index 0000000..e993dcc --- /dev/null +++ b/app/views/admin/room/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('admin.room.new') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/room", + locals: {path: admin_room_index_path, room: @room } %> diff --git a/app/views/admin/room/update.turbo_stream.erb b/app/views/admin/room/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/room/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/service/create.turbo_stream.erb b/app/views/admin/service/create.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/service/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/service/edit.turbo_stream.erb b/app/views/admin/service/edit.turbo_stream.erb new file mode 100644 index 0000000..4ebae7e --- /dev/null +++ b/app/views/admin/service/edit.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('.edit_service') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/service", + locals: {path: admin_service_path(@service), service: @service } %> diff --git a/app/views/admin/service/index.html.erb b/app/views/admin/service/index.html.erb new file mode 100644 index 0000000..7c2cc5d --- /dev/null +++ b/app/views/admin/service/index.html.erb @@ -0,0 +1,117 @@ +<% provide :page_title, "Службы" %> +<%= render 'shared/admin/navbar/admin', selected: "user" %> +<%= render 'shared/flash_alert' %> +
+
+ <%= render 'shared/admin/navbar/user_navbar', selected: "service" %> +
+
+

+ +

+
+ <%= search_form_for(@query, url: admin_service_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 :division_id %> + <%= f.search_field :division_name_cont, class:"form-control mb-2", placeholder:"Подразделение" %> + <%= f.label :organization_id %> + <%= f.collection_select(:organization_id_eq, Organization.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class =>'form-select mb-2'}) %> + <%= f.label :building_id %> + <%= f.search_field :building_name_cont, class:"form-control mb-2", placeholder:"Здание" %> +
+ <%= 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_service_path, classes: "btn btn-primary w-100", text: t("b_add") %> +
+
+
+ + + + + + + + + + + + + <% @services.each do |service| %> + + + + + <% if service.division.nil? %> + + <% else %> + + <% end %> + + <% if service.organization.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') %><%= t('action') %>
<%= service.id %><%= service.name %><%= "——" %><%= service.division.name %><%= "——" %><%= service.organization.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 %> +
+
+
+
+
+
+
+
+
+
+
+
+
+ <%= pagination @pagy %> +
+
+
+
+
+ diff --git a/app/views/admin/service/new.turbo_stream.erb b/app/views/admin/service/new.turbo_stream.erb new file mode 100644 index 0000000..ec98616 --- /dev/null +++ b/app/views/admin/service/new.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.update "modal-title", t('.add_service') %> +<%= turbo_stream.update "modal-body", partial: "shared/admin/form/service", + locals: {path: admin_service_index_path, service: @service } %> diff --git a/app/views/admin/service/update.turbo_stream.erb b/app/views/admin/service/update.turbo_stream.erb new file mode 100644 index 0000000..3ba4d15 --- /dev/null +++ b/app/views/admin/service/update.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.dispatch_event "modalClose" %> diff --git a/app/views/admin/supplementary_kit/index.html.erb b/app/views/admin/supplementary_kit/index.html.erb index c9a8434..f3dd2df 100644 --- a/app/views/admin/supplementary_kit/index.html.erb +++ b/app/views/admin/supplementary_kit/index.html.erb @@ -1,9 +1,9 @@ <% provide :page_title, "Наборы" %> <%= render 'shared/admin/navbar/admin', selected: "device" %> -<%= render 'shared/admin/navbar/device_bread', selected: "supplementary_kit" %> <%= render 'shared/flash_alert' %> -
-
+
+
+ <%= render 'shared/admin/navbar/device_bread', selected: "supplementary_kit" %>

@@ -14,28 +14,16 @@
<%= search_form_for(@query, url:admin_supplementary_kit_index_path, method: :get, class: "rounded accordion-body") do |f| %>
-
-
- <%= f.label :name %> - <%= f.search_field :name_cont, class:"form-control", placeholder:"БДЗБ" %> -
-
- <%= f.label :serial_id %> - <%= f.search_field :serial_id_cont, class:"form-control", placeholder:"0-123-N" %> -
-
- <%= f.label :description %> - <%= f.search_field :description_cont, class:"form-control", placeholder:"Набор для..." %> -
+ <%= f.label :name %> + <%= f.search_field :name_cont, class:"form-control mb-2", placeholder:"БДЗБ" %> + <%= f.label :serial_id %> + <%= f.search_field :serial_id_cont, class:"form-control mb-2", placeholder:"0-123-N" %> + <%= f.label :description %> + <%= f.search_field :description_cont, class:"form-control mb-2", placeholder:"Набор для..." %> + <%= f.submit t('b_accept'), class: 'my-2 btn btn-primary w-100'%> +
+ <%= t("b_clear")%>
-
-
- <%= f.submit t('b_accept'), class: 'col btn btn-primary w-100'%> -
- <%= t("b_clear")%> -
-
-
<% end %>
@@ -43,8 +31,9 @@
<%= 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}" %>
@@ -77,6 +66,7 @@
<% end %> +
diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index fc3545e..b537902 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,9 +1,10 @@ <% provide :page_title, "Панель администрирования" %> <%= render 'shared/admin/navbar/admin', selected: "user" %> <%= render 'shared/flash_alert' %> -
-
-
+
+
+ <%= render 'shared/admin/navbar/user_navbar', selected: "user" %> +

<%= search_form_for(@query, url:admin_users_path, method: :get, data:{controller: "filter"}, class: "rounded accordion-body") do |f| %> -
-
- <%= f.label :tabel_id, class:"mb-1" %> - <%= f.search_field :tabel_id_eq, class: 'form-control', placeholder: '1' %> -
-
- <%= f.label :first_name, class:"mb-1"%> - <%= f.search_field :first_name_cont, class: 'form-control', placeholder: 'Иван' %> -
-
- <%= f.label :last_name, class:"mb-1" %> - <%= f.search_field :last_name_cont, class: 'form-control', placeholder: 'Иванов' %> -
-
- <%= f.label :second_name, class:"mb-1" %> - <%= f.search_field :second_name_cont, class: 'form-control', placeholder: 'Иванович' %> -
-
-
-
- <%= f.label :role, class:"mb-1" %> - + + <% User::ROLES.each do |key,value| %> + <% if key == @selected_role %> +
-
- <%= f.label :email, class:"mb-1" %> - <%= f.search_field :email_cont, class: 'form-control', placeholder: 'Иванович' %> -
-
- <%= f.label :phone, class:"mb-1" %> - <%= f.search_field :phone_cont, class: 'form-control', placeholder: '+79021234578' %> -
-
- <%= f.label :service, class:"mb-1" %> - <%= f.collection_select(:service_id_eq, Service.all, - :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select'}) %> + <%= (value) %> + <% end %> + + <%= f.label :email %> + <%= f.search_field :email_cont, class: 'form-control mb-2', placeholder: 'Иванович' %> + <%= f.label :phone %> + <%= f.search_field :phone_cont, class: 'form-control mb-2', placeholder: '+79021234578' %> + <%= f.label :service %> + <%= f.collection_select(:service_id_eq, Service.all, + :id, :name, {:include_blank => t('combobox_blank')}, {:class=>'form-select form-select'}) %> + <%= f.label t('.created_at_from') %> + <%= f.date_field :created_at_gteq, class: 'form-control mb-2 ' %> + <%= f.label t('.created_at_to') %> + <%= f.date_field :created_at_lteq, class: 'form-control mb-2' %> + <%= f.label t('.updated_at_from') %> + <%= f.date_field :updated_at_gteq, class: 'form-control mb-2' %> + <%= f.label t('.updated_at_to') %> + <%= f.date_field :updated_at_lteq, class: 'form-control mb-2' %> + <%= f.submit t("b_accept"), class: 'btn btn-primary w-100 my-2'%> +
+ <%= t("b_clear")%>
-
-
- <%= f.label t('.created_at_from'), class:"mb-1" %> - <%= f.date_field :created_at_gteq, class: 'form-control ' %> -
-
- <%= f.label t('.created_at_to'), class:"mb-1" %> - <%= f.date_field :created_at_lteq, class: 'form-control' %> -
-
- <%= f.label t('.updated_at_from'), class:"mb-1" %> - <%= f.date_field :updated_at_gteq, class: 'form-control' %> -
-
- <%= f.label t('.updated_at_to'), class:"mb-1" %> - <%= f.date_field :updated_at_lteq, class: 'form-control' %> -
-
-
-
-
- <%= f.submit "Применить", class: 'col btn btn-primary w-100'%> -
-
-
<% end %>
@@ -92,13 +62,11 @@ <%= t('b_add')%> <% end %>
-
-
-
+
- + @@ -120,9 +88,9 @@ - - - + + +
<%=t('activerecord.attributes.user.tabel_id')%> <%=t('activerecord.attributes.user.last_name')%> <%=t('activerecord.attributes.user.first_name')%><%= user.first_name %> <%= user.second_name %> <%= user.role %><%= user.email %><%= user.phone %><%= user.service.name %><%= user.email %><%= user.phone %><%= user.service.name %> <%= formatted_date(user.created_at, :short_full) %> <%= formatted_date(user.updated_at, :short_full) %> @@ -158,3 +126,16 @@ + diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 1bdecb3..5408152 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,4 +1,14 @@
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 397b2c0..ce2fb7b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,5 +1,5 @@ - + <%= full_title(yield(:page_title))%> @@ -8,6 +8,12 @@ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> +
@@ -18,7 +24,13 @@ <% if user_signed_in? %>
  • <% if can? :read, :armstrong %> - <%= link_to t(".ARMS"), armstrong_index_path, class: "nav-link px-2 link-secondary" %> + <%= link_to armstrong_index_path, class: "nav-link px-2 link-secondary position-relative" do %> + <%= t(".ARMS") %> + + β + Этот раздел в разработке + + <% end %> <% end %>
  • @@ -39,6 +51,11 @@ <% if user_signed_in? %> + <% if current_user.admin? %> + <%= button_to admin_users_path, method: :get, class: "btn btn-light me-2" do %> + <%= t('.admin_panel') %> + <% end %> + <% end %> diff --git a/app/views/shared/_modal.html.erb b/app/views/shared/_modal.html.erb index 9cd0d27..db536a6 100644 --- a/app/views/shared/_modal.html.erb +++ b/app/views/shared/_modal.html.erb @@ -1,6 +1,6 @@
  • + diff --git a/app/views/shared/admin/navbar/_device_bread.html.erb b/app/views/shared/admin/navbar/_device_bread.html.erb index 37299d4..2388dc5 100644 --- a/app/views/shared/admin/navbar/_device_bread.html.erb +++ b/app/views/shared/admin/navbar/_device_bread.html.erb @@ -1,11 +1,43 @@ -
    +
    <% selected = local_assigns[:selected] %> - <%= link_to 'Приборы', admin_device_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'device' }" %> - <%= link_to 'Модели', admin_device_model_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'device_model' }" %> - <%= link_to 'Компоненты', admin_device_component_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'device_component' }" %> - <%= link_to 'Наборы', admin_supplementary_kit_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'supplementary_kit' }" %> - <%= link_to 'Рег.группы', admin_device_reg_group_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'device_reg_group' }" %> - <%= link_to 'Производители', admin_manufacturer_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'manufacturer' }" %> - <%= link_to 'Классы измерений', admin_measurement_class_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'measurement_class' }" %> - <%= link_to 'Группы измерений', admin_measurement_group_index_path, class: "px-0 col btn #{ 'btn-primary' if selected == 'measurement_group' }" %> +
    + <%= link_to admin_device_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'device' } text-start" do %> + <%= 'Приборы' %> + <% end %> +
    +
    + <%= link_to admin_device_model_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'device_model' } text-start" do %> + <%= 'Модели' %> + <% end %> +
    +
    + <%= link_to admin_device_component_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'device_component' } text-start" do %> + <%= 'Компоненты' %> + <% end %> +
    +
    + <%= link_to admin_supplementary_kit_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'supplementary_kit' } text-start" do %> + <%= 'Наборы' %> + <% end %> +
    +
    + <%= link_to admin_device_reg_group_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'device_reg_group' } text-start" do %> + <%= 'Рег.группы' %> + <% end %> +
    +
    + <%= link_to admin_manufacturer_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'manufacturer' } text-start" do %> + <%= 'Производители' %> + <% end %> +
    +
    + <%= link_to admin_measurement_class_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'measurement_class' } text-start" do %> + <%= 'Классы измерений' %> + <% end %> +
    +
    + <%= link_to admin_measurement_group_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'measurement_group' } text-start" do %> + <%= 'Группы измерений' %> + <% end %> +
    diff --git a/app/views/shared/admin/navbar/_location_navbar.html.erb b/app/views/shared/admin/navbar/_location_navbar.html.erb new file mode 100644 index 0000000..1a9db7d --- /dev/null +++ b/app/views/shared/admin/navbar/_location_navbar.html.erb @@ -0,0 +1,18 @@ +
    + <% selected = local_assigns[:selected] %> +
    + <%= link_to admin_control_point_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'control_point' } text-start" do %> + <%= 'Точки контроля' %> + <% end %> +
    +
    + <%= link_to admin_room_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'room' } text-start" do %> + <%= 'Помещения' %> + <% end %> +
    +
    + <%= link_to admin_building_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'building' } text-start" do %> + <%= 'Здания' %> + <% end %> +
    +
    diff --git a/app/views/shared/admin/navbar/_user_navbar.html.erb b/app/views/shared/admin/navbar/_user_navbar.html.erb new file mode 100644 index 0000000..4252d7b --- /dev/null +++ b/app/views/shared/admin/navbar/_user_navbar.html.erb @@ -0,0 +1,23 @@ +
    + <% selected = local_assigns[:selected] %> +
    + <%= link_to admin_users_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'user' } text-start" do %> + <%= 'Пользователи' %> + <% end %> +
    +
    + <%= link_to admin_service_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'service' } text-start" do %> + <%= 'Службы' %> + <% end %> +
    +
    + <%= link_to admin_division_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'division' } text-start" do %> + <%= 'Подразделения' %> + <% end %> +
    +
    + <%= link_to admin_organization_index_path, class: "btn btn-sm w-100 #{ 'btn-primary' if selected == 'organization' } text-start" do %> + <%= 'Организации' %> + <% end %> +
    +
    diff --git a/app/views/shared/index/_device.html.erb b/app/views/shared/index/_device.html.erb index 9013d35..d9af8d5 100644 --- a/app/views/shared/index/_device.html.erb +++ b/app/views/shared/index/_device.html.erb @@ -1,7 +1,10 @@ <% provide :page_title, "Приборы" %> <% show_path = show_path.from(0).to(show_path.length-2) %>
    -
    +
    + <% if current_page?(admin_device_index_path) %> + <%= render 'shared/admin/navbar/device_bread', selected: "device" %> + <% end %>

    @@ -70,7 +73,7 @@ <%=t('b_download_pdf')%> <% end %>

    -
    +
    diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 51f5b04..35496ec 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -142,6 +142,12 @@ ru: month: Месяц second: Секунд year: Год + placeholders: + organization: + add_edit_form: + name: Название организации + full_address: Адрес + message: user: create: @@ -193,6 +199,18 @@ ru: user: Пользователь inspection: Инспекция attributes: + building: + id: ID + name: Название + organization_id: Организация + organization: Организация + description: Описание + control_point: + name: Название + room: Помещение + room_id: Помещение + description: Описание + device: Устройство device: inventory_id: Инв. № device_model: Модель @@ -218,19 +236,19 @@ ru: name: Название manufacturer: Производитель manufacturer_id: Производитель - measurement_group: Группа измерений - measurement_group_id: Группа измерений - measurement_class: Класс измерений - measurement_class_id: Класс измерений - measuring_unit: Ед. измерений - measurement_sensitivity: Чувств. измерений - measurement_min: Мин. величина измерений - measurement_max: Макс. величина измерений - safety_class: Класс безопасности - accuracy_class: Класс точности + measurement_group: Группа изм. + measurement_group_id: Группа изм. + measurement_class: Класс изм. + measurement_class_id: Класс изм. + measuring_unit: Ед. изм. + measurement_sensitivity: Чувств. изм. + measurement_min: Мин. вел. изм. + measurement_max: Макс. вел. изм. + safety_class: Класс без-ти + accuracy_class: Класс точ-ти is_complete_device: Полный набор? - is_tape_rolling_mechanism: Имеет лентопротяжный механизм? - measurement_range: Диапазон измерений + is_tape_rolling_mechanism: ЛП механизм? + measurement_range: Диапазон изм. calibration_max: Макс. калибр. calibration_min: Мин. калибр. device_reg_group: @@ -243,28 +261,57 @@ ru: site_url: Ссылка на сайт measurement_class: name: Название - measurement_group: Группа измерений - measurement_group_id: Группа измерений + measurement_group: Группа изм. + measurement_group_id: Группа изм. arms_device_type: ARMS-тип measurement_group: name: Название + organization: + id: ID + name: Название + full_address: Адрес + zip_code: Индекс + phone: Телефон + fax: Факс + email: E-mail device_component: - serial_id: Серийный номер + serial_id: Сер. номер name: Название - measurement_min: Мин. величина измерений - measurement_max: Макс. величина измерений - measurement_unit: Единица измерений + measurement_min: Мин. вел. изм. + measurement_max: Макс. величина изм. + measuring_unit: Ед. изм. description: Описание supplementary_kit: Набор + division: + id: ID + name: Название + organization: Организация + organization_id: Организация supplementary_kit: serial_id: Серийный номер name: Название description: Описание + room: + id: ID + name: Название + building: Здание + building_id: Здание + level: Уровень + description: Описание post: title: Заголовок body: Текст записи user: Автор category: Категория + service: + id: ID + name: Название + division: Подразделение + division_id: Подразделение + organization: Организация + organization_id: Организация + building: Здание + building_id: Здание user: tabel_id: Таб. № first_name: Имя @@ -310,6 +357,81 @@ ru: leave_blank_if_you_don_t_want_to_change_it: оставьте поле пустым, если не хотите его менять title: Страница редактирования %{resource} we_need_your_current_password_to_confirm_your_changes: введите текущий пароль для подтверждения изменений + shared: + admin: + form: + division: + labels: + name: Название + division: Подразделение + organization: Организация + building: Здание + building: + labels: + name: Название + organization: Организация + placeholders: + name: "106" + description: "Здание СМ-3 и РБТ-6" + room: + placeholders: + name: "112" + level: "-4.8" + description: "Кобальтовый участок" + organization: + labels: + name: Название + full_address: Адрес + zip_code: Индекс + phone: Телефон + fax: Факс + email: E-mail + placeholders: + name: АО ГНЦ НИИАР + full_address: Западное шоссе, 9 + zip_code: "433019" + phone: 7-55-25 + fax: 7-55-25 + email: info@niiar.ru + show: + device: + send_to_inspection: Отправить на инспекцию + admin_send_to_inspection: Отправить на инспекцию (админ) + index: + division: + id: ID + name: Название + inspection: + device: Прибор + assigned_user: Инспектор + target: Цель + state: Состояние + conclusion: Заключение + conclusion_date: Дата заключения + description: Описание + creator: Направил + device_tabel_id: Таб.№ + device_serial_id: Сер.№ + text-no-new-task: Задач пока нет... + performer_last_name: Иванов + performer_first_name: Иван + performer_second_name: Иванович + inspection_description: Прибор был поверен... + creator_last_name: Петров + creator_first_name: Петр + creator_second_name: Петрович + conclusion_date_from: Дата заключения от + conclusion_date_to: Дата заключения до + device: + b_add_device: Прибор + b_add_device_component: Компонент + navbar: + inspection: + new_tasks: Новые задачи + my_tasks: Мои задачи + completed_tasks: Завершенные задачи + all_tasks: Все задачи + service_tasks: Задачи службы layouts: application: home: Главная @@ -322,11 +444,6 @@ ru: profile: Профиль logout: Выйти edit_me: Изм. профиль - shared: - show: - device: - send_to_inspection: Отправить на инспекцию - admin_send_to_inspection: Отправить на инспекцию (админ) navbar: inspection: new_tasks: Новые задачи @@ -387,6 +504,14 @@ ru: created_at_to: Создан до updated_at_from: Обновлен от updated_at_to: Обновлен до + building: + new: Добавить здание + edit: Изменить здание + control_point: + new: + add_control_point: Добавить т. контроля + edit: + edit_add_control_point: Изменить т. контроля device_component: new: add_device_component: Добавить компонент @@ -422,6 +547,12 @@ ru: add_measurement_class: Добавить класс изм. edit: edit_measurement_class: Изменить класс изм. + room: + new: Добавить пом. + edit: Изменить пом. + organization: + new: Добавить орг. + edit: Изменить орг. combobox_blank: Не учитывать b_change: Изменить b_delete: Удалить diff --git a/config/routes.rb b/config/routes.rb index 52a8c47..843d6db 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,8 @@ post :create_inspection, :to => 'device#create_inspection' end resources :device_model, :measurement_class - resources :manufacturer, :measurement_group, :device_reg_group, :supplementary_kit, :device_component, except: [:show] + resources :room, :building, :organization, :division, :service, :control_point, :manufacturer, :measurement_group, :device_reg_group, + :supplementary_kit, :device_component, except: [:show] end devise_for :users, controllers: { @@ -32,7 +33,7 @@ resources :device do post :create_inspection, :to => 'device#create_inspection' end - resources :device_model, :measurement_class, + resources :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/20240124055240_add_level_column_to_room.rb b/db/migrate/20240124055240_add_level_column_to_room.rb new file mode 100644 index 0000000..8ea1cce --- /dev/null +++ b/db/migrate/20240124055240_add_level_column_to_room.rb @@ -0,0 +1,5 @@ +class AddLevelColumnToRoom < ActiveRecord::Migration[7.0] + def change + add_column :rooms, :level, :string + end +end diff --git a/db/migrate/20240124055906_create_control_points.rb b/db/migrate/20240124055906_create_control_points.rb new file mode 100644 index 0000000..c2ee43a --- /dev/null +++ b/db/migrate/20240124055906_create_control_points.rb @@ -0,0 +1,13 @@ +class CreateControlPoints < ActiveRecord::Migration[7.0] + def change + create_table :control_points do |t| + t.string :name + t.string :description + t.references :room, null: false, foreign_key: true + t.references :channel, null: false, foreign_key: true + t.references :device, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20240124095819_change_null_constraint_on_control_points.rb b/db/migrate/20240124095819_change_null_constraint_on_control_points.rb new file mode 100644 index 0000000..d3fb288 --- /dev/null +++ b/db/migrate/20240124095819_change_null_constraint_on_control_points.rb @@ -0,0 +1,7 @@ +class ChangeNullConstraintOnControlPoints < ActiveRecord::Migration[7.0] + def change + change_column_null :control_points, :room_id, true + change_column_null :control_points, :channel_id, true + change_column_null :control_points, :device_id, true + end +end diff --git a/db/migrate/20240124103459_change_control_point_and_channel_relations.rb b/db/migrate/20240124103459_change_control_point_and_channel_relations.rb new file mode 100644 index 0000000..e6790ef --- /dev/null +++ b/db/migrate/20240124103459_change_control_point_and_channel_relations.rb @@ -0,0 +1,5 @@ +class ChangeControlPointAndChannelRelations < ActiveRecord::Migration[7.0] + def change + add_reference :channels, :control_point, null: true, foreign_key: true + end +end diff --git a/db/migrate/20240125055503_delete_column_from_channel.rb b/db/migrate/20240125055503_delete_column_from_channel.rb new file mode 100644 index 0000000..d2c25d9 --- /dev/null +++ b/db/migrate/20240125055503_delete_column_from_channel.rb @@ -0,0 +1,6 @@ +class DeleteColumnFromChannel < ActiveRecord::Migration[7.0] + def change + remove_column :channels, :device_id + remove_column :channels, :room_id + end +end diff --git a/db/migrate/20240125074727_remove_name_column_from_channel.rb b/db/migrate/20240125074727_remove_name_column_from_channel.rb new file mode 100644 index 0000000..a54edae --- /dev/null +++ b/db/migrate/20240125074727_remove_name_column_from_channel.rb @@ -0,0 +1,5 @@ +class RemoveNameColumnFromChannel < ActiveRecord::Migration[7.0] + def change + remove_column :channels, :name + end +end diff --git a/db/migrate/20240125082316_remove_channel_column_from_control_point.rb b/db/migrate/20240125082316_remove_channel_column_from_control_point.rb new file mode 100644 index 0000000..30c22c1 --- /dev/null +++ b/db/migrate/20240125082316_remove_channel_column_from_control_point.rb @@ -0,0 +1,5 @@ +class RemoveChannelColumnFromControlPoint < ActiveRecord::Migration[7.0] + def change + remove_column :control_points, :channel_id + end +end diff --git a/db/migrate/20240129094419_add_columnt_to_control_point.rb b/db/migrate/20240129094419_add_columnt_to_control_point.rb new file mode 100644 index 0000000..9742ac0 --- /dev/null +++ b/db/migrate/20240129094419_add_columnt_to_control_point.rb @@ -0,0 +1,5 @@ +class AddColumntToControlPoint < ActiveRecord::Migration[7.0] + def change + add_reference :control_points, :service, foreign_key: true + end +end diff --git a/db/migrate/20240202044407_add_room_description_column.rb b/db/migrate/20240202044407_add_room_description_column.rb new file mode 100644 index 0000000..91f0236 --- /dev/null +++ b/db/migrate/20240202044407_add_room_description_column.rb @@ -0,0 +1,5 @@ +class AddRoomDescriptionColumn < ActiveRecord::Migration[7.0] + def change + add_column :rooms, :description, :string + end +end diff --git a/db/migrate/20240202044416_add_building_description_column.rb b/db/migrate/20240202044416_add_building_description_column.rb new file mode 100644 index 0000000..4dea84b --- /dev/null +++ b/db/migrate/20240202044416_add_building_description_column.rb @@ -0,0 +1,5 @@ +class AddBuildingDescriptionColumn < ActiveRecord::Migration[7.0] + def change + add_column :buildings, :description, :string + end +end diff --git a/db/migrate/20240202104526_update_device_and_control_point_relative.rb b/db/migrate/20240202104526_update_device_and_control_point_relative.rb new file mode 100644 index 0000000..f0c29f2 --- /dev/null +++ b/db/migrate/20240202104526_update_device_and_control_point_relative.rb @@ -0,0 +1,6 @@ +class UpdateDeviceAndControlPointRelative < ActiveRecord::Migration[7.0] + def change + remove_reference :control_points, :device, index: true, foreign_key: :true + add_reference :devices, :control_point, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index faa389c..f3e6734 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: 2023_09_15_043035) do +ActiveRecord::Schema[7.0].define(version: 2024_02_02_104526) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -19,14 +19,12 @@ t.bigint "organization_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "description" t.index ["organization_id"], name: "index_buildings_on_organization_id" end create_table "channels", force: :cascade do |t| - t.string "name" t.integer "channel_id" - t.bigint "device_id", null: false - t.bigint "room_id", null: false t.bigint "server_id", null: false t.bigint "service_id", null: false t.text "location_description" @@ -46,12 +44,23 @@ t.string "state", default: "normal" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["device_id"], name: "index_channels_on_device_id" - t.index ["room_id"], name: "index_channels_on_room_id" + t.bigint "control_point_id" + t.index ["control_point_id"], name: "index_channels_on_control_point_id" t.index ["server_id"], name: "index_channels_on_server_id" t.index ["service_id"], name: "index_channels_on_service_id" end + create_table "control_points", force: :cascade do |t| + t.string "name" + t.string "description" + t.bigint "room_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "service_id" + t.index ["room_id"], name: "index_control_points_on_room_id" + t.index ["service_id"], name: "index_control_points_on_service_id" + end + create_table "device_components", force: :cascade do |t| t.bigint "supplementary_kit_id" t.string "serial_id" @@ -110,6 +119,8 @@ 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.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 @@ -205,6 +216,8 @@ t.bigint "building_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "level" + t.string "description" t.index ["building_id"], name: "index_rooms_on_building_id" end @@ -263,14 +276,16 @@ end add_foreign_key "buildings", "organizations" - add_foreign_key "channels", "devices" - add_foreign_key "channels", "rooms" + add_foreign_key "channels", "control_points" add_foreign_key "channels", "servers" add_foreign_key "channels", "services" + 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 96a468b..9bfb22d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -216,7 +216,8 @@ 100.times do |i| Room.create( name: "#{i}", - building: Building.find_by(id: rand(1..10)) + building: Building.find_by(id: rand(1..10)), + level: rand(0.0..10.0) ) end @@ -292,9 +293,21 @@ ) 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 -1000.times do |i| +100.times do |i| + puts ControlPoint.find_by(id: i + 1).name Device.create( inventory_id: i, serial_id: "#{i}-123-N", @@ -304,7 +317,8 @@ year_of_production: 1990, year_of_commissioning: 1991, supplementary_kit: SupplementaryKit.find_by(id: rand(1..20)), - service: Service.find_by(id: rand(1..10)) + service: Service.find_by(id: rand(1..10)), + control_point: ControlPoint.find_by(id: i + 1), ) end @@ -352,12 +366,10 @@ # seed Channel -200.times do |i| +100.times do |i| Channel.create( - name: "ДКЗ-#{i}", channel_id: "#{i}", - device: Device.find_by(id: rand(1..1000)), - room: Room.find_by(id: rand(1..100)), + control_point: ControlPoint.find_by(id: rand(1..100)), server: Server.find_by(id: rand(1..10)), service: Service.find_by(id: rand(1..10)), location_description: "Description", @@ -377,3 +389,13 @@ state: "normal" ) end + +100.times do |i| + History.create( + channel_id: Channel.first, + 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 new file mode 100644 index 0000000..ddc78ea --- /dev/null +++ b/test/controllers/admin/building_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Admin::BuildingControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/admin/division_controller_test.rb b/test/controllers/admin/division_controller_test.rb new file mode 100644 index 0000000..ff2791b --- /dev/null +++ b/test/controllers/admin/division_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class Admin::DivisionControllerTest < ActionDispatch::IntegrationTest + test 'should get index' do + get admin_division_index_url + assert_response :success + end +end diff --git a/test/controllers/admin/organization_controller_test.rb b/test/controllers/admin/organization_controller_test.rb new file mode 100644 index 0000000..8dd03d8 --- /dev/null +++ b/test/controllers/admin/organization_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Admin::OrganizationControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/admin/room_controller_test.rb b/test/controllers/admin/room_controller_test.rb new file mode 100644 index 0000000..b49c04b --- /dev/null +++ b/test/controllers/admin/room_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class Admin::RoomControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/control_point_controller_test.rb b/test/controllers/control_point_controller_test.rb new file mode 100644 index 0000000..90cc9e2 --- /dev/null +++ b/test/controllers/control_point_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ControlPointControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/licenses_controller_test.rb b/test/controllers/licenses_controller_test.rb index ea2b1c9..488236f 100644 --- a/test/controllers/licenses_controller_test.rb +++ b/test/controllers/licenses_controller_test.rb @@ -1,4 +1,4 @@ -require "test_helper" +require 'test_helper' class LicensesControllerTest < ActionController::TestCase end diff --git a/test/factories/channels.rb b/test/factories/channels.rb index d93e1e1..6b4c8f5 100644 --- a/test/factories/channels.rb +++ b/test/factories/channels.rb @@ -1,9 +1,7 @@ FactoryBot.define do factory :channel do - name channel_id { 1 } - device { association :device } - room { association :room } + control_point { association :control_point } server { association :server } service { association :service } location_description { 'MyText' } diff --git a/test/factories/control_points.rb b/test/factories/control_points.rb new file mode 100644 index 0000000..9b4e4c3 --- /dev/null +++ b/test/factories/control_points.rb @@ -0,0 +1,10 @@ +FactoryBot.define do + factory :control_point do + name { 'MyString' } + description { 'MyString' } + room { nil } + channel { nil } + device { nil } + service { association :service } + end +end diff --git a/test/factories/services.rb b/test/factories/services.rb index 01b5c54..cd46536 100644 --- a/test/factories/services.rb +++ b/test/factories/services.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :service do - name { 'MyStr2222isng' } + name division { association :division } organization { association :organization } building { association :building } diff --git a/test/models/control_point_test.rb b/test/models/control_point_test.rb new file mode 100644 index 0000000..bd6f5f5 --- /dev/null +++ b/test/models/control_point_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ControlPointTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end