Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feature/room expand #50

Merged
merged 31 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb5ab05
ADD: добавляет новую колонку level в room и новую таблицу control_poi…
owlscatcher Jan 24, 2024
fb550be
UPD: добавляет связи в модели room и device
owlscatcher Jan 24, 2024
c35b3d3
ADD: добавляет часть фукционала для работами с точками контроля, неко…
owlscatcher Jan 24, 2024
3a7f825
UPD: продолжает вносить изменения от коммита c35b3d3e, удаляет из cha…
owlscatcher Jan 25, 2024
8d622f0
UPD: отключает вертикальный скролл для всех браузеров
owlscatcher Jan 26, 2024
49c20d5
FIX: исправляет неработающие тесты после обновления моделей
owlscatcher Jan 26, 2024
06c7f67
ADD: добавляет заглушки тестов для новых моделей и контроллеров
owlscatcher Jan 26, 2024
8da4feb
UPD: продолжает 3a7f825c, продолжает обновлять UI и добавлять/исправ…
owlscatcher Jan 26, 2024
10a6bc7
UPD: немного обновляет страницу логина, добавляет ссылки на локальное…
owlscatcher Jan 29, 2024
d775ce9
FIX: исправляет верстку панели фитра для моделей СИ
owlscatcher Jan 29, 2024
f0a1c0a
FIX: исправляет верстку панели фитра для компонентов СИ
owlscatcher Jan 29, 2024
a9fa11f
FIX: исправляет верстку панели фитра для наборов СИ
owlscatcher Jan 29, 2024
9ed26fd
FIX: исправляет верстку панели фитра для регистрационных групп СИ
owlscatcher Jan 29, 2024
94c2cc8
FIX: исправляет верстку панели фитра для производителей СИ
owlscatcher Jan 29, 2024
cca9a18
FIX: исправляет верстку панели фитра для классов измерения СИ
owlscatcher Jan 29, 2024
8082d27
FIX: исправляет верстку панели фитра для Пользователей
owlscatcher Jan 29, 2024
ae6cd94
UPD: для точек контроля добавляет селектор службы на все нужные вьюшки
owlscatcher Jan 29, 2024
dfb484d
ADD: добавлен функционал для служб в админке (без русификации)
owlscatcher Jan 30, 2024
f4d9aa8
FIX: исправляет неработающие тесты
owlscatcher Jan 30, 2024
c8fde1e
UPD: применяет rubocop
owlscatcher Jan 30, 2024
5973df5
ADD: добавлен функционал для подразделений в админке (без русификации)
owlscatcher Jan 31, 2024
74a0c9d
ADD: добавлен функционал для организаций в админке (без русификации)
owlscatcher Jan 31, 2024
a828497
UPD: немного исправляет l18n
owlscatcher Feb 1, 2024
795b145
ADD: добавлен функционал для зданий и помещений в админке (с локализа…
owlscatcher Feb 1, 2024
2b8610b
UPD: исправляет заголовок для редактирования организации с l18n
owlscatcher Feb 1, 2024
c7f2d53
UPD: добавляет колонку с описанием в Rooms и Buildings
owlscatcher Feb 2, 2024
b0c9073
FIX: исправляет связи между ControlPoint и Device
owlscatcher Feb 2, 2024
0ba02f2
FIX: исправляет l18n на shared страницах
owlscatcher Feb 5, 2024
327da1a
FIX: исправляет страницу СРК
owlscatcher Feb 5, 2024
32319d1
FIX: исправляет l18n на shared страницах (2)
owlscatcher Feb 12, 2024
89172a2
FIX: исправляет падающий тест для Device
owlscatcher Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ GEM
zeitwerk (2.6.7)

PLATFORMS
x86_64-linux
x86_64-linux-musl

DEPENDENCIES
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/admin/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Admin::AdminController < ApplicationController
load_and_authorize_resource
def index; end
def index
redirect_to(admin_users_path)
end
end
30 changes: 30 additions & 0 deletions app/controllers/admin/building_controller.rb
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions app/controllers/admin/control_point_controller.rb
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions app/controllers/admin/division_controller.rb
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions app/controllers/admin/organization_controller.rb
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions app/controllers/admin/room_controller.rb
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions app/controllers/admin/service_controller.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 9 additions & 3 deletions app/controllers/api/v1/armstrong_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
55 changes: 55 additions & 0 deletions app/controllers/concerns/building_concern.rb
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions app/controllers/concerns/control_point_concern.rb
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading