From 2d174d4fd01791730808eff98598a1db9c7c57b3 Mon Sep 17 00:00:00 2001 From: ming Date: Thu, 29 May 2025 08:46:12 +0900 Subject: [PATCH] =?UTF-8?q?=EC=8B=A0=EA=B7=9C=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/images/svg/svg_valve.svg | 5 + .../stylesheets/application.tailwind.css | 69 ++++-- app/controllers/device_controller.rb | 2 - app/controllers/environment_controller.rb | 25 +++ app/controllers/nutrient_controller.rb | 2 + app/controllers/rack_controller.rb | 2 + app/controllers/web_controller.rb | 2 - app/helpers/application_helper.rb | 8 + app/helpers/device_helper.rb | 2 - app/helpers/environment_helper.rb | 2 + app/helpers/nutrient_helper.rb | 2 + app/helpers/rack_helper.rb | 2 + app/helpers/web_helper.rb | 2 - app/views/device/index.html.erb | 1 - app/views/environment/index.html.erb | 100 +++++++++ app/views/environment/view_area.html.erb | 79 +++++++ app/views/environment/view_co2.html.erb | 58 +++++ app/views/environment/view_humidity.html.erb | 58 +++++ app/views/environment/view_temp.html.erb | 64 ++++++ app/views/layouts/application.html.erb | 16 +- app/views/nutrient/index.html.erb | 212 ++++++++++++++++++ app/views/partials/_header.html.erb | 8 - app/views/partials/_modals_open.html.erb | 2 +- app/views/partials/_sidebar.html.erb | 83 +++++-- app/views/rack/index.html.erb | 38 ++++ app/views/schedules/index.html.erb | 18 +- app/views/schedules/schedule_edit.html.erb | 144 ++++++------ app/views/schedules/view.html.erb | 16 +- app/views/web/index.html.erb | 1 - config/routes.rb | 15 +- modbus.rb | 18 +- .../environment_controller_test.rb | 7 + ...er_test.rb => nutrient_controller_test.rb} | 2 +- ...roller_test.rb => rack_controller_test.rb} | 2 +- 34 files changed, 892 insertions(+), 175 deletions(-) create mode 100644 app/assets/images/svg/svg_valve.svg delete mode 100644 app/controllers/device_controller.rb create mode 100644 app/controllers/environment_controller.rb create mode 100644 app/controllers/nutrient_controller.rb create mode 100644 app/controllers/rack_controller.rb delete mode 100644 app/controllers/web_controller.rb delete mode 100644 app/helpers/device_helper.rb create mode 100644 app/helpers/environment_helper.rb create mode 100644 app/helpers/nutrient_helper.rb create mode 100644 app/helpers/rack_helper.rb delete mode 100644 app/helpers/web_helper.rb delete mode 100644 app/views/device/index.html.erb create mode 100644 app/views/environment/index.html.erb create mode 100644 app/views/environment/view_area.html.erb create mode 100644 app/views/environment/view_co2.html.erb create mode 100644 app/views/environment/view_humidity.html.erb create mode 100644 app/views/environment/view_temp.html.erb create mode 100644 app/views/nutrient/index.html.erb create mode 100644 app/views/rack/index.html.erb delete mode 100644 app/views/web/index.html.erb create mode 100644 test/controllers/environment_controller_test.rb rename test/controllers/{device_controller_test.rb => nutrient_controller_test.rb} (55%) rename test/controllers/{web_controller_test.rb => rack_controller_test.rb} (56%) diff --git a/app/assets/images/svg/svg_valve.svg b/app/assets/images/svg/svg_valve.svg new file mode 100644 index 0000000..7714dbc --- /dev/null +++ b/app/assets/images/svg/svg_valve.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index 4960433..0635597 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -9,14 +9,18 @@ --color-warning: rgb(255, 202, 40); --color-accept: rgb(121, 134, 203); --color-danger: rgb(239, 83, 80); - --color-table-border: rgb(130, 144, 158); + --color-table-border: rgb(181, 188, 199); + --color-table-background: rgb(226, 228, 234); /* theme */ --color-logo-color: rgb(21, 128, 120); - --color-base-background: rgb(39, 44, 56); - --color-base-secondary: rgb(55, 61, 71); - --color-base-text: rgb(255, 255, 255); - --color-base-border: rgb(77, 84, 102); + --color-base-primary: rgb(44, 137, 255); + --color-base-background: rgb(242, 244, 248); + --color-base-sidebar: rgb(235, 238, 244); + --color-base-content: rgb(253, 253, 253); + --color-base-third: rgb(201, 208, 210); + --color-base-text: rgb(39, 41, 49); + --color-base-border: rgb(223, 226, 234); --base-font-size: 0.85rem; --text-xs: calc(var(--base-font-size) * 0.75); @@ -53,7 +57,7 @@ } hr { - @apply border-table-border + @apply border-base-border } .background-pattern { @@ -89,7 +93,7 @@ } .select-style { - @apply block w-full px-2 py-1.5 border border-default-slate/50 rounded-xs text-base-background appearance-none + @apply block w-full px-2 py-1.5 border border-default-slate/50 rounded-xs appearance-none } .select-style option { @@ -109,7 +113,7 @@ @apply w-14 h-8 bg-danger rounded-full peer-checked:bg-notice transition-all duration-300 } - .toggle_btn { + .btn-toggle-round { @apply absolute left-1 top-1 w-6 h-6 bg-white rounded-full transition-all duration-300 peer-checked:translate-x-full shadow-sm } } @@ -121,11 +125,11 @@ .side-bar { /*@apply w-[16rem] pl-4 text-lg font-bold divide-y divide-base-border;*/ - @apply w-[16rem] pl-4 pr-4 lg:pr-0 text-lg font-bold; + @apply w-[16rem] p-4 text-lg font-bold; } .content { - @apply lg:rounded-lg bg-base-secondary; + @apply lg:rounded-lg bg-base-content p-0 lg:p-4 } .page-title { @@ -148,21 +152,25 @@ @apply inline-flex items-center rounded-xs px-2.5 py-1.5 text-sm font-semibold hover:opacity-75 disabled:cursor-not-allowed disabled:opacity-30 disabled:hover:bg-white } + .btn-toggle-text { + @apply bg-logo-color rounded-lg text-white text-center + } + /*Menu*/ .menu-group { - @apply flex flex-row py-2 px-4 my-4 gap-x-4 justify-between items-center w-full + @apply flex flex-row py-1 px-4 my-2 gap-x-4 justify-between items-center w-full } .menu-group-active { - @apply bg-base-secondary text-white rounded-md; + @apply bg-base-primary rounded-full text-base-content; } - .menu-group:hover { - @apply bg-base-secondary text-white transition-colors rounded-md; - } + /*.menu-group:hover {*/ + /* @apply bg-base-primary/30 transition-colors rounded-full;*/ + /*}*/ .menu-group-icon { - @apply py-1 text-sm font-medium justify-center + @apply flex py-1 justify-center items-center } .menu-group-name { @@ -179,7 +187,7 @@ /*Dashboard*/ .dashboard-group { - @apply rounded-md bg-base-background h-32 p-4 flex flex-col justify-between cursor-pointer + @apply rounded-md bg-base-background min-h-32 p-4 flex flex-col justify-between cursor-pointer } /*Pagy*/ @@ -217,15 +225,31 @@ /*Base Table*/ .base-table { - @apply min-w-full whitespace-nowrap border border-table-border + @apply min-w-full whitespace-nowrap } .base-table th { - @apply bg-base-background px-2 py-2 text-left font-bold lg:table-cell + @apply px-2 py-3 text-left font-bold lg:table-cell + } + + .base-table tr { + @apply divide-x divide-base-border } .base-table td { - @apply border-t border-table-border px-2 py-1 lg:table-cell whitespace-nowrap + @apply border-t border-base-border px-2 py-1 lg:table-cell whitespace-nowrap + } + + /*Base List*/ + .base-list { + @apply overflow-y-auto divide-y divide-base-border lg:border lg:border-base-border lg:rounded-lg + } + .base-list ul { + @apply divide-y divide-base-border lg:rounded-b-lg + } + + .base-list li{ + @apply flex justify-between items-center px-4 py-2 space-x-4 } } @@ -272,9 +296,8 @@ /*Fonts*/ @font-face { - font-family: 'GongGothicMedium'; - src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_20-10@1.0/GongGothicLight.woff') format('woff'); - font-weight: normal; + font-family: "Chakra_Petch", sans-serif; + font-weight: 300; font-style: normal; } diff --git a/app/controllers/device_controller.rb b/app/controllers/device_controller.rb deleted file mode 100644 index 65207d3..0000000 --- a/app/controllers/device_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class DeviceController < ApplicationController -end diff --git a/app/controllers/environment_controller.rb b/app/controllers/environment_controller.rb new file mode 100644 index 0000000..c629fde --- /dev/null +++ b/app/controllers/environment_controller.rb @@ -0,0 +1,25 @@ +class EnvironmentController < ApplicationController + def index + @controllers = Controller.all + end + + def view_temp + @controller = Controller.find(params[:id]) + @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute) + end + + def view_humidity + @controller = Controller.find(params[:id]) + @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute) + end + + def view_co2 + @controller = Controller.find(params[:id]) + @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute) + end + + def view_area + @controller = Controller.find(params[:id]) + @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute) + end +end diff --git a/app/controllers/nutrient_controller.rb b/app/controllers/nutrient_controller.rb new file mode 100644 index 0000000..2650667 --- /dev/null +++ b/app/controllers/nutrient_controller.rb @@ -0,0 +1,2 @@ +class NutrientController < ApplicationController +end diff --git a/app/controllers/rack_controller.rb b/app/controllers/rack_controller.rb new file mode 100644 index 0000000..fe53340 --- /dev/null +++ b/app/controllers/rack_controller.rb @@ -0,0 +1,2 @@ +class RackController < ApplicationController +end diff --git a/app/controllers/web_controller.rb b/app/controllers/web_controller.rb deleted file mode 100644 index 00168a4..0000000 --- a/app/controllers/web_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class WebController < ApplicationController -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..fe3f475 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,10 @@ module ApplicationHelper + def full_height_page? + controller_name.in?(%w[environment nutrient schedules]) && action_name == 'index' || action_name == 'schedule_edit' + end + + def content_container_classes + base_classes = "flex-1 h-full pb-0 px-0 lg:pb-4 lg:px-4" + full_height_page? ? base_classes : "#{base_classes} overflow-y-auto" + end end diff --git a/app/helpers/device_helper.rb b/app/helpers/device_helper.rb deleted file mode 100644 index 16e2118..0000000 --- a/app/helpers/device_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module DeviceHelper -end diff --git a/app/helpers/environment_helper.rb b/app/helpers/environment_helper.rb new file mode 100644 index 0000000..71b5472 --- /dev/null +++ b/app/helpers/environment_helper.rb @@ -0,0 +1,2 @@ +module EnvironmentHelper +end diff --git a/app/helpers/nutrient_helper.rb b/app/helpers/nutrient_helper.rb new file mode 100644 index 0000000..674effc --- /dev/null +++ b/app/helpers/nutrient_helper.rb @@ -0,0 +1,2 @@ +module NutrientHelper +end diff --git a/app/helpers/rack_helper.rb b/app/helpers/rack_helper.rb new file mode 100644 index 0000000..a6e5294 --- /dev/null +++ b/app/helpers/rack_helper.rb @@ -0,0 +1,2 @@ +module RackHelper +end diff --git a/app/helpers/web_helper.rb b/app/helpers/web_helper.rb deleted file mode 100644 index 55cd56a..0000000 --- a/app/helpers/web_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module WebHelper -end diff --git a/app/views/device/index.html.erb b/app/views/device/index.html.erb deleted file mode 100644 index 8700a95..0000000 --- a/app/views/device/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -
DEVICE
diff --git a/app/views/environment/index.html.erb b/app/views/environment/index.html.erb new file mode 100644 index 0000000..c724d39 --- /dev/null +++ b/app/views/environment/index.html.erb @@ -0,0 +1,100 @@ +
+
+ + <%= link_to view_temp_environment_path(id: params[:id]), class: "dashboard-group" do %> +
+
실내온도
+
+ +
+ 15.5 + °C +
+
+
+ <% end %> + + + <%= link_to view_humidity_environment_path(id: params[:id]), class: "dashboard-group" do %> +
+
실내습도
+
+ +
60 + % +
+
+
+ <% end %> + + + <%= link_to view_co2_environment_path(id: params[:id]), class: "dashboard-group" do %> +
+
CO2
+
+
+
+ CO2 +
+
+
60 + %
+
+
+ <% end %> + + +
+ + + <%= link_to rack_index_path, class: "dashboard-group" do %> +
+
랙 정보
+
+ +
5 + 라인 +
+
+
+ <% end %> + + + <%= link_to view_area_environment_path(id: params[:id]), class: "dashboard-group" do %> +
+
센서구역 정보
+
+ +
6 + 구역 +
+
+
+ <% end %> + + +
+
+
LED
+
+ +
AUTO
+
+
+
+
+ + +
+
+
FAN
+
+ +
AUTO
+
+
+
+
+ +
+
diff --git a/app/views/environment/view_area.html.erb b/app/views/environment/view_area.html.erb new file mode 100644 index 0000000..0f9bfae --- /dev/null +++ b/app/views/environment/view_area.html.erb @@ -0,0 +1,79 @@ +
+
+
+
+ <%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %> + + <% end %> +
<%= @controller.id %>동 센서구역 정보
+
+ <%= link_to "수정", schedule_edit_schedule_path(@controller.id), class: "btn bg-default-slate" %> +
+
+
    + <% if @schedule.present? %> + <% @schedule.each do |s| %> +
  • +
    + +
    +
    시간
    +
    +
    <%= s.hour.to_s.rjust(2, '0') %>
    +
    :
    +
    <%= s.minute.to_s.rjust(2, '0') %>
    +
    +
    + + +
    +
    온도
    +
    +
    <%= s.temperature %>
    +
    °C
    +
    +
    +
    + + +
    +
    ON/OFF
    +
    + <%#= s.is_active %> + <% if s.is_active %> + + <% else %> + + <% end %> +
    +
    +
  • + <% end %> + <% else %> +
  • 저장된 스케줄이 없습니다.
  • + <% end %> +
+ + + + + + + + + + + + <%# @schedule.each do |s| %> + + + + + + + <%# end %> + + +
+
+
diff --git a/app/views/environment/view_co2.html.erb b/app/views/environment/view_co2.html.erb new file mode 100644 index 0000000..c4dfbd0 --- /dev/null +++ b/app/views/environment/view_co2.html.erb @@ -0,0 +1,58 @@ +
+
+
+
+ <%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %> + + <% end %> +
<%= @controller.id %>동 CO2 스케줄러
+
+ <%= link_to "수정", schedule_edit_schedule_path(@controller.id), class: "btn bg-default-slate" %> +
+
+
    + <% if @schedule.present? %> + <% @schedule.each do |s| %> +
  • +
    + +
    +
    시간
    +
    +
    <%= s.hour.to_s.rjust(2, '0') %>
    +
    :
    +
    <%= s.minute.to_s.rjust(2, '0') %>
    +
    +
    + + +
    +
    농도
    +
    +
    <%= s.temperature %>
    +
    %
    +
    +
    +
    + + +
    +
    ON/OFF
    +
    + <%#= s.is_active %> + <% if s.is_active %> + + <% else %> + + <% end %> +
    +
    +
  • + <% end %> + <% else %> +
  • 저장된 스케줄이 없습니다.
  • + <% end %> +
+
+
+
diff --git a/app/views/environment/view_humidity.html.erb b/app/views/environment/view_humidity.html.erb new file mode 100644 index 0000000..f3e6e38 --- /dev/null +++ b/app/views/environment/view_humidity.html.erb @@ -0,0 +1,58 @@ +
+
+
+
+ <%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %> + + <% end %> +
<%= @controller.id %>동 습도 스케줄러
+
+ <%= link_to "수정", schedule_edit_schedule_path(@controller.id), class: "btn bg-default-slate" %> +
+
+
    + <% if @schedule.present? %> + <% @schedule.each do |s| %> +
  • +
    + +
    +
    시간
    +
    +
    <%= s.hour.to_s.rjust(2, '0') %>
    +
    :
    +
    <%= s.minute.to_s.rjust(2, '0') %>
    +
    +
    + + +
    +
    습도
    +
    +
    <%= s.temperature %>
    +
    %
    +
    +
    +
    + + +
    +
    ON/OFF
    +
    + <%#= s.is_active %> + <% if s.is_active %> + + <% else %> + + <% end %> +
    +
    +
  • + <% end %> + <% else %> +
  • 저장된 스케줄이 없습니다.
  • + <% end %> +
+
+
+
diff --git a/app/views/environment/view_temp.html.erb b/app/views/environment/view_temp.html.erb new file mode 100644 index 0000000..abae9ac --- /dev/null +++ b/app/views/environment/view_temp.html.erb @@ -0,0 +1,64 @@ +
+
+ <%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %> + + <% end %> +
<%= @controller.id %>동 온도 스케줄러
+
+
+
+ <%= link_to "수정", schedule_edit_schedule_path(@controller.id), class: "btn bg-default-slate" %> +
+
+ + + + + + + + + + <% if @schedule.present? %> + <% @schedule.each do |s| %> + + + + + + + + + + + <% end %> + <% else %> + + + + <% end %> + +
시간온도사용여부
+
+
<%= s.hour.to_s.rjust(2, '0') %>
+
:
+
<%= s.minute.to_s.rjust(2, '0') %>
+
+
+
+
<%= s.temperature %>
+
°C
+
+
+
+ <%#= s.is_active %> + <% if s.is_active %> + + <% else %> + + <% end %> +
+
저장된 스케줄이 없습니다.
+
+
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8913d63..0207552 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,16 +21,17 @@ <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> <%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> + - + <%= turbo_frame_tag :modals %> -
- <%= render "partials/header" %> -
- <%= render "partials/sidebar" %> -
-
+
+ <%= render "partials/sidebar" %> +
+ <%= render "partials/header" %> +
+
<% if flash[:notice] %>
<%= raw flash[:notice] %> @@ -43,6 +44,7 @@ <%= yield %>
+
© 2024 FARMITRY All Rights Reserved.
diff --git a/app/views/nutrient/index.html.erb b/app/views/nutrient/index.html.erb new file mode 100644 index 0000000..08b0991 --- /dev/null +++ b/app/views/nutrient/index.html.erb @@ -0,0 +1,212 @@ +
+
+ +
+
+
pH
+
7.1
+
+
+
+ 6.0 ~ 6.0 +
+
+
+
+ + +
+
+
EC
+
0.1
+
+
+
+ 0 ~ 1 +
+
+
+
+ + +
+
+
양액 온도
+
+ +
20.96 + °C
+
+
+
+ + +
+
+
수위 정보
+ + + + + +
+
+ + +
+
+
원수 탱크
+
+ +
+
ON
+
+
+
+
+ + +
+
+
원수 펌프
+
+ +
+
ON
+
+
+
+
+ + +
+
+
교반기A
+
+ +
+
ON
+
+
+
+
+ + +
+
+
교반기B
+
+ +
+
ON
+
+
+
+
+ + +
+
+
급수/공급 펌프
+
+ +
+
ON
+
+
+
+
+ + +
+
+
1번급수 솔벨브
+
+ +
+
ON
+
+
+
+
+ + +
+
+
2번급수 솔벨브
+
+ +
+
ON
+
+
+
+
+ + +
+
+
퇴수 솔벨브
+
+ +
+
ON
+
+
+
+
+ + +
+
+
솔레노이드 벨브A
+
+ +
+
ON
+
+
+
+
+ + +
+
+
솔레노이드 벨브B
+
+ +
+
ON
+
+
+
+
+ + +
+
+
솔레노이드 벨브C
+
+ +
+
ON
+
+
+
+
+ + +
+
+
긴급 정지
+
+ +
+
ON
+
+
+
+
+ +
+
\ No newline at end of file diff --git a/app/views/partials/_header.html.erb b/app/views/partials/_header.html.erb index effdcc1..9bf4c09 100644 --- a/app/views/partials/_header.html.erb +++ b/app/views/partials/_header.html.erb @@ -1,13 +1,5 @@
-
- <%= image_tag "svg/svg_logo.svg", class: "w-auto h-8 mr-4" %> - <%= link_to root_path do %> -
FARMITRY
- <% end %> -
- - diff --git a/app/views/partials/_modals_open.html.erb b/app/views/partials/_modals_open.html.erb index 539cea7..1e9c186 100644 --- a/app/views/partials/_modals_open.html.erb +++ b/app/views/partials/_modals_open.html.erb @@ -24,7 +24,7 @@ From: "opacity-100 translate-y-0 sm:scale-100" To: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" --> -
+
<%= render "partials/modals/#{type}" %>
diff --git a/app/views/partials/_sidebar.html.erb b/app/views/partials/_sidebar.html.erb index 6b56072..fde3da6 100644 --- a/app/views/partials/_sidebar.html.erb +++ b/app/views/partials/_sidebar.html.erb @@ -1,31 +1,66 @@ - -
-
60 %
+
60 %
@@ -49,7 +49,7 @@
FAN
-
60 % +
60 %
@@ -61,7 +61,7 @@
공조기
-
15.5 +
15.5 °C
@@ -73,7 +73,7 @@
LED
-
60 % +
60 %
@@ -86,7 +86,7 @@
pH
-
7.1
+
7.1
@@ -100,7 +100,7 @@
EC
-
0.1
+
0.1
@@ -116,7 +116,7 @@
양액온도
-
20.96 +
20.96 °C
diff --git a/app/views/schedules/schedule_edit.html.erb b/app/views/schedules/schedule_edit.html.erb index 5a32bae..191d494 100644 --- a/app/views/schedules/schedule_edit.html.erb +++ b/app/views/schedules/schedule_edit.html.erb @@ -1,81 +1,83 @@ -
-
- <%= form_with url: schedule_edit_update_schedules_path, method: :post, class: 'flex flex-col h-full' do %> - <%= hidden_field_tag :controller_id, params[:id] %> -
-
-
<%= @controller.name %> 컨트롤러
- <%= submit_tag "업데이트", class: "btn bg-primary" %> -
-
    - <% if @schedule.present? %> - <% @schedule.each do |s| %> -
  • -
    - -
    -
    시간
    -
    - <%= select_tag "schedule[#{s.id}][hour]", - options_for_select((0..23).map { |h| [h.to_s.rjust(2, '0'), h] }, s.hour), - class: "select-style text-white min-w-[60px]" %> -
    :
    - <%= number_field_tag "schedule[#{s.id}][minute]", - s.minute, min: 0, max: 59, step: 1, inputmode: "decimal", - class: "input-style min-w-[60px]" %> +
    +
    +
    + <%= form_with url: schedule_edit_update_schedules_path, method: :post, class: 'flex flex-col' do %> + <%= hidden_field_tag :controller_id, params[:id] %> +
    +
    +
    <%= @controller.name %> 컨트롤러
    + <%= submit_tag "업데이트", class: "btn bg-primary" %> +
    +
      + <% if @schedule.present? %> + <% @schedule.each do |s| %> +
    • +
      + +
      +
      시간
      +
      + <%= select_tag "schedule[#{s.id}][hour]", + options_for_select((0..23).map { |h| [h.to_s.rjust(2, '0'), h] }, s.hour), + class: "select-style min-w-[60px]" %> +
      :
      + <%= number_field_tag "schedule[#{s.id}][minute]", + s.minute, min: 0, max: 59, step: 1, inputmode: "decimal", + class: "input-style min-w-[60px]" %> +
      +
      + + +
      +
      온도 (°C)
      +
      + <%= number_field_tag "schedule[#{s.id}][temperature]", s.temperature, min: -99, max: 99, step: "0.1", inputmode: "decimal", class: "input-style min-w-[68px]" %> +
      - -
      -
      온도 (°C)
      -
      - <%= number_field_tag "schedule[#{s.id}][temperature]", s.temperature, min: -99, max: 99, step: "0.1", inputmode: "decimal", class: "input-style min-w-[68px]" %> +
      + +
      +
      ON/OFF
      + +
      + + +
      +
       
      + <%= link_to schedule_path(s), + data: { turbo_method: :delete, turbo_confirm: "정말 삭제하시겠습니까?" }, + class: "btn bg-danger text-sm flex items-center px-2 py-0 my-1.5 lg:px-4 lg:py-1.5 lg:my-0" do %> + +
      + <% end %>
      -
      - -
      - -
      -
      ON/OFF
      - -
      - - -
      -
       
      - <%= link_to schedule_path(s), - data: { turbo_method: :delete, turbo_confirm: "정말 삭제하시겠습니까?" }, - class: "btn bg-danger text-sm flex items-center px-2 py-0 my-1.5 lg:px-4 lg:py-1.5 lg:my-0" do %> - -
      - <% end %> -
      -
      -
    • + + <% end %> + <% else %> +
    • 저장된 스케줄이 없습니다.
    • <% end %> - <% else %> -
    • 저장된 스케줄이 없습니다.
    • - <% end %> -
    +
+
+ <% end %> +
+ <%= button_to "초기화", reset_schedule_path(params[:id]), + method: :post, + data: { turbo_confirm: "정말 초기화하시겠습니까? 모든 스케줄 데이터가 삭제됩니다." }, + class: "btn bg-danger" %> + <%= button_to "추가하기", open_modals_path(type: "add_schedule", id: params[:id]), + class: "btn bg-default-slate", + data: { + turbo_method: :post, + turbo_frame: "modals" + } %>
- <% end %> -
- <%= button_to "초기화", reset_schedule_path(params[:id]), - method: :post, - data: { turbo_confirm: "정말 초기화하시겠습니까? 모든 스케줄 데이터가 삭제됩니다." }, - class: "btn bg-danger" %> - <%= button_to "추가하기", open_modals_path(type: "add_schedule", id: params[:id]), - class: "btn bg-default-slate", - data: { - turbo_method: :post, - turbo_frame: "modals" - } %>
diff --git a/app/views/schedules/view.html.erb b/app/views/schedules/view.html.erb index e7272ce..f656a88 100644 --- a/app/views/schedules/view.html.erb +++ b/app/views/schedules/view.html.erb @@ -1,18 +1,18 @@ -
+
-
+
<%= @controller.name %> 컨트롤러
<%= link_to "수정", schedule_edit_schedule_path(@controller.id), class: "btn bg-default-slate" %>
-
    +
      <% if @schedule.present? %> <% @schedule.each do |s| %> -
    • +
    • -
      시간
      +
      시간
      <%= s.hour.to_s.rjust(2, '0') %>
      :
      @@ -22,17 +22,17 @@
      -
      온도
      +
      온도
      <%= s.temperature %>
      -
      °C
      +
      °C
      -
      ON/OFF
      +
      ON/OFF
      <%#= s.is_active %> <% if s.is_active %> diff --git a/app/views/web/index.html.erb b/app/views/web/index.html.erb deleted file mode 100644 index 4a09571..0000000 --- a/app/views/web/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -
      WEB
      diff --git a/config/routes.rb b/config/routes.rb index dcc1dfd..247bd8e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,7 +11,7 @@ Rails.application.routes.draw do # Defines the root path route ("/") - root "schedules#index" + root "environment#index" resources :schedules do member do @@ -30,6 +30,15 @@ Rails.application.routes.draw do end end - resources :device - resources :web + resources :environment do + member do + get "view_temp" + get "view_humidity" + get "view_co2" + get "view_area" + end + end + resources :nutrient + + resources :rack end diff --git a/modbus.rb b/modbus.rb index 77c989b..0ef6e52 100644 --- a/modbus.rb +++ b/modbus.rb @@ -22,13 +22,13 @@ begin end end rescue - error_message = "[#{Time.now}] #{mode} 실행 실패 (station_id: #{controller_id}, value: #{value})" - res = Sms.send_one( - { - to: '01062619801', - from: '01062619801', - text: error_message - } - ) - puts res + # error_message = "[#{Time.now}] #{mode} 실행 실패 (station_id: #{controller_id}, value: #{value})" + # res = Sms.send_one( + # { + # to: '01062619801', + # from: '01062619801', + # text: error_message + # } + # ) + # puts res end diff --git a/test/controllers/environment_controller_test.rb b/test/controllers/environment_controller_test.rb new file mode 100644 index 0000000..9ed1312 --- /dev/null +++ b/test/controllers/environment_controller_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class EnvironmentControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/device_controller_test.rb b/test/controllers/nutrient_controller_test.rb similarity index 55% rename from test/controllers/device_controller_test.rb rename to test/controllers/nutrient_controller_test.rb index 2abb94f..6a5c05c 100644 --- a/test/controllers/device_controller_test.rb +++ b/test/controllers/nutrient_controller_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class DeviceControllerTest < ActionDispatch::IntegrationTest +class NutrientControllerTest < ActionDispatch::IntegrationTest # test "the truth" do # assert true # end diff --git a/test/controllers/web_controller_test.rb b/test/controllers/rack_controller_test.rb similarity index 56% rename from test/controllers/web_controller_test.rb rename to test/controllers/rack_controller_test.rb index 97f91db..8df6f8b 100644 --- a/test/controllers/web_controller_test.rb +++ b/test/controllers/rack_controller_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class WebControllerTest < ActionDispatch::IntegrationTest +class RackControllerTest < ActionDispatch::IntegrationTest # test "the truth" do # assert true # end