-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pm job management #3899
Pm job management #3899
Changes from 10 commits
12ac653
ae7d979
8dcbb56
dc09e18
866909a
90acf35
ef811af
77f4355
6a3cb34
815fbb9
8ed04a7
bee998d
152333a
1797a92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,45 @@ def job_details | |
|
||
hpc_job = project.job(job_details_params[:jobid].to_s, cluster_str) | ||
|
||
render(partial: 'job_details', locals: { job: hpc_job }) | ||
@project = project | ||
|
||
render(partial: 'job_details', locals: { job: hpc_job, project: @project }) | ||
end | ||
|
||
# DELETE /projects/:project_id/jobs/:cluster/:jobid | ||
def delete_job | ||
@project = Project.find(job_details_params[:project_id]) | ||
|
||
cluster_str = job_details_params[:cluster].to_s | ||
|
||
@project.remove_logged_job(job_details_params[:jobid].to_s, cluster_str) | ||
|
||
@valid_project = Launcher.clusters? | ||
@valid_scripts = Launcher.scripts?(@project.directory) | ||
@scripts = Launcher.all(@project.directory) | ||
|
||
render :show | ||
end | ||
|
||
# POST /projects/:project_id/jobs/:cluster/:jobid/stop | ||
def stop_job | ||
@project = Project.find(job_details_params[:project_id]) | ||
cluster_str = job_details_params[:cluster].to_s | ||
cluster = OodAppkit.clusters[cluster_str.to_sym] | ||
|
||
hpc_job = @project.job(job_details_params[:jobid].to_s, cluster_str) | ||
|
||
begin | ||
cluster.job_adapter.delete(job_details_params[:jobid].to_s) unless hpc_job.status.to_s == 'completed' | ||
rescue StandardError => e | ||
flash.now[:alert] = I18n.t('dashboard.jobs_project_generic_error', error: e.message.to_s) | ||
end | ||
|
||
@valid_project = Launcher.clusters? | ||
@valid_scripts = Launcher.scripts?(@project.directory) | ||
@scripts = Launcher.all(@project.directory) | ||
|
||
render :show | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar comment to above, I think we should redirect instead of creating all these objects all over again. Also seems like you need a |
||
end | ||
|
||
private | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these destructive buttons need an alert confirmation. All you need to do is add a data-confirm attribute with some string. Here I just pulled a random confirm localized string. You could make a new one or use this, I'm sort of ambivalent on that. diff --git a/apps/dashboard/app/views/projects/buttons/_completed_buttons.html.erb b/apps/dashboard/app/views/projects/buttons/_completed_buttons.html.erb
index 7d09e06fe..0df5fa971 100644
--- a/apps/dashboard/app/views/projects/buttons/_completed_buttons.html.erb
+++ b/apps/dashboard/app/views/projects/buttons/_completed_buttons.html.erb
@@ -2,5 +2,6 @@
'Delete',
project_delete_job_path(project_id: project_id, cluster: cluster, jobid: id),
method: :delete,
+ data: { confirm: t('dashboard.batch_connect_sessions_delete_confirm') },
class: 'btn btn-danger'
) %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= button_to( | ||
'Delete', | ||
project_delete_job_path(project_id: project_id, cluster: cluster, jobid: id), | ||
method: :delete, | ||
class: 'btn btn-danger' | ||
) %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= button_to( | ||
'Stop', | ||
project_stop_job_path(project_id: project_id, cluster: cluster, jobid: id), | ||
method: :post, | ||
class: 'btn btn-danger' | ||
) %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= button_to( | ||
'Stop', | ||
project_stop_job_path(project_id: project_id, cluster: cluster, jobid: id), | ||
method: :post, | ||
class: 'btn btn-danger' | ||
) %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should follow a pattern here where
remove_logged_job
returnstrue
orfalse
based on whether the operation was successful. Then the controller toggles based off of that.Like say how
update
,destroy
,create
or works in this same controller. I think redirecting here is fine (so that we don't have to create/recreate those attributes), it just seems like the toggle is redirect with a notice when successful or an alert for a failure.