cpee-frames 2.0.1 → 2.0.3

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
  SHA256:
3
- metadata.gz: 5d8d8cd4a48b7c860535716f62c9dbe7476a0f25a14ca317d5f6a41a634f75d9
4
- data.tar.gz: 8a1ae031459158a8796ae00a2bcb188dd06de21199e02e05aa99c2d65becb8ef
3
+ metadata.gz: 96c90add2765c0e5f97bbf467def046b1a8632557576086bd71d6a2c69568896
4
+ data.tar.gz: 168699a50751396981c9cd889be5463feb413fcedba9baf4c5fd7f4b81a80e1c
5
5
  SHA512:
6
- metadata.gz: 89e1cfafe97abab3834f9417c826a580bb956853753509ce1f1d216e8d06552c4ba8338ac6e8458effd1445324db2f5c6f54fde053148e145f7dfcd6dccd0cfa
7
- data.tar.gz: 37b7f23935452b346ff75aed9411c5393ef5e4d50bcc1bdb57243acc1d4b387e2f12e10242e3701c18e01eca3cdcf8214115613d81733d206c8b84c67ca7be1e
6
+ metadata.gz: 02de1c08d9a3fc90d6726bb4355a690ebffa885c3365b27cb367396f99b133708437063f24b9bcc16add2f8f05bd865d0f36f36bf15a492c458c29bca9a5c1de
7
+ data.tar.gz: 7fd4d1ad019d9db4af5a8cbf286dc4569952b93adee109ed8f6110ee6e1e9687da6eef710c95b3b7a00a36be6cdace054a18778dc743bc18e9536b5baff5ebdf
data/cpee-frames.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-frames"
3
- s.version = "2.0.1"
3
+ s.version = "2.0.3"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "GPL-3.0-or-later"
6
6
  s.summary = "Dashboard management service with UI and backend for the cpee.org family of workflow management tools"
@@ -22,4 +22,5 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_runtime_dependency 'riddl', '~> 0.99'
24
24
  s.add_runtime_dependency 'json', '~> 2.1'
25
+ s.add_runtime_dependency 'typhoeus', '~> 1.4'
25
26
  end
@@ -18,16 +18,14 @@
18
18
 
19
19
  require 'rubygems'
20
20
  require 'json'
21
- require 'xml/smart'
22
21
  require 'riddl/server'
23
- require 'fileutils'
24
22
  require 'typhoeus'
25
23
 
26
24
  module CPEE
27
25
 
28
26
  module Frames
29
27
 
30
- SERVER = File.expand_path(File.join(__dir__,'frames.xml'))
28
+ SERVER = File.expand_path(File.join(__dir__,'implementation.xml'))
31
29
 
32
30
  def self::overlap?(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
33
31
  if l1x > r2x || l2x > r1x
@@ -39,6 +37,10 @@ module CPEE
39
37
  return true
40
38
  end
41
39
 
40
+ def self::target?(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
41
+ return l1x == l2x && l1y == l2y && r1x == r2x && r1y == r2y
42
+ end
43
+
42
44
  # https://coderwall.com/p/atyfyq/ruby-string-to-boolean
43
45
  # showbutton
44
46
  refine String do #{{{
@@ -88,12 +90,12 @@ module CPEE
88
90
  File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
89
91
  File.write(File.join(data_dir,@r.last,'cpeeinstance.url'),@h['CPEE_INSTANCE_URL'])
90
92
 
91
- @a[0].send('new')
93
+ @a[0].send(JSON.dump({ message: 'new' }))
92
94
  nil
93
95
  end
94
96
  end #}}}
95
97
 
96
- class NewFrameSet < Riddl::Implementation
98
+ class NewFrameSet < Riddl::Implementation #{{{
97
99
  def response
98
100
  data_dir = @a[1]
99
101
  path = File.join(data_dir,@r.last,'frames.json')
@@ -125,19 +127,19 @@ module CPEE
125
127
  infojson = JSON::parse(File.read(infofile))
126
128
  hash["url"] = urls.find{ |h| h['lang'] == infojson["lang"]}['url']
127
129
 
128
- @a[0].send(JSON.dump(hash))
130
+ @a[0].send(JSON.dump({ message: 'display', content: hash }))
129
131
  else
130
132
  File.write(path, JSON.dump(data_hash))
131
133
  hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: "empty", default: "{}", callback: @h['CPEE_CALLBACK']};
132
134
 
133
- @a[0].send(JSON.dump(hash))
135
+ @a[0].send(JSON.dump({ message: 'display', content: hash }))
134
136
  end
135
137
 
136
138
  nil
137
139
  end
138
- end
140
+ end #}}}
139
141
 
140
- class NewFrameWait < Riddl::Implementation
142
+ class NewFrameWait < Riddl::Implementation #{{{NewFrameWait
141
143
  def response
142
144
  data_dir = @a[1]
143
145
  path = File.join(data_dir,@r.last,'frames.json')
@@ -169,7 +171,7 @@ module CPEE
169
171
 
170
172
  File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
171
173
 
172
- @a[0].send(JSON.dump(hash))
174
+ @a[0].send(JSON.dump({ message: 'display', content: hash }))
173
175
  else
174
176
  File.write(path, JSON.dump(data_hash))
175
177
  hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: "empty", default: "{}", callback: @h['CPEE_CALLBACK']};
