Skip to content

Commit 330dd3b

Browse files
authored
Merge pull request #556 from OSC/feature/app-info-html
Add support for custom info in batch connect apps
2 parents d3743f2 + a515f4e commit 330dd3b

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

apps/dashboard/app/helpers/batch_connect/sessions_helper.rb

+10
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,21 @@ def session_view(session)
4242
concat created(session)
4343
concat time(session)
4444
concat id(session)
45+
safe_concat custom_info_view(session) if session.info_view
4546
end
4647
)
4748
concat content_tag(:div) { yield }
4849
end
4950
end
5051

52+
def custom_info_view(session)
53+
content_tag(:div) do
54+
content_tag(:hr) do
55+
render partial: "batch_connect/sessions/connections/info", locals: { view: session.info_view, session: session }
56+
end
57+
end
58+
end
59+
5160
def created(session)
5261
content_tag(:p) do
5362
concat content_tag(:strong, t('dashboard.batch_connect_sessions_stats_created_at'))
@@ -182,6 +191,7 @@ def connection_tabs(id, tabs)
182191
else
183192
# tabs
184193
content_tag(:div) do
194+
concat content_tag(:hr)
185195
# menu
186196
concat(
187197
content_tag(:ul, class: "nav nav-tabs") do

apps/dashboard/app/models/batch_connect/app.rb

+6
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ def session_view
200200
file.read if file.file?
201201
end
202202

203+
# View used for session info if it exists
204+
# @return [String, nil] session info
205+
def session_info_view
206+
Pathname.new(root).glob("info.{md,html}.erb").find(&:file?).try(:read)
207+
end
208+
203209
# Paths to custom javascript files
204210
# @return [Pathname] paths to custom javascript files that exist
205211
def custom_javascript_files

apps/dashboard/app/models/batch_connect/session.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ def get_binding
4141
# @return [String, nil] session view
4242
attr_accessor :view
4343

44+
# The view used to display custom info for this session
45+
# @return [String, nil] session info
46+
attr_accessor :info_view
47+
4448
# Batch connect script type
4549
# @return [String] script type
4650
attr_accessor :script_type
4751

4852
# Attributes used for serialization
4953
# @return [Hash] attributes to be serialized
5054
def attributes
51-
%w(id cluster_id job_id created_at token title view script_type).map do |attribute|
55+
%w(id cluster_id job_id created_at token title view info_view script_type).map do |attribute|
5256
[ attribute, nil ]
5357
end.to_h
5458
end
@@ -139,6 +143,7 @@ def save(app:, context:, format: nil)
139143
self.token = app.token
140144
self.title = app.title
141145
self.view = app.session_view
146+
self.info_view = app.session_info_view
142147
self.created_at = Time.now.to_i
143148

144149
submit_script = app.submit_opts(context, fmt: format) # could raise an exception
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= OodAppkit.markdown.render(ERB.new(view, nil, "-").result(session.instance_eval { binding })).html_safe %>

0 commit comments

Comments
 (0)