-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/room-expand' into develop
- Loading branch information
Showing
108 changed files
with
2,094 additions
and
401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,6 +302,7 @@ GEM | |
zeitwerk (2.6.7) | ||
|
||
PLATFORMS | ||
x86_64-linux | ||
x86_64-linux-musl | ||
|
||
DEPENDENCIES | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.