Skip to content

Commit

Permalink
feat(matrix): add simple ui
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 7, 2017
1 parent 6925dcb commit 36f9480
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/pact_broker/ui/app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'pact_broker/ui/controllers/relationships'
require 'pact_broker/ui/controllers/groups'
require 'pact_broker/ui/controllers/matrix'
require 'pact_broker/doc/controllers/app'

module PactBroker
Expand All @@ -21,6 +22,10 @@ def initialize
run PactBroker::Doc::Controllers::App
end

map "/the-matrix" do
run PactBroker::UI::Controllers::Matrix
end

map "/" do
run PactBroker::UI::Controllers::Relationships
end
Expand Down
27 changes: 27 additions & 0 deletions lib/pact_broker/ui/controllers/matrix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'pact_broker/ui/controllers/base_controller'
require 'pact_broker/ui/view_models/matrix_line'
require 'haml'

module PactBroker
module UI
module Controllers
class Matrix < Base

include PactBroker::Services

get "/provider/:provider_name/consumer/:consumer_name" do
lines = matrix_service.find consumer_name: params[:consumer_name], provider_name: params[:provider_name]
lines = lines.collect{|line| PactBroker::UI::ViewDomain::MatrixLine.new(line)}
locals = {
lines: lines,
title: "The Matrix",
consumer_name: params[:consumer_name],
provider_name: params[:provider_name]
}
haml :'matrix/show', {locals: locals, layout: :'layouts/main'}
end

end
end
end
end
42 changes: 42 additions & 0 deletions lib/pact_broker/ui/view_models/matrix_line.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'pact_broker/api/pact_broker_urls'
require 'pact_broker/ui/helpers/url_helper'
require 'pact_broker/date_helper'

module PactBroker
module UI
module ViewDomain
class MatrixLine

include PactBroker::Api::PactBrokerUrls

def initialize line
@line = line
end

def consumer_version_number
@line[:consumer_version_number]
end

def provider_version_number
@line[:provider_version]
end

def verification_status
case @line[:success]
when true then "Verified"
when false then "Failed"
else ''
end
end

def verification_status_class
case @line[:success]
when true then 'success'
when false then 'danger'
else ''
end
end
end
end
end
end
30 changes: 30 additions & 0 deletions lib/pact_broker/ui/views/matrix/show.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
%body
%link{rel: 'stylesheet', href: '/css/bootstrap.min.css'}
%link{rel: 'stylesheet', href: '/stylesheets/relationships.css'}
%script{type: 'text/javascript', src:'/javascripts/jquery-2.1.1.min.js'}
%script{type: 'text/javascript', src:'/javascripts/jquery.tablesorter.min.js'}
%script{type: 'text/javascript', src:'/js/bootstrap.min.js'}

.container
%h1.page-header
= title
%table.table.table-bordered.table-striped{id: 'relationships'}
%thead
%th.consumer
= "#{consumer_name} version"
%span.glyphicon.glyphicon-sort.sort
%th.provider
= "#{provider_name} version"
%span.glyphicon.glyphicon-sort.sort
%th.verification-result
Verification
%tbody
- lines.each do | line |
%tr
%td.consumer-version
= line.consumer_version_number
%td.provider
= line.provider_version_number
%td.verification-result{class: line.verification_status_class}
= line.verification_status

0 comments on commit 36f9480

Please sign in to comment.