diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css
index 1b3277a..7fa1d63 100644
--- a/app/assets/stylesheets/application.tailwind.css
+++ b/app/assets/stylesheets/application.tailwind.css
@@ -21,6 +21,8 @@
--color-base-background: rgb(242, 244, 248);
--color-base-sidebar: rgb(235, 238, 244);
--color-base-content: rgb(253, 253, 253);
+ --color-on-content: rgb(192, 216, 245);
+ --color-off-content: rgb(187, 187, 191);
--color-base-third: rgb(201, 208, 210);
--color-base-text: rgb(39, 41, 49);
--color-base-border: rgb(223, 226, 234);
@@ -190,7 +192,7 @@
/*Dashboard*/
.dashboard-group {
- @apply rounded-md bg-base-content min-h-32 p-4 flex flex-col justify-between cursor-pointer shadow-xs
+ @apply rounded-md min-h-32 p-4 flex flex-col justify-between cursor-pointer shadow-xs
}
/*Pagy*/
diff --git a/app/controllers/environment_controller.rb b/app/controllers/environment_controller.rb
index e606043..fe2b66c 100644
--- a/app/controllers/environment_controller.rb
+++ b/app/controllers/environment_controller.rb
@@ -3,31 +3,41 @@ class EnvironmentController < ApplicationController
@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_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
+ def edit_humidity
+ @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 edit_co2
+ @controller = Controller.find(params[:id])
+ @schedule = Schedule.where(controller_id: params[:id]).order(:hour, :minute)
+ end
+
def create
@schedule = Schedule.new(schedule_params)
diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js
index 611422d..96415ec 100644
--- a/app/javascript/controllers/index.js
+++ b/app/javascript/controllers/index.js
@@ -15,3 +15,6 @@ application.register("sidebar", SidebarController)
import TimerController from "./timer_controller"
application.register("timer", TimerController)
+
+import ToggleController from "./toggle_controller"
+application.register("toggle", ToggleController)
diff --git a/app/javascript/controllers/modals_controller.js b/app/javascript/controllers/modals_controller.js
index 844e913..6560fec 100644
--- a/app/javascript/controllers/modals_controller.js
+++ b/app/javascript/controllers/modals_controller.js
@@ -5,6 +5,7 @@ import { useClickOutside } from 'stimulus-use'
export default class extends Controller {
connect() {
// useClickOutside(this)
+ console.log("modal stimulus")
this.boundHandleKeydown = this.handleKeydown.bind(this)
document.addEventListener("keydown", this.boundHandleKeydown)
window.addEventListener('modals:close', this.close.bind(this))
diff --git a/app/javascript/controllers/toggle_controller.js b/app/javascript/controllers/toggle_controller.js
new file mode 100644
index 0000000..fb26a00
--- /dev/null
+++ b/app/javascript/controllers/toggle_controller.js
@@ -0,0 +1,40 @@
+// controllers/toggle_controller.js
+import { Controller } from "@hotwired/stimulus"
+
+export default class extends Controller {
+ static targets = ["label", "dot", "background"]
+
+ connect() {
+ this.state = true
+ this.update()
+ }
+
+ toggle() {
+ this.state = !this.state
+ this.update()
+ }
+
+ update() {
+ if (this.state) {
+ this.labelTarget.textContent = "ON"
+ this.labelTarget.classList.add("text-notice")
+ this.labelTarget.classList.remove("text-gray-400")
+
+ this.dotTarget.classList.add("bg-notice")
+ this.dotTarget.classList.remove("bg-gray-400")
+
+ // this.backgroundTarget.classList.add("bg-on-content")
+ // this.backgroundTarget.classList.remove("bg-off-content")
+ } else {
+ this.labelTarget.textContent = "OFF"
+ this.labelTarget.classList.add("text-gray-400")
+ this.labelTarget.classList.remove("text-notice")
+
+ this.dotTarget.classList.add("bg-gray-400")
+ this.dotTarget.classList.remove("bg-notice")
+
+ // this.backgroundTarget.classList.add("bg-off-content")
+ // this.backgroundTarget.classList.remove("bg-on-content")
+ }
+ }
+}
diff --git a/app/views/environment/edit_co2.html.erb b/app/views/environment/edit_co2.html.erb
index 30bbabe..47927eb 100644
--- a/app/views/environment/edit_co2.html.erb
+++ b/app/views/environment/edit_co2.html.erb
@@ -3,7 +3,7 @@
<%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %>
<% end %>
-
<%= @controller.id %>동 온도 스케줄러
+ <%= @controller.id %>동 CO2 스케줄러
<%= form_with url: edit_temp_environment_path, method: :post, class: 'flex flex-col h-full' do %>
diff --git a/app/views/environment/edit_humidity.html.erb b/app/views/environment/edit_humidity.html.erb
index 30bbabe..731fe59 100644
--- a/app/views/environment/edit_humidity.html.erb
+++ b/app/views/environment/edit_humidity.html.erb
@@ -3,7 +3,7 @@
<%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %>
<% end %>
-
<%= @controller.id %>동 온도 스케줄러
+
<%= @controller.id %>동 습도 스케줄러
<%= form_with url: edit_temp_environment_path, method: :post, class: 'flex flex-col h-full' do %>
diff --git a/app/views/environment/index.html.erb b/app/views/environment/index.html.erb
index f87562d..266cefe 100644
--- a/app/views/environment/index.html.erb
+++ b/app/views/environment/index.html.erb
@@ -1,7 +1,7 @@
- <%= link_to edit_temp_environment_path(id: params[:id]), class: "dashboard-group" do %>
+ <%= link_to edit_temp_environment_path(id: params[:id]), class: "dashboard-group bg-base-content" do %>
@@ -33,7 +33,7 @@
<% end %>
- <%= link_to edit_humidity_environment_path(id: params[:id]), class: "dashboard-group" do %>
+ <%= link_to edit_humidity_environment_path(id: params[:id]), class: "dashboard-group bg-base-content" do %>
@@ -65,7 +65,7 @@
<% end %>
- <%= link_to edit_co2_environment_path(id: params[:id]), class: "dashboard-group" do %>
+ <%= link_to edit_co2_environment_path(id: params[:id]), class: "dashboard-group bg-base-content" do %>
@@ -105,10 +105,13 @@
<% end %>
-
+
- <%= link_to rack_index_path, class: "dashboard-group" do %>
+ <%= link_to rack_index_path, class: "dashboard-group bg-base-content" do %>
@@ -133,7 +136,7 @@
<% end %>
- <%= link_to edit_area_environment_path(id: params[:id]), class: "dashboard-group" do %>
+ <%= link_to edit_area_environment_path(id: params[:id]), class: "dashboard-group bg-base-content" do %>
@@ -158,7 +161,10 @@
<% end %>
-
+
@@ -182,7 +188,10 @@
-
+
diff --git a/app/views/nutrient/edit_ec.html.erb b/app/views/nutrient/edit_ec.html.erb
new file mode 100644
index 0000000..30bbabe
--- /dev/null
+++ b/app/views/nutrient/edit_ec.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: edit_temp_environment_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
+
+ <%= check_box_tag "schedule[#{s.id}][is_active]", "1", s.is_active == true || s.is_active == 1, class: "sr-only peer" %>
+
+
+
+
+
+
+
+
+ <%= 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/nutrient/edit_mixa.html.erb b/app/views/nutrient/edit_mixa.html.erb
new file mode 100644
index 0000000..30bbabe
--- /dev/null
+++ b/app/views/nutrient/edit_mixa.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: edit_temp_environment_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
+
+ <%= check_box_tag "schedule[#{s.id}][is_active]", "1", s.is_active == true || s.is_active == 1, class: "sr-only peer" %>
+
+
+
+
+
+
+
+
+ <%= 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/nutrient/edit_mixb.html.erb b/app/views/nutrient/edit_mixb.html.erb
new file mode 100644
index 0000000..30bbabe
--- /dev/null
+++ b/app/views/nutrient/edit_mixb.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: edit_temp_environment_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
+
+ <%= check_box_tag "schedule[#{s.id}][is_active]", "1", s.is_active == true || s.is_active == 1, class: "sr-only peer" %>
+
+
+
+
+
+
+
+
+ <%= 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/nutrient/edit_ph.html.erb b/app/views/nutrient/edit_ph.html.erb
new file mode 100644
index 0000000..517aa09
--- /dev/null
+++ b/app/views/nutrient/edit_ph.html.erb
@@ -0,0 +1,86 @@
+
+
+ <%= link_to nutrient_index_path(id: params[:id]), class: "flex items-center" do %>
+
+ <% end %>
+
<%= @controller.id %>동 온도 스케줄러
+
+
+ <%= form_with url: edit_temp_environment_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
+
+ <%= check_box_tag "schedule[#{s.id}][is_active]", "1", s.is_active == true || s.is_active == 1, class: "sr-only peer" %>
+
+
+
+
+
+
+
+
+ <%= 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/nutrient/index.html.erb b/app/views/nutrient/index.html.erb
index b3917e7..235ccec 100644
--- a/app/views/nutrient/index.html.erb
+++ b/app/views/nutrient/index.html.erb
@@ -1,7 +1,7 @@
- <%= link_to edit_temp_environment_path(id: params[:id]), class: "dashboard-group" do %>
+ <%= link_to edit_temp_environment_path(id: params[:id]), class: "dashboard-group bg-base-content" do %>
@@ -34,7 +34,7 @@
<% end %>
- <%= link_to edit_temp_environment_path(id: params[:id]), class: "dashboard-group" do %>
+ <%= link_to edit_temp_environment_path(id: params[:id]), class: "dashboard-group bg-base-content" do %>
@@ -67,7 +67,10 @@
<% end %>
-
+
@@ -80,7 +83,11 @@
-
현재 온도
+
양액 온도
+
20.2 °C
+
+
@@ -88,7 +95,10 @@
-
+
@@ -103,7 +113,7 @@
@@ -112,8 +122,11 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
긴급 정지
diff --git a/config/routes.rb b/config/routes.rb
index 045884c..8b850ed 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -41,7 +41,16 @@ Rails.application.routes.draw do
post "edit_temp_update"
end
end
- resources :nutrient
-
+ resources :nutrient do
+ member do
+ get "edit_ph"
+ get "edit_ec"
+ get "edit_mixa"
+ get "edit_mixb"
+ end
+ collection do
+ post "edit_temp_update"
+ end
+ end
resources :rack
end