@@ -177,7 +179,7 @@ module CPEE
177
179
  File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
178
180
 
179
181
 
180
- @a[0].send(JSON.dump(hash))
182
+ @a[0].send(JSON.dump({ message: 'display', content: hash }))
181
183
 
182
184
  Typhoeus.put(@h['CPEE_CALLBACK'], body: "No Frame Set")
183
185
  end
@@ -187,9 +189,27 @@ module CPEE
187
189
  def headers
188
190
  Riddl::Header.new('CPEE-CALLBACK', 'true')
189
191
  end
190
- end
192
+ end #}}}
191
193
 
192
- class DeleteFrame < Riddl::Implementation
194
+ class SendDataToFrame < Riddl::Implementation #{{{NewFrameWait
195
+ def response
196
+ data_dir = @a[1]
197
+ path = File.join(data_dir,@r.last,'frames.json')
198
+ file = File.read(path)
199
+ data_hash = JSON::parse(file)
200
+
201
+ # check if new frame overlaps others if it does, delete overlapped frames
202
+ data_hash["data"].each do | c |
203
+ if CPEE::Frames::target?(c['lx'], c['ly'], c['rx'], c['ry'], @p[1].value.to_i, @p[2].value.to_i, (@p[1].value.to_i + @p[3].value.to_i - 1), (@p[2].value.to_i + @p[4].value.to_i - 1))
204
+ @a[0].send(JSON.dump({ message: 'update', content: { 'callback' => c['callback'], 'data' => @p[5].value.strip == '' ? {} : JSON::parse(@p[5].value) }}))
205
+ end
206
+ end
207
+
208
+ nil
209
+ end
210
+ end #}}}
211
+
212
+ class DeleteFrame < Riddl::Implementation #{{{
193
213
  def response
194
214
  data_dir = @a[1]
195
215
  path = File.join(data_dir,@r.last,'frames.json')
@@ -204,9 +224,9 @@ module CPEE
204
224
 
205
225
  File.write(path, JSON.dump(data_hash))
206
226
  end
207
- end
227
+ end #}}}
208
228
 
209
- class Delete < Riddl::Implementation
229
+ class Delete < Riddl::Implementation #{{{
210
230
  def response
211
231
  data_dir = @a[1]
212
232
  pp "in delete"
@@ -227,10 +247,10 @@ module CPEE
227
247
  # File.unlink(File.join(data_dir,@r.last,'document.xml')) rescue nil
228
248
  # File.unlink(File.join(data_dir,@r.last,'info.json')) rescue nil
229
249
 
230
- @a[0].send('reset')
250
+ @a[0].send(JSON.dump({ message: 'reset' }))
231
251
  nil
232
252
  end
233
- end
253
+ end #}}}
234
254
 
235
255
  class GetFrames < Riddl::Implementation #{{{
236
256
  def response
@@ -336,7 +356,7 @@ module CPEE
336
356
 
337
357
 
338
358
 
339
- @a[0].send('reset')
359
+ @a[0].send(JSON.dump({ message: 'reset' }))
340
360
  nil
341
361
  else
342
362
  @status = 404
@@ -388,7 +408,7 @@ module CPEE
388
408
  File.write(path, JSON.dump(content['values']))
389
409
  end
390
410
 
391
- @a[0].send(@r[0])
411
+ @a[0].send(JSON.dump({ message: @r[0] }))
392
412
  nil
393
413
  end
394
414
  end #}}}
@@ -397,7 +417,7 @@ module CPEE
397
417
  def onopen
398
418
  signals = @a[0]
399
419
  signals.add self
400
- send 'started'
420
+ send JSON.dump({ message: 'started' })
401
421
  true
402
422
  end
403
423
 
@@ -412,7 +432,7 @@ module CPEE
412
432
  def onopen
413
433
  signals = @a[0]
414
434
  signals.add self
415
- send 'started'
435
+ send JSON.dump({ message: 'started' })
416
436
  true
417
437
  end
418
438
 
@@ -454,10 +474,10 @@ module CPEE
454
474
  parallel do
455
475
  loop do
456
476
  opts[:signals].each do |k,v|
457
- v.send('keepalive')
477
+ v.send(JSON.dump({ message: 'keepalive' }))
458
478
  end
459
479
  opts[:signals2].each do |k,v|
460
- v.send('keepalive')
480
+ v.send(JSON.dump({ message: 'keepalive' }))
461
481
  end
462
482
  sleep 5
463
483
  end
@@ -480,6 +500,7 @@ module CPEE
480
500
 
481
501
  run NewFrameSet, opts[:signals][idx], opts[:data_dir] if put 'sframe'
482
502
  run NewFrameWait, opts[:signals][idx], opts[:data_dir] if put 'wframe'
503
+ run SendDataToFrame, opts[:signals][idx], opts[:data_dir] if put 'uframe'
483
504
 
484
505
  run DeleteFrame, opts[:signals][idx], opts[:data_dir] if post 'deleteframe'
485
506
 
@@ -43,6 +43,14 @@
43
43
  <parameter name="urls" type="string"/>
44
44
  <parameter name="default" type="string"/>
45
45
  </message>
46
+ <message name="uframe">
47
+ <parameter name="type" fixed="send"/>
48
+ <parameter name="lx" type="nonNegativeInteger"/>
49
+ <parameter name="ly" type="nonNegativeInteger"/>
50
+ <parameter name="x_amount" type="nonNegativeInteger"/>
51
+ <parameter name="y_amount" type="nonNegativeInteger"/>
52
+ <parameter name="default" type="string"/>
53
+ </message>
46
54
  <message name="deleteframe">
47
55
  <parameter name="lx" type="string"/>
48
56
  <parameter name="ly" type="string"/>
@@ -92,6 +100,8 @@
92
100
  <put in='wframe' out="callback"/>
93
101
  <!-- Set Frame Data without callback -->
94
102
  <put in='sframe'/>
103
+ <!-- Send Data to existing Frame -->
104
+ <put in='uframe'/>
95
105
 
96
106
  <post in='deleteframe'/>
97
107
 
@@ -24,17 +24,6 @@
24
24
 
25
25
  <!-- libs, do not modify. When local than load local libs. -->
26
26
  <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
27
- <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
28
- <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
29
- <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
30
- <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
31
- <script type="text/javascript" src="/js_libs/util.js"></script>
32
- <script type="text/javascript" src="/js_libs/printf.js"></script>
33
- <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
34
- <script type="text/javascript" src="/js_libs/parsequery.js"></script>
35
- <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
- <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
- <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
27
 
39
28
  <!-- custom stuff, play arround -->
40
29
  <script type="text/javascript" src="../js/ui.js"></script>
@@ -22,20 +22,6 @@
22
22
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
23
23
  <title>Frames - Tutorial</title>
24
24
 
25
- <!-- libs, do not modify. When local than load local libs. -->
26
- <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
27
- <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
28
- <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
29
- <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
30
- <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
31
- <script type="text/javascript" src="/js_libs/util.js"></script>
32
- <script type="text/javascript" src="/js_libs/printf.js"></script>
33
- <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
34
- <script type="text/javascript" src="/js_libs/parsequery.js"></script>
35
- <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
- <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
- <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
-
39
25
  <!-- custom stuff, play arround -->
40
26
  <link class='custom' rel="stylesheet" href="" type="text/css"/>
41
27
  <script>
data/tools/cpee-frames CHANGED
@@ -3,16 +3,16 @@
3
3
  # This file is part of CPEE-FRAMES.
4
4
  #
5
5
  # CPEE-FRAMES is free software: you can redistribute it and/or modify it under
6
- # the terms of the GNU Lesser General Public License as published by the Free
6
+ # the terms of the GNU General Public License as published by the Free
7
7
  # Software Foundation, either version 3 of the License, or (at your option) any
8
8
  # later version.
9
9
  #
10
10
  # CPEE-FRAMES is distributed in the hope that it will be useful, but WITHOUT
11
11
  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
- # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
13
  # details.
14
14
  #
15
- # You should have received a copy of the GNU Lesser General Public License
15
+ # You should have received a copy of the GNU General Public License
16
16
  # along with CPEE-FRAMES (file LICENSE in the main directory). If not, see
17
17
  # <http://www.gnu.org/licenses/>.
18
18
 
@@ -20,10 +20,6 @@ curpath = __dir__
20
20
  require 'rubygems'
21
21
  require 'optparse'
22
22
  require 'fileutils'
23
- require 'xml/smart'
24
- require 'yaml'
25
- require 'typhoeus'
26
- require 'stringio'
27
23
 
28
24
  def wrap(s, width=78, indent=18, extra_indent=4) #{{{
29
25
  lines = []
@@ -37,6 +37,10 @@
37
37
  </style>
38
38
  <script>
39
39
  // you have access to cpee.data and cpee.callback, because frames.js (remote includable) fills it through postMessage
40
+
41
+ document.addEventListener('cpee:message', function (e) {
42
+ console.log(cpee.data);
43
+ }, false);
40
44
  </script>
41
45
 
42
46
  </head>
data/ui/js/frames.js CHANGED
@@ -1,9 +1,10 @@
1
+ var cpee_message = new Event("cpee:message", {"bubbles":true, "cancelable":false});
1
2
  var cpee = { data: null, callback: null};
2
3
  window.addEventListener("message", (event) => {
3
4
  if (/(tum\.de|cpee\.org)$/.test(event.origin)) {
4
5
  cpee.data = event.data.data;
5
6
  cpee.callback = event.data.callback;
6
- $(document).trigger("cpee:message");
7
+ document.dispatchEvent(cpee_message);
7
8
  }
8
9
  });
9
10
 
data/ui/js/ui.js CHANGED
@@ -110,27 +110,23 @@ function init() {
110
110
  // load
111
111
  };
112
112
  es.onmessage = function(e) {
113
- if (e.data == 'new') {
114
- reason = '';
115
- showDocument();
113
+ var notification;
114
+ try {
115
+ notification = JSON.parse(e.data);
116
+ } catch (err) {
117
+ console.log(err);
118
+ return;
116
119
  }
117
- if (e.data == 'reset') {
120
+ if (notification.message == 'new' || notification.message == 'reset') {
118
121
  reason = '';
119
122
  showDocument();
120
- }
121
- else{
122
- if(e.data == "update"){
123
- alert("update")
124
- }
125
- if(e.data != "keepalive" && e.data != "started"){
126
- try {
127
- //alert(e.data)
128
- var frd = JSON.parse(e.data)
129
- makeFrame(frd.lx,frd.ly,frd.rx,frd.ry, frd.url, frd.callback, frd.default, frd.showbutton, frd.style);
130
- }
131
- catch (e) {
132
- }
133
- }
123
+ } else if (notification.message == 'display') {
124
+ var frd = notification.content;
125
+ makeFrame(frd.lx,frd.ly,frd.rx,frd.ry, frd.url, frd.callback, frd.default, frd.showbutton, frd.style);
126
+ } else if (notification.message == 'update') {
127
+ var frd = notification.content;
128
+ iframe = $('iframe[id="' + frd.callback + '"]').get(0);
129
+ iframe.contentWindow.postMessage({ data: frd.data },'*');
134
130
  }
135
131
  };
136
132
  es.onerror = function() {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-frames
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuell Gall
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: typhoeus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
41
55
  description: Flexibly arrange and display user interface components in a grid from
42
56
  executable process models. Very useful if you want to build dashboards.
43
57
  email: gall.manuel.89@gmail.com
@@ -52,8 +66,8 @@ files:
52
66
  - README.md
53
67
  - Rakefile
54
68
  - cpee-frames.gemspec
55
- - lib/cpee-frames/frames.xml
56
69
  - lib/cpee-frames/implementation.rb
70
+ - lib/cpee-frames/implementation.xml
57
71
  - lib/cpee-frames/ui/template.html
58
72
  - lib/cpee-frames/ui/tutorial.html
59
73
  - server/frames