signum 0.7.6 → 0.7.8

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: b1a703dbf5da5ca31e1275493f067a917802fb4caa606a6697e7fc64a62bbefa
4
+ data.tar.gz: f00fb2a6e2ea3639c5b2237498e0e2ba67bb421f230a7ef1d719653d4c083e23
5
5
  SHA512:
6
- metadata.gz: 75ebff55bdbf08eda7f36c1f1a27d3c78414412089a197b171e454c618be103c44ff17c2119912981131f31a0ccf96e3298c3eabe65cbc0be39dcaea879f4d6b
7
- data.tar.gz: 9cab86de0a234c0bd94f3a819b64899bf0f735963afcd641f7e482b18cbfd96f8066794e37de5311bd09c985de2189ce0dc7a745bd9d26f0c08e8eed785de3f9
6
+ metadata.gz: 810b2c5ebf4a0d36053780454cb1b5f2bac99fa81a5bf6d4b96d3f5fd7e9563428b7640cae4b10d4f7626e2683bdfe7f64630e26310d8b042a7c1e2cb4c8639f
7
+ data.tar.gz: 66e80f730d6c3ad91097c613742e51ed8f3809b2b2c55792b115732e18edab27ca9ac38666ff7e60fba48a249ba63aa9b16f87a43ae8bac9619f29c08495ee8f
@@ -2,95 +2,94 @@
2
2
  @apply flex flex-col w-full divide-y;
3
3
 
4
4
  &__mb {
5
- // main body
5
+ /* main body */
6
6
  @apply flex basis-full divide-x;
7
7
 
8
8
  &__bc {
9
- //body container
9
+ /* body container */
10
10
  @apply flex grow py-4 px-2 overflow-hidden;
11
11
 
12
12
  &__ic {
13
- //icon container
13
+ /* icon container */
14
14
  @apply grow-0 pl-2 pr-3;
15
-
16
- svg.info
17
- {
18
- //icon info
19
- @apply text-sky-400;
20
- }
21
15
 
22
- svg.success{
23
- //icon success
24
- @apply text-green-400;
25
- }
16
+ svg.info {
17
+ /* icon info */
18
+ @apply text-sky-400;
19
+ }
26
20
 
27
- svg.error{
28
- //icon error
29
- @apply text-red-400;
30
- }
21
+ svg.success {
22
+ /* icon success */
23
+ @apply text-green-400;
24
+ }
31
25
 
32
- svg.warning{
33
- //icon warning
34
- @apply text-orange-400;
26
+ svg.error {
27
+ /* icon error */
28
+ @apply text-red-400;
29
+ }
30
+
31
+ svg.warning {
32
+ /* icon warning */
33
+ @apply text-orange-400;
34
+ }
35
35
  }
36
- }
37
36
 
38
37
  &__mc {
39
- //main container
38
+ /* main container */
40
39
  @apply grow text-left break-words overflow-hidden;
41
40
 
42
41
  &__ti {
43
- // title
42
+ /* title */
44
43
  @apply text-[0.81rem] font-medium text-gray-900;
45
44
  }
46
45
 
47
46
  &__tx {
48
- //text
47
+ /* text */
49
48
  @apply text-xs text-gray-500 mt-1;
50
49
  }
51
50
 
52
51
  &__lkc {
53
- //links container
52
+ /* links container */
54
53
  @apply flex flex-wrap mt-3;
55
54
 
56
55
  &__lk {
57
- //link
56
+ /* link */
58
57
  @apply rounded-md text-xs font-medium text-gray-700 hover:text-gray-500 focus:outline-none mr-2;
59
58
  }
60
59
  }
61
60
 
62
61
  &__attc {
63
- //attachments links container
62
+ /* attachments links container */
64
63
  @apply flex flex-wrap mt-3;
65
64
 
66
65
  &__att {
67
- //attachment link
66
+ /* attachment link */
68
67
  @apply rounded-md text-xs font-medium text-gray-700 hover:text-gray-500 focus:outline-none mr-2;
69
68
  }
70
69
  }
71
70
  }
72
71
 
73
72
  &__bcc {
74
- //close button container
73
+ /* close button container */
75
74
  @apply grow-0 m-1;
76
75
 
77
76
  &__b {
78
- //button
77
+ /* button */
79
78
  @apply text-gray-400 hover:text-gray-500 cursor-pointer;
80
79
  }
81
80
  }
82
81
  }
83
82
 
84
83
  &__bmc {
85
- //buttons main container
84
+ /* buttons main container */
86
85
  @apply flex grow-0 flex-col divide-y divide-gray-200;
87
86
 
88
87
  &__bc {
89
- //buttons container
88
+ /* buttons container */
90
89
  @apply flex flex-1;
91
90
 
92
91
  &__b {
93
- //button
92
+ /* button */
94
93
  @apply flex w-full items-center justify-center text-xs font-medium text-gray-700 hover:text-gray-500 focus:outline-none px-4 py-3;
95
94
  }
96
95
  }
@@ -98,7 +97,7 @@
98
97
  }
99
98
 
100
99
  &__pbc {
101
- //progress bar container
100
+ /* progress bar container */
102
101
  @apply basis-full p-1;
103
102
  }
104
103
  }
@@ -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.8"
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.8
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-06-23 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