pg_rails 7.0.8.pre.alpha.64 → 7.0.8.pre.alpha.66

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: 897b3e763decbc3633e769f5c80b03b2ac4beeb6d7870418205890f07be921a3
4
- data.tar.gz: bcb3121b4f5c7dbdbf43f7363121617fdc1576b37fae413b508e947e68b1789b
3
+ metadata.gz: 22e075226a1a3f478fb957532cf0a66735c0939bbc28d90ea8460efd97834b04
4
+ data.tar.gz: 663f0f7daca3e65246799a307347d6da6f41a4359d44f69a2dbd4946e74cbfee
5
5
  SHA512:
6
- metadata.gz: 14f270d418616143ce27842e5ea615760ad472fdd81f758a41303a3cb45173b57beaec9ff54cdea07ef0b1200f02cfe24e2e978476f41d82f74627ce1de4c34c
7
- data.tar.gz: e66b21ddb42ee202b0bcd62b5e6cb0a22f16e6f5561edbc4e142b12acdcc91bd0131402dfef49f20db159fff99b05b76d5f57db9a53acec4ad92251d3e46ee42
6
+ metadata.gz: e49655fe8d4c9ef567248726306857dafed3c77904f2ca618db39893d65000216b123501733159a417e7b90aee26f5a290de7462337f2506ad6d8526ad421c37
7
+ data.tar.gz: 58be8026d80ad0e6c16c357649847e62beb4ecf1432c974d57c12d1118b0dc063c884dfb7c47afd124905ac60dfb3a8270ce3bb1b64f54c1111ede038c41d335
@@ -34,6 +34,8 @@ module PgEngine
34
34
  obj
35
35
  end
36
36
  notify(mensaje, :error)
37
+ rescue StandardError => e
38
+ Rails.logger.error("ERROR al loguear error: #{e}")
37
39
  end
38
40
 
39
41
  def warn(obj, type = :error)
@@ -43,6 +45,8 @@ module PgEngine
43
45
  obj
44
46
  end
45
47
  notify(mensaje, type)
48
+ rescue StandardError => e
49
+ Rails.logger.error("ERROR al loguear error: #{e}")
46
50
  end
47
51
 
48
52
  private
@@ -49,11 +49,11 @@ function bindToastElements () {
49
49
  const toastQuery = '.pg-toast:not(.hide):not(.show)'
50
50
 
51
51
  const toastElList = document.querySelectorAll(toastQuery)
52
- Array.from(toastElList).each(toastEl => {
53
- new bootstrap.Toast(toastEl).show()
52
+ Array.from(toastElList).map(toastEl => {
54
53
  toastEl.addEventListener('hidden.bs.toast', () => {
55
54
  toastEl.remove()
56
55
  })
56
+ return new bootstrap.Toast(toastEl).show()
57
57
  })
58
58
  }
59
59
 
@@ -1,10 +1,12 @@
1
1
  import consumer from '../channels/consumer'
2
2
  import CableReady from 'cable_ready'
3
+ import Rollbar from 'rollbar'
3
4
 
4
5
  const anycable = consumer.cable
5
6
 
6
7
  if (anycable) {
7
8
  anycable.on('connect', ev => {
9
+ document.head.dataset.cableConnected = true
8
10
  if (ev.reconnect) {
9
11
  console.log('Welcome back!')
10
12
  } else {
@@ -13,10 +15,14 @@ if (anycable) {
13
15
  })
14
16
 
15
17
  anycable.on('disconnect', ev => {
18
+ document.head.dataset.cableConnected = false
19
+ // document.head.dataset.cableDisconnectedEvent = ev
16
20
  if (ev.reason) {
21
+ Rollbar.warning(`Disconnected because: ${ev.reason}`)
17
22
  console.log(`Disconnected because: ${ev.reason}`)
18
23
  } else {
19
- console.log('Disconnected')
24
+ Rollbar.warning('Disconnected for unknown reason')
25
+ console.log('Disconnected for unknown reason')
20
26
  }
21
27
  })
22
28
  }
@@ -18,6 +18,46 @@ export function numberWithDots (x) {
18
18
  return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.')
19
19
  }
20
20
 
21
+ export function flashMessage (message, flashType = 'warning', toast = false) {
22
+ const el = document.createElement('div')
23
+ const toastClasses = toast ? 'position-absolute pg-toast' : ''
24
+ let iconClasses
25
+ let alertClassSuffix
26
+ switch (flashType) {
27
+ case 'critical':
28
+ iconClasses = 'bi bi-exclamation-triangle-fill me-3 fs-2'
29
+ alertClassSuffix = 'danger'
30
+ break
31
+ case 'alert':
32
+ iconClasses = 'bi bi-exclamation-triangle-fill me-2'
33
+ alertClassSuffix = 'danger'
34
+ break
35
+ case 'warning':
36
+ iconClasses = 'bi bi-exclamation-circle me-2'
37
+ alertClassSuffix = 'warning'
38
+ break
39
+ case 'success':
40
+ iconClasses = 'bi bi-check-lg me-2'
41
+ alertClassSuffix = 'success'
42
+ break
43
+ case 'notice':
44
+ default:
45
+ iconClasses = 'bi bi-info-circle me-2'
46
+ alertClassSuffix = 'info'
47
+ break
48
+ }
49
+
50
+ el.innerHTML = `
51
+ <div class="alert alert-dismissible mt-2 d-flex align-items-center alert-${alertClassSuffix} ${toastClasses}"
52
+ data-turbo-temporary="true" data-bs-autohide="false" aria-live="assertive" aria-atomic="true" role="alert">
53
+
54
+ <span class="${iconClasses}"></span>
55
+ ${message}
56
+ <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
57
+ </div>`
58
+ document.querySelector('#flash').appendChild(el.children[0])
59
+ }
60
+
21
61
  export function fadeOut (e) {
22
62
  if (window.getComputedStyle(e).visibility !== 'hidden') {
23
63
  e.classList.add('fade-out')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.64'
4
+ VERSION = '7.0.8-alpha.66'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.8.pre.alpha.64
4
+ version: 7.0.8.pre.alpha.66
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso