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 @@
+
| 시간 | -온도 | +시간 | +온도 | 사용여부 |
|---|
|
+
+
+ <%= 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 %>
-
- |
+ 저장된 스케줄이 없습니다. | ||
| 저장된 스케줄이 없습니다. | -|||||