Skip to content

Commit

Permalink
Merge f70ddb6 into abc7d73
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisma committed Apr 5, 2019
2 parents abc7d73 + f70ddb6 commit c213209
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 188 deletions.
4 changes: 3 additions & 1 deletion app/controllers/vms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def index
filter_vm_categories current_user unless current_user.admin?
end

def show; end
def show
@vm_request = Request.find_by_name params[:id]
end

def edit_config
@vm.ensure_config
Expand Down
4 changes: 4 additions & 0 deletions app/models/app_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def self.instance
@instance
end

def github_base_file_url
"https://github.com/#{github_user_name}/#{git_repository_name}/blob/#{git_branch}"
end

private

def apply_settings
Expand Down
8 changes: 4 additions & 4 deletions app/models/virtual_machine_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def users
def all_users
(users + sudo_users + responsible_users).uniq
end

def node_script
Puppetscript.node_script(name, (sudo_users + responsible_users).uniq, all_users)
end

private

Expand Down Expand Up @@ -72,10 +76,6 @@ def commit_message(git_writer)
end
end

def node_script
Puppetscript.node_script(name, (sudo_users + responsible_users).uniq, all_users)
end

def write_puppetscripts(git_writer, name_script, node_script)
git_writer.write_file(Puppetscript.class_file_name(name), name_script)
git_writer.write_file(Puppetscript.node_file_name(name), node_script)
Expand Down
16 changes: 16 additions & 0 deletions app/views/application/_modal.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%# Partial params: id, dialog_class, title %>
<div class="modal fade" id="<%= id %>" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog <%= dialog_class %>" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= title %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<%= yield %>
</div>
</div>
</div>
</div>
91 changes: 91 additions & 0 deletions app/views/requests/_detail.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<table class="table">
<tbody>
<tr>
<td><strong>VM Name</strong></td>
<td><%= request.name %></td>
</tr>

<tr>
<td><strong>CPU Cores</strong></td>
<td><%= request.cpu_cores %></td>
</tr>

<tr>
<td><strong>RAM</strong></td>
<td><%= request.ram_gb %> GB</td>
</tr>

<tr>
<td><strong>Storage</strong></td>
<td><%= request.storage_gb %> GB</td>
</tr>

<tr>
<td><strong>Operating System</strong></td>
<td><%= request.operating_system %></td>
</tr>

<tr>
<td><strong>Port Forwarding</strong></td>
<td>
Enabled: <%= t request.port_forwarding %><br>
<%= request.application_name %> <%= request.port %>
</td>
</tr>

<tr>
<td><strong>Description</strong></td>
<td class="col-md-4"><%= request.description %></td>
</tr>

<tr>
<td><strong>Comment</strong></td>
<td class="col-md-4"><%= request.comment %></td>
</tr>

<tr>
<td><strong>Status</strong></td>
<td>
<%= request.status %><br>
<% if request.rejected? %>
<strong>Rejection Information:</strong> <%= request.rejection_information %>
<% end %>
</td>
</tr>

<tr>
<td><strong>Responsible users</strong></td>
<td>
<% request.responsible_users.each do |user| %>
<p><%= user.email %></p>
<% end %>
</td>
</tr>

<tr>
<td><strong>Users with sudo rights</strong></td>
<td>
<% request.sudo_user_assignments.each do |assignment| %>
<p><%= assignment.user.email %></p>
<% end %>
</td>
</tr>

<tr>
<td><strong>Users</strong></td>
<td>
<% request.non_sudo_user_assignments.each do |assignment| %>
<p><%= assignment.user.email %></p>
<% end %>
</td>
</tr>

<tr>
<td><strong>Request Date</strong></td>
<td>
<%= I18n.l request.created_at, format: :long %> (<%= time_ago_in_words request.created_at %> ago)
</td>
</tr>
</tbody>
</table>

