cpee-frames 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cpee-frames.gemspec +1 -1
- data/lib/cpee-frames/implementation.rb +75 -60
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e3e17dafdfc33eea6a1985ef1195ae366e481783eee9a0521f2e24b376ab89
|
4
|
+
data.tar.gz: b1027c8c1e6ddea9122c87ccef384c1e628f8db1fa6369f61e819d235446cb96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 182e44f12d97f59918eaea3a2590614c7758f920f2a4ce06ed848623348941fd60bfc493add7228f4f228d32867fb42bf66984d0505a68f95d4c294b49e7c17b
|
7
|
+
data.tar.gz: 190580b76dfc5a2100ad0cd1fbee4056f7db53ce9fa9cc7845574b3d87c8ee7923470c8b7da53e0047590696bc563790c3c1f4caaa880227fb5d8d4ff9894d86
|
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 = "1.0.
|
3
|
+
s.version = "1.0.3"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "GPL-3.0"
|
6
6
|
s.summary = "Dashboard management service with UI and backend for the cpee.org family of workflow management tools"
|
@@ -29,6 +29,17 @@ module CPEE
|
|
29
29
|
|
30
30
|
SERVER = File.expand_path(File.join(__dir__,'frames.xml'))
|
31
31
|
|
32
|
+
def self::overlap?(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
|
33
|
+
if l1x > r2x || l2x > r1x
|
34
|
+
return false
|
35
|
+
end
|
36
|
+
if l1y > r2y || l2y > r1y
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
return true
|
40
|
+
end
|
41
|
+
|
42
|
+
|
32
43
|
# https://coderwall.com/p/atyfyq/ruby-string-to-boolean
|
33
44
|
# showbutton
|
34
45
|
refine String do #{{{
|
@@ -69,21 +80,22 @@ module CPEE
|
|
69
80
|
|
70
81
|
class InitFrame < Riddl::Implementation #{{{
|
71
82
|
def response
|
72
|
-
|
83
|
+
data_dir = @a[1]
|
84
|
+
Dir.mkdir(File.join(data_dir,@r.last)) rescue nil
|
73
85
|
|
74
86
|
if !@p[0].value.to_s.empty?
|
75
|
-
File.write(File.join(
|
87
|
+
File.write(File.join(data_dir,@r.last,'style.url'),@p[0].value)
|
76
88
|
end
|
77
89
|
|
78
|
-
File.write(File.join(
|
90
|
+
File.write(File.join(data_dir,@r.last,'frames.json'),JSON.dump(JSON.parse('{"data":[]}')))
|
79
91
|
|
80
92
|
#for handler
|
81
|
-
File.write(File.join(
|
93
|
+
File.write(File.join(data_dir,@r.last,'dataelements.json'),JSON.dump(JSON.parse('{"data":[]}')))
|
82
94
|
|
83
|
-
File.write(File.join(
|
95
|
+
File.write(File.join(data_dir,@r.last,'info.json'),JSON.dump(JSON.parse('{"x_amount":' + @p[2].value + ', "y_amount":' + @p[3].value + ', "lang":"' + @p[4].value + '", "langs":["' + @p[4].value + '"], "document_name": "' + @p[5].value + '"}')))
|
84
96
|
|
85
|
-
File.write(File.join(
|
86
|
-
File.write(File.join(
|
97
|
+
File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
|
98
|
+
File.write(File.join(data_dir,@r.last,'cpeeinstance.url'),@h['CPEE_INSTANCE_URL'])
|
87
99
|
|
88
100
|
@a[0].send('new')
|
89
101
|
nil
|
@@ -92,13 +104,14 @@ module CPEE
|
|
92
104
|
|
93
105
|
class NewFrameSet < Riddl::Implementation
|
94
106
|
def response
|
95
|
-
|
107
|
+
data_dir = @a[1]
|
108
|
+
path = File.join(data_dir,@r.last,'frames.json')
|
96
109
|
file = File.read(path)
|
97
110
|
data_hash = JSON::parse(file)
|
98
111
|
|
99
112
|
#check if new frame overlaps others if it does, delete overlapped frames
|
100
113
|
data_hash["data"].each do | c |
|
101
|
-
if
|
114
|
+
if CPEE::Frames::overlap?(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))
|
102
115
|
data_hash["data"].delete(c)
|
103
116
|
end
|
104
117
|
end
|
@@ -117,7 +130,7 @@ module CPEE
|
|
117
130
|
File.write(path, JSON.dump(data_hash))
|
118
131
|
|
119
132
|
#only send active url to client
|
120
|
-
infofile = File.join(
|
133
|
+
infofile = File.join(data_dir,@r.last,'info.json')
|
121
134
|
infojson = JSON::parse(File.read(infofile))
|
122
135
|
hash["url"] = urls.find{ |h| h['lang'] == infojson["lang"]}['url']
|
123
136
|
|
@@ -137,13 +150,14 @@ module CPEE
|
|
137
150
|
|
138
151
|
class NewFrameWait < Riddl::Implementation
|
139
152
|
def response
|
140
|
-
|
153
|
+
data_dir = @a[1]
|
154
|
+
path = File.join(data_dir,@r.last,'frames.json')
|
141
155
|
file = File.read(path)
|
142
156
|
data_hash = JSON::parse(file)
|
143
157
|
|
144
158
|
#check if new frame overlaps others if it does, delete overlapped frames
|
145
159
|
data_hash["data"].each do | c |
|
146
|
-
if
|
160
|
+
if CPEE::Frames::overlap?(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))
|
147
161
|
data_hash["data"].delete(c)
|
148
162
|
end
|
149
163
|
end
|
@@ -161,11 +175,11 @@ module CPEE
|
|
161
175
|
File.write(path, JSON.dump(data_hash))
|
162
176
|
|
163
177
|
#only send active url to client
|
164
|
-
infofile = File.join(
|
178
|
+
infofile = File.join(data_dir,@r.last,'info.json')
|
165
179
|
infojson = JSON::parse(File.read(infofile))
|
166
180
|
hash["url"] = urls.find{ |h| h['lang'] == infojson["lang"]}['url']
|
167
181
|
|
168
|
-
File.write(File.join(
|
182
|
+
File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
|
169
183
|
|
170
184
|
|
171
185
|
@a[0].send(JSON.dump(hash))
|
@@ -173,7 +187,7 @@ module CPEE
|
|
173
187
|
File.write(path, JSON.dump(data_hash))
|
174
188
|
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", showbutton: @p[5].value, style: @p[6].value, default: "{}", callback: @h['CPEE_CALLBACK']};
|
175
189
|
|
176
|
-
File.write(File.join(
|
190
|
+
File.write(File.join(data_dir,@r.last,'callback'),@h['CPEE_CALLBACK'])
|
177
191
|
|
178
192
|
|
179
193
|
@a[0].send(JSON.dump(hash))
|
@@ -190,12 +204,13 @@ module CPEE
|
|
190
204
|
|
191
205
|
class DeleteFrame < Riddl::Implementation
|
192
206
|
def response
|
193
|
-
|
207
|
+
data_dir = @a[1]
|
208
|
+
path = File.join(data_dir,@r.last,'frames.json')
|
194
209
|
file = File.read(path)
|
195
210
|
data_hash = JSON::parse(file)
|
196
211
|
|
197
212
|
data_hash["data"].each do | c |
|
198
|
-
if
|
213
|
+
if CPEE::Frames::overlap?(c['lx'], c['ly'], c['rx'], c['ry'], @p[0].value.to_i, @p[1].value.to_i, (@p[0].value.to_i + 1), (@p[1].value.to_i + 1))
|
199
214
|
data_hash["data"].delete(c)
|
200
215
|
end
|
201
216
|
end
|
@@ -204,20 +219,11 @@ module CPEE
|
|
204
219
|
end
|
205
220
|
end
|
206
221
|
|
207
|
-
def doOverlap(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
|
208
|
-
if l1x > r2x || l2x > r1x
|
209
|
-
return false;
|
210
|
-
end
|
211
|
-
if l1y > r2y || l2y > r1y
|
212
|
-
return false;
|
213
|
-
end
|
214
|
-
return true;
|
215
|
-
end
|
216
|
-
|
217
222
|
class Delete < Riddl::Implementation
|
218
223
|
def response
|
224
|
+
data_dir = @a[1]
|
219
225
|
pp "in delete"
|
220
|
-
if cbu = File.read(File.join(
|
226
|
+
if cbu = File.read(File.join(data_dir,@r.last,'callback'))
|
221
227
|
pp "XYZ"
|
222
228
|
send = { 'operation' => @p[0].value }
|
223
229
|
case send['operation']
|
@@ -229,11 +235,11 @@ module CPEE
|
|
229
235
|
Typhoeus.put(cbu, body: JSON::generate(send), headers: { 'content-type' => 'application/json'})
|
230
236
|
end
|
231
237
|
|
232
|
-
#File.unlink(File.join(
|
233
|
-
#File.unlink(File.join(
|
234
|
-
#File.unlink(File.join(
|
235
|
-
#File.unlink(File.join(
|
236
|
-
#File.unlink(File.join(
|
238
|
+
#File.unlink(File.join(data_dir,@r.last,'callback')) rescue nil
|
239
|
+
#File.unlink(File.join(data_dir,@r.last,'cpeeinstance.url')) rescue nil
|
240
|
+
#File.unlink(File.join(data_dir,@r.last,'style.url')) rescue nil
|
241
|
+
#File.unlink(File.join(data_dir,@r.last,'document.xml')) rescue nil
|
242
|
+
#File.unlink(File.join(data_dir,@r.last,'info.json')) rescue nil
|
237
243
|
|
238
244
|
@a[0].send('reset')
|
239
245
|
nil
|
@@ -242,10 +248,11 @@ module CPEE
|
|
242
248
|
|
243
249
|
class GetFrames < Riddl::Implementation #{{{
|
244
250
|
def response
|
245
|
-
|
251
|
+
data_dir = @a[0]
|
252
|
+
fname = File.join(data_dir,@r[-2],'frames.json')
|
246
253
|
if File.exists? fname
|
247
254
|
|
248
|
-
infofile = File.join(
|
255
|
+
infofile = File.join(data_dir,@r[-2],'info.json')
|
249
256
|
infojson = JSON::parse(File.read(infofile))
|
250
257
|
|
251
258
|
#remove not used languages
|
@@ -264,8 +271,9 @@ module CPEE
|
|
264
271
|
|
265
272
|
class SetDataElements < Riddl::Implementation #{{{
|
266
273
|
def response
|
274
|
+
data_dir = @a[0]
|
267
275
|
savejson = @p.map { |o| Hash[o.name, o.value] }.to_json
|
268
|
-
path = File.join(
|
276
|
+
path = File.join(data_dir,@r[0],'dataelements.json')
|
269
277
|
File.write(path, savejson)
|
270
278
|
|
271
279
|
#puts xyz
|
@@ -278,7 +286,7 @@ module CPEE
|
|
278
286
|
#puts @p[0].name
|
279
287
|
#puts @p[0].value
|
280
288
|
|
281
|
-
#fname = File.join(
|
289
|
+
#fname = File.join(data_dir,@r[-2],'dataelements.json')
|
282
290
|
#if File.exists? fname
|
283
291
|
# Riddl::Parameter::Complex.new('value','application/json',File.read(fname))
|
284
292
|
#else
|
@@ -289,7 +297,8 @@ module CPEE
|
|
289
297
|
|
290
298
|
class GetDataElements < Riddl::Implementation #{{{
|
291
299
|
def response
|
292
|
-
|
300
|
+
data_dir = @a[0]
|
301
|
+
fname = File.join(data_dir,@r[-2],'dataelements.json')
|
293
302
|
if File.exists? fname
|
294
303
|
Riddl::Parameter::Complex.new('value','application/json',File.read(fname))
|
295
304
|
else
|
@@ -300,7 +309,8 @@ module CPEE
|
|
300
309
|
|
301
310
|
class GetInfo < Riddl::Implementation #{{{
|
302
311
|
def response
|
303
|
-
|
312
|
+
data_dir = @a[0]
|
313
|
+
fname = File.join(data_dir,@r[-2],'info.json')
|
304
314
|
if File.exists? fname
|
305
315
|
Riddl::Parameter::Complex.new('value','application/json',File.read(fname))
|
306
316
|
else
|
@@ -311,7 +321,8 @@ module CPEE
|
|
311
321
|
|
312
322
|
class GetLangs < Riddl::Implementation #{{{
|
313
323
|
def response
|
314
|
-
|
324
|
+
data_dir = @a[0]
|
325
|
+
fname = File.join(data_dir,@r[-2],'info.json')
|
315
326
|
if File.exists? fname
|
316
327
|
infojson = JSON::parse(File.read(fname))
|
317
328
|
Riddl::Parameter::Complex.new('value','application/json',infojson["langs"])
|
@@ -323,7 +334,8 @@ module CPEE
|
|
323
334
|
|
324
335
|
class SetLang < Riddl::Implementation #{{{
|
325
336
|
def response
|
326
|
-
|
337
|
+
data_dir = @a[1]
|
338
|
+
fname = File.join(data_dir,@r[-2],'info.json')
|
327
339
|
if File.exists? fname
|
328
340
|
infojson = JSON::parse(File.read(fname))
|
329
341
|
infojson["lang"] = @p[0].value
|
@@ -348,7 +360,8 @@ module CPEE
|
|
348
360
|
|
349
361
|
class GetStyle < Riddl::Implementation #{{{
|
350
362
|
def response
|
351
|
-
|
363
|
+
data_dir = @a[0]
|
364
|
+
fname = File.join(data_dir,@r[-2],'style.url')
|
352
365
|
if File.exists? fname
|
353
366
|
Riddl::Parameter::Complex.new('url','text/plain',File.read(fname).strip)
|
354
367
|
else
|
@@ -359,7 +372,8 @@ module CPEE
|
|
359
372
|
|
360
373
|
class GetCpeeInstance < Riddl::Implementation #{{{
|
361
374
|
def response
|
362
|
-
|
375
|
+
data_dir = @a[0]
|
376
|
+
fname = File.join(data_dir,@r[-2],'cpeeinstance.url')
|
363
377
|
if File.exists? fname
|
364
378
|
Riddl::Parameter::Complex.new('url','text/plain',File.read(fname).strip)
|
365
379
|
else
|
@@ -376,6 +390,7 @@ module CPEE
|
|
376
390
|
|
377
391
|
class Handler < Riddl::Implementation
|
378
392
|
def response
|
393
|
+
data_dir = @a[1]
|
379
394
|
topic = @p[1].value
|
380
395
|
event_name = @p[2].value
|
381
396
|
notification = JSON.parse(@p[3].value.read)
|
@@ -394,7 +409,7 @@ module CPEE
|
|
394
409
|
if content['values']&.any?
|
395
410
|
#puts alldata['ausfuehrungen']
|
396
411
|
puts "writing file"
|
397
|
-
path = File.join(
|
412
|
+
path = File.join(data_dir,@r[0],'dataelements.json')
|
398
413
|
File.write(path, JSON.dump(content['values']))
|
399
414
|
end
|
400
415
|
|
@@ -486,49 +501,49 @@ module CPEE
|
|
486
501
|
opts[:signals2]["handler"] ||= Signaling.new
|
487
502
|
|
488
503
|
run Get, "test" if get
|
489
|
-
run InitFrame, opts[:signals][idx] if post 'input'
|
504
|
+
run InitFrame, opts[:signals][idx], opts[:data_dir] if post 'input'
|
490
505
|
|
491
|
-
run NewFrameSet, opts[:signals][idx] if put 'sframe'
|
492
|
-
run NewFrameWait, opts[:signals][idx] if put 'wframe'
|
506
|
+
run NewFrameSet, opts[:signals][idx], opts[:data_dir] if put 'sframe'
|
507
|
+
run NewFrameWait, opts[:signals][idx], opts[:data_dir] if put 'wframe'
|
493
508
|
|
494
|
-
run DeleteFrame, opts[:signals][idx] if post 'deleteframe'
|
509
|
+
run DeleteFrame, opts[:signals][idx], opts[:data_dir] if post 'deleteframe'
|
495
510
|
|
496
511
|
on resource 'handler' do
|
497
|
-
run Handler, opts[:signals2]["handler"] if post
|
512
|
+
run Handler, opts[:signals2]["handler"], opts[:data_dir] if post
|
498
513
|
on resource 'sse' do
|
499
514
|
run SSE2, opts[:signals2]["handler"] if sse
|
500
515
|
end
|
501
516
|
end
|
502
517
|
|
503
|
-
run Delete, opts[:signals][idx] if delete 'opa'
|
504
|
-
run Delete, opts[:signals][idx] if delete 'opb'
|
505
|
-
run Delete, opts[:signals][idx] if delete 'opc'
|
518
|
+
run Delete, opts[:signals][idx], opts[:data_dir] if delete 'opa'
|
519
|
+
run Delete, opts[:signals][idx], opts[:data_dir] if delete 'opb'
|
520
|
+
run Delete, opts[:signals][idx], opts[:data_dir] if delete 'opc'
|
506
521
|
on resource 'sse' do
|
507
522
|
run SSE, opts[:signals][idx] if sse
|
508
523
|
end
|
509
524
|
on resource 'languages' do
|
510
|
-
run GetLangs if get
|
511
|
-
run SetLang, opts[:signals][idx] if post 'lang'
|
525
|
+
run GetLangs, opts[:data_dir] if get
|
526
|
+
run SetLang, opts[:signals][idx], opts[:data_dir] if post 'lang'
|
512
527
|
end
|
513
528
|
on resource 'style.url' do
|
514
|
-
run GetStyle if get
|
529
|
+
run GetStyle, opts[:data_dir] if get
|
515
530
|
end
|
516
531
|
on resource 'cpeeinstance.url' do
|
517
|
-
run GetCpeeInstance if get
|
532
|
+
run GetCpeeInstance, opts[:data_dir] if get
|
518
533
|
end
|
519
534
|
on resource 'info.json' do
|
520
|
-
run GetInfo if get
|
535
|
+
run GetInfo, opts[:data_dir] if get
|
521
536
|
end
|
522
537
|
on resource 'frames.json' do
|
523
|
-
run GetFrames if get
|
538
|
+
run GetFrames, opts[:data_dir] if get
|
524
539
|
end
|
525
540
|
on resource 'test' do
|
526
541
|
run OutputTest if put
|
527
542
|
end
|
528
543
|
|
529
544
|
on resource 'dataelements.json' do
|
530
|
-
run SetDataElements if post
|
531
|
-
run GetDataElements if get
|
545
|
+
run SetDataElements, opts[:data_dir] if post
|
546
|
+
run GetDataElements, opts[:data_dir] if get
|
532
547
|
end
|
533
548
|
end
|
534
549
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpee-frames
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuell Gall
|
8
8
|
- Juergen 'eTM' Mangler
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: tools
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-02-
|
12
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riddl
|
@@ -75,7 +75,7 @@ homepage: https://github.com/ManuelGall/cpee-frames
|
|
75
75
|
licenses:
|
76
76
|
- GPL-3.0
|
77
77
|
metadata: {}
|
78
|
-
post_install_message:
|
78
|
+
post_install_message:
|
79
79
|
rdoc_options: []
|
80
80
|
require_paths:
|
81
81
|
- lib
|
@@ -90,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
94
|
-
signing_key:
|
93
|
+
rubygems_version: 3.3.26
|
94
|
+
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Dashboard management service with UI and backend for the cpee.org family
|
97
97
|
of workflow management tools
|