cpee-frames 2.0.1 → 2.0.2
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/cpee-frames.gemspec +1 -1
- data/lib/cpee-frames/implementation.rb +44 -21
- data/lib/cpee-frames/{frames.xml → implementation.xml} +10 -0
- data/ui/examples/button.html +4 -0
- data/ui/js/frames.js +2 -1
- data/ui/js/ui.js +13 -18
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbcc6ab7613127223f4cfd184b77101c3d7eb5dd98441616c92b37bcd732509d
|
|
4
|
+
data.tar.gz: 249be508581dda213ffe228cb1c70f7820f0470d2de4e0ad16817029b6a532ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd79c5ddabc1d6820c217828055ce28c2b3fa0d15929de370efe85dab805e08dbb635ca582d849732473e29fe95eaef0ee34d9cfab6c9df470b04bdfd7efe0ba
|
|
7
|
+
data.tar.gz: 07a6bf8aa76babfe444b4ed6408b2cb2746af3320ffdae77073084b432d2a2c45ba9c88c3e36edf9361ebd5bd5c9c8a6a1762f4e6887ef84b64262cb95ae0025
|
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.
|
|
3
|
+
s.version = "2.0.2"
|
|
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"
|
|
@@ -27,7 +27,7 @@ module CPEE
|
|
|
27
27
|
|
|
28
28
|
module Frames
|
|
29
29
|
|
|
30
|
-
SERVER = File.expand_path(File.join(__dir__,'
|
|
30
|
+
SERVER = File.expand_path(File.join(__dir__,'implementation.xml'))
|
|
31
31
|
|
|
32
32
|
def self::overlap?(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
|
|
33
33
|
if l1x > r2x || l2x > r1x
|
|
@@ -39,6 +39,10 @@ module CPEE
|
|
|
39
39
|
return true
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
def self::target?(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
|
|
43
|
+
return l1x == l2x && l1y == l2y && r1x == r2x && r1y == r2y
|
|
44
|
+
end
|
|
45
|
+
|
|
42
46
|
# https://coderwall.com/p/atyfyq/ruby-string-to-boolean
|
|
43
47
|
# showbutton
|
|
44
48
|
refine String do #{{{
|
|
@@ -88,12 +92,12 @@ module CPEE
|
|
|
88
92
|
File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
|
|
89
93
|
File.write(File.join(data_dir,@r.last,'cpeeinstance.url'),@h['CPEE_INSTANCE_URL'])
|
|
90
94
|
|
|
91
|
-
@a[0].send('new')
|
|
95
|
+
@a[0].send(JSON.dump({ message: 'new' }))
|
|
92
96
|
nil
|
|
93
97
|
end
|
|
94
98
|
end #}}}
|
|
95
99
|
|
|
96
|
-
class NewFrameSet < Riddl::Implementation
|
|
100
|
+
class NewFrameSet < Riddl::Implementation #{{{
|
|
97
101
|
def response
|
|
98
102
|
data_dir = @a[1]
|
|
99
103
|
path = File.join(data_dir,@r.last,'frames.json')
|
|
@@ -125,19 +129,19 @@ module CPEE
|
|
|
125
129
|
infojson = JSON::parse(File.read(infofile))
|
|
126
130
|
hash["url"] = urls.find{ |h| h['lang'] == infojson["lang"]}['url']
|
|
127
131
|
|
|
128
|
-
@a[0].send(JSON.dump(hash))
|
|
132
|
+
@a[0].send(JSON.dump({ message: 'display', content: hash }))
|
|
129
133
|
else
|
|
130
134
|
File.write(path, JSON.dump(data_hash))
|
|
131
135
|
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
136
|
|
|
133
|
-
@a[0].send(JSON.dump(hash))
|
|
137
|
+
@a[0].send(JSON.dump({ message: 'display', content: hash }))
|
|
134
138
|
end
|
|
135
139
|
|
|
136
140
|
nil
|
|
137
141
|
end
|
|
138
|
-
end
|
|
142
|
+
end #}}}
|
|
139
143
|
|
|
140
|
-
class NewFrameWait < Riddl::Implementation
|
|
144
|
+
class NewFrameWait < Riddl::Implementation #{{{NewFrameWait
|
|
141
145
|
def response
|
|
142
146
|
data_dir = @a[1]
|
|
143
147
|
path = File.join(data_dir,@r.last,'frames.json')
|
|
@@ -169,7 +173,7 @@ module CPEE
|
|
|
169
173
|
|
|
170
174
|
File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
|
|
171
175
|
|
|
172
|
-
@a[0].send(JSON.dump(hash))
|
|
176
|
+
@a[0].send(JSON.dump({ message: 'display', content: hash }))
|
|
173
177
|
else
|
|
174
178
|
File.write(path, JSON.dump(data_hash))
|
|
175
179
|
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 +181,7 @@ module CPEE
|
|
|
177
181
|
File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
|
|
178
182
|
|
|
179
183
|
|
|
180
|
-
@a[0].send(JSON.dump(hash))
|
|
184
|
+
@a[0].send(JSON.dump({ message: 'display', content: hash }))
|
|
181
185
|
|
|
182
186
|
Typhoeus.put(@h['CPEE_CALLBACK'], body: "No Frame Set")
|
|
183
187
|
end
|
|
@@ -187,9 +191,27 @@ module CPEE
|
|
|
187
191
|
def headers
|
|
188
192
|
Riddl::Header.new('CPEE-CALLBACK', 'true')
|
|
189
193
|
end
|
|
190
|
-
end
|
|
194
|
+
end #}}}
|
|
191
195
|
|
|
192
|
-
class
|
|
196
|
+
class SendDataToFrame < Riddl::Implementation #{{{NewFrameWait
|
|
197
|
+
def response
|
|
198
|
+
data_dir = @a[1]
|
|
199
|
+
path = File.join(data_dir,@r.last,'frames.json')
|
|
200
|
+
file = File.read(path)
|
|
201
|
+
data_hash = JSON::parse(file)
|
|
202
|
+
|
|
203
|
+
# check if new frame overlaps others if it does, delete overlapped frames
|
|
204
|
+
data_hash["data"].each do | c |
|
|
205
|
+
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))
|
|
206
|
+
@a[0].send(JSON.dump({ message: 'update', content: { 'callback' => c['callback'], 'data' => @p[5].value.strip == '' ? {} : JSON::parse(@p[5].value) }}))
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
nil
|
|
211
|
+
end
|
|
212
|
+
end #}}}
|
|
213
|
+
|
|
214
|
+
class DeleteFrame < Riddl::Implementation #{{{
|
|
193
215
|
def response
|
|
194
216
|
data_dir = @a[1]
|
|
195
217
|
path = File.join(data_dir,@r.last,'frames.json')
|
|
@@ -204,9 +226,9 @@ module CPEE
|
|
|
204
226
|
|
|
205
227
|
File.write(path, JSON.dump(data_hash))
|
|
206
228
|
end
|
|
207
|
-
end
|
|
229
|
+
end #}}}
|
|
208
230
|
|
|
209
|
-
class Delete < Riddl::Implementation
|
|
231
|
+
class Delete < Riddl::Implementation #{{{
|
|
210
232
|
def response
|
|
211
233
|
data_dir = @a[1]
|
|
212
234
|
pp "in delete"
|
|
@@ -227,10 +249,10 @@ module CPEE
|
|
|
227
249
|
# File.unlink(File.join(data_dir,@r.last,'document.xml')) rescue nil
|
|
228
250
|
# File.unlink(File.join(data_dir,@r.last,'info.json')) rescue nil
|
|
229
251
|
|
|
230
|
-
@a[0].send('reset')
|
|
252
|
+
@a[0].send(JSON.dump({ message: 'reset' }))
|
|
231
253
|
nil
|
|
232
254
|
end
|
|
233
|
-
end
|
|
255
|
+
end #}}}
|
|
234
256
|
|
|
235
257
|
class GetFrames < Riddl::Implementation #{{{
|
|
236
258
|
def response
|
|
@@ -336,7 +358,7 @@ module CPEE
|
|
|
336
358
|
|
|
337
359
|
|
|
338
360
|
|
|
339
|
-
@a[0].send('reset')
|
|
361
|
+
@a[0].send(JSON.dump({ message: 'reset' }))
|
|
340
362
|
nil
|
|
341
363
|
else
|
|
342
364
|
@status = 404
|
|
@@ -388,7 +410,7 @@ module CPEE
|
|
|
388
410
|
File.write(path, JSON.dump(content['values']))
|
|
389
411
|
end
|
|
390
412
|
|
|
391
|
-
@a[0].send(@r[0])
|
|
413
|
+
@a[0].send(JSON.dump({ message: @r[0] }))
|
|
392
414
|
nil
|
|
393
415
|
end
|
|
394
416
|
end #}}}
|
|
@@ -397,7 +419,7 @@ module CPEE
|
|
|
397
419
|
def onopen
|
|
398
420
|
signals = @a[0]
|
|
399
421
|
signals.add self
|
|
400
|
-
send 'started'
|
|
422
|
+
send JSON.dump({ message: 'started' })
|
|
401
423
|
true
|
|
402
424
|
end
|
|
403
425
|
|
|
@@ -412,7 +434,7 @@ module CPEE
|
|
|
412
434
|
def onopen
|
|
413
435
|
signals = @a[0]
|
|
414
436
|
signals.add self
|
|
415
|
-
send 'started'
|
|
437
|
+
send JSON.dump({ message: 'started' })
|
|
416
438
|
true
|
|
417
439
|
end
|
|
418
440
|
|
|
@@ -454,10 +476,10 @@ module CPEE
|
|
|
454
476
|
parallel do
|
|
455
477
|
loop do
|
|
456
478
|
opts[:signals].each do |k,v|
|
|
457
|
-
v.send('keepalive')
|
|
479
|
+
v.send(JSON.dump({ message: 'keepalive' }))
|
|
458
480
|
end
|
|
459
481
|
opts[:signals2].each do |k,v|
|
|
460
|
-
v.send('keepalive')
|
|
482
|
+
v.send(JSON.dump({ message: 'keepalive' }))
|
|
461
483
|
end
|
|
462
484
|
sleep 5
|
|
463
485
|
end
|
|
@@ -480,6 +502,7 @@ module CPEE
|
|
|
480
502
|
|
|
481
503
|
run NewFrameSet, opts[:signals][idx], opts[:data_dir] if put 'sframe'
|
|
482
504
|
run NewFrameWait, opts[:signals][idx], opts[:data_dir] if put 'wframe'
|
|
505
|
+
run SendDataToFrame, opts[:signals][idx], opts[:data_dir] if put 'uframe'
|
|
483
506
|
|
|
484
507
|
run DeleteFrame, opts[:signals][idx], opts[:data_dir] if post 'deleteframe'
|
|
485
508
|
|
|
@@ -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
|
|
data/ui/examples/button.html
CHANGED
|
@@ -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
|
-
|
|
7
|
+
document.dispatchEvent(cpee_message);
|
|
7
8
|
}
|
|
8
9
|
});
|
|
9
10
|
|
data/ui/js/ui.js
CHANGED
|
@@ -110,27 +110,22 @@ function init() {
|
|
|
110
110
|
// load
|
|
111
111
|
};
|
|
112
112
|
es.onmessage = function(e) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
var notification;
|
|
114
|
+
try {
|
|
115
|
+
notification = JSON.parse(e.data);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
return;
|
|
116
118
|
}
|
|
117
|
-
if (
|
|
119
|
+
if (notification.message == 'new' || notification.message == 'reset') {
|
|
118
120
|
reason = '';
|
|
119
121
|
showDocument();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
}
|
|
122
|
+
} else if (notification.message == 'display') {
|
|
123
|
+
var frd = notification.content;
|
|
124
|
+
makeFrame(frd.lx,frd.ly,frd.rx,frd.ry, frd.url, frd.callback, frd.default, frd.showbutton, frd.style);
|
|
125
|
+
} else if (notification.message == 'update') {
|
|
126
|
+
var frd = notification.content;
|
|
127
|
+
iframe = $('iframe[id="' + frd.callback + '"]').get(0);
|
|
128
|
+
iframe.contentWindow.postMessage({ data: frd.data });
|
|
134
129
|
}
|
|
135
130
|
};
|
|
136
131
|
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.
|
|
4
|
+
version: 2.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Manuell Gall
|
|
@@ -52,8 +52,8 @@ files:
|
|
|
52
52
|
- README.md
|
|
53
53
|
- Rakefile
|
|
54
54
|
- cpee-frames.gemspec
|
|
55
|
-
- lib/cpee-frames/frames.xml
|
|
56
55
|
- lib/cpee-frames/implementation.rb
|
|
56
|
+
- lib/cpee-frames/implementation.xml
|
|
57
57
|
- lib/cpee-frames/ui/template.html
|
|
58
58
|
- lib/cpee-frames/ui/tutorial.html
|
|
59
59
|
- server/frames
|