41 changes: 6 additions & 35 deletions app/views/requests/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
title: 'New VM request',
:data => { toggle: 'tooltip', placement: 'bottom' },
class: "btn btn-primary float-right mt-3" %>
<% if current_user.admin? %>
<%= link_to "Templates", request_templates_path,
class: "btn btn-primary float-right mt-3 mr-3" %>
<%= link_to 'Operating Systems', operating_systems_path,
class: 'btn btn-primary float-right mt-3 mr-3' %>
<% end %>
<% if current_user.admin? %>
<%= link_to "Templates", request_templates_path,
class: "btn btn-primary float-right mt-3 mr-3" %>
<%= link_to 'Operating Systems', operating_systems_path,
class: 'btn btn-primary float-right mt-3 mr-3' %>
<% end %>
</div>

<h2 id="pending">Pending requests</h2>
Expand Down Expand Up @@ -58,7 +58,6 @@
<th>Application Name</th>
<th>Comment</th>
<th>Status</th>
<th data-orderable="false">Actions</th>
</tr>
</thead>
<tbody>
Expand All @@ -79,34 +78,6 @@
:data => { toggle: 'tooltip', placement: 'right' },
class: "round #{request.accepted? ? 'bg-success' : 'bg-warning'}" %>
</td>
<td>
<% if request.accepted? %>
<a class="btn btn-primary btn-sm fa fa-code text-white" data-toggle="modal" title="Puppet script" data-target=<%= '#puppet-script-' + request.name %>>
</a>
<div class="modal fade" id=<%= 'puppet-script-' + request.name %> tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="puppet-scriptTite">Puppet Script</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<pre>
<%= debug puppet_node_script(request) %>
<%= debug puppet_name_script(request) %>
</pre>
</div>
<div class="modal-footer">
<%= link_to "Push to git", push_to_git_request_path(request), method: :post, class: "btn btn-primary" %>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<% end %>
</td>
</tr>
<% end %> <%# @resolved_requests&.each %>
</tbody>
Expand Down
89 changes: 1 addition & 88 deletions app/views/requests/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,92 +1,5 @@
<h1>Request Information</h1>

<table class="table">
<tbody>
<tr>
<td><strong>VM Name</strong></td>
<td><%= @request.name %></td>
</tr>

<tr>
<td><strong>CPU cores</strong></td>
<td><%= @request.cpu_cores %></td>
</tr>

<tr>
<td><strong>RAM in GB:</strong></td>
<td><%= @request.ram_gb %></td>
</tr>

<tr>
<td><strong>Storage in GB:</strong></td>
<td><%= @request.storage_gb %></td>
</tr>

<tr>
<td><strong>Operating System</strong></td>
<td><%= @request.operating_system %></td>
</tr>

<tr>
<td><strong>Port</strong></td>
<td><%= @request.port %></td>
</tr>

<tr>
<td><strong>Application Name</strong></td>
<td><%= @request.application_name %></td>
</tr>

<tr>
<td><strong>Description</strong></td>
<td class="col-md-4"><%= @request.description %></td>
</tr>

<tr>
<td><strong>Comment</strong></td>
<td class="col-md-4"><%= @request.comment %></td>
</tr>

<tr>
<td><strong>Status</strong></td>
<td><%= @request.status %></td>
</tr>

<tr>
<td><strong>Responsible users</strong></td>
<td>
<% @request.responsible_users.each do |user| %>
<p><%= user.email %></p>
<% end %>
</td>
</tr>

<tr>
<td><strong>Users with sudo rights</strong></td>
<td>
<% @request.sudo_user_assignments.each do |assignment| %>
<p><%= assignment.user.email %></p>
<% end %>
</td>
</tr>

<tr>
<td><strong>Users</strong></td>
<td>
<% @request.non_sudo_user_assignments.each do |assignment| %>
<p><%= assignment.user.email %></p>
<% end %>
</td>
</tr>

</tbody>
</table>

<% if @request.rejected? %>
<p>
<strong>Rejection Information:</strong>
<%= @request.rejection_information %>
</p>
<% end %>
<%= render 'detail', request: @request %>
<%= link_to 'Back', requests_path, class: "btn btn-secondary" %>
Loading

0 comments on commit c213209

Please sign in to comment.