rocketjob_mission_control 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/rocket_job_mission_control/application_controller.rb +5 -0
- data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +3 -3
- data/app/controllers/rocket_job_mission_control/jobs_controller.rb +18 -18
- data/app/datatables/rocket_job_mission_control/servers_datatable.rb +1 -1
- data/app/helpers/rocket_job_mission_control/application_helper.rb +8 -32
- data/app/helpers/rocket_job_mission_control/jobs_helper.rb +12 -5
- data/app/models/rocket_job_mission_control/dirmon_sanitizer.rb +2 -1
- data/app/models/rocket_job_mission_control/job_sanitizer.rb +33 -6
- data/app/models/rocket_job_mission_control/record_editor.rb +36 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_input_category_fields.html.erb +6 -1
- data/app/views/rocket_job_mission_control/dirmon_entries/_output_category_fields.html.erb +6 -1
- data/app/views/rocket_job_mission_control/jobs/_input_categories.html.erb +6 -0
- data/app/views/rocket_job_mission_control/jobs/_input_category_fields.html.erb +14 -1
- data/app/views/rocket_job_mission_control/jobs/_output_categories.html.erb +6 -0
- data/app/views/rocket_job_mission_control/jobs/_output_category_fields.html.erb +14 -1
- data/app/views/rocket_job_mission_control/jobs/edit_slice.html.erb +10 -10
- data/lib/rocket_job_mission_control/version.rb +1 -1
- metadata +5 -7
- data/app/assets/javascripts/rocket_job_mission_control/nested_fields.js +0 -112
- data/app/views/rocket_job_mission_control/dirmon_entries/_input_categories.html.erb +0 -59
- data/app/views/rocket_job_mission_control/dirmon_entries/_output_categories.html.erb +0 -44
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d87a588101a2991a0a96c91fddf0d65fff5e8cf3d19ff76e80eb8fbcd03376dc
|
|
4
|
+
data.tar.gz: 4ae561bcd05ee619bbce72313e2bab214fb1f33966796d6d5c6f18fdeb03702c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f271d1d3616fb9b72257295df739c1100f5e9b2097885d036ff3e1951ab93b1b9c19d2a0d28d2d16814aeef6159fbe172550021774a937b619c22a1994ffd7fd
|
|
7
|
+
data.tar.gz: adf12d3ab3ff7717d6830e523d5ad36318cda367ccb6209de8139a0ea2edf06b34e1977fbda674ed9bb8d15a131d84926bd4c6049dc5dc3aa53de68ccff24eb6
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Rocket Job Mission Control
|
|
2
|
-
[](https://rubygems.org/gems/rocketjob_mission_control) [](https://github.com/reidmorrison/rocketjob_mission_control/actions?query=workflow%3Abuild) [](https://rubygems.org/gems/rocketjob_mission_control) [](http://opensource.org/licenses/Apache-2.0) 
|
|
2
|
+
[](https://rubygems.org/gems/rocketjob_mission_control) [](https://github.com/reidmorrison/rocketjob_mission_control/actions?query=workflow%3Abuild) [](https://rubygems.org/gems/rocketjob_mission_control) [](https://github.com/reidmorrison/rocketjob_mission_control/actions/workflows/ci.yml) [](http://opensource.org/licenses/Apache-2.0) 
|
|
3
3
|
|
|
4
4
|
Rocket Job Mission Control is the web based user interface for [Rocket Job](https://rocketjob.reidmorrison.com/),
|
|
5
5
|
Ruby's missing batch system.
|
|
@@ -2,6 +2,11 @@ module RocketJobMissionControl
|
|
|
2
2
|
class ApplicationController < ActionController::Base
|
|
3
3
|
protect_from_forgery with: :exception
|
|
4
4
|
|
|
5
|
+
# The status of a form that is rendered again to show why it could not be saved. Turbo Drive ignores a form
|
|
6
|
+
# response that renders with 200, so the errors would never be shown. Rack 2.2, which Rails 7.2 allows, does not
|
|
7
|
+
# know the name :unprocessable_content, and Rack 3.1 deprecates :unprocessable_entity.
|
|
8
|
+
FORM_ERROR_STATUS = 422
|
|
9
|
+
|
|
5
10
|
around_action :with_time_zone
|
|
6
11
|
|
|
7
12
|
private
|
|
@@ -62,7 +62,7 @@ module RocketJobMissionControl
|
|
|
62
62
|
if @dirmon_entry.errors.empty? && @dirmon_entry.save
|
|
63
63
|
redirect_to(dirmon_entry_path(@dirmon_entry))
|
|
64
64
|
else
|
|
65
|
-
render :new
|
|
65
|
+
render :new, status: FORM_ERROR_STATUS
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -76,7 +76,7 @@ module RocketJobMissionControl
|
|
|
76
76
|
if @dirmon_entry.errors.empty? && @dirmon_entry.valid? && @dirmon_entry.update(sanitized_params)
|
|
77
77
|
redirect_to(rocket_job_mission_control.dirmon_entry_path(@dirmon_entry))
|
|
78
78
|
else
|
|
79
|
-
render :edit
|
|
79
|
+
render :edit, status: FORM_ERROR_STATUS
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
@@ -111,7 +111,7 @@ module RocketJobMissionControl
|
|
|
111
111
|
dirmon_entry_replicate.errors.messages.each_pair do |field, message|
|
|
112
112
|
@dirmon_entry.errors.add(field, message)
|
|
113
113
|
end
|
|
114
|
-
render :copy
|
|
114
|
+
render :copy, status: FORM_ERROR_STATUS
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
@@ -83,7 +83,7 @@ module RocketJobMissionControl
|
|
|
83
83
|
if @job.errors.empty? && @job.valid? && @job.save
|
|
84
84
|
redirect_to job_path(@job)
|
|
85
85
|
else
|
|
86
|
-
render :edit
|
|
86
|
+
render :edit, status: FORM_ERROR_STATUS
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
89
|
|
|
@@ -172,21 +172,20 @@ module RocketJobMissionControl
|
|
|
172
172
|
authorize! :update_slice, @job
|
|
173
173
|
|
|
174
174
|
# Params from the edit_slice form
|
|
175
|
-
error_type
|
|
176
|
-
offset
|
|
177
|
-
|
|
175
|
+
error_type = params[:error_type]
|
|
176
|
+
offset = params.fetch(:offset, 0).to_i
|
|
177
|
+
line_index = params[:line_index].to_i
|
|
178
178
|
|
|
179
179
|
# Find the same slice edit_slice displayed: filtered by error type and
|
|
180
180
|
# ordered so the offset selects the matching slice.
|
|
181
181
|
scope = @job.input.failed.where("exception.class_name" => error_type)
|
|
182
182
|
slice = scope.order(_id: 1).limit(1).skip(offset).first
|
|
183
183
|
|
|
184
|
-
#
|
|
185
|
-
#
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
slice.records = updated_records
|
|
184
|
+
# Replace only the edited record, converting its text back into a record
|
|
185
|
+
# of the same kind, see RecordEditor. The other records are left as they are.
|
|
186
|
+
records = slice.to_a.dup
|
|
187
|
+
records[line_index] = RecordEditor.from_text(params.dig("job", "record"), records[line_index])
|
|
188
|
+
slice.records = records
|
|
190
189
|
|
|
191
190
|
if slice.save
|
|
192
191
|
logger.info("Slice Updated By #{login}, job: #{@job.id}, file_name: #{@job.upload_file_name}")
|
|
@@ -195,9 +194,10 @@ module RocketJobMissionControl
|
|
|
195
194
|
else
|
|
196
195
|
flash[:danger] = "Error updating slice."
|
|
197
196
|
end
|
|
198
|
-
rescue EncodingError => e
|
|
197
|
+
rescue EncodingError, JSON::ParserError, BSON::Error => e
|
|
199
198
|
# Mongo only stores UTF-8, so a record left with invalid bytes cannot be
|
|
200
|
-
# saved
|
|
199
|
+
# saved, and the JSON of a record that is not text must be valid.
|
|
200
|
+
# Surface it instead of returning a 500.
|
|
201
201
|
flash[:danger] = "Error updating slice: #{e.message}"
|
|
202
202
|
redirect_to view_slice_job_path(@job, error_type: params[:error_type], offset: offset)
|
|
203
203
|
end
|
|
@@ -214,12 +214,10 @@ module RocketJobMissionControl
|
|
|
214
214
|
scope = @job.input.failed.where("exception.class_name" => error_type)
|
|
215
215
|
slice = scope.order(_id: 1).limit(1).skip(offset).first
|
|
216
216
|
|
|
217
|
-
#
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
# Assings full array back to slice
|
|
222
|
-
slice.records = slice.to_a
|
|
217
|
+
# Deletes only the selected record, not every record equal to it.
|
|
218
|
+
records = slice.to_a.dup
|
|
219
|
+
records.delete_at(line_index)
|
|
220
|
+
slice.records = records
|
|
223
221
|
|
|
224
222
|
if slice.save
|
|
225
223
|
logger.info("Line Deleted By #{login}, job: #{@job.id}, file_name: #{@job.upload_file_name}")
|
|
@@ -301,6 +299,7 @@ module RocketJobMissionControl
|
|
|
301
299
|
:name,
|
|
302
300
|
:format,
|
|
303
301
|
:format_options,
|
|
302
|
+
:schema,
|
|
304
303
|
:mode,
|
|
305
304
|
:skip_unknown,
|
|
306
305
|
:slice_size,
|
|
@@ -311,6 +310,7 @@ module RocketJobMissionControl
|
|
|
311
310
|
:name,
|
|
312
311
|
:format,
|
|
313
312
|
:format_options,
|
|
313
|
+
:schema,
|
|
314
314
|
{columns: []}
|
|
315
315
|
]
|
|
316
316
|
)
|
|
@@ -62,7 +62,7 @@ module RocketJobMissionControl
|
|
|
62
62
|
|
|
63
63
|
if server.stopping? && view.can?(:destroy, server)
|
|
64
64
|
actions += "Server is stopping..."
|
|
65
|
-
confirmation = ""
|
|
65
|
+
confirmation = +""
|
|
66
66
|
unless server.zombie?
|
|
67
67
|
confirmation << "Warning!\n\nDestroying this server will hard kill its active workers/jobs.\nKilled jobs will be requeued for processing on another worker.\n\n"
|
|
68
68
|
end
|
|
@@ -83,6 +83,14 @@ module RocketJobMissionControl
|
|
|
83
83
|
values
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
# Returns the text area for the schema of a category, see RocketJob::Category::Base#schema: the JSON of a schema,
|
|
87
|
+
# or the path or url of the JSON file that holds it. Blank is no schema.
|
|
88
|
+
def schema_text_area(f, value)
|
|
89
|
+
text = value.is_a?(Hash) ? JSON.pretty_generate(value) : value
|
|
90
|
+
f.text_area(:schema, value: text, rows: 4, class: "form-control font-monospace",
|
|
91
|
+
placeholder: '{"fields": [{"name": "name"}, {"name": "age", "type": "integer"}]}')
|
|
92
|
+
end
|
|
93
|
+
|
|
86
94
|
# Returns the editable field as html for use in editing dynamic fields from a Job class.
|
|
87
95
|
def editable_field_html(klass, field_name, value, f)
|
|
88
96
|
# When editing a job the values are of the correct type.
|
|
@@ -123,37 +131,5 @@ placeholder: '{"key1":"value1", "key2":"value2", "key3":"value3"}')
|
|
|
123
131
|
f.text_field(field_name, value: value, class: "form-control", placeholder: placeholder)
|
|
124
132
|
end
|
|
125
133
|
end
|
|
126
|
-
|
|
127
|
-
# This method creates a link with `data-id` `data-fields` attributes. These attributes are used to create new instances of the nested fields through Javascript.
|
|
128
|
-
def link_to_add_fields(name, f, association, option)
|
|
129
|
-
# Takes an object (@job) and creates a new instance of its associated model (:properties)
|
|
130
|
-
new_object = f.object.send(association).klass.new
|
|
131
|
-
|
|
132
|
-
# Saves the unique ID of the object into a variable.
|
|
133
|
-
# This is needed to ensure the key of the associated array is unique. This is makes parsing the content in the `data-fields` attribute easier through Javascript.
|
|
134
|
-
# We could use another method to achive this.
|
|
135
|
-
id = new_object.object_id
|
|
136
|
-
|
|
137
|
-
# https://api.rubyonrails.org/ fields_for(record_name, record_object = nil, fields_options = {}, &block)
|
|
138
|
-
# record_name = :addresses
|
|
139
|
-
# record_object = new_object
|
|
140
|
-
# fields_options = { child_index: id }
|
|
141
|
-
# child_index` is used to ensure the key of the associated array is unique, and that it matched the value in the `data-id` attribute.
|
|
142
|
-
# `person[addresses_attributes][child_index_value][_destroy]`
|
|
143
|
-
fields = f.fields_for(association, new_object, child_index: id) do |builder|
|
|
144
|
-
# `association.to_s.singularize + "_fields"` ends up evaluating to `address_fields`
|
|
145
|
-
# The render function will then look for `views/people/_address_fields.html.erb`
|
|
146
|
-
# The render function also needs to be passed the value of 'builder', because `views/dirmon_entries/_input_categories.html.erb` needs this to render the form tags.
|
|
147
|
-
render("#{association.to_s.singularize}_fields", f: builder)
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
# This renders a simple link, but passes information into `data` attributes.
|
|
151
|
-
# This info can be named anything we want, but in this case we chose `data-id:` and `data-fields:`.
|
|
152
|
-
# The `id:` is from `new_object.object_id`.
|
|
153
|
-
# The `fields:` are rendered from the `fields` blocks.
|
|
154
|
-
# We use `gsub("\n", "")` to remove anywhite space from the rendered partial.
|
|
155
|
-
# The `id:` value needs to match the value used in `child_index: id`.
|
|
156
|
-
link_to(name, "#", class: "add_fields btn btn-#{option}", data: {id: id, fields: fields.delete("\n")})
|
|
157
|
-
end
|
|
158
134
|
end
|
|
159
135
|
end
|
|
@@ -107,6 +107,12 @@ module RocketJobMissionControl
|
|
|
107
107
|
(job.record_count.to_f / job.input_category.slice_size).ceil
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
+
# The category's schema: its fields as a JSON tree, or the path or url of the JSON file that holds it.
|
|
111
|
+
def job_category_schema(category)
|
|
112
|
+
schema = category.schema
|
|
113
|
+
schema.is_a?(Hash) ? render_json_tree(schema) : schema
|
|
114
|
+
end
|
|
115
|
+
|
|
110
116
|
def job_custom_fields(job)
|
|
111
117
|
attrs = job.attributes.dup
|
|
112
118
|
DISPLAYED_FIELDS.each { |key| attrs.delete(key) }
|
|
@@ -183,19 +189,20 @@ module RocketJobMissionControl
|
|
|
183
189
|
backtrace_strip_paths.any? { |path| line.to_s.start_with?(path) }
|
|
184
190
|
end
|
|
185
191
|
|
|
186
|
-
# Reversible
|
|
187
|
-
# See
|
|
192
|
+
# Reversible form of a failed record for an edit textarea, which keeps its type.
|
|
193
|
+
# See RecordEditor; convert it back with RecordEditor.from_text on save.
|
|
188
194
|
def escape_record(value)
|
|
189
|
-
|
|
195
|
+
RecordEditor.to_text(value)
|
|
190
196
|
end
|
|
191
197
|
|
|
192
198
|
# Read-only HTML for a failed record, with each unprintable/invalid byte
|
|
193
199
|
# rendered as a highlighted `\xHH` token. Each highlight carries a hover
|
|
194
200
|
# tooltip naming the byte, so an operator can see (in context) exactly which
|
|
195
|
-
# byte broke the record and what it is.
|
|
201
|
+
# byte broke the record and what it is. A record that is not a String, such as
|
|
202
|
+
# a Hash, is shown as Extended JSON, see RecordEditor.
|
|
196
203
|
def highlight_record(value)
|
|
197
204
|
safe_join(
|
|
198
|
-
RecordEscaper.segments(value).map do |type, text|
|
|
205
|
+
RecordEscaper.segments(RecordEditor.to_display_text(value)).map do |type, text|
|
|
199
206
|
next text if type == :text
|
|
200
207
|
|
|
201
208
|
content_tag(:span, text, class: "record-escape", title: record_escape_title(text))
|
|
@@ -23,7 +23,8 @@ module RocketJobMissionControl
|
|
|
23
23
|
# Returns [Hash] the difference between the supplied params and those already set in the job itself
|
|
24
24
|
def self.diff_properties(sanitized_properties, dirmon_entry)
|
|
25
25
|
default_job = dirmon_entry.job_class.new
|
|
26
|
-
|
|
26
|
+
# Without properties to change, such as when only the pattern changed, the job has the defaults.
|
|
27
|
+
updated_job = dirmon_entry.job_class.from_properties(sanitized_properties || {})
|
|
27
28
|
properties = {}
|
|
28
29
|
sanitized_properties&.each_pair do |name, value|
|
|
29
30
|
if name == :input_categories
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module RocketJobMissionControl
|
|
2
2
|
module JobSanitizer
|
|
3
|
-
CATEGORIES_FIELDS = %i[id name format format_options mode skip_unknown slice_size columns].freeze
|
|
3
|
+
CATEGORIES_FIELDS = %i[id name format format_options schema mode skip_unknown slice_size columns].freeze
|
|
4
|
+
|
|
5
|
+
# The category fields whose blank value means their default, nil, such as no `schema`, so that blanking them
|
|
6
|
+
# clears a value that was set.
|
|
7
|
+
CLEARABLE_CATEGORY_FIELDS = %i[schema].freeze
|
|
4
8
|
|
|
5
9
|
# Returns [Hash] the permissible params for the specified job class, after sanitizing.
|
|
6
10
|
# Parameters
|
|
@@ -49,19 +53,21 @@ module RocketJobMissionControl
|
|
|
49
53
|
end
|
|
50
54
|
|
|
51
55
|
if properties.key?(:input_categories_attributes)
|
|
52
|
-
categories
|
|
56
|
+
categories = sanitize_categories(properties[:input_categories_attributes], nil_blank, target)
|
|
53
57
|
permissible_params[:input_categories] = categories unless categories == [{}]
|
|
54
58
|
end
|
|
55
59
|
|
|
56
60
|
if properties.key?(:output_categories_attributes)
|
|
57
|
-
categories
|
|
61
|
+
categories = sanitize_categories(properties[:output_categories_attributes], nil_blank, target)
|
|
58
62
|
permissible_params[:output_categories] = categories unless categories == [{}]
|
|
59
63
|
end
|
|
60
64
|
|
|
61
65
|
permissible_params
|
|
62
66
|
end
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
# Returns [Array<Hash>] the permissible properties of each category, see .sanitize for `nil_blank`, which only
|
|
69
|
+
# applies to the CLEARABLE_CATEGORY_FIELDS, and `target`, which gets the error of a schema that is not valid JSON.
|
|
70
|
+
def self.sanitize_categories(properties, nil_blank = true, target = nil)
|
|
65
71
|
categories = []
|
|
66
72
|
|
|
67
73
|
properties.each_pair do |_, category|
|
|
@@ -70,10 +76,17 @@ module RocketJobMissionControl
|
|
|
70
76
|
next unless category.key?(key)
|
|
71
77
|
|
|
72
78
|
value = category[key]
|
|
73
|
-
|
|
79
|
+
if value.blank?
|
|
80
|
+
hash[key] = nil if nil_blank && CLEARABLE_CATEGORY_FIELDS.include?(key)
|
|
81
|
+
next
|
|
82
|
+
end
|
|
74
83
|
next if (key == :columns) && value == [""]
|
|
75
84
|
|
|
76
|
-
value
|
|
85
|
+
value = JSON.parse(value) if key == :format_options
|
|
86
|
+
if key == :schema
|
|
87
|
+
value = sanitize_schema(value, target)
|
|
88
|
+
next if value.nil?
|
|
89
|
+
end
|
|
77
90
|
hash[key] = value
|
|
78
91
|
end
|
|
79
92
|
categories << hash
|
|
@@ -81,5 +94,19 @@ module RocketJobMissionControl
|
|
|
81
94
|
|
|
82
95
|
categories
|
|
83
96
|
end
|
|
97
|
+
|
|
98
|
+
# Returns [Hash|String] the schema of a category as its form gives it, see RocketJob::Category::Base#schema: the
|
|
99
|
+
# JSON of a schema, which is parsed, or the path or url of the JSON file that holds it.
|
|
100
|
+
# Returns nil, and adds the error to the supplied target, when the JSON is not valid, so that the schema is not
|
|
101
|
+
# changed.
|
|
102
|
+
def self.sanitize_schema(value, target)
|
|
103
|
+
text = value.strip
|
|
104
|
+
return text unless text.start_with?("{")
|
|
105
|
+
|
|
106
|
+
JSON.parse(text)
|
|
107
|
+
rescue JSON::ParserError => e
|
|
108
|
+
target&.errors&.add(:properties, "Schema is not valid JSON: #{e.message}")
|
|
109
|
+
nil
|
|
110
|
+
end
|
|
84
111
|
end
|
|
85
112
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module RocketJobMissionControl
|
|
2
|
+
# Converts a failed batch record into the text that an operator views and edits, and the edited text back into a
|
|
3
|
+
# record of the same kind, so that editing a record keeps its type.
|
|
4
|
+
#
|
|
5
|
+
# A String record is shown as its text, with each unprintable or invalid byte escaped, see RecordEscaper. Any other
|
|
6
|
+
# record, such as a Hash or an Array uploaded in :hash or :array mode, or the [first, last] range of an integer range
|
|
7
|
+
# upload, is shown as MongoDB Extended JSON, so that values such as a Time or a BSON::ObjectId keep their types.
|
|
8
|
+
module RecordEditor
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
# Returns [String] the record as the text to edit.
|
|
12
|
+
def to_text(record)
|
|
13
|
+
return RecordEscaper.escape(record) if record.is_a?(String)
|
|
14
|
+
|
|
15
|
+
JSON.pretty_generate(record.as_extended_json(mode: :relaxed))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns [String] the record as the text to view on one line, see #to_text.
|
|
19
|
+
def to_display_text(record)
|
|
20
|
+
return record if record.is_a?(String)
|
|
21
|
+
|
|
22
|
+
JSON.generate(record.as_extended_json(mode: :relaxed))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Returns the record that the edited text holds, of the same kind as the record that was edited.
|
|
26
|
+
#
|
|
27
|
+
# Raises JSON::ParserError, or BSON::Error, when the text for a record that is not a String is not valid
|
|
28
|
+
# Extended JSON.
|
|
29
|
+
def from_text(text, record)
|
|
30
|
+
text = text.to_s.gsub("\r\n", "\n")
|
|
31
|
+
return RecordEscaper.unescape(text) if record.is_a?(String)
|
|
32
|
+
|
|
33
|
+
BSON::ExtJSON.parse(text, mode: :bson)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<% input_category = f.object %>
|
|
2
2
|
|
|
3
|
-
<div
|
|
3
|
+
<div>
|
|
4
4
|
<div class="card border-primary">
|
|
5
5
|
<div class="card-header">
|
|
6
6
|
<div class="row">
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
<%= f.select(:format, options, { include_blank: true, selected: value }, { class: "tom-select form-select" }) %>
|
|
27
27
|
</div>
|
|
28
28
|
|
|
29
|
+
<div class="mb-3">
|
|
30
|
+
<%= f.label :schema %>
|
|
31
|
+
<%= schema_text_area(f, input_category.schema) %>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
29
34
|
<div class="mb-3">
|
|
30
35
|
<%= f.label :format_options %>
|
|
31
36
|
<% value = input_category.format_options %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<% output_category = f.object %>
|
|
2
2
|
|
|
3
|
-
<div
|
|
3
|
+
<div>
|
|
4
4
|
<div class="card border-success">
|
|
5
5
|
<div class="card-header">
|
|
6
6
|
<div class="row">
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
<%= f.select(:format, options, { include_blank: true, selected: value }, { class: "tom-select form-select" }) %>
|
|
27
27
|
</div>
|
|
28
28
|
|
|
29
|
+
<div class="mb-3">
|
|
30
|
+
<%= f.label :schema %>
|
|
31
|
+
<%= schema_text_area(f, output_category.schema) %>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
29
34
|
<div class="mb-3">
|
|
30
35
|
<%= f.label :format_options %>
|
|
31
36
|
<% value = output_category.format_options %>
|
|
@@ -24,6 +24,12 @@
|
|
|
24
24
|
<td><label>Format:</label></td>
|
|
25
25
|
<td><%= category.format %></td>
|
|
26
26
|
</tr>
|
|
27
|
+
<% if category.schema.present? %>
|
|
28
|
+
<tr>
|
|
29
|
+
<td><label>Schema:</label></td>
|
|
30
|
+
<td><%= job_category_schema(category) %></td>
|
|
31
|
+
</tr>
|
|
32
|
+
<% end %>
|
|
27
33
|
<tr>
|
|
28
34
|
<td><label>Header Cleanser:</label></td>
|
|
29
35
|
<td><%= category.header_cleanser %></td>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<% input_category = f.object %>
|
|
2
2
|
|
|
3
|
-
<div
|
|
3
|
+
<div>
|
|
4
4
|
<div class="card border-primary">
|
|
5
5
|
<div class="card-header">
|
|
6
6
|
<div class="row">
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
<div class="card-body">
|
|
14
14
|
<%= f.hidden_field :name, value: input_category.name %>
|
|
15
15
|
|
|
16
|
+
<% if input_category.errors.any? %>
|
|
17
|
+
<div class="alert alert-danger">
|
|
18
|
+
<% input_category.errors.full_messages.each do |message| %>
|
|
19
|
+
<div><%= message %></div>
|
|
20
|
+
<% end %>
|
|
21
|
+
</div>
|
|
22
|
+
<% end %>
|
|
23
|
+
|
|
16
24
|
<div class="mb-3">
|
|
17
25
|
<%= f.label :columns %>
|
|
18
26
|
<% options = input_category.columns || [] %>
|
|
@@ -26,6 +34,11 @@
|
|
|
26
34
|
<%= f.select(:format, options, { include_blank: true, selected: value }, { class: "tom-select form-select" }) %>
|
|
27
35
|
</div>
|
|
28
36
|
|
|
37
|
+
<div class="mb-3">
|
|
38
|
+
<%= f.label :schema %>
|
|
39
|
+
<%= schema_text_area(f, input_category.schema) %>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
29
42
|
<div class="mb-3">
|
|
30
43
|
<%= f.label :format_options %>
|
|
31
44
|
<% value = input_category.format_options %>
|
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
<td><label>Format:</label></td>
|
|
28
28
|
<td><%= category.format %></td>
|
|
29
29
|
</tr>
|
|
30
|
+
<% if category.schema.present? %>
|
|
31
|
+
<tr>
|
|
32
|
+
<td><label>Schema:</label></td>
|
|
33
|
+
<td><%= job_category_schema(category) %></td>
|
|
34
|
+
</tr>
|
|
35
|
+
<% end %>
|
|
30
36
|
<% if category.format_options %>
|
|
31
37
|
<tr>
|
|
32
38
|
<td><label>Format Options:</label></td>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<% output_category = f.object %>
|
|
2
2
|
|
|
3
|
-
<div
|
|
3
|
+
<div>
|
|
4
4
|
<div class="card border-success">
|
|
5
5
|
<div class="card-header">
|
|
6
6
|
<div class="row">
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
<div class="card-body">
|
|
14
14
|
<%= f.hidden_field :name, value: output_category.name %>
|
|
15
15
|
|
|
16
|
+
<% if output_category.errors.any? %>
|
|
17
|
+
<div class="alert alert-danger">
|
|
18
|
+
<% output_category.errors.full_messages.each do |message| %>
|
|
19
|
+
<div><%= message %></div>
|
|
20
|
+
<% end %>
|
|
21
|
+
</div>
|
|
22
|
+
<% end %>
|
|
23
|
+
|
|
16
24
|
<div class="mb-3">
|
|
17
25
|
<%= f.label :columns %>
|
|
18
26
|
<% options = output_category.columns || [] %>
|
|
@@ -26,6 +34,11 @@
|
|
|
26
34
|
<%= f.select(:format, options, { include_blank: true, selected: value }, { class: "tom-select form-select" }) %>
|
|
27
35
|
</div>
|
|
28
36
|
|
|
37
|
+
<div class="mb-3">
|
|
38
|
+
<%= f.label :schema %>
|
|
39
|
+
<%= schema_text_area(f, output_category.schema) %>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
29
42
|
<div class="mb-3">
|
|
30
43
|
<%= f.label :format_options %>
|
|
31
44
|
<% value = output_category.format_options %>
|
|
@@ -11,19 +11,19 @@
|
|
|
11
11
|
<div class='job-status'>
|
|
12
12
|
<div class='section-header'>Edit Record: <%= @first_record_number + @line_index %></div>
|
|
13
13
|
|
|
14
|
+
<% record = @lines[@line_index] %>
|
|
14
15
|
<p class='form-text'>
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
<% if record.is_a?(String) %>
|
|
17
|
+
Unprintable bytes are shown as <code>\xHH</code> escapes (for example a null byte as <code>\x00</code>)
|
|
18
|
+
and are converted back to the original bytes when saved. A literal backslash is shown as <code>\\</code>.
|
|
19
|
+
<% else %>
|
|
20
|
+
This record is not text, so it is shown as MongoDB Extended JSON, and saved with the same types of values.
|
|
21
|
+
For example <code>{"$date": "..."}</code> is saved as a time.
|
|
22
|
+
<% end %>
|
|
17
23
|
</p>
|
|
18
24
|
|
|
19
|
-
<%= form_for(:job, url: update_slice_job_path(@job, offset: @offset, error_type: @failure_exception.class_name), method: :patch) do |f| %>
|
|
20
|
-
|
|
21
|
-
<% if @line_index == index %>
|
|
22
|
-
<%= f.text_area :records, value: escape_record(line), class: 'input_slices form-control', id: index, multiple: true, rows: 20, wrap: "soft" %>
|
|
23
|
-
<% else %>
|
|
24
|
-
<%= f.hidden_field :records, value: escape_record(line), class: 'input_slices', id: index, multiple: true %>
|
|
25
|
-
<% end %>
|
|
26
|
-
<% end %>
|
|
25
|
+
<%= form_for(:job, url: update_slice_job_path(@job, offset: @offset, error_type: @failure_exception.class_name, line_index: @line_index), method: :patch) do |f| %>
|
|
26
|
+
<%= f.text_area :record, value: escape_record(record), class: 'input_slices form-control', id: @line_index, rows: 20, wrap: "soft" %>
|
|
27
27
|
|
|
28
28
|
<div id='submit'>
|
|
29
29
|
<%= f.submit 'Save', class: 'btn btn-primary' %>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rocketjob_mission_control
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Cloutier
|
|
@@ -46,14 +46,14 @@ dependencies:
|
|
|
46
46
|
requirements:
|
|
47
47
|
- - "~>"
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '7.
|
|
49
|
+
version: '7.1'
|
|
50
50
|
type: :runtime
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - "~>"
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: '7.
|
|
56
|
+
version: '7.1'
|
|
57
57
|
description: Rocket Job Mission Control is the Web user interface to manage Rocket
|
|
58
58
|
Job.
|
|
59
59
|
executables: []
|
|
@@ -84,7 +84,6 @@ files:
|
|
|
84
84
|
- app/assets/javascripts/rocket_job_mission_control/jquery-3.7.1.min.js
|
|
85
85
|
- app/assets/javascripts/rocket_job_mission_control/jquery.json-viewer.js
|
|
86
86
|
- app/assets/javascripts/rocket_job_mission_control/json_tree_init.js
|
|
87
|
-
- app/assets/javascripts/rocket_job_mission_control/nested_fields.js
|
|
88
87
|
- app/assets/javascripts/rocket_job_mission_control/tom-select.complete.min.js
|
|
89
88
|
- app/assets/javascripts/rocket_job_mission_control/tom_select_init.js
|
|
90
89
|
- app/assets/javascripts/rocket_job_mission_control/turbo.min.js
|
|
@@ -124,6 +123,7 @@ files:
|
|
|
124
123
|
- app/models/rocket_job_mission_control/dirmon_sanitizer.rb
|
|
125
124
|
- app/models/rocket_job_mission_control/job_sanitizer.rb
|
|
126
125
|
- app/models/rocket_job_mission_control/query.rb
|
|
126
|
+
- app/models/rocket_job_mission_control/record_editor.rb
|
|
127
127
|
- app/models/rocket_job_mission_control/record_escaper.rb
|
|
128
128
|
- app/views/layouts/rocket_job_mission_control/application.html.erb
|
|
129
129
|
- app/views/layouts/rocket_job_mission_control/partials/_flash.html.erb
|
|
@@ -133,9 +133,7 @@ files:
|
|
|
133
133
|
- app/views/rocket_job_mission_control/dirmon_entries/_details.html.erb
|
|
134
134
|
- app/views/rocket_job_mission_control/dirmon_entries/_exception.html.erb
|
|
135
135
|
- app/views/rocket_job_mission_control/dirmon_entries/_form.html.erb
|
|
136
|
-
- app/views/rocket_job_mission_control/dirmon_entries/_input_categories.html.erb
|
|
137
136
|
- app/views/rocket_job_mission_control/dirmon_entries/_input_category_fields.html.erb
|
|
138
|
-
- app/views/rocket_job_mission_control/dirmon_entries/_output_categories.html.erb
|
|
139
137
|
- app/views/rocket_job_mission_control/dirmon_entries/_output_category_fields.html.erb
|
|
140
138
|
- app/views/rocket_job_mission_control/dirmon_entries/_properties.html.erb
|
|
141
139
|
- app/views/rocket_job_mission_control/dirmon_entries/_sidebar.html.erb
|
|
@@ -182,7 +180,7 @@ metadata:
|
|
|
182
180
|
changelog_uri: https://github.com/reidmorrison/rocketjob_mission_control/blob/main/CHANGELOG.md
|
|
183
181
|
documentation_uri: https://rocketjob.reidmorrison.com/
|
|
184
182
|
homepage_uri: https://rocketjob.reidmorrison.com/
|
|
185
|
-
source_code_uri: https://github.com/reidmorrison/rocketjob_mission_control/tree/v7.
|
|
183
|
+
source_code_uri: https://github.com/reidmorrison/rocketjob_mission_control/tree/v7.1.0
|
|
186
184
|
rubygems_mfa_required: 'true'
|
|
187
185
|
rdoc_options: []
|
|
188
186
|
require_paths:
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _createClass = function () {
|
|
4
|
-
function defineProperties(target, props) {
|
|
5
|
-
for (var i = 0; i < props.length; i++) {
|
|
6
|
-
var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true;
|
|
7
|
-
|
|
8
|
-
if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor);
|
|
9
|
-
}
|
|
10
|
-
} return function (Constructor, protoProps, staticProps) {
|
|
11
|
-
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
12
|
-
if (staticProps) defineProperties(Constructor, staticProps); return Constructor;
|
|
13
|
-
};
|
|
14
|
-
}();
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) {
|
|
17
|
-
if (!(instance instanceof Constructor)) {
|
|
18
|
-
throw new TypeError("Cannot call a class as a function");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var addFields = function () {
|
|
23
|
-
// This executes when the function is instantiated.
|
|
24
|
-
function addFields() {
|
|
25
|
-
_classCallCheck(this, addFields);
|
|
26
|
-
|
|
27
|
-
this.links = document.querySelectorAll('.add_fields');
|
|
28
|
-
this.iterateLinks();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
_createClass(addFields, [{
|
|
32
|
-
key: 'iterateLinks',
|
|
33
|
-
value: function iterateLinks() {
|
|
34
|
-
var _this = this;
|
|
35
|
-
|
|
36
|
-
// If there are no links on the page, stop the function from executing.
|
|
37
|
-
if (this.links.length === 0) return; // Loop over each link on the page. A page could have multiple nested forms.
|
|
38
|
-
|
|
39
|
-
this.links.forEach(function (link) {
|
|
40
|
-
link.addEventListener('click', function (e) {
|
|
41
|
-
_this.handleClick(link, e);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: 'handleClick',
|
|
47
|
-
value: function handleClick(link, e) {
|
|
48
|
-
// Stop the function from executing if a link or event were not passed into the function.
|
|
49
|
-
if (!link || !e) return; // Prevent the browser from following the URL.
|
|
50
|
-
|
|
51
|
-
e.preventDefault(); // Save a unique timestamp to ensure the key of the associated array is unique.
|
|
52
|
-
|
|
53
|
-
var time = new Date().getTime(); // Save the data id attribute into a variable. This corresponds to `new_object.object_id`.
|
|
54
|
-
var linkId = link.dataset.id; // Create a new regular expression needed to find any instance of the `new_object.object_id` used in the fields data attribute if there's a value in `linkId`.
|
|
55
|
-
var regexp = linkId ? new RegExp(linkId, 'g') : null; // Replace all instances of the `new_object.object_id` with `time`, and save markup into a variable if there's a value in `regexp`.
|
|
56
|
-
var newFields = regexp ? link.dataset.fields.replace(regexp, time) : null; // Add the new markup to the form if there are fields to add.
|
|
57
|
-
|
|
58
|
-
newFields ? link.insertAdjacentHTML('beforebegin', newFields) : null;
|
|
59
|
-
}
|
|
60
|
-
}]);
|
|
61
|
-
|
|
62
|
-
return addFields;
|
|
63
|
-
}();
|
|
64
|
-
|
|
65
|
-
var removeFields = function () {
|
|
66
|
-
// This executes when the function is instantiated.
|
|
67
|
-
function removeFields() {
|
|
68
|
-
_classCallCheck(this, removeFields);
|
|
69
|
-
|
|
70
|
-
this.iterateLinks();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
_createClass(removeFields, [{
|
|
74
|
-
key: 'iterateLinks',
|
|
75
|
-
value: function iterateLinks() {
|
|
76
|
-
var _this2 = this;
|
|
77
|
-
|
|
78
|
-
// Use event delegation to ensure any fields added after the page loads are captured.
|
|
79
|
-
document.addEventListener('click', function (e) {
|
|
80
|
-
if (e.target && e.target.className == "remove_fields btn btn-danger") {
|
|
81
|
-
_this2.handleClick(e.target, e);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
key: 'handleClick',
|
|
87
|
-
value: function handleClick(link, e) {
|
|
88
|
-
// Stop the function from executing if a link or event were not passed into the function.
|
|
89
|
-
if (!link || !e) return; // Prevent the browser from following the URL.
|
|
90
|
-
|
|
91
|
-
e.preventDefault(); // Find the parent wrapper for the set of nested fields.
|
|
92
|
-
|
|
93
|
-
var fieldParent = link.closest('.nested-fields'); // If there is a parent wrapper, find the hidden delete field.
|
|
94
|
-
var deleteField = fieldParent ? fieldParent.querySelector('input[type="hidden"]') : null; // If there is a delete field, update the value to `1` and hide the corresponding nested fields.
|
|
95
|
-
|
|
96
|
-
if (deleteField) {
|
|
97
|
-
deleteField.value = 1;
|
|
98
|
-
fieldParent.style.display = 'none';
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}]);
|
|
102
|
-
|
|
103
|
-
return removeFields;
|
|
104
|
-
}();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
window.addEventListener('DOMContentLoaded', function () {
|
|
108
|
-
return new addFields();
|
|
109
|
-
});
|
|
110
|
-
window.addEventListener('DOMContentLoaded', function () {
|
|
111
|
-
return new removeFields();
|
|
112
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<div class='lead'>Input Categories:</div>
|
|
2
|
-
<% @job.input_categories.each do |category| %>
|
|
3
|
-
<div class='row'>
|
|
4
|
-
<div class='col-md-12'>
|
|
5
|
-
<div class='status-message'><label><%= category.name.to_s.camelcase %>:</label></div>
|
|
6
|
-
<div class='row'>
|
|
7
|
-
<div class='col-md-12'>
|
|
8
|
-
<table>
|
|
9
|
-
<% if category.name == :main %>
|
|
10
|
-
<tr>
|
|
11
|
-
<td><label>Slice Size:</label></td>
|
|
12
|
-
<td><%= category.slice_size %></td>
|
|
13
|
-
</tr>
|
|
14
|
-
<% end %>
|
|
15
|
-
</tr>
|
|
16
|
-
<tr>
|
|
17
|
-
<td><label>Format:</label></td>
|
|
18
|
-
<td><%= category.format %></td>
|
|
19
|
-
</tr>
|
|
20
|
-
<tr>
|
|
21
|
-
<td><label>Skip Unknown Columns:</label></td>
|
|
22
|
-
<td><%= category.skip_unknown %></td>
|
|
23
|
-
</tr>
|
|
24
|
-
<tr>
|
|
25
|
-
<td><label>Mode:</label></td>
|
|
26
|
-
<td><%= category.mode %></td>
|
|
27
|
-
</tr>
|
|
28
|
-
<% if category.format_options %>
|
|
29
|
-
<tr>
|
|
30
|
-
<td><label>Format Options:</label></td>
|
|
31
|
-
<td>
|
|
32
|
-
<%= render_json_tree(category.format_options) %>
|
|
33
|
-
</td>
|
|
34
|
-
</tr>
|
|
35
|
-
<% end %>
|
|
36
|
-
<% if category.columns %>
|
|
37
|
-
<% first = true %>
|
|
38
|
-
<% category.columns.each do |item| %>
|
|
39
|
-
<% if first %>
|
|
40
|
-
<tr>
|
|
41
|
-
<td><label>Columns:</label></td>
|
|
42
|
-
<td><%= item %></td>
|
|
43
|
-
</tr>
|
|
44
|
-
<% first = false %>
|
|
45
|
-
<% else %>
|
|
46
|
-
<tr>
|
|
47
|
-
<td></td>
|
|
48
|
-
<td><%= item %></td>
|
|
49
|
-
</tr>
|
|
50
|
-
<% end %>
|
|
51
|
-
<% end %>
|
|
52
|
-
<% end %>
|
|
53
|
-
</table>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
<br/>
|
|
59
|
-
<% end %>
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
<div class='lead'>Output Categories:</div>
|
|
2
|
-
<% @job.output_categories.each do |category| %>
|
|
3
|
-
<div class='row'>
|
|
4
|
-
<div class='col-md-12'>
|
|
5
|
-
<div class='status-message'><label><%= category.name.to_s.camelcase %>:</label></div>
|
|
6
|
-
<div class='row'>
|
|
7
|
-
<div class='col-md-12'>
|
|
8
|
-
<table>
|
|
9
|
-
<tr>
|
|
10
|
-
<td><label>Format:</label></td>
|
|
11
|
-
<td><%= category.format %></td>
|
|
12
|
-
</tr>
|
|
13
|
-
<% if category.format_options %>
|
|
14
|
-
<tr>
|
|
15
|
-
<td><label>Format Options:</label></td>
|
|
16
|
-
<td>
|
|
17
|
-
<%= render_json_tree(category.format_options) %>
|
|
18
|
-
</td>
|
|
19
|
-
</tr>
|
|
20
|
-
<% end %>
|
|
21
|
-
<% if category.columns %>
|
|
22
|
-
<% first = true %>
|
|
23
|
-
<% category.columns.each do |item| %>
|
|
24
|
-
<% if first %>
|
|
25
|
-
<tr>
|
|
26
|
-
<td><label>Columns:</label></td>
|
|
27
|
-
<td><%= item %></td>
|
|
28
|
-
</tr>
|
|
29
|
-
<% first = false %>
|
|
30
|
-
<% else %>
|
|
31
|
-
<tr>
|
|
32
|
-
<td></td>
|
|
33
|
-
<td><%= item %></td>
|
|
34
|
-
</tr>
|
|
35
|
-
<% end %>
|
|
36
|
-
<% end %>
|
|
37
|
-
<% end %>
|
|
38
|
-
</table>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
<br/>
|
|
44
|
-
<% end %>
|