mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Adding nameservers to domain
This commit is contained in:
parent
24e7beed5b
commit
c24c8c7181
10 changed files with 69 additions and 8 deletions
|
@ -1,7 +1,16 @@
|
|||
$(".js-registrars-typeahead").typeahead
|
||||
source: (query, process) ->
|
||||
$.get "/admin/registrars/search", {query: query}, (data) ->
|
||||
process data
|
||||
map = {}
|
||||
registrars = []
|
||||
|
||||
$.each data, (i, registrar) ->
|
||||
map[registrar.id] = registrar
|
||||
registrars.push registrar.display
|
||||
|
||||
process registrars
|
||||
updater: (item) ->
|
||||
$('input[name="domain[registrar_id]"]').val()
|
||||
|
||||
$(".js-contacts-typeahead").typeahead
|
||||
source: (query, process) ->
|
||||
|
|
|
@ -5,6 +5,9 @@ class Admin::DomainsController < ApplicationController
|
|||
@domain = Domain.new
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def index
|
||||
@q = Domain.search(params[:q])
|
||||
@domains = @q.result.page(params[:page])
|
||||
|
@ -15,4 +18,8 @@ class Admin::DomainsController < ApplicationController
|
|||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
|
||||
def domain_params
|
||||
params.require(:domain).permit(:name, :period, :registrar, :owner_contact)
|
||||
end
|
||||
end
|
||||
|
|
21
app/controllers/admin/nameservers_controller.rb
Normal file
21
app/controllers/admin/nameservers_controller.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
class Admin::NameserversController < ApplicationController
|
||||
def new
|
||||
@domain = Domain.find_by(params[:id])
|
||||
@nameserver = @domain.nameservers.build
|
||||
end
|
||||
|
||||
def create
|
||||
@domain = Domain.find(params[:domain_id])
|
||||
if @domain.nameservers.create(nameserver_params)
|
||||
redirect_to [:admin, @domain]
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def nameserver_params
|
||||
params.require(:nameserver).permit(:hostname, :ipv4, :ipv6)
|
||||
end
|
||||
end
|
|
@ -1,7 +1,5 @@
|
|||
class Admin::RegistrarsController < ApplicationController
|
||||
def search
|
||||
r = Registrar.arel_table
|
||||
query_string = "%#{params[:query]}%"
|
||||
render json: Registrar.where(r[:name].matches(query_string)).pluck(:name)
|
||||
render json: Registrar.search_by_query(params[:query])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,4 +7,11 @@ class Registrar < ActiveRecord::Base
|
|||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
class << self
|
||||
def search_by_query(query)
|
||||
res = Registrar.search(name_or_reg_no_cont: query).result
|
||||
res.reduce([]) { |o, v| o << { id: v[:id], display: "#{v[:name]} (#{v[:reg_no]})" } }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
.col-md-6
|
||||
.form-group
|
||||
= f.label :registrar
|
||||
= f.text_field(:registrar, class: 'form-control js-registrars-typeahead', placeholder: t('shared.registrar_name'))
|
||||
= f.text_field(:registrar, class: 'form-control js-registrars-typeahead', placeholder: t('shared.registrar_name'), autocomplete: 'off')
|
||||
= f.hidden_field(:registrar_id)
|
||||
.form-group
|
||||
= f.label :owner_contact
|
||||
= f.text_field(:owner_contact, class: 'form-control js-contacts-typeahead', placeholder: t('shared.contact_code'))
|
||||
= f.text_field(:owner_contact, class: 'form-control js-contacts-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
= button_tag(t('shared.save'), class: 'btn btn-primary')
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
.panel.panel-default
|
||||
.panel-heading= t('shared.nameservers')
|
||||
.panel-heading.clearfix
|
||||
.pull-left
|
||||
= t('shared.nameservers')
|
||||
.pull-right
|
||||
= link_to(t('shared.add'), new_admin_domain_nameserver_path(@domain), class: 'btn btn-primary btn-xs')
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
|
@ -17,3 +21,7 @@
|
|||
%td
|
||||
= link_to(t('shared.edit'), root_path, class: 'btn btn-primary btn-xs')
|
||||
= link_to(t('shared.delete'), root_path, method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger btn-xs')
|
||||
%tfoot
|
||||
%tr
|
||||
%td{colspan: 4}
|
||||
Nameservers count must be between %{min}-%{max}
|
||||
|
|
3
app/views/admin/nameservers/new.haml
Normal file
3
app/views/admin/nameservers/new.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
= form_for([:admin, @domain, @nameserver]) do |f|
|
||||
= f.text_field :hostname
|
||||
= f.button 'save'
|
|
@ -184,3 +184,4 @@ en:
|
|||
new_domain: 'New domain'
|
||||
registrar_name: 'Registrar name'
|
||||
contact_code: 'Contact code'
|
||||
add: 'Add'
|
||||
|
|
|
@ -6,7 +6,10 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
namespace(:admin) do
|
||||
resources :domains
|
||||
resources :domains do
|
||||
resources :nameservers, shallow: true
|
||||
|
||||
end
|
||||
resources :setting_groups
|
||||
resources :registrars do
|
||||
collection do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue