sinatra-hexacta 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sinatra/extensions/mailsender.rb +35 -11
- data/lib/sinatra/handlers/constants.rb +1 -1
- data/lib/sinatra/handlers/cross_origin.rb +1 -1
- data/lib/sinatra/handlers/reports.rb +1 -1
- data/lib/sinatra/public/js/app.js +29 -10
- data/lib/sinatra/public/vendors/bootstrap-validator/validator.js +16 -2
- data/lib/sinatra/views/inputs/select.slim +18 -2
- data/lib/sinatra/views/notifications.slim +3 -3
- data/lib/sinatra/views/notifications/view.slim +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e27f66144b0ee4048817d8c92a6fc993ab63ca176a79ac1feb9288175e93103
|
4
|
+
data.tar.gz: 5abf03f218822c22896a9200c05912afed6994e2b3b9fc872dcad45a8cb32072
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4738793bb01253652be89cb9b8462c96663c9d4ffcfdd161cccd7fa6fa07437d48e2fb90ce82a74fa08548d878c0f827fcc31d515bcfa80421564645fce43a8
|
7
|
+
data.tar.gz: a9931739f2585cc09789a9a116f75b2303d967c9e2d73350386d79f5c9b71f073d4000bfb863ed80380be61564d0a5eaabbe59de9fa8a24ced6a140980d084cb
|
@@ -20,16 +20,32 @@ class MailSender
|
|
20
20
|
http.start { |http| http.request(request) }
|
21
21
|
end
|
22
22
|
|
23
|
+
|
23
24
|
def _authorize_mail
|
24
25
|
params = [ [ "grant_type", "password" ], [ "client_id", "MailApp" ], [ "client_secret", "MailAppPRD2018!" ] ]
|
25
|
-
|
26
|
+
retry_times = 0
|
27
|
+
begin
|
28
|
+
response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
|
29
|
+
rescue StandardError => bang
|
30
|
+
response = nil
|
31
|
+
end
|
32
|
+
until response.is_a?( Net::HTTPSuccess ) || retry_times > 10 do
|
33
|
+
begin
|
34
|
+
retry_times = retry_times + 1
|
35
|
+
sleep(retry_times)
|
36
|
+
response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
|
37
|
+
rescue StandardError => bang
|
38
|
+
end
|
39
|
+
end
|
26
40
|
if( response.is_a?( Net::HTTPSuccess ) )
|
27
41
|
token = JSON.parse(response.body)
|
28
42
|
@access_token = token["access_token"]
|
29
43
|
@refresh_token = token["refresh_token"]
|
30
44
|
@expire = DateTime.parse(token[".expires"])
|
45
|
+
return true
|
31
46
|
else
|
32
47
|
NotificationSender.instance.send_error(nil,'Authorize mail failed',response.body)
|
48
|
+
return false
|
33
49
|
end
|
34
50
|
end
|
35
51
|
|
@@ -54,26 +70,34 @@ class MailSender
|
|
54
70
|
end
|
55
71
|
|
56
72
|
def _expired?
|
57
|
-
expire.nil? || DateTime.now < expire
|
73
|
+
@expire.nil? || DateTime.now < @expire
|
58
74
|
end
|
59
75
|
|
76
|
+
|
60
77
|
def do_send(mail)
|
61
|
-
|
62
|
-
if _expired?
|
63
|
-
_authorize_mail
|
64
|
-
end
|
78
|
+
authorized = _expired?? _authorize_mail : true
|
65
79
|
|
80
|
+
if authorized
|
66
81
|
params = [ [ "ApplicationCode", 2009 ], [ "Name", mail.template ], [ "Subject", mail.subject ], [ "EmailAddress", mail.from ] ]
|
67
82
|
params = params + _build_map_values(mail.values) + _build_to_map(mail.to)
|
68
83
|
|
69
|
-
|
70
|
-
|
84
|
+
retry_times = 0
|
85
|
+
begin
|
86
|
+
response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
|
87
|
+
rescue StandardError => bang
|
88
|
+
response = nil
|
89
|
+
end
|
90
|
+
until response.is_a?( Net::HTTPSuccess ) || retry_times > 10 do
|
91
|
+
begin
|
92
|
+
retry_times = retry_times + 1
|
93
|
+
sleep(retry_times)
|
94
|
+
response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
|
95
|
+
rescue StandardError => bang
|
96
|
+
end
|
97
|
+
end
|
71
98
|
if( !response.is_a?( Net::HTTPSuccess ) )
|
72
99
|
NotificationSender.instance.send_error(nil,'Send mail failed',response.body)
|
73
100
|
end
|
74
|
-
rescue StandardError => error
|
75
|
-
message = error.backtrace.join(',');
|
76
|
-
NotificationSender.instance.send_error(nil,"Mail send error",message)
|
77
101
|
end
|
78
102
|
end
|
79
103
|
|
@@ -9,7 +9,7 @@ module Sinatra
|
|
9
9
|
ConstantHandler.copy_all_files("/lib/sinatra/views/constants","/app/views/#{Hexacta::GEM_FILE_DIR}/constants")
|
10
10
|
|
11
11
|
before '/constant*' do
|
12
|
-
error(403)
|
12
|
+
error(403) unless authenticated(User).admin?
|
13
13
|
end
|
14
14
|
|
15
15
|
get '/constants' do
|
@@ -5,7 +5,24 @@ if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(naviga
|
|
5
5
|
$('html').addClass('ismobile');
|
6
6
|
}
|
7
7
|
|
8
|
+
// create a new instance of `MutationObserver` named `observer`,
|
9
|
+
// passing it a callback function
|
10
|
+
const observer = new MutationObserver(function() {
|
11
|
+
update_html_elements();
|
12
|
+
});
|
13
|
+
|
8
14
|
$(document).ready(function(){
|
15
|
+
/*
|
16
|
+
* Waves Animation
|
17
|
+
*/
|
18
|
+
(function(){
|
19
|
+
Waves.attach('.btn:not(.btn-icon):not(.btn-float)');
|
20
|
+
Waves.attach('.btn-icon, .btn-float', ['waves-circle', 'waves-float']);
|
21
|
+
Waves.init();
|
22
|
+
})();
|
23
|
+
});
|
24
|
+
|
25
|
+
function update_html_elements() {
|
9
26
|
|
10
27
|
// Fix modal inside other components
|
11
28
|
$('.modal').appendTo("body");
|
@@ -340,15 +357,6 @@ $(document).ready(function(){
|
|
340
357
|
});
|
341
358
|
}
|
342
359
|
|
343
|
-
/*
|
344
|
-
* Waves Animation
|
345
|
-
*/
|
346
|
-
(function(){
|
347
|
-
Waves.attach('.btn:not(.btn-icon):not(.btn-float)');
|
348
|
-
Waves.attach('.btn-icon, .btn-float', ['waves-circle', 'waves-float']);
|
349
|
-
Waves.init();
|
350
|
-
})();
|
351
|
-
|
352
360
|
/*
|
353
361
|
* Lightbox
|
354
362
|
*/
|
@@ -499,7 +507,14 @@ $(document).ready(function(){
|
|
499
507
|
$(this).find(':submit').attr("disabled",false);
|
500
508
|
});
|
501
509
|
|
502
|
-
}
|
510
|
+
}
|
511
|
+
|
512
|
+
const elementToObserve = document.querySelector("body");
|
513
|
+
|
514
|
+
if (elementToObserve != null) {
|
515
|
+
observer.observe(elementToObserve, {subtree: true, childList: true});
|
516
|
+
}
|
517
|
+
|
503
518
|
|
504
519
|
function start_load() {
|
505
520
|
if (!$("#loader")[0]) {
|
@@ -677,4 +692,8 @@ function read_notify(id,url) {
|
|
677
692
|
window.location = url;
|
678
693
|
}
|
679
694
|
});
|
695
|
+
}
|
696
|
+
|
697
|
+
function capitalize(word) {
|
698
|
+
return word[0].toUpperCase() + word.slice(1).toLowerCase();
|
680
699
|
}
|
@@ -394,12 +394,26 @@
|
|
394
394
|
|
395
395
|
// VALIDATOR DATA-API
|
396
396
|
// ==================
|
397
|
+
const elementToObserve = document.querySelector("body");
|
397
398
|
|
398
|
-
|
399
|
+
// create a new instance of `MutationObserver` named `observer`,
|
400
|
+
// passing it a callback function
|
401
|
+
const observer = new MutationObserver(function() {
|
399
402
|
$('form[data-toggle="validator"]').each(function () {
|
400
403
|
var $form = $(this)
|
401
404
|
Plugin.call($form, $form.data())
|
402
405
|
})
|
403
|
-
})
|
406
|
+
});
|
407
|
+
|
408
|
+
// call `observe()` on that MutationObserver instance,
|
409
|
+
// passing it the element to observe, and the options object
|
410
|
+
observer.observe(elementToObserve, {subtree: true, childList: true});
|
411
|
+
|
412
|
+
//$(window).on('load', function () {
|
413
|
+
// $('form[data-toggle="validator"]').each(function () {
|
414
|
+
// var $form = $(this)
|
415
|
+
// Plugin.call($form, $form.data())
|
416
|
+
// })
|
417
|
+
//})
|
404
418
|
|
405
419
|
}(jQuery);
|
@@ -11,7 +11,16 @@
|
|
11
11
|
-unless defined? readonly
|
12
12
|
-readonly = false
|
13
13
|
|
14
|
-
-if
|
14
|
+
-if readonly
|
15
|
+
.form-group
|
16
|
+
label #{placeholder}
|
17
|
+
select.chosen id="#{id}" class="#{clazz}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;") disabled=""
|
18
|
+
-for element in elements
|
19
|
+
-if chosen == element[:value]
|
20
|
+
option value="#{element[:value]}" selected="" #{element[:text]}
|
21
|
+
-else
|
22
|
+
option value="#{element[:value]}" #{element[:text]}
|
23
|
+
-elsif required
|
15
24
|
.form-group.has-success
|
16
25
|
label #{placeholder}
|
17
26
|
select.chosen.form-control id="#{id}" class="#{clazz}" name="#{name}" data-placeholder=("#{placeholder}") style=("display: none;") required=""
|
@@ -29,4 +38,11 @@
|
|
29
38
|
-if chosen == element[:value]
|
30
39
|
option value="#{element[:value]}" selected="" #{element[:text]}
|
31
40
|
-else
|
32
|
-
option value="#{element[:value]}" #{element[:text]}
|
41
|
+
option value="#{element[:value]}" #{element[:text]}
|
42
|
+
|
43
|
+
|
44
|
+
/ For enabling
|
45
|
+
/ var myselect=$('select');
|
46
|
+
/ myselect.chosen();
|
47
|
+
/ myselect.prop('disabled', true);
|
48
|
+
/ myselect.trigger("chosen:updated");
|
@@ -45,7 +45,7 @@
|
|
45
45
|
-total_pending = Notification.pending.for(authenticated(User)).exclude_message.count
|
46
46
|
|
47
47
|
.footer-btn
|
48
|
-
-
|
48
|
+
-if authenticated(User).admin?
|
49
49
|
a.btn.btn-float.bgm-blue.m-btn.waves-effect.waves-circle.waves-float data-toggle="modal" data-target="#new-notification"
|
50
50
|
i.zmdi.zmdi-notifications-active
|
51
51
|
-if total_pending > 0
|
@@ -55,13 +55,13 @@
|
|
55
55
|
i.zmdi.zmdi-delete
|
56
56
|
|
57
57
|
.footer-text
|
58
|
-
-
|
58
|
+
-if authenticated(User).admin?
|
59
59
|
a.text.btn.bgm-white.c-gray data-toggle="modal" data-target="#new-notification" Nueva notificación
|
60
60
|
-if total_pending > 0
|
61
61
|
a.text.btn.bgm-white.c-gray onclick="read_all_notifications(#{{Notification.pending.for(authenticated(User)).exclude_message.all.collect { |notification| notification.id}}});this.onclick='';" Marcar como leidas
|
62
62
|
a.text.btn.bgm-white.c-gray.delete-notifications.hidden.animated.bounceIn onclick="delete_all_notifications();this.onclick='';" Borrar notificaciones
|
63
63
|
|
64
|
-
-
|
64
|
+
-if authenticated(User).admin?
|
65
65
|
== slim :'sinatra-hexacta/notifications/new'
|
66
66
|
|
67
67
|
javascript:
|
@@ -48,7 +48,7 @@
|
|
48
48
|
.media-body
|
49
49
|
.lv-title Fecha de lectura
|
50
50
|
small.lv-small #{notification.read_date.display}
|
51
|
-
-
|
51
|
+
-if authenticated(User).superadmin?
|
52
52
|
a.lv-item
|
53
53
|
.media
|
54
54
|
.media-body
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-hexacta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marco Zanger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sucker_punch
|
@@ -250,7 +250,7 @@ homepage: https://rubygems.org/gems/sinatra-hexacta
|
|
250
250
|
licenses:
|
251
251
|
- MIT
|
252
252
|
metadata: {}
|
253
|
-
post_install_message:
|
253
|
+
post_install_message:
|
254
254
|
rdoc_options: []
|
255
255
|
require_paths:
|
256
256
|
- lib
|
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
266
|
version: '0'
|
267
267
|
requirements: []
|
268
268
|
rubygems_version: 3.0.6
|
269
|
-
signing_key:
|
269
|
+
signing_key:
|
270
270
|
specification_version: 4
|
271
271
|
summary: Hexacta general tools!
|
272
272
|
test_files: []
|