marty 2.5.2 → 2.5.4
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 +5 -5
- data/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +11 -589
- data/Gemfile +9 -9
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -3
- data/app/components/marty/api_auth_view.rb +3 -3
- data/app/components/marty/api_config_view.rb +8 -8
- data/app/components/marty/api_log_view.rb +16 -20
- data/app/components/marty/auth_app.rb +6 -6
- data/app/components/marty/base_rule_view.rb +27 -19
- data/app/components/marty/config_view.rb +12 -9
- data/app/components/marty/data_grid_view.rb +26 -26
- data/app/components/marty/delorean_rule_view.rb +0 -1
- data/app/components/marty/event_view.rb +27 -27
- data/app/components/marty/extras/layout.rb +26 -26
- data/app/components/marty/extras/misc.rb +2 -2
- data/app/components/marty/grid.rb +13 -13
- data/app/components/marty/grid_append_only.rb +0 -1
- data/app/components/marty/import_type_view.rb +13 -13
- data/app/components/marty/import_view.rb +17 -16
- data/app/components/marty/log_view.rb +16 -14
- data/app/components/marty/main_auth_app.rb +59 -59
- data/app/components/marty/main_auth_app/client/main_auth_app.js +3 -3
- data/app/components/marty/mcfly_grid_panel.rb +10 -10
- data/app/components/marty/new_posting_form.rb +11 -11
- data/app/components/marty/new_posting_window.rb +0 -1
- data/app/components/marty/posting_grid.rb +12 -13
- data/app/components/marty/promise_view.rb +6 -6
- data/app/components/marty/report_form.rb +50 -53
- data/app/components/marty/report_select.rb +27 -27
- data/app/components/marty/reporting.rb +4 -4
- data/app/components/marty/script_form.rb +40 -42
- data/app/components/marty/script_grid.rb +24 -24
- data/app/components/marty/script_tester.rb +40 -42
- data/app/components/marty/scripting.rb +25 -27
- data/app/components/marty/simple_app.rb +24 -9
- data/app/components/marty/tag_grid.rb +12 -13
- data/app/components/marty/user_view.rb +35 -35
- data/app/controllers/marty/application_controller.rb +3 -4
- data/app/controllers/marty/components_controller.rb +1 -1
- data/app/controllers/marty/delayed_job_controller.rb +1 -0
- data/app/controllers/marty/diagnostic/controller.rb +4 -6
- data/app/controllers/marty/job_controller.rb +6 -6
- data/app/controllers/marty/report_controller.rb +11 -11
- data/app/controllers/marty/rpc_controller.rb +15 -16
- data/app/helpers/marty/script_set.rb +4 -4
- data/app/models/marty/api_auth.rb +4 -5
- data/app/models/marty/api_config.rb +1 -1
- data/app/models/marty/base.rb +9 -8
- data/app/models/marty/base_rule.rb +18 -13
- data/app/models/marty/config.rb +4 -5
- data/app/models/marty/data_grid.rb +157 -181
- data/app/models/marty/delorean_rule.rb +63 -62
- data/app/models/marty/enum.rb +1 -1
- data/app/models/marty/event.rb +56 -59
- data/app/models/marty/helper.rb +38 -6
- data/app/models/marty/import_type.rb +6 -6
- data/app/models/marty/log.rb +3 -2
- data/app/models/marty/name_validator.rb +3 -2
- data/app/models/marty/pg_enum.rb +3 -4
- data/app/models/marty/posting.rb +20 -24
- data/app/models/marty/promise.rb +28 -30
- data/app/models/marty/script.rb +30 -28
- data/app/models/marty/tag.rb +8 -8
- data/app/models/marty/token.rb +2 -2
- data/app/models/marty/user.rb +24 -23
- data/app/models/marty/vw_promise.rb +10 -11
- data/config/routes.rb +2 -2
- data/delorean/blame_report.dl +268 -0
- data/{spec/dummy/delorean/fields.dl → delorean/marty_fields.dl} +8 -0
- data/delorean/table_report.dl +34 -0
- data/docker-compose.dummy.yml +2 -3
- data/lib/marty/aws/base.rb +8 -8
- data/lib/marty/aws/request.rb +4 -4
- data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -0
- data/lib/marty/content_handler.rb +25 -25
- data/lib/marty/data_change.rb +49 -71
- data/lib/marty/data_conversion.rb +20 -28
- data/lib/marty/data_exporter.rb +25 -28
- data/lib/marty/data_importer.rb +25 -27
- data/lib/marty/engine.rb +1 -2
- data/lib/marty/json_schema.rb +22 -24
- data/lib/marty/logger.rb +6 -9
- data/lib/marty/mcfly_model.rb +20 -24
- data/lib/marty/migrations.rb +37 -35
- data/lib/marty/monkey.rb +33 -33
- data/lib/marty/permissions.rb +18 -18
- data/lib/marty/promise_job.rb +17 -17
- data/lib/marty/promise_proxy.rb +6 -6
- data/lib/marty/relation.rb +6 -7
- data/lib/marty/rpc_call.rb +13 -12
- data/lib/marty/rule_script_set.rb +32 -28
- data/lib/marty/schema_helper.rb +37 -51
- data/lib/marty/util.rb +25 -24
- data/lib/marty/version.rb +1 -1
- data/lib/marty/xl.rb +121 -115
- data/make-dummy.mk +3 -0
- data/marty.gemspec +21 -21
- data/other/marty/api/base.rb +34 -35
- data/other/marty/diagnostic/aws/ec2_instance.rb +8 -8
- data/other/marty/diagnostic/base.rb +13 -14
- data/other/marty/diagnostic/collection.rb +2 -1
- data/other/marty/diagnostic/connections.rb +8 -6
- data/other/marty/diagnostic/database.rb +1 -0
- data/other/marty/diagnostic/delayed_job_version.rb +7 -9
- data/other/marty/diagnostic/delayed_job_worker_total_count.rb +1 -1
- data/other/marty/diagnostic/delayed_job_workers.rb +1 -1
- data/other/marty/diagnostic/environment_variables.rb +17 -15
- data/other/marty/diagnostic/fatal.rb +1 -1
- data/other/marty/diagnostic/node.rb +5 -9
- data/other/marty/diagnostic/nodes.rb +7 -5
- data/other/marty/diagnostic/packer.rb +7 -7
- data/other/marty/diagnostic/reporter.rb +24 -27
- data/other/marty/diagnostic/version.rb +3 -5
- data/script/rails +2 -1
- data/spec/controllers/application_controller_spec.rb +6 -6
- data/spec/controllers/delayed_job_controller_spec.rb +4 -4
- data/spec/controllers/diagnostic/controller_spec.rb +59 -60
- data/spec/controllers/job_controller_spec.rb +68 -69
- data/spec/controllers/rpc_controller_spec.rb +353 -359
- data/spec/controllers/rpc_import_spec.rb +15 -16
- data/spec/dummy/delorean/blame_report.dl +110 -15
- data/spec/dummy/delorean/data_report.dl +4 -4
- data/spec/dummy/delorean/marty_fields.dl +63 -0
- data/spec/dummy/delorean/table_report.dl +34 -0
- data/spec/features/auth_app_spec.rb +1 -2
- data/spec/features/data_import_spec.rb +2 -3
- data/spec/features/enum_spec.rb +42 -46
- data/spec/features/jobs_dashboard_spec.rb +14 -8
- data/spec/features/log_view_spec.rb +40 -43
- data/spec/features/reporting_spec.rb +15 -15
- data/spec/features/rule_spec.rb +195 -190
- data/spec/features/scripting_spec.rb +17 -20
- data/spec/features/scripting_test_spec.rb +32 -33
- data/spec/features/user_view_spec.rb +15 -17
- data/spec/job_helper.rb +11 -11
- data/spec/lib/data_blame_spec.rb +82 -0
- data/spec/lib/data_exporter_spec.rb +31 -32
- data/spec/lib/data_importer_spec.rb +382 -395
- data/spec/lib/delorean_query_spec.rb +117 -119
- data/spec/lib/json_schema_spec.rb +382 -392
- data/spec/lib/logger_spec.rb +23 -24
- data/spec/lib/mcfly_model_spec.rb +112 -109
- data/spec/lib/migrations_spec.rb +10 -10
- data/spec/lib/struct_compare_spec.rb +6 -6
- data/spec/lib/table_report_spec.rb +90 -0
- data/spec/lib/xl_spec.rb +63 -65
- data/spec/lib/xl_styles_spec.rb +16 -19
- data/spec/models/api_auth_spec.rb +30 -30
- data/spec/models/config_spec.rb +32 -32
- data/spec/models/data_grid_spec.rb +642 -655
- data/spec/models/event_spec.rb +96 -88
- data/spec/models/import_type_spec.rb +20 -20
- data/spec/models/posting_spec.rb +35 -35
- data/spec/models/promise_spec.rb +5 -5
- data/spec/models/rule_spec.rb +280 -269
- data/spec/models/script_spec.rb +27 -18
- data/spec/models/user_spec.rb +9 -9
- data/spec/other/diagnostic/base_spec.rb +20 -19
- data/spec/other/diagnostic/collection_spec.rb +6 -5
- data/spec/other/diagnostic/delayed_job_version_spec.rb +1 -1
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +8 -8
- data/spec/other/diagnostic/reporter_spec.rb +31 -33
- data/spec/spec_helper.rb +5 -5
- data/spec/support/chromedriver.rb +3 -5
- data/spec/support/components/netzke_combobox.rb +1 -1
- data/spec/support/components/netzke_grid.rb +17 -17
- data/spec/support/custom_matchers.rb +2 -2
- data/spec/support/download_helper.rb +1 -1
- data/spec/support/helper.rb +1 -2
- data/spec/support/netzke.rb +31 -31
- data/spec/support/performance_helper.rb +8 -8
- data/spec/support/post_run_logger.rb +1 -2
- data/spec/support/setup.rb +1 -4
- data/spec/support/shared_connection.rb +2 -2
- data/spec/support/structure_compare.rb +21 -22
- data/spec/support/suite.rb +1 -2
- data/spec/support/users.rb +5 -6
- metadata +32 -26
|
@@ -5,18 +5,18 @@ class Marty::ReportSelect < Marty::Form
|
|
|
5
5
|
c.klass = Marty::TagGrid
|
|
6
6
|
c.height = 200
|
|
7
7
|
c.load_inline_data = false
|
|
8
|
-
c.title = I18n.t(
|
|
9
|
-
c.attributes
|
|
8
|
+
c.title = I18n.t('script.selection_history')
|
|
9
|
+
c.attributes = [:name, :created_dt, :comment]
|
|
10
10
|
c.bbar = []
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
component :script_grid do |c|
|
|
14
14
|
c.height = 350
|
|
15
15
|
c.klass = Marty::ScriptGrid
|
|
16
|
-
c.title = I18n.t(
|
|
16
|
+
c.title = I18n.t('script.selection_list')
|
|
17
17
|
c.bbar = []
|
|
18
|
-
c.attributes
|
|
19
|
-
c.scope
|
|
18
|
+
c.attributes = [:name, :tag]
|
|
19
|
+
c.scope = lambda { |r|
|
|
20
20
|
r.where("name like '%Report'")
|
|
21
21
|
}
|
|
22
22
|
end
|
|
@@ -28,18 +28,18 @@ class Marty::ReportSelect < Marty::Form
|
|
|
28
28
|
|
|
29
29
|
c.items =
|
|
30
30
|
[
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
:tag_grid,
|
|
32
|
+
:script_grid,
|
|
33
|
+
fieldset(I18n.t('reporting.report_select'),
|
|
34
|
+
{
|
|
35
|
+
xtype: :netzkeremotecombo,
|
|
36
|
+
name: 'nodename',
|
|
37
|
+
attr_type: :string,
|
|
38
|
+
virtual: true,
|
|
39
|
+
hide_label: true,
|
|
40
|
+
width: 200,
|
|
41
|
+
},
|
|
42
|
+
{},
|
|
43
43
|
),
|
|
44
44
|
]
|
|
45
45
|
c.bbar = nil
|
|
@@ -51,7 +51,7 @@ class Marty::ReportSelect < Marty::Form
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# FIXME: should be in a library
|
|
54
|
-
REPORT_ATTR_SET = Set[
|
|
54
|
+
REPORT_ATTR_SET = Set['title', 'form', 'result', 'format']
|
|
55
55
|
|
|
56
56
|
def node_list
|
|
57
57
|
sset = Marty::ScriptSet.new root_sess[:selected_tag_id]
|
|
@@ -59,26 +59,26 @@ class Marty::ReportSelect < Marty::Form
|
|
|
59
59
|
|
|
60
60
|
return [] unless engine
|
|
61
61
|
|
|
62
|
-
nodes = engine.enumerate_nodes.select
|
|
62
|
+
nodes = engine.enumerate_nodes.select do |n|
|
|
63
63
|
attrs = Set.new(engine.enumerate_attrs_by_node(n))
|
|
64
64
|
attrs.superset? REPORT_ATTR_SET
|
|
65
|
-
|
|
65
|
+
end
|
|
66
66
|
|
|
67
|
-
nodes.map
|
|
68
|
-
roles = engine.evaluate(node,
|
|
69
|
-
next if roles && !roles.any?{ |r| Marty::User.has_role(r) }
|
|
67
|
+
nodes.map do |node|
|
|
68
|
+
roles = engine.evaluate(node, 'roles') rescue nil
|
|
69
|
+
next if roles && !roles.any? { |r| Marty::User.has_role(r) }
|
|
70
70
|
|
|
71
71
|
begin
|
|
72
|
-
title, format = engine.evaluate(node, [
|
|
72
|
+
title, format = engine.evaluate(node, ['title', 'format'])
|
|
73
73
|
format ? [node, "#{title} (#{format})"] : nil
|
|
74
|
-
rescue
|
|
74
|
+
rescue StandardError
|
|
75
75
|
[node, node]
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
end.compact.sort { |a, b| a[1] <=> b[1] }
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
endpoint :get_combobox_options do |params|
|
|
81
|
-
client.data = node_list if params[
|
|
81
|
+
client.data = node_list if params['attr'] == 'nodename'
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
######################################################################
|
|
@@ -2,15 +2,15 @@ class Marty::Reporting < Netzke::Base
|
|
|
2
2
|
def configure(c)
|
|
3
3
|
super
|
|
4
4
|
c.items = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
:report_select,
|
|
6
|
+
:report_form,
|
|
7
|
+
]
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
client_class do |c|
|
|
11
11
|
c.header = false
|
|
12
12
|
c.layout = :border
|
|
13
|
-
c.defaults = {body_style: 'padding:0px'}
|
|
13
|
+
c.defaults = { body_style: 'padding:0px' }
|
|
14
14
|
|
|
15
15
|
c.include :reporting
|
|
16
16
|
end
|
|
@@ -8,8 +8,7 @@ class Marty::ScriptForm < Marty::Form
|
|
|
8
8
|
######################################################################
|
|
9
9
|
|
|
10
10
|
endpoint :netzke_load do |params|
|
|
11
|
-
|
|
12
|
-
return client.netzke_notify("Permission Denied") unless
|
|
11
|
+
return client.netzke_notify('Permission Denied') unless
|
|
13
12
|
self.class.has_any_perm?
|
|
14
13
|
|
|
15
14
|
script_name = params[:script_name]
|
|
@@ -23,9 +22,9 @@ class Marty::ScriptForm < Marty::Form
|
|
|
23
22
|
|
|
24
23
|
# create an empty record if no script
|
|
25
24
|
js_data = @record ? js_record_data : {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
'body' => '',
|
|
26
|
+
'id' => -1,
|
|
27
|
+
'meta' => {},
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
client.netzke_set_form_values(js_data)
|
|
@@ -46,45 +45,44 @@ class Marty::ScriptForm < Marty::Form
|
|
|
46
45
|
######################################################################
|
|
47
46
|
|
|
48
47
|
action :apply do |a|
|
|
49
|
-
a.text = I18n.t(
|
|
50
|
-
a.tooltip = I18n.t(
|
|
51
|
-
a.icon_cls =
|
|
48
|
+
a.text = I18n.t('script_form.save')
|
|
49
|
+
a.tooltip = I18n.t('script_form.save')
|
|
50
|
+
a.icon_cls = 'fa fa-save glyph'
|
|
52
51
|
a.disabled = true
|
|
53
52
|
end
|
|
54
53
|
|
|
55
54
|
endpoint :submit do |params|
|
|
56
|
-
|
|
57
|
-
return client.netzke_notify("Permission Denied") unless
|
|
55
|
+
return client.netzke_notify('Permission Denied') unless
|
|
58
56
|
self.class.has_any_perm?
|
|
59
57
|
|
|
60
58
|
# copied from corresponding method in form_panel.services
|
|
61
59
|
data = ActiveSupport::JSON.decode(params[:data])
|
|
62
|
-
data.each_pair do |k,v|
|
|
63
|
-
data[k] = nil if v.blank? || v ==
|
|
60
|
+
data.each_pair do |k, v|
|
|
61
|
+
data[k] = nil if v.blank? || v == 'null'
|
|
64
62
|
end
|
|
65
63
|
|
|
66
|
-
@record = script = Marty::Script.find_by_id(data[
|
|
64
|
+
@record = script = Marty::Script.find_by_id(data['id'])
|
|
67
65
|
|
|
68
66
|
unless script
|
|
69
|
-
client.netzke_notify
|
|
67
|
+
client.netzke_notify 'no record'
|
|
70
68
|
return
|
|
71
69
|
end
|
|
72
70
|
|
|
73
|
-
if script.body == data[
|
|
74
|
-
client.netzke_notify
|
|
71
|
+
if script.body == data['body']
|
|
72
|
+
client.netzke_notify 'no save needed'
|
|
75
73
|
# clear the error line if any
|
|
76
74
|
client.set_line_error -1
|
|
77
75
|
return
|
|
78
76
|
end
|
|
79
77
|
|
|
80
78
|
unless can_save?(script)
|
|
81
|
-
client.netzke_notify
|
|
79
|
+
client.netzke_notify 'Permission denied'
|
|
82
80
|
return
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
begin
|
|
86
|
-
dev = Marty::Tag.find_by_name(
|
|
87
|
-
Marty::ScriptSet.new(dev).parse_check(script.name, data[
|
|
84
|
+
dev = Marty::Tag.find_by_name('DEV')
|
|
85
|
+
Marty::ScriptSet.new(dev).parse_check(script.name, data['body'])
|
|
88
86
|
rescue Delorean::ParseError => exc
|
|
89
87
|
client.netzke_notify exc.message
|
|
90
88
|
client.netzke_apply_form_errors({})
|
|
@@ -92,7 +90,7 @@ class Marty::ScriptForm < Marty::Form
|
|
|
92
90
|
return
|
|
93
91
|
end
|
|
94
92
|
|
|
95
|
-
script.body = data[
|
|
93
|
+
script.body = data['body']
|
|
96
94
|
|
|
97
95
|
if script.save
|
|
98
96
|
client.netzke_set_form_values(js_record_data)
|
|
@@ -105,12 +103,12 @@ class Marty::ScriptForm < Marty::Form
|
|
|
105
103
|
end
|
|
106
104
|
|
|
107
105
|
endpoint :do_print do |script_id|
|
|
108
|
-
return client.netzke_notify(
|
|
106
|
+
return client.netzke_notify('Permission Denied') unless
|
|
109
107
|
self.class.has_any_perm?
|
|
110
108
|
|
|
111
109
|
script = Marty::Script.find_by_id(script_id)
|
|
112
110
|
|
|
113
|
-
return client.netzke_notify(
|
|
111
|
+
return client.netzke_notify('bad script') unless script
|
|
114
112
|
|
|
115
113
|
begin
|
|
116
114
|
rep_params = {
|
|
@@ -118,11 +116,11 @@ class Marty::ScriptForm < Marty::Form
|
|
|
118
116
|
title: script.name
|
|
119
117
|
}
|
|
120
118
|
|
|
121
|
-
path = Marty::Util.gen_report_path(
|
|
122
|
-
|
|
119
|
+
path = Marty::Util.gen_report_path('ScriptReport',
|
|
120
|
+
'PrettyScript',
|
|
123
121
|
rep_params)
|
|
124
122
|
client.get_report(path)
|
|
125
|
-
rescue => exc
|
|
123
|
+
rescue StandardError => exc
|
|
126
124
|
return client.netzke_notify "ERROR: #{exc}"
|
|
127
125
|
end
|
|
128
126
|
end
|
|
@@ -130,9 +128,9 @@ class Marty::ScriptForm < Marty::Form
|
|
|
130
128
|
######################################################################
|
|
131
129
|
|
|
132
130
|
action :do_print do |a|
|
|
133
|
-
a.text = I18n.t(
|
|
134
|
-
a.tooltip = I18n.t(
|
|
135
|
-
a.icon_cls =
|
|
131
|
+
a.text = I18n.t('script_form.print')
|
|
132
|
+
a.tooltip = I18n.t('script_form.print')
|
|
133
|
+
a.icon_cls = 'fa fa-print glyph'
|
|
136
134
|
end
|
|
137
135
|
|
|
138
136
|
######################################################################
|
|
@@ -149,22 +147,22 @@ class Marty::ScriptForm < Marty::Form
|
|
|
149
147
|
def configure(c)
|
|
150
148
|
super
|
|
151
149
|
|
|
152
|
-
c.title =
|
|
153
|
-
c.model =
|
|
150
|
+
c.title = 'Script Form'
|
|
151
|
+
c.model = 'Marty::Script'
|
|
154
152
|
c.items =
|
|
155
153
|
[
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
154
|
+
{
|
|
155
|
+
line_numbers: true,
|
|
156
|
+
indent_unit: 4,
|
|
157
|
+
tab_mode: 'shift',
|
|
158
|
+
match_brackets: true,
|
|
159
|
+
hide_label: true,
|
|
160
|
+
xtype: :codemirror,
|
|
161
|
+
mode: 'text/x-delorean',
|
|
162
|
+
name: :body,
|
|
163
|
+
empty_text: 'No script selected.',
|
|
164
|
+
getter: lambda { |r| r.body },
|
|
165
|
+
},
|
|
168
166
|
]
|
|
169
167
|
end
|
|
170
168
|
end
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
class Marty::ScriptGrid < Marty::Grid
|
|
2
2
|
has_marty_permissions \
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
create: [:dev],
|
|
4
|
+
read: :any,
|
|
5
|
+
update: [:dev],
|
|
6
|
+
delete: [:dev]
|
|
7
7
|
|
|
8
8
|
def configure(c)
|
|
9
9
|
super
|
|
10
10
|
|
|
11
|
-
c.model =
|
|
11
|
+
c.model = 'Marty::Script'
|
|
12
12
|
c.multi_select = false
|
|
13
13
|
c.attributes ||= [:name, :created_dt, :tag]
|
|
14
|
-
c.title
|
|
15
|
-
c.store_config.merge!(
|
|
14
|
+
c.title ||= I18n.t('scripts', default: 'Scripts')
|
|
15
|
+
c.store_config.merge!(sorters: [{ property: :name, direction: 'ASC' }])
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def get_records(params)
|
|
19
19
|
begin
|
|
20
20
|
ts = Marty::Tag.map_to_tag(root_sess[:selected_tag_id]).created_dt
|
|
21
21
|
ts = Mcfly.normalize_infinity(ts)
|
|
22
|
-
rescue
|
|
22
|
+
rescue StandardError
|
|
23
23
|
# if there are no non-DEV tags we get an exception above
|
|
24
24
|
ts = 'infinity'
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
tb = model.table_name
|
|
28
28
|
model.where("#{tb}.obsoleted_dt >= ? AND #{tb}.created_dt < ?",
|
|
29
|
-
|
|
29
|
+
ts, ts).scoping do
|
|
30
30
|
super
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
action :delete do |a|
|
|
35
|
-
a.text = I18n.t(
|
|
36
|
-
a.tooltip = I18n.t(
|
|
37
|
-
a.icon_cls =
|
|
35
|
+
a.text = I18n.t('script_grid.delete')
|
|
36
|
+
a.tooltip = I18n.t('script_grid.delete')
|
|
37
|
+
a.icon_cls = 'fa fa-trash glyph'
|
|
38
38
|
a.disabled = config[:prohibit_delete]
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
endpoint :destroy do |params|
|
|
42
|
-
return client.netzke_notify(
|
|
42
|
+
return client.netzke_notify('Permission Denied') if
|
|
43
43
|
!config[:permissions][:delete]
|
|
44
44
|
|
|
45
45
|
tag = Marty::Tag.map_to_tag(root_sess[:selected_tag_id])
|
|
46
46
|
|
|
47
|
-
return client.netzke_notify(
|
|
47
|
+
return client.netzke_notify('Can only delete in DEV tag') unless
|
|
48
48
|
tag && tag.isdev?
|
|
49
49
|
|
|
50
50
|
super(params)
|
|
@@ -55,15 +55,15 @@ class Marty::ScriptGrid < Marty::Grid
|
|
|
55
55
|
endpoint :add_window__add_form__submit do |params|
|
|
56
56
|
data = ActiveSupport::JSON.decode(params[:data])
|
|
57
57
|
|
|
58
|
-
return client.netzke_notify(
|
|
58
|
+
return client.netzke_notify('Permission Denied') if
|
|
59
59
|
!config[:permissions][:create]
|
|
60
60
|
|
|
61
61
|
tag = Marty::Tag.map_to_tag(root_sess[:selected_tag_id])
|
|
62
62
|
|
|
63
|
-
return client.netzke_notify(
|
|
63
|
+
return client.netzke_notify('Can only add in DEV tag') unless
|
|
64
64
|
tag && tag.isdev?
|
|
65
65
|
|
|
66
|
-
name = data[
|
|
66
|
+
name = data['name']
|
|
67
67
|
script = Marty::Script.create_script(name, "# Script #{name}")
|
|
68
68
|
|
|
69
69
|
if script.valid?
|
|
@@ -75,9 +75,9 @@ class Marty::ScriptGrid < Marty::Grid
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
action :add_in_form do |a|
|
|
78
|
-
a.text = I18n.t(
|
|
79
|
-
a.tooltip = I18n.t(
|
|
80
|
-
a.icon_cls =
|
|
78
|
+
a.text = I18n.t('script_grid.new')
|
|
79
|
+
a.tooltip = I18n.t('script_grid.new')
|
|
80
|
+
a.icon_cls = 'fa fa-plus glyph'
|
|
81
81
|
a.disabled = !config[:permissions][:create]
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -95,17 +95,17 @@ class Marty::ScriptGrid < Marty::Grid
|
|
|
95
95
|
|
|
96
96
|
attribute :name do |c|
|
|
97
97
|
c.flex = 1
|
|
98
|
-
c.text = I18n.t(
|
|
98
|
+
c.text = I18n.t('script_grid.name')
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
attribute :created_dt do |c|
|
|
102
|
-
c.text = I18n.t(
|
|
103
|
-
c.format =
|
|
102
|
+
c.text = I18n.t('script_grid.created_dt')
|
|
103
|
+
c.format = 'Y-m-d H:i'
|
|
104
104
|
c.read_only = true
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
attribute :tag do |c|
|
|
108
|
-
c.text = I18n.t(
|
|
108
|
+
c.text = I18n.t('script_grid.tag')
|
|
109
109
|
c.flex = 1
|
|
110
110
|
c.getter = lambda { |r| r.find_tag.try(:name) }
|
|
111
111
|
end
|
|
@@ -6,27 +6,27 @@ class Marty::ScriptTester < Marty::Form
|
|
|
6
6
|
|
|
7
7
|
c.items =
|
|
8
8
|
[
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
fieldset(I18n.t('script_tester.attributes'),
|
|
10
|
+
{
|
|
11
|
+
name: 'attrs',
|
|
12
|
+
xtype: :textarea,
|
|
13
|
+
value: '',
|
|
14
|
+
hide_label: true,
|
|
15
|
+
min_height: 125,
|
|
16
|
+
},
|
|
17
|
+
{},
|
|
18
18
|
),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
fieldset(I18n.t('script_tester.parameters'),
|
|
20
|
+
{
|
|
21
|
+
name: 'params',
|
|
22
|
+
xtype: :textarea,
|
|
23
|
+
value: '',
|
|
24
|
+
hide_label: true,
|
|
25
|
+
min_height: 125,
|
|
26
|
+
},
|
|
27
|
+
{},
|
|
28
28
|
),
|
|
29
|
-
|
|
29
|
+
:result,
|
|
30
30
|
]
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -44,65 +44,63 @@ class Marty::ScriptTester < Marty::Form
|
|
|
44
44
|
endpoint :submit do |params|
|
|
45
45
|
data = ActiveSupport::JSON.decode(params[:data])
|
|
46
46
|
|
|
47
|
-
attrs = data[
|
|
47
|
+
attrs = data['attrs'].split(';').map(&:strip).reject(&:empty?)
|
|
48
48
|
|
|
49
|
-
pjson = data[
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
pjson = data['params'].split("\n").map(&:strip).reject(&:empty?).map do |s|
|
|
50
|
+
s.sub(/^([a-z0-9_]*)\s*=/, '"\1": ')
|
|
51
|
+
end.join(',')
|
|
52
52
|
|
|
53
53
|
begin
|
|
54
54
|
phash = ActiveSupport::JSON.decode("{ #{pjson} }")
|
|
55
55
|
rescue MultiJson::DecodeError
|
|
56
|
-
client.netzke_notify
|
|
56
|
+
client.netzke_notify 'Malformed input parameters'
|
|
57
57
|
return
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
engine = new_engine
|
|
61
61
|
|
|
62
62
|
begin
|
|
63
|
-
result = attrs.map
|
|
63
|
+
result = attrs.map do |a|
|
|
64
64
|
node, attr = a.split('.')
|
|
65
65
|
raise "bad attribute: '#{a}'" if !attr
|
|
66
|
+
|
|
66
67
|
# Need to clone phash since it's modified by eval. It can
|
|
67
68
|
# be reused for a given node but not across nodes.
|
|
68
69
|
res = engine.evaluate(node, attr, phash.clone)
|
|
69
70
|
q = CGI::escapeHTML(res.to_json)
|
|
70
71
|
"#{a} = #{q}"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
client.netzke_notify "done"
|
|
74
|
-
client.set_result result.join("<br/>")
|
|
72
|
+
end
|
|
75
73
|
|
|
74
|
+
client.netzke_notify 'done'
|
|
75
|
+
client.set_result result.join('<br/>')
|
|
76
76
|
rescue SystemStackError
|
|
77
|
-
return client.netzke_notify
|
|
78
|
-
|
|
79
|
-
rescue => exc
|
|
77
|
+
return client.netzke_notify 'System Stack Error'
|
|
78
|
+
rescue StandardError => exc
|
|
80
79
|
res = Delorean::Engine.grok_runtime_exception(exc)
|
|
81
80
|
|
|
82
|
-
result = ["Error: #{res['error']}",
|
|
83
|
-
res[
|
|
81
|
+
result = ["Error: #{res['error']}", 'Backtrace:'] +
|
|
82
|
+
res['backtrace'].map { |m, line, fn| "#{m}:#{line} #{fn}" }
|
|
84
83
|
|
|
85
|
-
client.netzke_notify
|
|
86
|
-
client.set_result '<font color="red">' + result.join(
|
|
84
|
+
client.netzke_notify 'failed'
|
|
85
|
+
client.set_result '<font color="red">' + result.join('<br/>') + '</font>'
|
|
87
86
|
end
|
|
88
87
|
end
|
|
89
88
|
|
|
90
89
|
action :apply do |a|
|
|
91
|
-
a.text = I18n.t(
|
|
92
|
-
a.tooltip = I18n.t(
|
|
93
|
-
a.icon_cls =
|
|
90
|
+
a.text = I18n.t('script_tester.compute')
|
|
91
|
+
a.tooltip = I18n.t('script_tester.compute')
|
|
92
|
+
a.icon_cls = 'fa fa-bug glyph'
|
|
94
93
|
a.disabled = false
|
|
95
94
|
end
|
|
96
95
|
|
|
97
96
|
component :result do |c|
|
|
98
97
|
c.klass = Marty::Panel
|
|
99
|
-
c.title = I18n.t(
|
|
100
|
-
c.html =
|
|
98
|
+
c.title = I18n.t('script_tester.results')
|
|
99
|
+
c.html = ''
|
|
101
100
|
c.flex = 1
|
|
102
101
|
c.min_height = 250
|
|
103
102
|
c.auto_scroll = true
|
|
104
103
|
end
|
|
105
|
-
|
|
106
104
|
end
|
|
107
105
|
|
|
108
106
|
ScriptTester = Marty::ScriptTester
|