signum 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56ad1a15e3abcc754f0f2c389b7c59aaa8c43adfe6b3d7ef2296379a0d42f6d6
4
- data.tar.gz: 146fe001b1ba7664c5bbf1b0834a0adc41f3a3fd889822b30fdb436042fcd1b9
3
+ metadata.gz: afc66ab9111c5abd8514d9886085a4009616b991088f8e942125fc193d3cb1b1
4
+ data.tar.gz: 5e86e69e0e07f2cff2f377ceb9dc652e41d2ec31069649f7bd364c74b04583b4
5
5
  SHA512:
6
- metadata.gz: 75ebff55bdbf08eda7f36c1f1a27d3c78414412089a197b171e454c618be103c44ff17c2119912981131f31a0ccf96e3298c3eabe65cbc0be39dcaea879f4d6b
7
- data.tar.gz: 9cab86de0a234c0bd94f3a819b64899bf0f735963afcd641f7e482b18cbfd96f8066794e37de5311bd09c985de2189ce0dc7a745bd9d26f0c08e8eed785de3f9
6
+ metadata.gz: 0037367c3fbc51de0dacae3f556a6edfaed552c4dd1c6dc1b5ac6ae375d5f4fa59f1ab2c1d769851d5923b3a645ed4997ce979cc6cdd59924564cdd3f92cab12
7
+ data.tar.gz: 706885e899ea2fe06c37e8191f45e17196dfd4a020a39633337f07d4f626555125a055196c4784feec9b202178e3164fa5e0fcc676ecc6599edfc3bf4f63bb61
@@ -1,4 +1,5 @@
1
1
  import ApplicationController from "signum/controllers/application_controller"
2
+ import { post } from '@rails/request.js';
2
3
 
3
4
  export default class extends ApplicationController {
4
5
  static values = { type: String, timeout: Number, sticky: Boolean, signalId: String, signalState: String }
@@ -19,23 +20,23 @@ export default class extends ApplicationController {
19
20
  }, 300)
20
21
  }
21
22
 
22
- markClose() {
23
- fetch("/signal/close", {
24
- method: "POST",
25
- headers: {
26
- "Content-Type": "application/json",
27
- },
28
- body: JSON.stringify({ id: this.signalIdValue }),
29
- })
30
- .then((res) => {
23
+ async markClose() {
24
+ try {
25
+ const response = await post('/signal/close', {
26
+ body: JSON.stringify({ id: this.signalIdValue }),
27
+ contentType: 'application/json'
28
+ });
29
+ if (response.ok) {
31
30
  const niE = new CustomEvent("nd-item-activity", {
32
31
  bubbles: true,
33
32
  detail: "closed",
34
- })
35
- window.dispatchEvent(niE)
36
- })
37
- .catch((err) => {
38
- console.log(err)
39
- })
33
+ });
34
+ window.dispatchEvent(niE);
35
+ } else {
36
+ console.error('Error: ', response.statusText);
37
+ }
38
+ } catch (error) {
39
+ console.error('Request failed', error);
40
+ }
40
41
  }
41
42
  }
@@ -1,4 +1,5 @@
1
1
  import ApplicationController from "signum/controllers/application_controller"
2
+ import { post } from '@rails/request.js';
2
3
 
3
4
  export default class extends ApplicationController {
4
5
  static targets = ["alertBellIcon", "bellIcon", "submenu", "item", "crossIcon"]
@@ -33,22 +34,22 @@ export default class extends ApplicationController {
33
34
  }
34
35
  }
35
36
 
36
- closeNotifications(event) {
37
- fetch("/signal/close_all", {
38
- method: "POST",
39
- headers: {
40
- "Content-Type": "application/json",
41
- },
42
- body: JSON.stringify({}),
43
- })
44
- .then((res) => {
37
+ async closeNotifications(event) {
38
+ try {
39
+ const response = await post('/signal/close_all', {
40
+ body: JSON.stringify({}),
41
+ contentType: 'application/json'
42
+ });
43
+ if (response.ok) {
45
44
  setTimeout(() => {
46
45
  this.manageBellIcon()
47
- }, 300)
48
- })
49
- .catch((err) => {
50
- console.log(err)
51
- })
46
+ }, 300);
47
+ } else {
48
+ console.error('Error: ', response.statusText);
49
+ }
50
+ } catch (error) {
51
+ console.error('Request failed', error);
52
+ }
52
53
  }
53
54
 
54
55
  itemActivity(event) {
@@ -1,4 +1,5 @@
1
1
  import ApplicationController from "signum/controllers/application_controller"
2
+ import { post } from '@rails/request.js';
2
3
 
3
4
  export default class extends ApplicationController {
4
5
  static targets = []
@@ -14,17 +15,22 @@ export default class extends ApplicationController {
14
15
  })
15
16
  window.dispatchEvent(niE)
16
17
  if (this.signalStateValue == "broadcasted") {
17
- fetch("/signal/show", {
18
- method: "POST",
19
- headers: {
20
- "Content-Type": "application/json",
21
- },
18
+ this.showSignal()
19
+ }
20
+ }
21
+
22
+ async showSignal() {
23
+ try {
24
+ const response = await post("/signal/show", {
22
25
  body: JSON.stringify({ id: this.signalIdValue }),
23
- })
24
- .then((res) => {})
25
- .catch((err) => {
26
- console.log(err)
27
- })
26
+ contentType: 'application/json'
27
+ });
28
+ if (response.ok) {
29
+ } else {
30
+ console.error('Error: ', response.statusText);
31
+ }
32
+ } catch (error) {
33
+ console.error('Request failed', error);
28
34
  }
29
35
  }
