diff --git a/app/controllers/dataset_controller.rb b/app/controllers/dataset_controller.rb index 53601074b18330fbf89bdc166f0a21f4ab0089ec..e3d41a120097fdbf67390fe80a1305d2ea28fdf7 100644 --- a/app/controllers/dataset_controller.rb +++ b/app/controllers/dataset_controller.rb @@ -130,7 +130,7 @@ class DatasetController < ApplicationController message = "

#{@nb_added_docs} document#{@nb_added_docs > 1 ? "s were" : " was"} added to your dataset.

" message.concat "

#{existing.size} document#{existing.size > 1 ? "s" : ""} already exist in this dataset.

" unless existing.empty? # render partial: "shared/notification", locals: {notif_title: title, notif_content: message.html_safe} - out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } + out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe, notif_autohide: "true" } out["nbissues"] = dataset.documents.select { |d| d["type"] == "issue" }.size out["nbarticles"] = dataset.documents.select { |d| d["type"] == "article" }.size out["nbdocs"] = out["nbissues"] + out["nbarticles"] @@ -145,7 +145,7 @@ class DatasetController < ApplicationController existing = dataset.add_compound params[:compound_id] # Add docs and return existing ids title = dataset.title message = "

The compound article was added to your dataset.

" - out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } + out["notif"] = render_to_string layout: false, partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe, notif_autohide: "true" } out["nbissues"] = dataset.documents.select { |d| d["type"] == "issue" }.size out["nbarticles"] = dataset.documents.select { |d| d["type"] == "article" }.size out["nbcompounds"] = dataset.documents.select { |d| d["type"] == "compound" }.size @@ -164,21 +164,27 @@ class DatasetController < ApplicationController end def add_all_documents - SearchToDatasetWorker.perform_async(current_user.id, session[:working_dataset], params[:search_params].to_unsafe_h) + time = Time.now.to_i + SearchToDatasetWorker.perform_async(current_user.id, session[:working_dataset], params[:search_params].to_unsafe_h, time) title = Dataset.find(session[:working_dataset]).title message = "

Documents are being added to your dataset.

-
+
0%
" - render partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } + render partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe, notif_autohide: "false" } end def export_dataset - ExportDatasetWorker.perform_async(current_user.id, params[:dataset_id], params[:export_type]) + time = Time.now.to_i + ExportDatasetWorker.perform_async(current_user.id, params[:dataset_id], params[:export_type], time) title = Dataset.find(params[:dataset_id]).title - message = "

The export is being prepared. You will be notified when the operation is done.

" - render partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe } + message = "

The export is being prepared.

+
+
0%
+
+
" + render partial: "shared/notification", locals: { notif_title: title, notif_content: message.html_safe, notif_autohide: "false" } end def toggle_sharing_status diff --git a/app/javascript/channels/notification_channel.js b/app/javascript/channels/notification_channel.js index 7b32a094d08d496133393e1f3ffd66c1196de22e..031fd2e0092a46629c652d72d6a82675c407e632 100644 --- a/app/javascript/channels/notification_channel.js +++ b/app/javascript/channels/notification_channel.js @@ -41,11 +41,15 @@ consumer.subscriptions.create("NotificationChannel", { progress_bar.attr("aria-valuenow", data.completion) progress_bar.html(`${data.completion}%`) } - if(window.location.pathname.endsWith("/search")) { - const progress_bar = $("#progress-".concat(data.dataset_id)).find('.progress-bar') + if(window.location.pathname.endsWith("/search") || window.location.pathname.endsWith("/dataset/".concat(data.dataset_id))) { + const progress_bar = $("#progress-".concat(data.dataset_id).concat(data.time)).find('.progress-bar') progress_bar.attr("style", `width: ${data.completion}%;`) progress_bar.attr("aria-valuenow", data.completion) progress_bar.html(`${data.completion}%`) + + if(data.completion == 100) { + progress_bar.closest(".toast").hide(2000); + } } break case "experiment_finished": diff --git a/app/views/dataset/add_documents.js.erb b/app/views/dataset/add_documents.js.erb index de326e7676531a3a24a3f98d9a9db52d5f58cf19..6bfb328805f051b9477899fd1f330188b2122118 100644 --- a/app/views/dataset/add_documents.js.erb +++ b/app/views/dataset/add_documents.js.erb @@ -2,7 +2,8 @@ $("#notifications").append("<%= j render(partial: "shared/notification", locals: { notif_title: "Dataset modified", - notif_content: content + notif_content: content, + notif_autohide: "true" }) %>") for(const notif of $('.toast')) { diff --git a/app/views/dataset/set_working_dataset.js.erb b/app/views/dataset/set_working_dataset.js.erb index 877d6fbe60edb9be6eae06f95ea486cbf5537d20..b0a2f4ea1454fbc91fbdb8b46f2da2f817da4e01 100644 --- a/app/views/dataset/set_working_dataset.js.erb +++ b/app/views/dataset/set_working_dataset.js.erb @@ -2,7 +2,8 @@ $("#notifications").append("<%= j render(partial: "shared/notification", locals: { notif_title: "Working dataset", - notif_content: content + notif_content: content, + notif_autohide: "true" }) %>") for(let notif of $('.toast')) { diff --git a/app/views/shared/_notification.html.erb b/app/views/shared/_notification.html.erb index 00ff70781a48ce4e57a46f6a9a22fa6df672c0a4..9bdd00d31940cad691955166b052eeed48a96c4c 100644 --- a/app/views/shared/_notification.html.erb +++ b/app/views/shared/_notification.html.erb @@ -1,4 +1,4 @@ -