foreman_datacenter 0.1.37 → 0.1.38

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b851bab3120b7c4df74cb7ce12aeeed27688047
4
- data.tar.gz: 72c137e7e300c640f898e21beaa690a1b556c345
3
+ metadata.gz: 7f50da38ff54df5eb9e31605246b6fd62cf15520
4
+ data.tar.gz: 29a39738d7bcd6c5a3dd439a49eb3e7799ad30da
5
5
  SHA512:
6
- metadata.gz: 990fa58e3d5fcd8f37b02f3600636f48ba13154ebc296d958cab91d973a665c88817716f814a9bd427ac524d2d174a219cd7ec338bbb2351efd253809054f01b
7
- data.tar.gz: 6260c29af8dfd26be3d004f5cfa010d793db5f8860dad31e8ed108da387282f9d078957c1179b1c9070ff7362060819064d63b9db8977db5abefe4a95264b7fa
6
+ metadata.gz: 2c2407376388b1a70e6ac5aef59341e8212c90517ca7cdbccf25d6452f5fdc2f076d2096be3cd06d371a1b2337dd8df2fc8d5063dbea185a437c7498990834bb
7
+ data.tar.gz: bf0545dde92e7babf6a89ee942469415718d20fadb92141430fc957468aadf09846ef404c0b599d2d01d4384ecb08db3cbcb7a95d83d880d4169db8a704e646d
@@ -31,3 +31,20 @@ function devicesNewSiteSelected(item) {
31
31
  });
32
32
  }
33
33
  }
34
+
35
+ function devicesNewDeviceTypeSelected(item) {
36
+ var $item = $(item);
37
+ var type = $item.val();
38
+ if (type === '') {
39
+ return false;
40
+ } else {
41
+ tfm.tools.showSpinner();
42
+ var url = $item.data('url');
43
+ var params = $.param({ device_type_id: type });
44
+ var $container = $('#device-type-size-container');
45
+ $container.load(url + ' #device-type-size', params, function () {
46
+ $container.find('select').select2({allowClear: true});
47
+ tfm.tools.hideSpinner();
48
+ });
49
+ }
50
+ }
@@ -79,6 +79,11 @@ module ForemanDatacenter
79
79
  render partial: 'device_types'
80
80
  end
81
81
 
82
+ def device_type_size
83
+ @device_type_id = params[:device_type_id]
84
+ render partial: 'device_type_size'
85
+ end
86
+
82
87
  def racks
83
88
  @site_id = params[:site_id]
84
89
  render partial: 'racks'
@@ -18,8 +18,21 @@ module ForemanDatacenter
18
18
  end
19
19
  selectable_f f, :device_type_id,
20
20
  options_from_collection_for_select(collection, 'id', 'model', device_type_id),
21
- { include_blank: 'Choose a device type' },
22
- { required: true, label: 'Device Type' }
21
+ { include_blank: 'Choose a device type'},
22
+ { required: true, label: 'Device Type',
23
+ :onchange => 'devicesNewDeviceTypeSelected(this)',
24
+ :'data-url' => device_type_size_devices_path }
25
+ end
26
+
27
+ def device_type_size_for_device_form(f, device_type_id)
28
+ if device_type_id
29
+ device_type = DeviceType.find(device_type_id)
30
+ height = device_type.u_height
31
+ else
32
+ height = 1
33
+ end
34
+ text_f f, :size, type: 'number', min: 0, value: height, id: 'device_type_size', label: 'Size',
35
+ help_inline: 'For multi-U devices, how many rack units occupied be device.'
23
36
  end
24
37
 
25
38
  def racks_for_device_form(f, site_id, rack_id = nil)
@@ -58,8 +58,10 @@
58
58
  { include_blank: 'Choose a rack side', label: 'Rack side' } %>
59
59
  <%= text_f f, :position, type: 'number', min: 0,
60
60
  help_inline: 'For multi-U devices, this is the lowest occupied rack unit.' %>
61
- <%= text_f f, :size, type: 'number', min: 0,
62
- help_inline: 'For multi-U devices, how many rack units occupied by device.' %>
61
+ <div id="device-type-size-container">
62
+ <%= text_f f, :size, type: 'number', min: 0,
63
+ help_inline: 'For multi-U devices, how many rack units occupied by device.' %>
64
+ </div>
63
65
  </div>
64
66
  </div>
65
67
 
data/config/routes.rb CHANGED
@@ -34,7 +34,7 @@ Foreman::Application.routes.draw do
34
34
  end
35
35
  resources :devices do
36
36
  collection do
37
- get :device_types, :racks, :for_rack
37
+ get :device_types, :racks, :for_rack, :device_type_size
38
38
  get :auto_complete_search
39
39
  end
40
40
  member do
@@ -1,3 +1,3 @@
1
1
  module ForemanDatacenter
2
- VERSION = '0.1.37'.freeze
2
+ VERSION = '0.1.38'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_datacenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.37
4
+ version: 0.1.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2017-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface