mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
111396946-templates_and_actions
This commit is contained in:
parent
e7aef75b25
commit
b111285334
4 changed files with 132 additions and 14 deletions
|
@ -2,11 +2,43 @@ class Admin::ReservedDomainsController < AdminController
|
|||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
names = ReservedDomain.pluck(:name, :password).each_with_object({}){|domain, hash| hash[domain[0]] = domain[1]}
|
||||
names.names = nil if names.blank?
|
||||
@reserved_domains = names.to_yaml.gsub(/---.?\n/, '').gsub(/\.\.\..?\n/, '')
|
||||
|
||||
params[:q] ||= {}
|
||||
domains = ReservedDomain.all
|
||||
@q = domains.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@domain = ReservedDomain.new
|
||||
end
|
||||
|
||||
def edit
|
||||
authorize! :update, Depp::Domain
|
||||
@data = @domain.info(params[:domain_name])
|
||||
@domain_params = Depp::Domain.construct_params_from_server_data(@data)
|
||||
end
|
||||
|
||||
def update
|
||||
authorize! :update, Depp::Domain
|
||||
@domain_params = params[:domain]
|
||||
@data = @domain.update(@domain_params)
|
||||
|
||||
if response_ok?
|
||||
redirect_to info_registrar_domains_url(domain_name: @domain_params[:name])
|
||||
else
|
||||
params[:domain_name] = @domain_params[:name]
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
authorize! :delete, Depp::Domain
|
||||
end
|
||||
|
||||
|
||||
def create
|
||||
@reserved_domains = params[:reserved_domains]
|
||||
|
||||
|
|
23
app/views/admin/reserved_domains/_form.haml
Normal file
23
app/views/admin/reserved_domains/_form.haml
Normal file
|
@ -0,0 +1,23 @@
|
|||
= form_for([:admin, @domain], html: {class: 'form-horizontal'}) do |f|
|
||||
= render 'shared/full_errors', object: @domain
|
||||
|
||||
.row
|
||||
.col-md-8
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
.pull-left= t(:general)
|
||||
.panel-body
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
= f.label :name
|
||||
.col-md-7
|
||||
= f.text_field(:name, class: 'form-control')
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
= f.label :password
|
||||
.col-md-7
|
||||
= f.text_field(:password, class: 'form-control')
|
||||
%hr
|
||||
.row
|
||||
.col-md-8.text-right
|
||||
= button_tag(t(:save), class: 'btn btn-primary')
|
|
@ -1,14 +1,74 @@
|
|||
- content_for :actions do
|
||||
= link_to('#', class: 'btn btn-default', "data-container": "body", "data-title": t('list_format_is_in_yaml'), "data-content": "domain.ee: authinfopw<br>seconddomain.ee:<br>thirddomain.ee: authinfo3<br><br>#{t('if_auth_info_is_left_empty_it_will_be_auto_generated')}<br>#{t('each_domain_name_must_end_with_colon_sign')}", "data-placement": "left", "data-toggle": "popover", "data-html" => "true") do
|
||||
%span.glyphicon.glyphicon-info-sign{"aria-hidden" => "true"}
|
||||
|
||||
= link_to(t(:new), new_admin_reserved_domain_path, class: 'btn btn-primary')
|
||||
= render 'shared/title', name: t(:reserved_domains)
|
||||
|
||||
= form_tag([:admin, :reserved_domains]) do |f|
|
||||
.row
|
||||
.row
|
||||
.col-md-12
|
||||
= text_area_tag :reserved_domains, @reserved_domains, class: 'form-control', rows: 30
|
||||
%hr
|
||||
= search_form_for [:admin, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f|
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
%button.btn.btn-warning=t(:save)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label :name
|
||||
= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:created_at_from)
|
||||
= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control datepicker', placeholder: t(:created_at_from)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:created_at_until)
|
||||
= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:created_at_until)
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
= label_tag t(:results_per_page)
|
||||
= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page)
|
||||
.col-md-3{style: 'padding-top: 25px;'}
|
||||
%button.btn.btn-primary
|
||||
|
||||
%span.glyphicon.glyphicon-search
|
||||
|
||||
%button.btn.btn-default.js-reset-form
|
||||
= t(:clear_fields)
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'name')
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'password')
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'created_at', t(:created_at))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'updated_at', t(:updated_at))
|
||||
%th{class: 'col-xs-2'}
|
||||
= t(:actions)
|
||||
%tbody
|
||||
- @domains.each do |x|
|
||||
%tr
|
||||
%td= x.name
|
||||
%td= x.password
|
||||
%td= l(x.created_at, format: :short)
|
||||
%td= l(x.updated_at, format: :short)
|
||||
%td
|
||||
= link_to(t(:edit), edit_admin_reserved_domains_path(name: x.name),
|
||||
class: 'btn btn-primary btn-xs')
|
||||
= link_to(t(:renew), renew_admin_reserved_domains_path(name: x.name),
|
||||
class: 'btn btn-default btn-xs')
|
||||
= link_to(t(:delete), delete_admin_reserved_domains_path(name: x.name),
|
||||
class: 'btn btn-default btn-xs')
|
||||
.row
|
||||
.col-md-6
|
||||
= paginate @domains
|
||||
.col-md-6.text-right
|
||||
.pagination
|
||||
= t(:result_count, count: @domains.total_count)
|
||||
|
||||
:coffee
|
||||
$(".js-reset-form").on "click", (e) ->
|
||||
e.preventDefault();
|
||||
window.location = "#{admin_reserved_domains_path}"
|
||||
|
|
3
app/views/admin/reserved_domains/new.haml
Normal file
3
app/views/admin/reserved_domains/new.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
= render 'shared/title', name: t(:new_reserved_domain)
|
||||
|
||||
= render 'form'
|
Loading…
Add table
Add a link
Reference in a new issue