marty 0.5.17 → 0.5.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e0cd1fb1ea76e53a48783a66d697d7d7014d2ed
4
- data.tar.gz: 4f3bc6b7970ed8f8bcb394b28ad4a91f583078bd
3
+ metadata.gz: a348a98b692037a2ab1dbc2d09d32d64be591374
4
+ data.tar.gz: bb8f318e11ba6164af0102b71c3edffbc852c78b
5
5
  SHA512:
6
- metadata.gz: 9d0859d91f1b17547f132cef0123b19255f8186839fcbc11e145d716272de3f2b3f749eec155e5f00ff249b4640f2e61ee76cb01f7c2d6b8f37e57cd7637f8bf
7
- data.tar.gz: 9d05effd3f15b9f08ac668c6ba9cd7bfa6d3bb22eac7351c7cd3726cab51e7da6bea0683080023234683d52d6373735818bc50a96a160f26ddc4535719192361
6
+ metadata.gz: 60e777f722bdd38bea19a725018210bef66700acc5fb5c6b14356e4454deaf4dc9bcd2150bd6fc17c4de098c504f9c8706537943ecede9791b988ad3381f7204
7
+ data.tar.gz: e66099a715242f06fec907becf577f37d40c058125c6dd4244509b6443f9f8a62255d518e30faa2cd9c0936b506b6ae4fc872496b9994ba3b198b4462063f0cf
@@ -25,35 +25,36 @@ class Marty::ReportForm < Marty::Form
25
25
 
26
26
  ######################################################################
27
27
 
28
- # FIXME: Most of the following functionality should be moved out to
29
- # a library. It doesn't belong here in a component. These are
30
- # currently also getting called form the report controller.
31
-
32
- # FIXME: The usage of session/root_sess should be entirely removed.
33
- # Instead we should send in :selected_node, :selected_tag_id,
34
- # :selected_script_name as params.
35
-
36
- def self.get_report_engine(params, session)
28
+ def self.get_report_engine(params)
37
29
  d_params = ActiveSupport::JSON.decode(params[:data] || "{}")
38
30
  d_params.each_pair do |k,v|
39
31
  d_params[k] = nil if v.blank? || v == "null"
40
32
  end
41
33
 
42
- tag_id, script_name =
43
- session[:selected_tag_id], session[:selected_script_name]
34
+ tag_id = d_params.delete("selected_tag_id")
35
+ script_name = d_params.delete("selected_script_name")
36
+ node = d_params.delete("selected_node")
44
37
 
45
38
  engine = Marty::ScriptSet.new(tag_id).get_engine(script_name)
46
39
 
47
- [engine, d_params]
40
+ roles = engine.evaluate(node, "roles", {}) rescue nil
41
+
42
+ if roles && !roles.any?{ |r| Marty::User.has_role(r) }
43
+ # insufficient permissions
44
+ return []
45
+ end
46
+
47
+ d_params["p_title"] ||= engine.evaluate(node, "title", {}).to_s
48
+
49
+ [engine, d_params, node]
48
50
  end
49
51
 
50
- def self.run_eval(params, session)
51
- node = session[:selected_node]
52
+ def self.run_eval(params)
53
+ engine, d_params, node = get_report_engine(params)
52
54
 
55
+ raise "no engine" unless engine # insufficient permissions
53
56
  raise "no selected report node" unless String === node
54
57
 
55
- engine, d_params = get_report_engine(params, session)
56
-
57
58
  begin
58
59
  engine.evaluate(node, "result", d_params)
59
60
  rescue => exc
@@ -66,42 +67,16 @@ class Marty::ReportForm < Marty::Form
66
67
  end
67
68
  end
68
69
 
69
- def export_content(format, title, params={})
70
- data = self.class.run_eval(params, session)
71
-
72
- # hacky: shouldn't have error parsing logic here
73
- format = "json" if data.is_a?(Hash) && (data[:error] || data["error"])
74
-
75
- # hack for testing -- txt -> csv
76
- exp_format = format == "txt" ? "csv" : format
77
-
78
- res, type, disposition, filename =
79
- Marty::ContentHandler.export(data, exp_format, title)
80
-
81
- # hack for testing -- set content-type
82
- type = "text/plain" if format == "txt" && type =~ /csv/
83
-
84
- [res, type, disposition, filename]
85
- end
86
-
87
70
  endpoint :netzke_submit do |params, this|
88
71
  # We get here when user is asking for a background report
89
72
 
90
- engine, d_params = self.class.get_report_engine(params, session)
73
+ engine, d_params, node = self.class.get_report_engine(params)
91
74
 
92
- roles = engine.
93
- evaluate(session[:selected_node], "roles", {}) rescue nil
94
-
95
- if roles && !roles.any?{ |r| Marty::User.has_role(r) }
96
- this.netzke_feedback "Insufficient permissions to run report!"
97
- return
98
- end
99
-
100
- d_params["p_title"] ||= engine.
101
- evaluate(session[:selected_node], "title", {}).to_s
75
+ return this.netzke_feedback "Insufficient permissions to run report!" unless
76
+ engine
102
77
 
103
78
  # start background promise to get report result
104
- engine.background_eval(session[:selected_node],
79
+ engine.background_eval(node,
105
80
  d_params,
106
81
  ["result", "title", "format"],
107
82
  )
@@ -220,13 +195,15 @@ class Marty::ReportForm < Marty::Form
220
195
  items = [{html: "<br><b>No input is needed for this report.</b>"}] if
221
196
  items.empty?
222
197
 
223
- # Hacky: store these globally in session so we can get them on
224
- # report generation request which comes out of band. Also, if the
225
- # user's script/tag selection changes, we don't need to redraw
226
- # report_form.
227
- session[:selected_tag_id] = root_sess[:selected_tag_id]
228
- session[:selected_script_name] = root_sess[:selected_script_name]
229
- session[:selected_node] = root_sess[:selected_node]
198
+ # add hidden fields for selected tag/script/node
199
+ items += [:selected_tag_id, :selected_script_name, :selected_node].map { |f|
200
+ {
201
+ name: f,
202
+ xtype: :textfield,
203
+ hidden: true,
204
+ value: root_sess[f],
205
+ }
206
+ }
230
207
 
231
208
  c.items = items
232
209
  c.repformat = format
@@ -62,6 +62,7 @@ class Marty::ScriptForm < Marty::Form
62
62
 
63
63
  ######################################################################
64
64
 
65
+ # FIXME: no longer works -- see related FIXME below.
65
66
  c.on_print = <<-JS
66
67
  function() {
67
68
  window.open(
@@ -197,7 +198,10 @@ class Marty::ScriptForm < Marty::Form
197
198
 
198
199
  ######################################################################
199
200
 
200
- # used for printing
201
+ # Used for printing: REALLY FIXME -- this no longer works since the
202
+ # removal of the component export_content hack. -- To fix, we should
203
+ # create a ScriptPrint report. Then, we should have the button run
204
+ # this report in the foreground.
201
205
  def export_content(format, title, params={})
202
206
  raise "unknown format: #{format}" unless format == "html"
203
207
 
@@ -5,7 +5,7 @@ class Marty::ReportController < ActionController::Base
5
5
 
6
6
  raise "bad format" unless Marty::ContentHandler::GEN_FORMATS.member?(format)
7
7
 
8
- data = Marty::ReportForm.run_eval(params, session)
8
+ data = Marty::ReportForm.run_eval(params)
9
9
 
10
10
  # hacky: shouldn't have error parsing logic here
11
11
  format = "json" if data.is_a?(Hash) && (data[:error] || data["error"])
data/lib/marty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Marty
2
- VERSION = "0.5.17"
2
+ VERSION = "0.5.18"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.17
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-12-04 00:00:00.000000000 Z
15
+ date: 2015-12-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pg