-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into save-fixed-attributes
- Loading branch information
Showing
23 changed files
with
1,729 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 49 additions & 45 deletions
94
apps/dashboard/app/controllers/batch_connect/settings_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
# The controller to manage BatchConnect saved settings | ||
class BatchConnect::SettingsController < ApplicationController | ||
include BatchConnectConcern | ||
include UserSettingStore | ||
|
||
# GET /batch_connect/<app_token>/settings/<settings_name> | ||
def show | ||
set_app_groups | ||
set_saved_settings | ||
|
||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
settings_values = bc_templates(app_token)[settings_name.to_sym] | ||
if settings_values.nil? | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
alert: t('dashboard.bc_saved_settings.missing_settings') | ||
return | ||
module BatchConnect | ||
class SettingsController < ApplicationController | ||
include BatchConnectConcern | ||
include UserSettingStore | ||
|
||
# GET /batch_connect/<app_token>/settings/<settings_name> | ||
def show | ||
set_app_groups | ||
set_saved_settings | ||
|
||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
settings_values = bc_templates(app_token)[settings_name.to_sym] | ||
if settings_values.nil? | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
alert: t('dashboard.bc_saved_settings.missing_settings') | ||
return | ||
end | ||
|
||
@settings = BatchConnect::Settings.new(app_token, settings_name, settings_values) | ||
if @settings.outdated? | ||
flash.now[:alert] = t('dashboard.bc_saved_settings.outdated_message', app_title: @settings.app.title) | ||
end | ||
end | ||
|
||
@settings = BatchConnect::Settings.new(app_token, settings_name, settings_values) | ||
if @settings.outdated? | ||
flash.now[:alert] = t('dashboard.bc_saved_settings.outdated_message', app_title: @settings.app.title) | ||
# DELETE /batch_connect/<app_token>/settings/<settings_name> | ||
def destroy | ||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
delete_bc_template(app_token, settings_name) | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
notice: t('dashboard.bc_saved_settings.deleted_message', settings_name: settings_name) | ||
end | ||
end | ||
|
||
# DELETE /batch_connect/<app_token>/settings/<settings_name> | ||
def destroy | ||
request_params = settings_request_params | ||
app_token = request_params[:token] | ||
settings_name = request_params[:id] | ||
delete_bc_template(app_token, settings_name) | ||
redirect_to new_batch_connect_session_context_path(token: app_token), | ||
notice: t('dashboard.bc_saved_settings.deleted_message', settings_name: settings_name) | ||
end | ||
|
||
private | ||
private | ||
|
||
def settings_request_params | ||
params.permit(:token, :id) | ||
end | ||
def settings_request_params | ||
params.permit(:token, :id) | ||
end | ||
|
||
# Set the all the saved settings to render the navigation | ||
def set_saved_settings | ||
@bc_saved_settings = all_bc_templates | ||
end | ||
# Set the all the saved settings to render the navigation | ||
def set_saved_settings | ||
@bc_saved_settings = all_bc_templates | ||
end | ||
|
||
# Set list of app lists for navigation | ||
def set_app_groups | ||
@sys_app_groups = bc_sys_app_groups | ||
@usr_app_groups = bc_usr_app_groups | ||
@dev_app_groups = bc_dev_app_groups | ||
@apps_menu_group = bc_custom_apps_group | ||
# Set list of app lists for navigation | ||
def set_app_groups | ||
@sys_app_groups = bc_sys_app_groups | ||
@usr_app_groups = bc_usr_app_groups | ||
@dev_app_groups = bc_dev_app_groups | ||
@apps_menu_group = bc_custom_apps_group | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { makeChangeHandlers } from './dynamic_forms'; | ||
|
||
jQuery(function() { | ||
makeChangeHandlers('script'); | ||
makeChangeHandlers('launcher'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
module ClusterCache | ||
def cluster_options | ||
Rails.cache.fetch('script_cluster_options', expires_in: 4.hours) do | ||
max_cores_map = cluster_max_cores | ||
batch_clusters.map do |cluster| | ||
options = if max_cores_map[cluster.id] | ||
{ 'data-max-auto-cores': max_cores_map[cluster.id] } | ||
else | ||
{} | ||
end | ||
[cluster.id.to_s, cluster.id.to_s, options] | ||
end.sort_by { |option| option[0] } | ||
end | ||
end | ||
|
||
def cluster_nodes | ||
Rails.cache.fetch('script_cluster_nodes', expires_in: 4.hours) do | ||
{}.tap do |hash| | ||
batch_clusters.map do |cluster| | ||
hash[cluster.id] = cluster.job_adapter.nodes if cluster.slurm? | ||
end | ||
end | ||
end | ||
end | ||
|
||
def cluster_max_cores | ||
Rails.cache.fetch('script_cluster_max_values', exipres_in: 4.hours) do | ||
{}.tap do |hash| | ||
cluster_nodes.each do |cluster_id, nodes| | ||
max_node = nodes.max { |a, b| a.procs <=> b.procs } | ||
hash[cluster_id] = max_node.procs if max_node | ||
end | ||
end | ||
end | ||
end | ||
|
||
def batch_clusters | ||
Rails.cache.fetch('script_batch_clusters', expires_in: 4.hours) do | ||
Configuration.job_clusters.reject do |c| | ||
reject_cluster?(c) | ||
end | ||
end | ||
end | ||
|
||
def reject_cluster?(cluster) | ||
cluster.kubernetes? || cluster.linux_host? || cluster.systemd? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.