30
36
  }
@@ -1,5 +1,5 @@
1
1
  module Signum
2
- class ApplicationController < ActionController::Base
2
+ class ApplicationController < Signum.config.base_controller.constantize
3
3
  protect_from_forgery with: :exception
4
4
  end
5
5
  end
@@ -1,5 +1,7 @@
1
+ require_dependency 'signum/application_controller'
2
+
1
3
  module Signum
2
- class SignalController < ApiController
4
+ class SignalController < ApplicationController
3
5
  def show
4
6
  signal = Signum::Signal.find(signal_params[:id])
5
7
  signal.show! if signal.broadcasted?
@@ -13,8 +15,7 @@ module Signum
13
15
  end
14
16
 
15
17
  def close_all
16
- # signals = Signum.config.current_user.call.signals.where.not(state: "closed") // current_user is nil when called from an api
17
- signals = current_user.signals.where.not(state: "closed")
18
+ signals = Signum.config.current_user.call.signals.where.not(state: "closed")
18
19
  signals.each(&:close!)
19
20
  head :ok
20
21
  end
@@ -14,10 +14,10 @@ module Signum
14
14
  broadcast! if can_broadcast?
15
15
 
16
16
  broadcast_prepend_to(:signals, target: Signum.config.balloon_notifications_container_id.call(key || signalable),
17
- html: ApplicationController.render(Signum::Notification::Component.new(self)))
17
+ html: ActionController::Base.render(Signum::Notification::Component.new(self)))
18
18
 
19
19
  broadcast_prepend_to(:signals, target: Signum.config.drawer_notifications_container_id.call(key || signalable),
20
- html: ApplicationController.render(Signum::NotificationDrawerItem::Component.new(signal: self)))
20
+ html: ActionController::Base.render(Signum::NotificationDrawerItem::Component.new(signal: self)))
21
21
  end
22
22
 
23
23
  def broadcast_update
@@ -29,9 +29,9 @@ module Signum
29
29
  end
30
30
 
31
31
  broadcast_replace_to(:signals, target: Signum.config.notification_body_id.call(:balloon, self),
32
- html: ApplicationController.render(Signum::NotificationBody::Component.new(self, {type: :balloon, timeout: 5})))
32
+ html: ActionController::Base.render(Signum::NotificationBody::Component.new(self, {type: :balloon, timeout: 5})))
33
33
  broadcast_replace_to(:signals, target: Signum.config.notification_body_id.call(:drawer_item, self),
34
- html: ApplicationController.render(Signum::NotificationBody::Component.new(self, {type: :drawer_item, timeout: 5})))
34
+ html: ActionController::Base.render(Signum::NotificationBody::Component.new(self, {type: :drawer_item, timeout: 5})))
35
35
  end
36
36
 
37
37
  validates :text, presence: true
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Signum.setup do |config|
4
+ config.base_controller = "::ApplicationController"
5
+ config.admin_authentication_module = "Authenticated"
4
6
  config.hide_after = 60_000 if Rails.env.test?
5
7
  config.current_user = -> { Current.user }
6
8
  config.drawer_notifications_container_id = -> { "drawer_notifications_#{Current.user.id}" }
@@ -32,9 +32,7 @@ module Signum
32
32
  option :user_model_name, default: "User"
33
33
  option :hide_after, default: 3000
34
34
  option :base_controller, default: "::ApplicationController"
35
- option :base_service, default: "::ApplicationService"
36
- option :base_service_context, default: "::ApplicationContext"
37
- option :current_user, default: -> {}
35
+ option :current_user, default: lambda {}
38
36
  option :drawer_notifications_container_id, default: ->(signalable = nil) {
39
37
  signalable.is_a?(String) ? "drawer_notifications_#{signalable}" : "drawer_notifications_#{(signalable || Signum.config.current_user.call)&.class&.name}_#{(signalable || Signum.config.current_user.call)&.id}"
40
38
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Signum
4
- VERSION = "0.7.6"
4
+ VERSION = "0.7.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-17 00:00:00.000000000 Z
11
+ date: 2024-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -242,7 +242,6 @@ files:
242
242
  - app/components/signum/notification_drawer_item/component_controller.js
243
243
  - app/components/signum/notifications/component.html.slim
244
244
  - app/components/signum/notifications/component.rb
245
- - app/controllers/signum/api_controller.rb
246
245
  - app/controllers/signum/application_controller.rb
247
246
  - app/controllers/signum/signal_controller.rb
248
247
  - app/helpers/signum/application_helper.rb
@@ -1,4 +0,0 @@
1
- module Signum
2
- class ApiController < ActionController::API
3
- end
4
- end