-
Notifications
You must be signed in to change notification settings - Fork 928
Expand file tree
/
Copy path_policy_details.html.haml
More file actions
247 lines (241 loc) · 11.4 KB
/
_policy_details.html.haml
File metadata and controls
247 lines (241 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
- if @edit
- url = url_for(:action => 'policy_field_changed', :id => "#{@policy.id || 'new'}")
- observe_with_interval = {:interval => '.5', :url => url}.to_json
#policy_details_div
- if @policy
#policy_info_div
= render :partial => "layouts/flash_msg"
-# Description and active fields
- if @edit
- if @edit && @edit[:typ] == "basic"
%h3
= _("Basic Information")
.form-horizontal
.form-group
%label.control-label.col-md-2
= _("Description")
- if @edit
.col-md-8
= text_field_tag("description", @edit[:new][:description],
:maxlength => MAX_DESC_LEN,
:class => "form-control",
"data-miq_observe" => observe_with_interval)
= javascript_tag(javascript_focus('description'))
- else
.col-md-8
= h(@policy.description)
.form-group
%label.control-label.col-md-2
= _("Active")
.col-md-8
= check_box_tag("active", "1", @edit[:new][:active], "data-miq_observe_checkbox" => {:url => url}.to_json)
- else
%h3= _('Basic Information')
.form-horizontal.static
.form-group
%label.control-label.col-md-2= _('Active')
.col-md-8
%p.form-control-static= h(@policy.active ? _("Yes") : _("No"))
.form-group
%label.control-label.col-md-2= _('Created')
.col-md-8
%p.form-control-static
= h(_("By Username %{username} %{created_on}") % {:username => @policy.created_by || _("N/A"), :created_on => format_timezone(@policy.created_on, session[:user_tz], "gtl")})
- if @policy.created_on != @policy.updated_on
.form-group
%label.control-label.col-md-2= _("Last Updated")
.col-md-8
%p.form-control-static
= h(_("By Username %{username} %{updated_on}") % {:username => @policy.updated_by || _("N/A"), :updated_on => format_timezone(@policy.updated_on, session[:user_tz], "gtl")})
%hr
-# Scope
- if @edit
- if @edit[:typ] == "basic"
%h3= _("Scope (Choose an element of the Policy scope to edit)")
= render :partial => 'layouts/exp_editor'
%hr
- else
%h3= _("Scope")
- if !@expression_table.nil?
- @expression_table.each do |token|
- if ! ["AND", "OR", "(", ")"].include?([token].flatten.first)
= h([token].flatten.first)
- else
%font{:color => "black"}
%b
= h([token].flatten.first)
- else
= render :partial => 'layouts/info_msg', :locals => {:message => _("No Policy scope defined, the scope of this policy includes all elements.")}
%hr
-# Conditions for this policy
- if @edit
- if @edit[:typ] == "conditions"
%h3= _("Condition Selection")
%table#formtest.form{:width => "100%"}
%tr
%td{:align => "left"}= _("Available %{model} Conditions:") % {:model => ui_lookup(:model => @edit[:new][:towhat])}
%td
%td.widthed{:align => "left"}= _("Policy Conditions:")
%tr
%td.widthed{:align => "left", :valign => "top"}
%span#choices_chosen_div
= select_tag('choices_chosen[]',
options_for_select(@edit[:choices].sort),
:multiple => true,
:class => "widthed",
:size => 8,
:id => "choices_chosen")
%p
%td{:width => "20", :valign => "middle"}
.btn-group-vertical
- [[_("Move selected Conditions into this Policy"), 'choices_chosen_div', 'move_right', 'fa-angle-right'],
[_("Remove all Conditions from this Policy"), nil, 'move_allleft', 'fa-angle-double-left'],
[_("Remove selected Conditions from this Policy"), 'members_chosen_div', 'move_left', 'fa-angle-left']].each do |title, chosen_div, action, arrow_style|
%button.btn.btn-default{:title => title,
:remote => true,
"data-submit" => chosen_div,
"data-method" => :post,
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true,
"data-click_url" => {:url => url_for(:action => 'policy_edit',
:button => action,
:id => @policy)}.to_json}
%i.fa{:class => arrow_style}
%td{:align => "right", :valign => "top"}
%span#members_chosen_div
= select_tag('members_chosen[]',
options_for_select(@edit[:new][:conditions].sort),
:multiple => true,
:class => "widthed",
:size => 8,
:id => "members_chosen")
%strong
= _("* If all Conditions are removed from a Policy, it will be unconditional and always evaluate to true.")
- else
%h3= _("Conditions")
- if @policy_conditions.empty?
= render :partial => 'layouts/info_msg', :locals => {:message => _("No conditions defined. This policy is unconditional and will ALWAYS return true.")}
- else
%table.table.table-striped.table-bordered.table-hover
%thead
%tr
%th.narrow
%th= _("Description")
%th= _("Scopes / Expressions")
%tbody
- @policy_conditions.each do |c|
%tr{:title => _("View this Condition"),
:onclick => "miqTreeActivateNode('#{x_active_tree}', '#{x_node}_co-#{to_cid(c.id)}');"}
%td.narrow
%i{:class => "product product-miq_condition"}
%td
= c.description
%td
%div
%table
- unless c.applies_to_exp.blank?
%tr
%td= _("Scope")
%td
= h(MiqExpression.to_human(c.applies_to_exp))
%tr
%td
= _("Expression")
%td
= h(MiqExpression.to_human(c.expression))
%hr
-# Events for this policy
- if @edit
- if @edit[:typ] == "events"
%h3= _("Event Selection")
- @edit[:allevents].keys.sort.each do |k|
%fieldset
%h3= h(k)
- @edit[:allevents][k].sort_by(&:first).each do |e|
%div{:style => "width: 300px; height: 18px; float:left; padding: 0px 5px 0px 0px;"}
= check_box_tag("event_#{e.last}", "1", @edit[:new][:events].include?(e.last) ? true : false,
"data-miq_observe_checkbox" => {:url => url}.to_json)
= h(e.first)
- else
%h3= _("Events")
- if @policy_events.empty?
= render :partial => 'layouts/info_msg', :locals => {:message => _("This policy does not currently respond to any Events.")}
- else
%table.table.table-striped.table-bordered.table-hover
%thead
%tr
%th.narrow
%th= _("Description")
%th= _("Actions")
%tbody
- @policy_events.each do |e|
%tr
%td.narrow{:title => _("View this Policy Event"),
:onclick => "miqTreeActivateNode('#{x_active_tree}', '#{x_node}_ev-#{to_cid(e.id)}');"}
%i{:class => e.decorate.try(:fonticon)}
%td{:title => _("View this Policy Event"),
:onclick => "miqTreeActivateNode('#{x_active_tree}', '#{x_node}_ev-#{to_cid(e.id)}');"}
= h(e.description)
%td
- ta = @policy.actions_for_event(e, :success)
- fa = @policy.actions_for_event(e, :failure)
- if ta.empty? && fa.empty?
= _("* No Actions are configured for this Event.")
- else
- unless ta.empty?
%table
%tbody
- ta.each do |a|
%tr{:title => _("View this Event Action"),
:onclick => "miqTreeActivateNode('#{x_active_tree}', '#{x_node}_ev-#{to_cid(e.id)}_a-#{to_cid(a.id)}');"}
%td
%span.pficon.pficon-ok
= h(a.description)
- unless fa.empty?
%table
%tbody
- fa.each do |a|
%tr{:title => _("View this Event Action"),
:onclick => "miqTreeActivateNode('#{x_active_tree}', '#{x_node}_ev-#{to_cid(e.id)}_a-#{to_cid(a.id)}');"}
%td
%span.pficon.pficon-close
= h(a.description)
%hr
-# Notes field
- if @edit
- if @edit[:typ] == "basic"
%h3
= _("Notes")
(
%span#notes_count= @edit[:new][:notes] ? @edit[:new][:notes].length : 0
\/ 512)
= text_area_tag("notes", @edit[:new][:notes],
:rows => 4,
:maxlength => "512",
:counter => "notes_count",
"data-miq_check_max_length" => true,
"data-miq_observe" => observe_with_interval)
- else
%h3= _("Notes")
- if @policy.notes.blank?
= render :partial => 'layouts/info_msg', :locals => {:message => _("No notes have been entered.")}
- else
= text_area_tag("notes", @policy.notes, :readonly => true, :rows => 4)
-# Profiles policy is assigned to
- unless @edit
- if x_active_tree == :policy_tree
%h3= _("Belongs to Profiles")
- if @policy_profiles.empty?
= render :partial => 'layouts/info_msg', :locals => {:message => _("This Policy is not assigned to any Profiles.")}
- else
%table.table.table-striped.table-bordered.table-hover
%tbody
- @policy_profiles.each do |pp|
- id = "pp-#{to_cid(pp.id)}"
%tr{:title => _("View this Profile"),
:onclick => remote_function(:url => "/miq_policy/x_show/#{id}?accord=policy_profile")}
%td.narrow
%img{:src => image_path("100/policy_profile#{pp.active? ? '' : '_inactive'}.png")}
%td
= pp.description
%br