foreman-katello-engine 0.0.14 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,44 +23,32 @@ module ForemanKatelloEngine
23
23
  end
24
24
  end
25
25
 
26
- def envs_by_kt_env(envs)
27
- envs.group_by do |env|
28
- env.katello_id.split('/')[1]
29
- end
30
- end
31
-
32
- def envs_without_kt_org
33
- envs_without_kt_org = ::Environment.all.reject(&:katello_id)
34
- end
35
-
36
- def envs_without_kt_org_options
37
- options_from_collection_for_select(envs_without_kt_org,
38
- :id,
39
- :to_label,
40
- (@host || @hostgroup).environment_id)
41
- end
42
-
43
26
  def grouped_env_options
44
- envs_by_org = envs_by_kt_org.reduce({}) do |hash, (org, envs)|
45
- hash.update(org => envs_by_kt_env(envs))
46
- end
47
- grouped_options = envs_by_org.sort_by(&:first).map do |org, envs_by_env|
48
- optgroup = %[<optgroup label="#{org}">]
49
- opts = envs_by_env.sort_by(&:first).map do |kt_env, envs|
50
- envs.sort_by(&:katello_id).map do |env|
51
- selected = env.id == (@host || @hostgroup).environment_id ? "selected" : ""
52
- if cv = env.katello_id.split('/')[2]
53
- %[<option value="#{env.id}" class="kt-cv" #{selected}>#{cv}</option>]
54
- else
55
- %[<option value="#{env.id}" class="kt-env" #{selected}>#{kt_env}</option>]
56
- end
57
- end.join
27
+ grouped_options = envs_by_kt_org.sort_by(&:first).map do |kt_org_label, envs_by_org|
28
+ optgroup = %[<optgroup label="#{kt_org_label}">]
29
+ opts = envs_by_org.sort_by(&:katello_id).reduce({}) do |env_options, env|
30
+ selected = env.id == (@host || @hostgroup).environment_id ? "selected" : nil
31
+ kt_env_label = env.katello_id.split('/')[1]
32
+ env_options[kt_env_label] ||= selected
33
+ env_options
34
+ end.sort_by(&:first).map do |kt_env_label, selected|
35
+ %[<option value="#{kt_org_label}/#{kt_env_label}" class="kt-env" #{selected}>#{kt_env_label}</option>]
58
36
  end.join
59
37
  optgroup << opts
60
38
  optgroup << '</optgroup>'
61
39
  end.join
40
+ grouped_options.insert(0, %[<option value=""></option>])
41
+ grouped_options.html_safe
42
+ end
43
+
44
+ def content_view_options
45
+ cv_options = ::Environment.order(:katello_id).all.map do |env|
46
+ selected = env.id == (@host || @hostgroup).environment_id ? "selected" : ""
47
+ env_text = env.katello_id ? env.katello_id.split('/')[2] : env.name
48
+ %[<option value="#{env.id}" data-katello-id="#{env.katello_id}" #{selected}>#{env_text}</option>]
49
+ end.join
62
50
 
63
- return grouped_options.html_safe + envs_without_kt_org_options
51
+ return cv_options.html_safe
64
52
  end
65
53
 
66
54
  end
@@ -3,9 +3,48 @@
3
3
  option.kt-cv { margin-left: 1em; }
4
4
  </style>
5
5
 
6
- <%= field(f, :environment_id, {:include_blank => true}) do
6
+ <script>
7
+ $(function () {
8
+ function ktUpdateContentViews() {
9
+ var ktEnvId = $("#kt_environment_id").val();
10
+ var cvSelect = $("#hostgroup_environment_id");
11
+ if(cvSelect.length == 0) {
12
+ cvSelect = $("#host_environment_id");
13
+ }
14
+ cvSelect.children("option").each(function (i, option) {
15
+ var option = $(option);
16
+ var display = false
17
+ if(ktEnvId &&
18
+ option.attr('data-katello-id') &&
19
+ option.attr('data-katello-id').indexOf(ktEnvId) == 0) {
20
+ display = true;
21
+ } else if(!ktEnvId && !option.attr('data-katello-id')) {
22
+ display = true;
23
+ }
24
+ if(display) {
25
+ option.show();
26
+ } else {
27
+ if(cvSelect.val() == option.val()) {
28
+ cvSelect.val('');
29
+ };
30
+ option.hide();
31
+ }
32
+ });
33
+ }
34
+
35
+ ktUpdateContentViews();
36
+ $("#kt_environment_id").change(ktUpdateContentViews);
37
+ });
38
+ </script>
39
+
40
+ <%= field(f, "Environment", {:include_blank => true}) do
41
+ select_tag :kt_environment_id,
42
+ grouped_env_options
43
+ end %>
44
+
45
+ <%= field(f, "Content View", {:include_blank => true}) do
7
46
  f.select :environment_id,
8
- grouped_env_options,
47
+ content_view_options,
9
48
  {:include_blank =>true},
10
49
  {:onchange => 'update_puppetclasses(this);',
11
50
  :"data-url" => environment_selected_hostgroups_path,
@@ -62,7 +62,8 @@ $(function() {
62
62
  function ktHideParams() {
63
63
  var paramsToHide = [ktFindParamContainer(KT_AK_LABEL),
64
64
  ktFindParamContainer('kt_org'),
65
- ktFindParamContainer('kt_env')];
65
+ ktFindParamContainer('kt_env'),
66
+ ktFindParamContainer('kt_cv')];
66
67
  $.each(paramsToHide, function (i, paramContainer) {
67
68
  if(paramContainer) {
68
69
  paramContainer.hide();
@@ -75,20 +76,12 @@ $(function() {
75
76
  var selectedOption = $("#hostgroup_environment_id option[ value ='" + selectedEnvId + "' ]");
76
77
 
77
78
  var ktEnvOption, ktCvOption, ktOrgLabel, ktEnvLabel, ktCvLabel;
78
- if(selectedOption.hasClass('kt-cv')) {
79
- ktCvOption = selectedOption;
80
- ktEnvOption = ktCvOption.prevAll('option.kt-env').first();
81
- } else if(selectedOption.hasClass('kt-env')) {
82
- ktEnvOption = selectedOption;
83
- }
84
-
85
- if(ktEnvOption) {
86
- ktEnvLabel = ktEnvOption.text();
87
- ktOrgLabel = ktEnvOption.parent().attr('label');
88
- }
89
-
90
- if(ktCvOption) {
91
- ktCvLabel = ktCvOption.text();
79
+ var ktEnvId = selectedOption.attr('data-katello-id');
80
+ if(ktEnvId) {
81
+ var idParts = ktEnvId.split('/');
82
+ ktOrgLabel = idParts[0];
83
+ ktEnvLabel = idParts[1];
84
+ ktCvLabel = idParts[2];
92
85
  }
93
86
  return [ktOrgLabel, ktEnvLabel, ktCvLabel];
94
87
  }
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "foreman-katello-engine"
3
- s.version = "0.0.14"
3
+ s.version = "0.0.19"
4
4
 
5
5
  s.authors = ["Katello"]
6
6
  s.date = "2013-03-04"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-katello-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -54,36 +54,36 @@ files:
54
54
  - LICENSE
55
55
  - Rakefile
56
56
  - README.md
57
- - app/models/foreman_katello_engine/environment.rb
58
- - app/models/setting/katello.rb
57
+ - app/overrides/add_katello_link.rb
58
+ - app/overrides/add_activation_keys_input.rb
59
+ - app/assets/images/foreman_katello_engine/link.png
59
60
  - app/helpers/foreman_katello_engine/hosts_and_hostgroups_helper.rb
60
61
  - app/helpers/foreman_katello_engine/katello_urls_helper.rb
62
+ - app/views/unattended/snippets/_subscription_manager_registration.erb
63
+ - app/views/unattended/kickstart-katello_rhel.erb
64
+ - app/views/unattended/kickstart-katello.erb
65
+ - app/views/foreman_katello_engine/layout/_katello_link.html.erb
61
66
  - app/views/foreman_katello_engine/activation_keys/_host_tab_pane.html.erb
62
67
  - app/views/foreman_katello_engine/activation_keys/_host_tab.html.erb
63
68
  - app/views/foreman_katello_engine/activation_keys/_host_environment_select.html.erb
64
- - app/views/foreman_katello_engine/layout/_katello_link.html.erb
65
- - app/views/unattended/kickstart-katello.erb
66
- - app/views/unattended/snippets/_subscription_manager_registration.erb
67
- - app/views/unattended/kickstart-katello_rhel.erb
68
- - app/assets/images/foreman_katello_engine/link.png
69
- - app/overrides/add_activation_keys_input.rb
70
- - app/overrides/add_katello_link.rb
71
69
  - app/controllers/foreman_katello_engine/api/environments_controller.rb
72
70
  - app/controllers/foreman_katello_engine/activation_keys_controller.rb
71
+ - app/models/setting/katello.rb
72
+ - app/models/foreman_katello_engine/environment.rb
73
73
  - config/routes.rb
74
74
  - db/migrate/20130418105901_add_katello_ptables.rb
75
75
  - db/migrate/20130416152224_add_katello_templates.rb
76
76
  - db/migrate/20130419110332_update_environments_add_katello_id.rb
77
- - lib/foreman-katello-engine.rb
77
+ - lib/foreman_katello_engine.rb
78
78
  - lib/foreman_katello_engine/engine.rb
79
79
  - lib/foreman_katello_engine/renderer.rb
80
80
  - lib/foreman_katello_engine/bindings.rb
81
- - lib/foreman_katello_engine.rb
81
+ - lib/foreman-katello-engine.rb
82
82
  - test/test_helper.rb
83
83
  - test/lib/settings_test.rb
84
84
  - test/lib/bindings_test.rb
85
- - test/functional/activation_keys_controller_test.rb
86
85
  - test/functional/api/environments_controller_test.rb
86
+ - test/functional/activation_keys_controller_test.rb
87
87
  homepage: http://github.com/katello/foreman-katello-engine
88
88
  licenses:
89
89
  - GPL-3
@@ -105,8 +105,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 1.8.25
108
+ rubygems_version: 1.8.23
109
109
  signing_key:
110
110
  specification_version: 3
111
111
  summary: Katello specific parts of Foreman
112
112
  test_files: []
113
+ has_rdoc: