Skip to content

Commit

Permalink
success
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Dec 6, 2023
1 parent 0be6af9 commit fd98702
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/work-design/rails_com.git
revision: b719f7e862907c1717ab3643fe20706f86cd652d
revision: 9b7d865b7436e7a12f458398ac6c9969c3562f15
specs:
rails_com (1.3.0)
acme-client
Expand All @@ -18,14 +18,14 @@ GIT

GIT
remote: https://github.com/work-design/rails_design.git
revision: d564b9906a7d1942300ebf91e1329643c46c72a4
revision: 2c9a09d68bb237b99a78dc83817310ddf0f4ce1a
specs:
rails_design (0.0.1)
rails

GIT
remote: https://github.com/work-design/rails_extend.git
revision: e2c0b14dc046c5173c7e4f2c63abafa116bb5614
revision: d7f6c61e28fbc3a9a8b9e536e5c5bc0e6b58c791
specs:
rails_extend (1.0.1)
rails (>= 5.0)
Expand Down
2 changes: 1 addition & 1 deletion app/channels/datum/done_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Datum
class DoneChannel < ApplicationCable::Channel

def subscribed
stream_from "done:#{current_receiver.class.base_class.name}:#{current_receiver.id}" if current_receiver
stream_from "datum:done:#{verified_receiver.identity}"
end

def unsubscribed
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/datum/panel/table_lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def pdf
end

def run
@table_list.run_later
@table_list.run_later(current_authorized_token.identity)
end

private
Expand Down
6 changes: 2 additions & 4 deletions app/jobs/datum/table_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ module Datum
class TableJob < ApplicationJob
queue_as :default

def perform(table_list)
table_list.run

ActionCable.server.broadcast "", body: '<i class="green checkmark icon"></i>', done_id: table_list.id
def perform(table_list, identifier)
table_list.run(identifier)
end

end
Expand Down
16 changes: 13 additions & 3 deletions app/models/datum/model/table_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,28 @@ module Model::TableList
has_one_attached :file
end

def run
def run(identifier = nil)
clear_old
if data_list.is_a? DataImport
runner = Importer.new(self)
else
runner = CacheExporter.new(self)
end
runner.run
notify_done(identifier)
end

def run_later
TableJob.perform_later(self)
def notify_done(identifier)
content = ApplicationController.render(
formats: [:turbo_stream],
partial: 'datum/panel/table_lists/done_success',
locals: { model: self }
)
DoneChannel.broadcast_to identifier, content
end

def run_later(identifier)
TableJob.perform_later(self, identifier)
end

def convert_parameters
Expand Down
4 changes: 2 additions & 2 deletions app/views/datum/panel/table_lists/_base/_index_tbody.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<td><%= model.timestamp %></td>
<td id="done_<%= model.id %>">
<% if model.done %>
<i class="fa-solid fa-check"></i>
<i class="fa-solid fa-check has-text-success"></i>
<% else %>
<i class="fa-solid fa-times"></i>
<i class="fa-solid fa-times has-text-danger"></i>
<% end %>
</td>
1 change: 1 addition & 0 deletions app/views/datum/panel/table_lists/_done_success.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<i class="fa-solid fa-check has-text-success"></i>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= turbo_stream.update "done_#{model.id}", partial: 'datum/panel/table_lists/done_success' %>
2 changes: 1 addition & 1 deletion app/views/datum/panel/table_lists/_run/_process.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<progress class="progress is-primary" max="100">15%</progress>
<progress data-controller="done" max="100" class="progress is-primary">15%</progress>

0 comments on commit fd98702

Please sign in to comment.