Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a smart attribute for automatically loading modules (#1930)
Add a smart attribute for automatically loading modules in the form: "auto_modules_#{app_name}" where app_name is something like matlab or jupyter. These are also cluster aware meaning they'll hide & show if dynamic bc js is enabled.
- Loading branch information
Showing
10 changed files
with
148 additions
and
19 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
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
40 changes: 40 additions & 0 deletions
40
apps/dashboard/lib/smart_attributes/attributes/auto_modules.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
module SmartAttributes | ||
class AttributeFactory | ||
# Build this attribute object with defined options | ||
# @param opts [Hash] attribute's options | ||
# @return [Attributes::AutoModules] the attribute object | ||
def self.build_auto_modules(opts = {}) | ||
Attributes::AutoModules.new('auto_modules', opts) | ||
end | ||
end | ||
|
||
module Attributes | ||
# AutoModules populates a select widget of modules from HpcModule class | ||
# that is cluster aware. Meaning it will attach data-option-for-cluster-X | ||
# attributes to the options. | ||
class AutoModules < Attribute | ||
def initialize(id, opts = {}) | ||
super | ||
|
||
@hpc_module = @opts[:module] | ||
@id = "#{id}_#{@hpc_module}" # reset the id to be unique from other auto_module_* | ||
end | ||
|
||
def widget | ||
'select' | ||
end | ||
|
||
def select_choices | ||
HpcModule.all_versions(@hpc_module).map do |mod| | ||
data_opts = Configuration.job_clusters.map do |cluster| | ||
{ "data-option-for-cluster-#{cluster.id}": false } unless mod.on_cluster?(cluster.id) | ||
end.compact | ||
|
||
[mod.version, mod.version].concat(data_opts) | ||
end | ||
end | ||
end | ||
end | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -140,3 +140,5 @@ form: | |
- classroom | ||
- classroom_size | ||
- advanced_options | ||
- auto_modules_app_jupyter | ||
- auto_modules_intel |
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