foreman_datacenter 0.1.27 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/foreman_datacenter/comments.css +4 -0
- data/app/controllers/foreman_datacenter/comments_controller.rb +17 -3
- data/app/controllers/foreman_datacenter/devices_controller.rb +3 -1
- data/app/models/foreman_datacenter/comment.rb +3 -2
- data/app/views/foreman_datacenter/comments/_children.html.erb +9 -0
- data/app/views/foreman_datacenter/comments/_comments.html.erb +23 -0
- data/app/views/foreman_datacenter/comments/_form.html.erb +35 -3
- data/app/views/foreman_datacenter/comments/_item.html.erb +24 -0
- data/app/views/foreman_datacenter/comments/new.html.erb +4 -0
- data/app/views/foreman_datacenter/devices/index.html.erb +1 -0
- data/config/routes.rb +4 -1
- data/lib/foreman_datacenter/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3bb886dd6e594c44644dc906e0a114d3753fd41
|
4
|
+
data.tar.gz: 37c34a36aba8e89822ac4b470ad169dad4ad948c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ce51989419d2d0118522ba9d1692d63a1abb560493e5b53d1445dc81c8cc852f78a411e39d7ff2888678945419d929380bcd9edbeeb63acbae52526c7542fe6
|
7
|
+
data.tar.gz: 7535811c728a339ef7f220d786e42f3a257e8af504986c6137ad91331230e0ddb8d1f062e5a0506f4728e4a4934f9affdb5007d59bfe38a261f6b7bbfc4a4498
|
@@ -2,8 +2,14 @@ module ForemanDatacenter
|
|
2
2
|
class CommentsController < ApplicationController
|
3
3
|
before_filter :load_resource, :load_commentable
|
4
4
|
|
5
|
+
def new
|
6
|
+
@comment = Comment.new
|
7
|
+
@parent = Comment.find(params[:parent_id])
|
8
|
+
end
|
9
|
+
|
5
10
|
def edit
|
6
11
|
@comment = Comment.find(params[:id])
|
12
|
+
@parent = @comment.parent
|
7
13
|
end
|
8
14
|
|
9
15
|
def create
|
@@ -38,15 +44,23 @@ module ForemanDatacenter
|
|
38
44
|
private
|
39
45
|
|
40
46
|
def load_resource
|
41
|
-
|
47
|
+
if (params[:resource] && params[:resource_id])
|
48
|
+
@resource, @id = params[:resource], params[:resource_id]
|
49
|
+
else
|
50
|
+
@resource, @id = request.path.split('/')[2, 3]
|
51
|
+
end
|
42
52
|
end
|
43
53
|
|
44
54
|
def load_commentable
|
45
|
-
|
55
|
+
begin
|
56
|
+
@commentable = "foreman_datacenter::#{@resource.capitalize}".singularize.classify.constantize.find(@id.to_i)
|
57
|
+
rescue
|
58
|
+
@commentable = "foreman_datacenter::#{params[:resource].capitalize}".singularize.classify.constantize.find(params[:resource_id].to_i)
|
59
|
+
end
|
46
60
|
end
|
47
61
|
|
48
62
|
def comment_params
|
49
|
-
params[:foreman_datacenter_comment].permit(:content, :commntable_type, :commentable_id)
|
63
|
+
params[:foreman_datacenter_comment].permit(:content, :commntable_type, :commentable_id, :parent_id)
|
50
64
|
end
|
51
65
|
|
52
66
|
def find_commentable(comment)
|
@@ -116,7 +116,8 @@ module ForemanDatacenter
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def load_resource
|
119
|
-
|
119
|
+
resource, id = request.path.split('/')[2, 3]
|
120
|
+
@commentable_data = {resource: resource, id: id }
|
120
121
|
end
|
121
122
|
|
122
123
|
def populate_from_host
|
@@ -142,3 +143,4 @@ module ForemanDatacenter
|
|
142
143
|
end
|
143
144
|
end
|
144
145
|
end
|
146
|
+
|
@@ -2,7 +2,8 @@ module ForemanDatacenter
|
|
2
2
|
class Comment < ActiveRecord::Base
|
3
3
|
self.table_name = "datacenter_comments"
|
4
4
|
belongs_to :commentable, polymorphic: true
|
5
|
-
|
6
|
-
|
5
|
+
has_ancestry
|
6
|
+
# belongs_to :parent, class_name: "ForemanDatacenter::Comment"
|
7
|
+
# has_many :children, class_name: "ForemanDatacenter::Comment", foreign_key: "parent_id"
|
7
8
|
end
|
8
9
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<ul class="none-list">
|
2
|
+
<li>
|
3
|
+
<% c.each do |comment, children |%>
|
4
|
+
<%= render 'foreman_datacenter/comments/item', comment: comment, commentable_data: commentable_data %>
|
5
|
+
<%= render 'foreman_datacenter/comments/children', commentable_data: commentable_data, c: children if children.present? %>
|
6
|
+
<% end %>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<% stylesheet 'foreman_datacenter/comments' %>
|
2
|
+
|
3
|
+
<table class="table table-hover panel-body table-striped">
|
4
|
+
<tbody>
|
5
|
+
<% comments.roots.each do |c| %>
|
6
|
+
<tr>
|
7
|
+
<td>
|
8
|
+
<ul class="none-list">
|
9
|
+
<li>
|
10
|
+
<%= render 'foreman_datacenter/comments/item', comment: c, commentable_data: commentable_data %>
|
11
|
+
</li>
|
12
|
+
<% if c.root.descendants != [] %>
|
13
|
+
<%= render 'foreman_datacenter/comments/children', c: c.root.descendants.arrange, commentable_data: commentable_data %>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
</td>
|
17
|
+
</tr>
|
18
|
+
<% end %>
|
19
|
+
</tbody>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<%= render 'foreman_datacenter/comments/form'%>
|
23
|
+
|
@@ -2,12 +2,44 @@
|
|
2
2
|
<%= form_for @comment, url: "/datacenter/comments/#{@comment.id}" do |f| %>
|
3
3
|
<div class="clearfix">
|
4
4
|
<div class="form-group">
|
5
|
+
<% if @parent %>
|
6
|
+
<%= f.label "Parent comment" %>
|
7
|
+
<p>
|
8
|
+
<%= @parent.content %>
|
9
|
+
</p>
|
10
|
+
<% end %>
|
5
11
|
<div class="col-md-5">
|
6
|
-
<%= f.text_area :content, rows:
|
12
|
+
<%= f.text_area :content, rows: 6, class: "form-control" %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="btn-toolbar">
|
17
|
+
<%= link_to 'Back', url_for(:back), class: 'btn btn-success' %>
|
18
|
+
<%= f.submit "Edit", class: "btn btn-primary remove_form_templates" %>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
21
|
+
<% elsif action_name == "new" %>
|
22
|
+
<%= form_for @comment, url: "/datacenter/comments", method: :post do |f| %>
|
23
|
+
<div class="clearfix">
|
24
|
+
<div class="form-group">
|
25
|
+
<% if @parent %>
|
26
|
+
<%= f.label "Parent comment" %>
|
27
|
+
<p>
|
28
|
+
<%= @parent.content %>
|
29
|
+
</p>
|
30
|
+
<% end %>
|
31
|
+
<div class="col-md-5">
|
32
|
+
<%= f.text_area :content, rows: 6, class: "form-control" %>
|
33
|
+
<%= f.hidden_field :parent_id, value: @parent.id %>
|
34
|
+
<%= hidden_field_tag "resource", params[:resource] %>
|
35
|
+
<%= hidden_field_tag "resource_id", params[:resource_id] %>
|
7
36
|
</div>
|
8
37
|
</div>
|
9
38
|
</div>
|
10
|
-
|
39
|
+
<div class="btn-toolbar">
|
40
|
+
<%= link_to 'Back', url_for(:back), class: 'btn btn-success' %>
|
41
|
+
<%= f.submit "Reply", class: "btn btn-primary remove_form_templates" %>
|
42
|
+
</div>
|
11
43
|
<% end %>
|
12
44
|
<% else %>
|
13
45
|
<%= form_for [@commentable, @comment], url: "/datacenter/devices/#{@commentable.id}/comments" do |f| %>
|
@@ -18,7 +50,7 @@
|
|
18
50
|
</div>
|
19
51
|
</div>
|
20
52
|
</div>
|
21
|
-
<%= f.submit "
|
53
|
+
<%= f.submit "Post", class: "btn btn-primary remove_form_templates" %>
|
22
54
|
<% end %>
|
23
55
|
<% end %>
|
24
56
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<strong>
|
2
|
+
<small class="text-left pull-left">
|
3
|
+
Posted by ... <%#= "#{@user.firstname} #{@user.lastname}" %> at <%= comment.updated_at %>
|
4
|
+
</small>
|
5
|
+
|
6
|
+
<small class="text-right pull-right">
|
7
|
+
<%= link_to "##{comment.id}", "#comment-#{comment.id}" %>
|
8
|
+
</small>
|
9
|
+
</strong>
|
10
|
+
<br/>
|
11
|
+
<div class="text-left pull-left">
|
12
|
+
<%= comment.content %>
|
13
|
+
<br/>
|
14
|
+
<small>
|
15
|
+
<%= link_to "Reply", new_comment_path(parent_id: comment.id, resource: commentable_data[:resource], resource_id: commentable_data[:id]) %>
|
16
|
+
|
17
|
+
<%= link_to "Edit", "/datacenter/comments/#{comment.id}/edit" %>
|
18
|
+
|
19
|
+
<%= link_to "Delete", "/datacenter/#{commentable_data[:resource]}/#{commentable_data[:id]}/comments/#{comment.id}", method: :delete, data: {confirm: "Are you sure?"} %>
|
20
|
+
</small>
|
21
|
+
</div>
|
22
|
+
<br/>
|
23
|
+
<br/>
|
24
|
+
|
data/config/routes.rb
CHANGED
@@ -4,8 +4,10 @@ Foreman::Application.routes.draw do
|
|
4
4
|
get 'datacenter/import_to_device', to: 'hosts#import_to_device',
|
5
5
|
as: 'import_to_device'
|
6
6
|
|
7
|
+
|
7
8
|
scope 'datacenter', module: :foreman_datacenter do
|
8
|
-
resources :comments, only: [:edit, :update]
|
9
|
+
resources :comments, only: [:new, :edit, :create, :update]
|
10
|
+
|
9
11
|
resources :sites
|
10
12
|
resources :racks do
|
11
13
|
get :rack_groups, on: :collection
|
@@ -103,3 +105,4 @@ Foreman::Application.routes.draw do
|
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
108
|
+
|
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.
|
4
|
+
version: 0.1.28
|
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-
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- app/assets/javascripts/foreman_datacenter/management_devices.js
|
112
112
|
- app/assets/javascripts/foreman_datacenter/racks.js
|
113
113
|
- app/assets/javascripts/foreman_datacenter/shared.js
|
114
|
+
- app/assets/stylesheets/foreman_datacenter/comments.css
|
114
115
|
- app/assets/stylesheets/foreman_datacenter/device_interface_connections.css
|
115
116
|
- app/controllers/concerns/foreman_datacenter/hosts_controller_extensions.rb
|
116
117
|
- app/controllers/foreman_datacenter/comments_controller.rb
|
@@ -176,8 +177,12 @@ files:
|
|
176
177
|
- app/models/foreman_datacenter/rack.rb
|
177
178
|
- app/models/foreman_datacenter/rack_group.rb
|
178
179
|
- app/models/foreman_datacenter/site.rb
|
180
|
+
- app/views/foreman_datacenter/comments/_children.html.erb
|
181
|
+
- app/views/foreman_datacenter/comments/_comments.html.erb
|
179
182
|
- app/views/foreman_datacenter/comments/_form.html.erb
|
183
|
+
- app/views/foreman_datacenter/comments/_item.html.erb
|
180
184
|
- app/views/foreman_datacenter/comments/edit.html.erb
|
185
|
+
- app/views/foreman_datacenter/comments/new.html.erb
|
181
186
|
- app/views/foreman_datacenter/console_port_templates/_form.html.erb
|
182
187
|
- app/views/foreman_datacenter/console_port_templates/new.html.erb
|
183
188
|
- app/views/foreman_datacenter/console_ports/_for_device.html.erb
|