diff --git a/app/assets/images/svg/svg_pump.svg b/app/assets/images/svg/svg_pump.svg new file mode 100644 index 0000000..9ec45ee --- /dev/null +++ b/app/assets/images/svg/svg_pump.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/app/assets/images/svg/svg_valve.svg b/app/assets/images/svg/svg_valve.svg index 7714dbc..ed8596c 100644 --- a/app/assets/images/svg/svg_valve.svg +++ b/app/assets/images/svg/svg_valve.svg @@ -1,5 +1,4 @@ - - + \ No newline at end of file diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index 0635597..83e263f 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -14,6 +14,9 @@ /* theme */ --color-logo-color: rgb(21, 128, 120); + --color-env-color: rgb(86, 145, 172); + --color-nut-color: rgb(39, 156, 26); + --color-etc-color: rgb(140, 152, 154); --color-base-primary: rgb(44, 137, 255); --color-base-background: rgb(242, 244, 248); --color-base-sidebar: rgb(235, 238, 244); @@ -229,7 +232,7 @@ } .base-table th { - @apply px-2 py-3 text-left font-bold lg:table-cell + @apply p-3 text-left font-bold lg:table-cell } .base-table tr { @@ -237,7 +240,7 @@ } .base-table td { - @apply border-t border-base-border px-2 py-1 lg:table-cell whitespace-nowrap + @apply border-t border-base-border p-3 lg:table-cell whitespace-nowrap } /*Base List*/ diff --git a/app/controllers/environment_controller.rb b/app/controllers/environment_controller.rb index c629fde..e606043 100644 --- a/app/controllers/environment_controller.rb +++ b/app/controllers/environment_controller.rb @@ -22,4 +22,75 @@ class EnvironmentController < ApplicationController @controller = Controller.find(params[:id]) @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute) end + + def edit_temp + @controller = Controller.find(params[:id]) + @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute) + end + + def create + @schedule = Schedule.new(schedule_params) + + if @schedule.save + redirect_to schedule_edit_schedule_path(@schedule.controller_id), notice: "스케쥴이 추가 되었습니다." + else + error_messages = @schedule.errors.full_messages.join(", ") + redirect_to schedule_edit_schedule_path(@schedule.controller_id), alert: "스케쥴 추가 실패: #{error_messages}" + end + end + + def destroy + @schedule = Schedule.find_by(id: params[:id]) + + if @schedule.destroy + redirect_to schedule_edit_schedule_path(@schedule.controller_id), notice: "스케줄이 삭제되었습니다." + else + error_messages = @schedule.errors.full_messages.join(", ") + redirect_to schedule_edit_schedule_path(@schedule.controller_id), alert: "스케쥴 삭제 실패: #{error_messages}" + end + end + + def reset + Schedule.where(controller_id: params[:id]).destroy_all + ActiveRecord::Base.connection.execute("DELETE FROM sqlite_sequence WHERE name='schedules'") + + redirect_to schedule_edit_schedule_path(params[:id]), notice: "스케줄이 초기화되었습니다." + end + + def schedule_edit + @controller = Controller.find(params[:id]) + @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute) + end + + def schedule_edit_update + error_messages = [] + + params[:schedule]&.each do |id, attributes| + schedule = Schedule.find_by(id: id) + next unless schedule + + unless schedule.update( + hour: attributes[:hour], + minute: attributes[:minute], + is_active: attributes[:is_active], + temperature: attributes[:temperature] + ) + + error_detail = schedule.errors.full_messages.join(", ") + time_label = "#{attributes[:hour]}시 #{attributes[:minute]}분" + error_messages << "#{time_label} - #{error_detail}" + end + end + + if error_messages.any? + redirect_to schedule_edit_schedule_path(params[:controller_id]), alert: error_messages.join("
") + else + redirect_to schedule_edit_schedule_path(params[:controller_id]), notice: "스케줄이 성공적으로 업데이트되었습니다." + end + end + + private + def schedule_params + params.require(:schedule).permit(:controller_id, :hour, :minute, :is_active, :temperature) + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fe3f475..de6be79 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,10 +1,2 @@ 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/views/environment/edit_temp.html.erb b/app/views/environment/edit_temp.html.erb new file mode 100644 index 0000000..4ba3b47 --- /dev/null +++ b/app/views/environment/edit_temp.html.erb @@ -0,0 +1,86 @@ +
+
+ <%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %> + + <% end %> +
<%= @controller.id %>동 온도 스케줄러
+
+
+ <%= form_with url: schedule_edit_update_schedules_path, method: :post, class: 'flex flex-col h-full' do %> + <%= hidden_field_tag :controller_id, params[:id] %> +
+ <%= submit_tag "업데이트", class: "btn bg-primary w-fit" %> +
+
    + <% 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]" %> +
    +
    +
    + +
    + +
    +
    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 %> +
+
+
+ <%= 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 %> +
+
diff --git a/app/views/environment/index.html.erb b/app/views/environment/index.html.erb index c724d39..8ba1d9f 100644 --- a/app/views/environment/index.html.erb +++ b/app/views/environment/index.html.erb @@ -1,14 +1,32 @@ -
-
+
+
<%= link_to view_temp_environment_path(id: params[:id]), class: "dashboard-group" do %> -
-
실내온도
-
- -
- 15.5 - °C +
+
+
+ +
+ 온도 +
+
+
+ + +
+
+
+
+
+
현재 온도
+
16.5 °C
+
+
+
+
+
+
설정 온도
+
15.5 °C
@@ -16,12 +34,31 @@ <%= link_to view_humidity_environment_path(id: params[:id]), class: "dashboard-group" do %> -
-
실내습도
-
- -
60 - % +
+
+
+ +
+ 습도 +
+
+
+ + +
+
+
+
+
+
현재 습도
+
78 %
+
+
+
+
+
+
설정 습도
+
80 %
@@ -29,16 +66,40 @@ <%= link_to view_co2_environment_path(id: params[:id]), class: "dashboard-group" do %> -
-
CO2
-
-
-
- CO2 +
+
+
+
+
+ CO2 +
+
+
+ CO2
-
60 - %
+
+ + +
+
+
+
+
+
현재 CO2
+
700 ppm
+
+
+
+
+
+
최소 CO2
+
300 ppm
+
+
+
최대 CO2
+
1000 ppm
+
<% end %> @@ -48,12 +109,24 @@ <%= link_to rack_index_path, class: "dashboard-group" do %> -
-
랙 정보
-
- -
5 - 라인 +
+
+
+ +
+ +
+
+
+ + +
+
+
+
+
+
현재 랙 정보
+
5 라인
@@ -61,12 +134,24 @@ <%= link_to view_area_environment_path(id: params[:id]), class: "dashboard-group" do %> -
-
센서구역 정보
-
- -
6 - 구역 +
+
+
+ +
+ 센서구역 +
+
+
+ + +
+
+
+
+
+
현재 센서구역 정보
+
6 구역
@@ -74,11 +159,23 @@
-
-
LED
-
- -
AUTO
+
+
+
+ +
+ LED +
+
+
+
+
+
+
모드
+
+
+
자동
+
@@ -86,11 +183,23 @@
-
-
FAN
-
- -
AUTO
+
+
+
+ +
+ FAN +
+
+
+
+
+
+
모드
+
+
+
수동
+
diff --git a/app/views/environment/view_temp.html.erb b/app/views/environment/view_temp.html.erb index abae9ac..0ab5427 100644 --- a/app/views/environment/view_temp.html.erb +++ b/app/views/environment/view_temp.html.erb @@ -7,58 +7,58 @@
- <%= link_to "수정", schedule_edit_schedule_path(@controller.id), class: "btn bg-default-slate" %> + <%= link_to "수정", edit_temp_environment_path(@controller.id), class: "btn bg-default-slate" %>
- +
- - + + - - <% if @schedule.present? %> - <% @schedule.each do |s| %> +
시간온도시간온도 사용여부
+ + +
+ + + <% if @schedule.present? %> + <% @schedule.each do |s| %> + + + + + + <% end %> + <% else %> - - - - - - - - + <% end %> - <% else %> - - - - <% end %> - +
+
+
<%= s.hour.to_s.rjust(2, '0') %>
+
:
+
<%= s.minute.to_s.rjust(2, '0') %>
+
+
+
+
<%= s.temperature %>
+
°C
+
+
+
+ <% if s.is_active %> + + <% 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/nutrient/index.html.erb b/app/views/nutrient/index.html.erb index 08b0991..8fa38f0 100644 --- a/app/views/nutrient/index.html.erb +++ b/app/views/nutrient/index.html.erb @@ -1,65 +1,135 @@ -
-
+
+
-
-
-
pH
-
7.1
-
-
-
- 6.0 ~ 6.0 + <%= link_to view_temp_environment_path(id: params[:id]), class: "dashboard-group" do %> +
+
+
+
+
+ pH +
+
+
+ pH +
+
+
+ + +
+
+
+
+
+
현재 pH
+
6.0 pH
+
+
+
오차 pH
+
0.1 pH
+
-
-
+ <% end %> -
-
-
EC
-
0.1
-
-
-
- 0 ~ 1 + <%= link_to view_temp_environment_path(id: params[:id]), class: "dashboard-group" do %> +
+
+
+
+
+ EC +
+
+
+ EC +
+
+
+ + +
+
+
+
+
+
현재 EC
+
1.2 mS/cm
+
+
+
오차 pH
+
0.1 mS/cm
+
-
-
+ <% end %>
-
-
양액 온도
-
- -
20.96 - °C
+
+
+
+ +
+ 양액 온도 +
+
+
+
+
+
+
현재 온도
+
20.2 °C
+
-
-
수위 정보
- - - - - +
+
+
+ +
+ 수위 정보 +
+
+
+
+
+
+
상태
+
+
+
정상
+
+
+
-
-
원수 탱크
-
- -
-
ON
+
+
+
+ +
+ 원수 탱크 +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -67,12 +137,23 @@
-
-
원수 펌프
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/pump_icon", class: "w-auto h-6 text-etc-color" %> +
+ 원수 펌프 +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -80,12 +161,31 @@
-
-
교반기A
-
- -
-
ON
+
+
+
+ +
+ 교반기A +
+
+
+ + +
+
+
+
+
+
설정 시간
+
30
+
+
+
모드
+
+
+
ON
+
@@ -93,12 +193,31 @@
-
-
교반기B
-
- -
-
ON
+
+
+
+ +
+ 교반기B +
+
+
+ + +
+
+
+
+
+
설정 시간
+
30
+
+
+
모드
+
+
+
ON
+
@@ -106,12 +225,23 @@
-
-
급수/공급 펌프
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/pump_icon", class: "w-auto h-6 text-etc-color" %> +
+ 급수/공급 펌프 +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -119,12 +249,23 @@
-
-
1번급수 솔벨브
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/valve_icon", class: "w-auto h-6 text-etc-color" %> +
+ 1번급수 솔벨브 +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -132,12 +273,23 @@
-
-
2번급수 솔벨브
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/valve_icon", class: "w-auto h-6 text-etc-color" %> +
+ 2번급수 솔벨브 +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -145,12 +297,23 @@
-
-
퇴수 솔벨브
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/valve_icon", class: "w-auto h-6 text-etc-color" %> +
+ 퇴수 솔벨브 +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -158,12 +321,23 @@
-
-
솔레노이드 벨브A
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/valve_icon", class: "w-auto h-6 text-etc-color" %> +
+ 솔레노이드 벨브A +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -171,12 +345,23 @@
-
-
솔레노이드 벨브B
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/valve_icon", class: "w-auto h-6 text-etc-color" %> +
+ 솔레노이드 벨브B +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -184,12 +369,23 @@
-
-
솔레노이드 벨브C
-
- -
-
ON
+
+
+
+ <%= render "partials/icons/valve_icon", class: "w-auto h-6 text-etc-color" %> +
+ 솔레노이드 벨브C +
+
+
+
+
+
+
모드
+
+
+
ON
+
@@ -198,15 +394,14 @@
-
긴급 정지
-
- -
-
ON
+
긴급 정지
+
+
+
-
\ No newline at end of file +
diff --git a/app/views/partials/_header.html.erb b/app/views/partials/_header.html.erb index 9bf4c09..31a6995 100644 --- a/app/views/partials/_header.html.erb +++ b/app/views/partials/_header.html.erb @@ -1,6 +1,18 @@ -
- - +
+
+ + +
+ + +
+ + 홍길동 + <%= button_to "로그아웃", root_path, + method: :post, + data: { turbo_confirm: "로그아웃 하시겠습니까?" }, + class: "btn bg-danger" %> +
diff --git a/app/views/partials/_sidebar.html.erb b/app/views/partials/_sidebar.html.erb index fde3da6..e8f1530 100644 --- a/app/views/partials/_sidebar.html.erb +++ b/app/views/partials/_sidebar.html.erb @@ -9,7 +9,7 @@
<%= link_to environment_index_path(id: 1), class: "menu-group #{'menu-group-active' if current_page?(environment_index_path(id: 1))}" do %>