pg_rails 7.0.8.pre.alpha.65 → 7.0.8.pre.alpha.67

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: c1b7d742107efb7bfdd00d458d0df8b298395702ae8aacaa1cf1ffe9083ca09e
4
- data.tar.gz: 2592e3ec5a153c28314bab3c754c86dfee514fe5cf308380bae1324e14167565
3
+ metadata.gz: b10c0027abbd150b13c0151f1c00fc808867db2507c392ae1553584ccc54c7fa
4
+ data.tar.gz: c839f6004a12b70d8c28e19719185eb9a883290ee53f1b2da159138f9fff5021
5
5
  SHA512:
6
- metadata.gz: 1022d09e2a8fad3a7bca4cf92038ed521951daca564ecbca33c52c440cf565bd71758edbc7445f68e023c1eea4292647f50350f378675063912d1c3556a26030
7
- data.tar.gz: 10910645b466eeb4bcbaae5610977f4ed61fe4c5886e9562ac25d3a4970f3b9a3c2f3153843d0be3f3d69e2c829683f5b1178e1ed8bb2d56f770aae3b6a8724c
6
+ metadata.gz: 2046f277cc5103994b1c5f4d260fced6db73cf6ba8a46f03e9807aac59cbe535004fcbefeac65c6823ea0a71e756f1aa266870776a840fabe50b7678715b2ac1
7
+ data.tar.gz: d3efc68090305c1214135747e7fa9dabe9a8478c4dc654c24a6be14d58130e296a575400468688168c96a96c09c749cec2cbd238db7217670e58276d16d58b83
@@ -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
@@ -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
  }
@@ -0,0 +1,11 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ // Connects to data-controller="clear-timeout"
4
+ export default class extends Controller {
5
+ connect () {
6
+ const timeoutId = parseInt(this.element.dataset.timeoutId)
7
+ clearTimeout(timeoutId)
8
+ console.log(`clearedTimeout: ${timeoutId}`)
9
+ this.element.remove()
10
+ }
11
+ }
@@ -4,8 +4,10 @@ import NavbarController from './navbar_controller'
4
4
  import NestedController from './nested_controller'
5
5
  import PgFormController from './pg_form_controller'
6
6
  import FadeinOnloadController from './fadein_onload_controller'
7
+ import ClearTimeoutController from './clear_timeout_controller'
7
8
 
8
9
  application.register('navbar', NavbarController)
9
10
  application.register('nested', NestedController)
10
11
  application.register('pg_form', PgFormController)
11
12
  application.register('fadein_onload', FadeinOnloadController)
13
+ application.register('clear-timeout', ClearTimeoutController)
@@ -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.65'
4
+ VERSION = '7.0.8-alpha.67'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.65
4
+ version: 7.0.8.pre.alpha.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-11 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -1054,6 +1054,7 @@ files:
1054
1054
  - pg_layout/app/javascript/config/cable_ready.js
1055
1055
  - pg_layout/app/javascript/config/index.js
1056
1056
  - pg_layout/app/javascript/controllers/application.js
1057
+ - pg_layout/app/javascript/controllers/clear_timeout_controller.js
1057
1058
  - pg_layout/app/javascript/controllers/fadein_onload_controller.js
1058
1059
  - pg_layout/app/javascript/controllers/index.js
1059
1060
  - pg_layout/app/javascript/controllers/navbar_controller.js