Page MenuHomeGRNET

No OneTemporary

File Metadata

Created
Tue, Nov 18, 1:07 AM
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 5999b3a..7122da5 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -1,98 +1,106 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery.min
//= require jquery_ujs
//= require bootstrap.min
//= require typeahead.bundle.min
//= require jquery.dataTables.min
//= require dataTables.bootstrap.min
//= require_tree .
$(function() {
// Show priority on MX/SRV record only
$('#record_type').change(function() {
if ($(this).val() == 'MX') { // MX, default priority 10
$('#record_prio.autohide').parents('div.form-group').removeClass('hidden');
$('#record_prio.autodisable').prop('disabled', false);
$('#record_prio').val('10');
} else if ($(this).val() == 'SRV') { // SRV
$('#record_prio').val('');
$('#record_prio.autohide').parents('div.form-group').removeClass('hidden');
$('#record_prio.autodisable').prop('disabled', false);
} else {
$('#record_prio').val('');
$('#record_prio.autohide').parents('div.form-group').addClass('hidden');
$('#record_prio.autodisable').prop('disabled', true);
}
});
// Show master only on SLAVE domains
$('#domain_type').change(function() {
if ($(this).val() == 'SLAVE') {
$('#domain_master').parents('div.form-group').removeClass('hidden');
} else {
$('#domain_master').parents('div.form-group').addClass('hidden');
}
});
// Disable DNSSEC options
$('#domain_dnssec').change(function() {
if ($(this).val()== 'true') {
$("#dnssec_fieldset").prop('disabled', false)
} else {
$("#dnssec_fieldset").prop('disabled', true);
}
});
var searchMembersGroup = $('#js-search-member').data('group');
var searchMembers = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('email'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
identify: function(obj) { return obj.id; },
remote: {
url: '/groups/' + searchMembersGroup + '/search_member.json?q=%QUERY',
wildcard: '%QUERY'
}
});
$('#js-search-member').typeahead({
hint: true,
minLength: 2
}, {
name: 'members',
display: 'email',
source: searchMembers
});
// Highlighter helper
//
// Applies 'highlight' class to the element followed by 'hl-' prefix
function highlighter() {
$('.highlight').removeClass('highlight');
if (!window.location.hash)
return;
if (window.location.hash.indexOf('#hl-') == 0) {
var id = window.location.hash.slice('hl-'.length + 1);
$('#' + id).addClass('highlight');
}
}
$(window).bind('hashchange', highlighter);
highlighter();
+ $('table#domains').DataTable({
+ paging: false,
+ columnDefs: [{
+ targets: 'no-order-and-search',
+ orderable: false,
+ searchable: false
+ }],
+ });
});
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 312db9c..27eb7fd 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -1,45 +1,50 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require bootstrap.min
*= require dataTables.bootstrap.min
*= require_tree .
*= require_self
*/
/* Make sure navbar does not overlay body */
body {
padding-top: 70px;
}
.highlight {
background-color: #b8e0b8 !important;
}
+/* DataTable resets bootstrap's margin-bottom */
+.datatable-wrapper {
+ margin-bottom: 20px;
+}
+
/* Reset bootstrap's help cursor on control links */
table a abbr[title] {
cursor: pointer;
}
.tab-pane table {
margin-top: 20px;
}
#inline-record-form #record_ttl {
width: 80px;
}
#inline-record-form #record_prio {
width: 80px;
}
#inline-record-form #record_content {
width: 300px;
}
diff --git a/app/controllers/domains_controller.rb b/app/controllers/domains_controller.rb
index 06ea754..70678b0 100644
--- a/app/controllers/domains_controller.rb
+++ b/app/controllers/domains_controller.rb
@@ -1,89 +1,89 @@
class DomainsController < ApplicationController
before_action :authenticate_user!
before_action :domain, only: [:show, :edit, :edit_dnssec, :update, :destroy]
before_action :group, only: [:show, :edit, :edit_dnssec, :update, :destroy]
helper_method :edit_group_scope
# GET /domains
def index
- @domains = show_domain_scope.all
+ @domains = show_domain_scope.includes(:group, :soa).all
end
# GET /domains/1
def show
@record = Record.new(domain_id: @domain.id)
end
# GET /domains/new
def new
@domain = Domain.new(new_domain_params)
end
# GET /domains/1/edit
def edit
end
# GET /domains/1/edit_dnssec
def edit_dnssec
end
# POST /domains
def create
@domain = Domain.new(domain_params)
if @domain.save
notify_domain(@domain, :create)
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)
notify_domain(@domain, :update)
redirect_to @domain, notice: "#{@domain.name} was successfully updated."
else
if domain_params[:dnssec] # DNSSEC form
render :edit_dnssec
else
render :edit
end
end
end
# DELETE /domains/1
def destroy
if @domain.remove
notify_domain(@domain, :destroy)
redirect_to domains_url, notice: "#{@domain.name} is scheduled for removal."
else
redirect_to domains_url, alert: "#{@domain.name} cannot be deleted! (state '#{@domain.state}')"
end
end
private
def group
domain.group
end
def new_domain_params
params.permit(:group_id)
end
def domain_params
params.require(:domain).tap { |d|
# Make sure group id is permitted (belongs to edit_group_scope)
d[:group_id] = edit_group_scope.find_by_id(d[:group_id]).try(:id)
}.permit(:name, :type, :master, :group_id, :dnssec, :dnssec_parent, :dnssec_parent_authority)
end
def notify_domain(*args)
notification.notify_domain(current_user, *args)
end
end
diff --git a/app/views/domains/index.html.erb b/app/views/domains/index.html.erb
index a8ec88c..b4025e6 100644
--- a/app/views/domains/index.html.erb
+++ b/app/views/domains/index.html.erb
@@ -1,60 +1,54 @@
<% if current_user.memberships.empty? %>
<div class="jumbotron">
<h2>Wellcome to WebDNS!</h2>
<p>
In order to manage domains you have to be a member of a group.
</p>
<p>
You can either contact an admin to create a new group for you, or ask another user for an invite to an existing group.
</p>
</div>
<% end %>
-<table class="table table-striped">
- <thead>
- </thead>
-
- <tbody>
- <% @domains.group_by(&:group).each do |group, domains| %>
+<div class="datatable-wrapper">
+ <table id="domains" class="table table-striped">
+ <thead>
<tr>
- <th colspan="2" style="width:800px">
- <%= link_to group.name, group_path(group) %>
- <%= link_to glyph('menu-down'), "##{group.id}", onclick: "$('tr.group-#{group.id}').toggleClass('hidden');" %>
- </th>
+ <th>Domain</th>
+ <th>Serial</th>
+ <th>Group</th>
<th>State</th>
- <th colspan="2">Controls</th>
+ <th>Slave</th>
+ <th>DNSSEC</th>
+ <th class="no-order-and-search">Controls</th>
</tr>
- <% domains.each do |domain| %>
- <tr class="group-<%= group.id =%>">
- <td>
- <% if domain.reverse? %>
- <%= abbr_glyph('chevron-left', 'Reverse') %>
- <% elsif domain.enum? %>
- <%= abbr_glyph('phone-alt', 'Enum') %>
- <% else %>
- <%= abbr_glyph('chevron-right', 'Forward') %>
- <% end %>
- <% if domain.slave? %>
- <%= abbr_glyph('link', 'Slave') %>
- <% end %>
- <% if domain.dnssec? %>
- <%= abbr_glyph('flash', 'DNSSEC') %>
- <% end %>
- </td>
- <td style="width:800px"><%= link_to domain.name, domain %></td>
- <td><%= human_state(domain.state) %></td>
- <td><%= link_to_edit edit_domain_path(domain) %></td>
- <td><%= link_to_destroy domain, method: :delete, data: { confirm: 'Are you sure?' } if domain.can_remove? %></td>
- </tr>
+ </thead>
+
+ <tbody>
+ <% @domains.group_by(&:group).each do |group, domains| %>
+ <% domains.each do |domain| %>
+ <tr class="group-<%= group.id =%>">
+ <td><%= link_to domain.name, domain %></td>
+ <td><%= domain.soa.serial %></td>
+ <td><%= link_to group.name, group_path(group) %></td>
+ <td><%= human_state(domain.state) %></td>
+ <td><%= domain.slave? ? domain.master : '-' %></td>
+ <td><%= domain.dnssec? ? 'secure' : '-' %></td>
+ <td>
+ <%= link_to_edit edit_domain_path(domain) %>
+ <%= link_to_destroy domain, method: :delete, data: { confirm: 'Are you sure?' } if domain.can_remove? %>
+ </td>
+ </tr>
+ <% end %>
<% end %>
- <% end %>
- </tbody>
-</table>
+ </tbody>
+ </table>
+</div>
<p>
<% if current_user.memberships.any? %>
<%= link_to 'Add Domain', new_domain_path, class: 'btn btn-primary' %>
<% else %>
<%= link_to 'Add Domain', new_domain_path, class: 'btn btn-primary disabled' %>
<% end %>
</p>

Event Timeline