Page Menu
Home
GRNET
Search
Configure Global Search
Log In
Files
F461588
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 18, 3:47 AM
Size
6 KB
Mime Type
text/x-diff
Expires
Tue, May 20, 3:47 AM (1 d, 9 h)
Engine
blob
Format
Raw Data
Handle
220344
Attached To
rWEBDNS WebDNS (edet4)
View Options
diff --git a/app/controllers/domains_controller.rb b/app/controllers/domains_controller.rb
index 5a157ea..13d2bae 100644
--- a/app/controllers/domains_controller.rb
+++ b/app/controllers/domains_controller.rb
@@ -1,66 +1,67 @@
class DomainsController < ApplicationController
before_action :authenticate_user!
before_action :group_scope
before_action :domain, only: [:show, :edit, :update, :destroy]
before_action :group, only: [:show, :edit, :update, :destroy]
# GET /domains
def index
@domains = domain_scope.all
end
# GET /domains/1
def show
+ @record = Record.new(domain_id: @domain.id)
end
# GET /domains/new
def new
@domain = Domain.new
end
# GET /domains/1/edit
def edit
end
# POST /domains
def create
@domain = Domain.new(domain_params)
if @domain.save
redirect_to @domain, notice: "#{@domain.name} was successfully created."
else
render :new
end
end
# PATCH/PUT /domains/1
def update
if @domain.update(domain_params)
redirect_to @domain, notice: "#{@domain.name} was successfully updated."
else
render :edit
end
end
# DELETE /domains/1
def destroy
@domain.destroy
redirect_to domains_url, notice: "#{@domain.name} was successfully destroyed."
end
private
def group
domain.group
end
def domain_params
params.require(:domain).tap { |d|
# Make sure group id is permitted (belongs to group_scope)
d[:group_id] = group_scope.find_by_id(d[:group_id]).try(:id)
}.permit(:name, :type, :group_id)
end
end
diff --git a/app/controllers/records_controller.rb b/app/controllers/records_controller.rb
index 4ff086b..2090230 100644
--- a/app/controllers/records_controller.rb
+++ b/app/controllers/records_controller.rb
@@ -1,61 +1,62 @@
class RecordsController < ApplicationController
before_action :authenticate_user!
before_action :domain
before_action :record, only: [:edit, :update, :destroy]
# GET /records/new
def new
@record = domain.records.build
end
# GET /records/1/edit
def edit
end
# POST /records
def create
@record = domain.records.new(new_record_params)
if @record.save
redirect_to domain, notice: 'Record was successfully created.'
else
+ flash[:alert] = 'There were some errors creating the record!'
render :new
end
end
# PATCH/PUT /records/1
def update
if @record.update(edit_record_params)
redirect_to domain, notice: 'Record was successfully updated.'
else
render :edit
end
end
# DELETE /records/1
def destroy
@record.destroy
redirect_to domain, notice: 'Record was successfully destroyed.'
end
private
def edit_record_params
if @record.type == 'SOA'
permitted = [:contact, :serial, :refresh, :retry, :expire, :nx]
else
permitted = [:name, :content, :ttl, :prio, :disable]
end
params.require(:record).permit(*permitted).tap { |r|
r[:drop_privileges] = true if not admin?
}
end
def new_record_params
params.require(:record).permit(:name, :content, :ttl, :type, :prio).tap { |r|
r[:drop_privileges] = true if not admin?
}
end
end
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 8330b7c..c216917 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -1,60 +1,58 @@
module BreadcrumbHelper
# Domain
# Domain / group / example.com
# Domain / group / example.com / ns1.example.com IN A
# Domain / group / example.com / new
def breadcrumbs(leaf)
crumbs = generate_crumbs_for(leaf)
crumbs.each { |c|
# Last element should not be a link
if c == crumbs.last || c[:link].nil?
yield c[:name]
else
yield link_to(c[:name], c[:link])
end
}
end
private
# rubocop:disable all
def generate_crumbs_for(leaf)
stack = []
crumbs = []
stack.push leaf if leaf
while crumb = stack.pop # rubocop:disable Lint/AssignmentInCondition
case crumb
when Record
if crumb.persisted?
crumbs.push(
name: "#{crumb.name} IN #{crumb.type}",
link: domain_record_path(crumb.domain_id, crumb))
- else
- crumbs.push(name: :new)
end
stack.push crumb.domain
when Domain
if crumb.persisted?
crumbs.push(name: crumb.name, link: domain_path(crumb))
else
crumbs.push(name: :new)
end
stack.push crumb.group
when Group
if crumb.persisted?
crumbs.push(name: crumb.name, link: group_path(crumb))
else
crumbs.push(name: :new)
end
end
end
crumbs.push(name: glyph(:home), link: '/')
crumbs.reverse
end
# rubocop:enable all
end
diff --git a/app/views/domains/show.html.erb b/app/views/domains/show.html.erb
index a838d6e..f95db1c 100644
--- a/app/views/domains/show.html.erb
+++ b/app/views/domains/show.html.erb
@@ -1,38 +1,44 @@
<table class="table table-striped table-hover">
<thead>
<tr>
<th colspan="6">Records</th>
<th colspan="3">Controls</th>
</tr>
</thead>
<tbody>
<% @domain.records.each do |record| %>
<tr class="<%= record.disabled? ? 'warning' : '' %>">
<td><%= record.name %></td>
<td><%= record.ttl %></td>
<td>IN</td>
<td><%= record.type %></td>
<td><%= record.supports_prio? ? record.prio : '' %></td>
<td><%= record.content %></td>
<% if can_edit?(record) %>
<td>
<% if record.disabled? %>
<%= link_to_enable enable_domain_record_path(@domain, record), method: :put %>
<% else %>
<%= link_to_disable disable_domain_record_path(@domain, record), method: :put %>
<% end %>
</td>
<td><%= link_to_edit edit_domain_record_path(@domain, record) if can_edit?(record) %></td>
<td><%= link_to_destroy [@domain, record], method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% else %>
<td/>
<td/>
<td/>
<% end %>
</tr>
<% end %>
</tbody>
</table>
-<p><%= link_to 'New Record', new_domain_record_path(@domain) %></p>
+<p>
+ <%= link_to 'Add Record', '#new_record', class: 'btn btn-primary', onclick: '$("#new_record_wrapper").toggleClass("hidden");' %>
+</p>
+
+<div class="jumbotron hidden" id="new_record_wrapper">
+ <%= render 'records/form' %>
+</div>
Event Timeline
Log In to Comment