sinatra-hexacta 1.3.0 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f0b5543f96de1b88e37c6eaf7bc8cfcf61a3419fda741a9597f333a49f4ec1b
4
- data.tar.gz: 4224a9d29c78106f70fcef411891a9d54efbe62025becd73201d0740198e4d20
3
+ metadata.gz: 309f78d43f4e7447e920edaa8e90d36f4992e1cdc0fde8a40ee7ad8f0e17498a
4
+ data.tar.gz: 66e5d4cceb9b6bf3e1f83919bc2f0962827ef6fba83d459eec4aceea85ac6675
5
5
  SHA512:
6
- metadata.gz: e22aa655547b0c55ab14163e7043dbf4e4fee7d321d51e99ccc7823dff01cda2139df7fd7fc7b68d51f999453239fc199d7af663109ab32283d5069e1c1ab473
7
- data.tar.gz: 885f0a1b6b4d3324217067cee4e976b25a967e7888b8ce5404c9a46c80c3e1faef444462bc409f1b85836f598d877b491633f1443cedca776858a47a3bd26d52
6
+ metadata.gz: 8c0c94b820a01db53ae1450f5dd014ca2d1541b6c9f2bb1a0f216e6579b64352ef59bfb2940e405e69a8ae7f19eef4b0f3e434d178a51d75cf3bfe75751b019e
7
+ data.tar.gz: 3536f3971f4cb17aa0674a496b98d33d2794a0dfe84bf5418ce88b8b4b9e65354d7a7784226b2bf3378cf9de4a775d9f72ef740280b4afc6c0d134c8f5e55e74
@@ -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
- response = _do_connect("https://comunicacion.hexacta.com:4443/apptoken",params)
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
- begin
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
- response = _do_connect("https://comunicacion.hexacta.com:4444/api/app/TemplateNotification/SendMail",params,@access_token)
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
 
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ module Sinatra
3
+ module CrossOriginHandler
4
+ extend Hexacta
5
+
6
+ def enable_cross_origin
7
+ p "Enabling cross origin..."
8
+
9
+ configure do
10
+ enable :cross_origin
11
+ end
12
+
13
+ before do
14
+ response.headers['Access-Control-Allow-Origin'] = '*'
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+ register CrossOriginHandler
21
+ end
22
+
@@ -6,3 +6,4 @@ require_relative 'reports'
6
6
  require_relative 'processes'
7
7
  require_relative 'constants'
8
8
  require_relative 'user_configurations'
9
+ require_relative 'cross_origin'
@@ -14,7 +14,6 @@ module Sinatra
14
14
  p "Setting up user configurations directory..."
15
15
  setup_dir("/app/views/#{Hexacta::GEM_FILE_DIR}/user_configurations")
16
16
  copy_all_files("/lib/sinatra/views/user_configurations","/app/views/#{Hexacta::GEM_FILE_DIR}/user_configurations")
17
-
18
17
  end
19
18
 
20
19
  helpers UserConfigurationHelper
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'sinatra/base'
3
+ require 'sinatra/cross_origin'
3
4
  require 'fileutils'
4
5
  require 'sucker_punch'
5
6
  require 'rufus-scheduler'
@@ -677,4 +677,8 @@ function read_notify(id,url) {
677
677
  window.location = url;
678
678
  }
679
679
  });
680
+ }
681
+
682
+ function capitalize(word) {
683
+ return word[0].toUpperCase() + word.slice(1).toLowerCase();
680
684
  }
@@ -11,7 +11,16 @@
11
11
  -unless defined? readonly
12
12
  -readonly = false
13
13
 
14
- -if required
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");
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.3.0
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Zanger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-17 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sucker_punch
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.0.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra-cross_origin
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.3.1
69
83
  description: A gem to support general functionality accross all apps
70
84
  email: mzanger@hexacta.com
71
85
  executables: []
@@ -84,6 +98,7 @@ files:
84
98
  - lib/sinatra/extensions/notification.rb
85
99
  - lib/sinatra/extensions/processmanager.rb
86
100
  - lib/sinatra/handlers/constants.rb
101
+ - lib/sinatra/handlers/cross_origin.rb
87
102
  - lib/sinatra/handlers/errors.rb
88
103
  - lib/sinatra/handlers/init.rb
89
104
  - lib/sinatra/handlers/notifications.rb