Skip to content

Commit

Permalink
fixed issues by feedback 20-10-2023
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegPhenomenon committed Oct 24, 2023
1 parent acba007 commit e6dc727
Show file tree
Hide file tree
Showing 36 changed files with 400 additions and 183 deletions.
50 changes: 50 additions & 0 deletions app/components/common/statuses_info/component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<div class="sm:col-span-2">
<div class="mt-8 border-t border-gray-200 pt-8">
<% if status_notes.present? %>
<h2 class="text-sm font-medium text-gray-500 mb-2"><%= t('.status_notes') %></h2>

<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg mt-8">
<table class="min-w-full divide-y divide-gray-300">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Status</th>
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Note</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
<% status_notes.each do |k, v| %>
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
<span class="inline-flex items-center rounded-full bg-indigo-100 px-3 py-0.5 text-sm font-medium text-indigo-800">
<svg class="-ml-1 mr-1.5 h-2 w-2 text-indigo-400" fill="currentColor" viewBox="0 0 8 8">
<circle cx="4" cy="4" r="3" />
</svg>
<%= k %>
</span>
</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500"><%= v %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<h2 class="text-sm font-medium text-gray-500 mb-2"><%= t('.statuses') %></h2>

<div class="prose prose-sm mt-4 text-gray-500">
<ul role="list" class='flex space-x-3'>
<% statuses.each do |status| %>
<li>
<span class="inline-flex items-center rounded-full bg-indigo-100 px-3 py-0.5 text-sm font-medium text-indigo-800">
<svg class="-ml-1 mr-1.5 h-2 w-2 text-indigo-400" fill="currentColor" viewBox="0 0 8 8">
<circle cx="4" cy="4" r="3" />
</svg>
<%= status %>
</span>
</li>
<% end %>
</ul>
</div>
<% end %>
</div>
</div>
15 changes: 15 additions & 0 deletions app/components/common/statuses_info/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Common
module StatusesInfo
class Component < ViewComponent::Base

attr_reader :status_notes, :statuses

def initialize(status_notes:, statuses:, **options)
super

@statuses = statuses
@status_notes = status_notes
end
end
end
end
77 changes: 77 additions & 0 deletions app/components/contacts/info/component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<dl class="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2">
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.name') %></dt>
<dd class="mt-1 text-sm text-gray-900"><%= @contact.name %></dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.object_code') %></dt>
<% if @contact.code.present? %>
<dd class="mt-1 text-sm text-gray-900"><%= @contact.code %></dd>
<% else %>
<dd class="mt-1 text-sm text-red-500"><%= t('.no_code_need_synchronize') %></dd>
<% end %>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.identity_code') %></dt>
<dd class="mt-1 text-sm text-gray-900"><%= @contact.ident %></dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.email')%></dt>
<dd class="mt-1 text-sm text-gray-900"><%= @contact.email %></dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.phone')%></dt>
<dd class="mt-1 text-sm text-gray-900"><%= @contact.phone %></dd>
</div>

<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.registry_created_at')%></dt>
<dd class="mt-1 text-sm text-gray-900"><%= l(@contact.registry_created_at.to_datetime) %></dd>
</div>

<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.registry_updated_at')%></dt>
<dd class="mt-1 text-sm text-gray-900"><%= l(@contact.registry_updated_at.to_datetime) %></dd>
</div>

<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.state')%></dt>
<dd class="mt-1">
<span class="py-1 px-4 rounded-3xl text-white <%= @contact.active? ? 'bg-green-500' : 'bg-gray-500' %>"><%= @contact.state %></span>
</dd>
</div>

<% if show_address? %>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.postal_address')%></dt>
<dd class="mt-1 text-sm text-gray-900"><%= @contact.postal_address %></dd>
</div>
<% end %>

<div class="sm:col-span-2">
<div class="mt-8 border-t border-gray-200 pt-8">
<h2 class="text-sm font-medium text-gray-900"><%= t('.statuses') %></h2>

<% if @contact.statuses.present? %>
<div class="prose prose-sm mt-4 text-gray-500">
<ul role="list" class='flex space-x-3'>
<% @contact.statuses.each do |status| %>
<li>
<span class="inline-flex items-center rounded-full bg-indigo-100 px-3 py-0.5 text-sm font-medium text-indigo-800">
<svg class="-ml-1 mr-1.5 h-2 w-2 text-indigo-400" fill="currentColor" viewBox="0 0 8 8">
<circle cx="4" cy="4" r="3" />
</svg>
<%= status.join %>
</span>
</li>
<% end %>
</ul>
</div>
<% else %>
<div class="prose prose-sm mt-4 text-red-500">
<p><%= t('.no_statuses_need_synchronize') %></p>
</div>
<% end %>
</div>
</div>
</dl>
15 changes: 15 additions & 0 deletions app/components/contacts/info/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Contacts
module Info
class Component < ViewComponent::Base
include ::Registrars::ContactsHelper

attr_reader :contact

def initialize(contact:, **options)
super

@contact = contact
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="relative flex items-start">
<div class="flex h-5 items-center">
<%= form.check_box attribute, { class: "h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500", checked: value }, "true", "false" %>
</div>
<div class="ml-3 text-sm">
<%= form.label label_name, class: 'font-medium text-gray-700' %>
<p id="comments-description" class="text-gray-500"><%= description %></p>
</div>
</div>
17 changes: 17 additions & 0 deletions app/components/form/checkbox_with_description/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Form
module CheckboxWithDescription
class Component < ApplicationViewComponent
attr_reader :form, :attribute, :label_name, :description, :value

def initialize(form:, attribute:, label_name: nil, description: nil, value: false, **options)
super

@form = form
@attribute = attribute
@label_name = label_name
@description = description
@value = value
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<%= heroicon @heroicon_name, options: { class: 'h-5 w-5 text-gray-400' } %>
</div>
<%= @form.country_select @attribute, { priority_countries: ["EE", "LV", "LT"], include_blank: t('.select_country') }, { class: 'block w-full rounded-md pl-3 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm py-2 bg-white border-gray-200 shadow-sm sm:text-sm text-gray-400'} %>
<%= @form.country_select @attribute, { priority_countries: ["EE", "LV", "LT"], include_blank: t('.select_country') }, { class: 'block w-full rounded-md pl-3 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm py-2 bg-white border-gray-200 shadow-sm sm:text-sm text-gray-800'} %>
</div>
2 changes: 1 addition & 1 deletion app/components/form/dropdown_input/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<%= heroicon @heroicon_name, variant: :solid, options: { class: 'h-5 w-5 text-gray-400' } %>
</div>
<%= @form.select @attribute, @enum, { include_blank: true }, { class: 'block w-full rounded-md pl-10 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm py-2 bg-white border-gray-200 shadow-sm sm:text-sm text-gray-400' } %>
<%= @form.select @attribute, @enum, { include_blank: true }, { class: 'block w-full rounded-md pl-3 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm py-2 bg-white border-gray-200 shadow-sm sm:text-sm text-gray-800' } %>
</div>
43 changes: 2 additions & 41 deletions app/components/lists/basic_list/list/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,8 @@
<div class='hidden' data-behaviour--togglable-target='content'>
<% if item.class.name.underscore == 'contact' %>
<div class="px-4 py-5 sm:px-6 container mx-auto mt-12">
<dl class="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2">
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.contact_name') %></dt>
<dd class="mt-1 text-sm text-gray-900"><%= item.name %></dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.contact_code') %></dt>
<dd class="mt-1 text-sm text-gray-900"><%= item.code %></dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.contact_ident ') %></dt>
<dd class="mt-1 text-sm text-gray-900"><%= item.ident %></dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.contact_email')%></dt>
<dd class="mt-1 text-sm text-gray-900"><%= item.email %></dd>
</div>
<div class="sm:col-span-1">
<dt class="text-sm font-medium text-gray-500"><%= t('.contact_phone')%></dt>
<dd class="mt-1 text-sm text-gray-900"><%= item.phone %></dd>
</div>
<div class="sm:col-span-2">
<h2 class="text-sm font-medium text-gray-900"><%= t('.statuses') %></h2>

<div class="prose prose-sm mt-4 text-gray-500">
<ul role="list" class='flex space-x-3'>
<% item.statuses.each do |status| %>
<li>
<span class="inline-flex items-center rounded-full bg-indigo-100 px-3 py-0.5 text-sm font-medium text-indigo-800">
<svg class="-ml-1 mr-1.5 h-2 w-2 text-indigo-400" fill="currentColor" viewBox="0 0 8 8">
<circle cx="4" cy="4" r="3" />
</svg>
<%= status.join %>
</span>
</li>
<% end %>
</ul>
</div>
</div>
</dl>
<%= component 'contacts/info', contact: item %>
</div>
<% end %>
</div>
</li>
</li>
1 change: 1 addition & 0 deletions app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class SettingsController < ApplicationController

def show
@invoice_group = Setting.with_group('invoice')
@contact_group = Setting.with_group('contacts')
end

def update
Expand Down
7 changes: 7 additions & 0 deletions app/helpers/registrars/contacts_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Registrars
module ContactsHelper
def show_address?
Setting.show_address_customer
end
end
end
11 changes: 11 additions & 0 deletions app/javascript/controllers/filter/clear_form_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// app/javascript/controllers/debounce_controller.js
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["form"]

clearForm() {
this.formTarget.reset();
this.formTarget.requestSubmit();
}
}
3 changes: 3 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ application.register("behaviour--togglable", Behaviour__Togglable_Controller);
import Behaviour__DebounceController from "./behaviour/debounce_controller";
application.register("behaviour--debounce", Behaviour__DebounceController);

import Filter__ClearFormController from "./filter/clear_form_controller";
application.register("filter--clear-form", Filter__ClearFormController);

import DropzoneController from "./dropzone_controller"
application.register("dropzone", DropzoneController)
26 changes: 16 additions & 10 deletions app/jobs/estonian_tld/contacts_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ def perform(tld)
offset: 0
}

dirty_contacs = EstonianTld::ContactService.new(tld:).contact_list(url_params:)
dirty_contacts = EstonianTld::ContactService.new(tld:).contact_list(url_params:)

unless dirty_contacs.success
unless dirty_contacts.success
inform_admin_service(tld:, message: 'Error fetching contacts')
@perform_callback = false

return
end

total_count = dirty_contacs.body['data']['count']
contact_count = dirty_contacs['body']['data']['contacts'].count
contact_creator(dirty_contacs)
total_count = dirty_contacts.body['data']['count']
contact_count = dirty_contacts['body']['data']['contacts'].count
contact_creator(dirty_contacts)

return if contact_count < STEP

(STEP..total_count + STEP - 1).step(STEP) do |offset|
url_params[:offset] = offset
dirty_contacs = EstonianTld::ContactService.new(tld:).contact_list(url_params:)
contact_creator(dirty_contacs)
dirty_contacts = EstonianTld::ContactService.new(tld:).contact_list(url_params:)
contact_creator(dirty_contacts)

inform_admin_service(tld:, message: "Processed contacts #{url_params[:offset]} of #{total_count}")

Expand All @@ -47,12 +47,18 @@ def perform(tld)
inform_admin_service(tld:, message: 'All contacts were synchronized!')
end

def contact_creator(dirty_contacs)
contacts = EstonianTld::ContactSerializer.call(dirty: dirty_contacs)
def contact_creator(dirty_contacts)
contacts = EstonianTld::ContactSerializer.call(dirty: dirty_contacts)

contacts_attributes = []

contacts.each do |contact|
next if ::Contact.exists?(code: contact.code)
if ::Contact.exists?(code: contact.code)
c = ::Contact.find_by(code: contact.code)
c.update(contact.to_h)

next
end

contacts_attributes << contact.to_h
end
Expand Down
7 changes: 6 additions & 1 deletion app/jobs/estonian_tld/domains_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def perform(tld)
(STEP..total_count + STEP - 1).step(STEP) do |offset|
url_params[:offset] = offset
dirty_domains = EstonianTld::DomainService.new(tld:).domain_list(url_params:)

domain_creator(dirty_domains)

EstonianTld::InformAdminService.call({tld: Tld.first, message: "Processed domains #{url_params[:offset]} of #{total_count}"})
Expand All @@ -58,7 +59,11 @@ def domain_creator(dirty_domains)
domain_dnskeys = EstonianTld::DomainDnskeySerializer.call(dirty:)

d = ::Domain.find_by(name: domain.name)
next if d.present?
if d.present?
d.update(domain.to_h)

next
end

ActiveRecord::Base.transaction do
begin
Expand Down
Loading

0 comments on commit e6dc727

Please sign in to comment.