-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #529 from roomorama/release/1.0.0
Release/1.0.0
- Loading branch information
Showing
75 changed files
with
921 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.flash-message { | ||
font-size: 0.9em; | ||
color: #aaa; | ||
padding: 20px; | ||
background-color: #eee; | ||
margin-bottom: 20px; | ||
border: 1px solid #bbb; | ||
text-align: center; | ||
} | ||
|
||
.flash-message.notice { | ||
background-color: #2ebbab; | ||
color: #fff; | ||
} | ||
|
||
.flash-message.error { | ||
background-color: #e14536; | ||
color: #fff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.host-form .host-form-control { | ||
padding: 5px; | ||
} | ||
|
||
.host-form .host-form-control label { | ||
display: inline-block; | ||
width: 150px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
get "/sync_processes/:id/stats", to: "sync_processes#stats", as: :stats | ||
post "/suppliers/worker_resync", to: "workers#resync", as: :worker_resync | ||
get "/", to: "dashboard#index", as: :root | ||
|
||
resources :errors, only: [:index, :show], controller: "external_errors" | ||
resources :reservations, only: [:index] | ||
resources :suppliers, only: [:show] | ||
resources :suppliers, only: [:show] do | ||
resources :hosts, only: [:new, :create], controller: "hosts" | ||
end | ||
resources :sync_processes, only: [:index] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Web::Controllers::Hosts | ||
class Create | ||
include Web::Action | ||
|
||
params do | ||
param :supplier_id, type: String, presence: true | ||
param :host do | ||
param :identifier, type: String, presence: true | ||
param :username, type: String, presence: true | ||
param :access_token, type: String, presence: true | ||
param :fee_percentage, type: Integer, presence: true | ||
end | ||
end | ||
|
||
def call(params) | ||
if params.valid? | ||
host_creation = build_host_creation(params) | ||
result = host_creation.perform | ||
|
||
if result.success? | ||
flash[:notice] = "Host was successfully created" | ||
else | ||
flash[:error] = "Host creation unsuccessful: #{result.error.code}" | ||
end | ||
else | ||
flash[:error] = "Host parameters validation error" | ||
end | ||
|
||
redirect_to routes.supplier_path(params[:supplier_id]) | ||
end | ||
|
||
private | ||
def build_host_creation(params) | ||
Concierge::Flows::HostCreation.new( | ||
supplier: supplier, | ||
identifier: params.get("host.identifier"), | ||
username: params.get("host.username"), | ||
access_token: params.get("host.access_token"), | ||
fee_percentage: params.get("host.fee_percentage"), | ||
config_path: config_path | ||
) | ||
end | ||
|
||
def supplier | ||
SupplierRepository.find(params[:supplier_id]) | ||
end | ||
|
||
def config_path | ||
Hanami.root.join("config", "suppliers.yml").to_s | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Web::Controllers::Hosts | ||
class New | ||
include Web::Action | ||
|
||
expose :supplier | ||
|
||
def call(params) | ||
@supplier = SupplierRepository.find(params[:supplier_id]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require_relative "../internal_error" | ||
|
||
module Web::Controllers::Workers | ||
class Resync | ||
include Web::Action | ||
include Web::Controllers::InternalError | ||
|
||
def call(params) | ||
worker = find_worker(params.get("worker.worker_id")) | ||
|
||
if worker | ||
if worker.idle? | ||
Concierge::Flows::WorkerJobEnqueue.new(worker).perform | ||
|
||
flash[:notice] = "#{worker.type} worker with id #{worker.id} was queued to synchronisation" | ||
else | ||
flash[:error] = "#{worker.type} worker with id #{worker.id} cannot be queued because it has #{worker.status} status" | ||
end | ||
else | ||
flash[:error] = "Couldn't find requested worker" | ||
end | ||
|
||
redirect_to request.referer | ||
end | ||
|
||
private | ||
def find_worker(worker_id) | ||
BackgroundWorkerRepository.find(worker_id) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% if flash_message(flash) %> | ||
<div class="flash-message <%= flash_message_type(flash) %>"> | ||
<%= flash_message(flash) %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<%= stylesheet "host_form" %> | ||
|
||
<div class="content"> | ||
<h2 class="content-subhead"><%= supplier.name %></h2> | ||
<h3>Create new host</h3> | ||
<%= | ||
form_for :host, routes.supplier_hosts_path(supplier.id), class: 'host-form' do | ||
div(class: 'host-form-control') do | ||
label :identifier | ||
text_field :identifier | ||
end | ||
|
||
div(class: 'host-form-control') do | ||
label :username | ||
text_field :username | ||
end | ||
|
||
div(class: 'host-form-control') do | ||
label :access_token | ||
text_field :access_token | ||
end | ||
|
||
div(class: 'host-form-control') do | ||
label :fee_percentage | ||
number_field :fee_percentage | ||
end | ||
|
||
div do | ||
submit 'Create host' | ||
end | ||
end | ||
%> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Web::Views::Hosts | ||
class New | ||
include Web::View | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.