lato 3.18.1 → 3.19.0

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: 0e61b931ff0b3fe86aa8c722e1ca3b016be7799e935d072979de181a4e025b89
4
- data.tar.gz: 487f4fc01d7f58be47a74556498922f05230869998d91cfb95459d766746d118
3
+ metadata.gz: 3e9bc22ce3f30979695df7a71d397d319eae7b5ac80a5b28d4581a2fa959efe5
4
+ data.tar.gz: 9616d1b12c930765ae3c00a1fbcc813c37310193a776cee7ee7d2c469779e3e2
5
5
  SHA512:
6
- metadata.gz: f82274922dc305b1e19a506b7958fd0c89dbb52ad00923bb1b9d1e72b16002a6f8e71bac6b4fde9f1af4ae4eb56884be3056b3ac5e99a735b9ecfb4fbb5a3acb
7
- data.tar.gz: c8db5342fd6e9aa26b298ac91a9ed939907e8b02499603b4e5b2359f3b1cb9c891028d7f7d344c858f07cce16e9275c33a2de16c94538591db5a6b7fa5481737
6
+ metadata.gz: 93f49738ee88b189cc814d2dba9221a6602ec667a8db504535668481b710eb59a0f663d015a833113d2dd56872719651eae789aa83af7e705cd204e5978f849d
7
+ data.tar.gz: f6eff2ccfce2088fb82a968d8688fde484824f3c05ec8331ffbd9fb2a83d6bd5ce66c210a4785421c29a2258ee9d20e1b0cdbd6f2b2581d6a8e2765aa2b1009b
data/README.md CHANGED
@@ -121,6 +121,17 @@ rails lato:generate:favicon
121
121
  rails lato:generate:pwa
122
122
  ```
123
123
 
124
+ ## Upgrading
125
+
126
+ To upgrade Lato to the latest version, run the following commands:
127
+
128
+ ```bash
129
+ bundle update lato
130
+ rails lato:install:application
131
+ rails lato:install:migrations
132
+ rails db:migrate
133
+ ```
134
+
124
135
  ## Development
125
136
 
126
137
  Clone repository, install dependencies, run migrations and start:
@@ -24,6 +24,36 @@ module Lato
24
24
  )
25
25
  end
26
26
 
27
+ # This method can be used to add a log message to the operation.
28
+ def add_operation_log(message)
29
+ return false unless operation?
30
+
31
+ @operation.update(
32
+ logs: @operation.logs + [[Time.now.utc, message]]
33
+ )
34
+ end
35
+
36
+ # This method can be used to replace a log message to the operation.
37
+ def replace_operation_log(message, index = -1)
38
+ return false unless operation?
39
+
40
+ logs = @operation.logs
41
+ index = 0 if logs.empty?
42
+ logs[index] = [Time.now.utc, message]
43
+ @operation.update(
44
+ logs: logs
45
+ )
46
+ end
47
+
48
+ # This method can be used to clear all logs of the operation.
49
+ def clear_operation_logs
50
+ return false unless operation?
51
+
52
+ @operation.update(
53
+ logs: []
54
+ )
55
+ end
56
+
27
57
  # This method can be used to save a file as output of the operation.
28
58
  def save_operation_output_file(file_path)
29
59
  return false unless operation?
@@ -43,8 +73,15 @@ module Lato
43
73
  @operation.update(
44
74
  active_job_output: @operation.active_job_output.merge(_message: message)
45
75
  )
76
+ end
77
+
78
+ # This method can be used to save an action as output of the operation.
79
+ def save_operation_output_action(label, href, attributes = {})
80
+ return false unless operation?
46
81
 
47
- true
82
+ @operation.update(
83
+ active_job_output: @operation.active_job_output.merge(_action: { label: label, href: href, attributes: attributes })
84
+ )
48
85
  end
49
86
 
50
87
  private
@@ -25,6 +25,7 @@ module Lato
25
25
 
26
26
  before_create do
27
27
  self.status = :created
28
+ self.logs ||= []
28
29
  self.active_job_input ||= {}
29
30
  self.active_job_output ||= {}
30
31
  end
@@ -40,6 +41,10 @@ module Lato
40
41
  active_job_output && !active_job_output['_message'].blank?
41
42
  end
42
43
 
44
+ def output_action?
45
+ active_job_output && !active_job_output['_action'].blank?
46
+ end
47
+
43
48
  def output_error?
44
49
  active_job_output && !active_job_output['_error'].blank?
45
50
  end
@@ -59,6 +64,10 @@ module Lato
59
64
  active_job_output['_message']
60
65
  end
61
66
 
67
+ def output_action
68
+ active_job_output['_action']
69
+ end
70
+
62
71
  # Operations
63
72
  ##
64
73
 
@@ -14,6 +14,7 @@
14
14
  <div class="text-center">
15
15
  <h2><%= I18n.t('lato.operation_title') %></h2>
16
16
  <p><%= I18n.t('lato.operation_subtitle') %></p>
17
+
17
18
  <% if operation.percentage.nil? %>
18
19
  <div class="progress" style="height: 20px;">
19
20
  <div class="progress-bar progress-bar-animated progress-bar-striped bg-primary" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
@@ -43,6 +44,12 @@
43
44
  <%= operation.output_message %>
44
45
  </p>
45
46
  <% end %>
47
+
48
+ <% if operation.output_action? %>
49
+ <div class="mt-3 d-flex justify-content-center">
50
+ <%= link_to operation.output_action['label'], operation.output_action['href'], { class: 'btn btn-primary' }.merge(operation.output_action['attributes']) %>
51
+ </div>
52
+ <% end %>
46
53
  </div>
47
54
  <% end %>
48
55
 
@@ -61,6 +68,19 @@
61
68
  </div>
62
69
  <% end %>
63
70
 
71
+ <% if operation.logs&.any? %>
72
+ <div class="mt-4">
73
+ <div class="border rounded p-3 bg-light" style="max-height: 300px; overflow-y: auto;">
74
+ <% operation.logs.reverse.each do |log| %>
75
+ <div class="mb-2 pb-2 border-bottom d-flex justify-content-between align-items-center">
76
+ <p class="mb-0"><%= log[1] %></p>
77
+ <small class="text-muted ms-2"><%= I18n.l(Time.parse(log[0]), format: '%H:%M:%S') %></small>
78
+ </div>
79
+ <% end %>
80
+ </div>
81
+ </div>
82
+ <% end %>
83
+
64
84
  <% unless operation.finished? %>
65
85
  <%= link_to '', lato.operation_path(operation), class: 'd-none', data: { lato_operation_target: 'update', turbo_frame: '_self' } %>
66
86
  <% end %>
@@ -0,0 +1,5 @@
1
+ class AddLogsOnLatoOperation < ActiveRecord::Migration[8.1]
2
+ def change
3
+ add_column :lato_operations, :logs, :json
4
+ end
5
+ end
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "3.18.1"
2
+ VERSION = "3.19.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.18.1
4
+ version: 3.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-18 00:00:00.000000000 Z
11
+ date: 2025-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -296,6 +296,7 @@ files:
296
296
  - db/migrate/20240222171418_add_indexes_on_lato_users_email.rb
297
297
  - db/migrate/20240318074025_add_authenticator_secret_to_user.rb
298
298
  - db/migrate/20251206170443_add_webauthn_id_to_user.rb
299
+ - db/migrate/20251218192614_add_logs_on_lato_operation.rb
299
300
  - lib/lato.rb
300
301
  - lib/lato/btstrap.rb
301
302
  - lib/lato/config.rb