Merge pull request #47 from Pear-Trading/finn/ViewTransactionList
View Single Transactions
This commit is contained in:
commit
bb239ba000
8 changed files with 147 additions and 14 deletions
|
@ -185,6 +185,10 @@ sub startup {
|
|||
$admin_routes->get('/feedback')->to('admin-feedback#index');
|
||||
$admin_routes->get('/feedback/:id')->to('admin-feedback#read');
|
||||
|
||||
$admin_routes->get('/transactions')->to('admin-transactions#index');
|
||||
$admin_routes->get('/transactions/:id')->to('admin-transactions#read');
|
||||
$admin_routes->get('/transactions/:id/image')->to('admin-transactions#image');
|
||||
|
||||
# my $user_routes = $r->under('/')->to('root#under');
|
||||
|
||||
# $user_routes->get('/home')->to('root#home');
|
||||
|
|
51
lib/Pear/LocalLoop/Controller/Admin/Transactions.pm
Normal file
51
lib/Pear/LocalLoop/Controller/Admin/Transactions.pm
Normal file
|
@ -0,0 +1,51 @@
|
|||
package Pear::LocalLoop::Controller::Admin::Transactions;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
has result_set => sub {
|
||||
my $c = shift;
|
||||
return $c->schema->resultset('Transaction');
|
||||
};
|
||||
|
||||
sub index {
|
||||
my $c = shift;
|
||||
|
||||
my $transactions = $c->result_set->search(
|
||||
undef, {
|
||||
page => $c->param('page') || 1,
|
||||
rows => 10,
|
||||
order_by => { -desc => 'submitted_at' },
|
||||
},
|
||||
);
|
||||
$c->stash(
|
||||
transactions => $transactions,
|
||||
);
|
||||
}
|
||||
|
||||
sub read {
|
||||
my $c = shift;
|
||||
|
||||
my $id = $c->param('id');
|
||||
|
||||
if ( my $transaction = $c->result_set->find($id) ) {
|
||||
$c->stash( transaction => $transaction );
|
||||
} else {
|
||||
$c->flash( error => 'No transaction found' );
|
||||
$c->redirect_to( '/admin/transactions' );
|
||||
}
|
||||
}
|
||||
|
||||
sub image {
|
||||
my $c = shift;
|
||||
|
||||
my $id = $c->param('id');
|
||||
|
||||
my $transaction = $c->result_set->find($id);
|
||||
|
||||
if ( $transaction->proof_image ) {
|
||||
$c->reply->asset($c->get_file_from_uuid($transaction->proof_image));
|
||||
} else {
|
||||
$c->reply->static('image/no_transaction.jpg');
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
BIN
public/image/no_transaction.jpg
Normal file
BIN
public/image/no_transaction.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
|
@ -71,6 +71,7 @@
|
|||
% for my $transaction ( $transactions->all ) {
|
||||
<li class="list-group-item">
|
||||
<div class="container">
|
||||
<a href="<%= url_for '/admin/transactions/' . $transaction->id %>" class="list-group-item list-group-item-action">
|
||||
<div class="row text-center">
|
||||
<div class="col">From: <%= $transaction->buyer->name %></div>
|
||||
<div class="col">To: <%= $transaction->seller->name %></div>
|
||||
|
@ -78,6 +79,7 @@
|
|||
<div class="col">Submitted At: <%= $transaction->submitted_at %></div>
|
||||
<div class="col">Purchase Time: <%= $transaction->purchase_time %></div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
% }
|
||||
|
|
35
templates/admin/transactions/index.html.ep
Normal file
35
templates/admin/transactions/index.html.ep
Normal file
|
@ -0,0 +1,35 @@
|
|||
% layout 'admin';
|
||||
% title 'Transactions';
|
||||
% content_for javascript => begin
|
||||
% end
|
||||
% if ( my $error = flash 'error' ) {
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error!</strong> <%= $error %>
|
||||
</div>
|
||||
% } elsif ( my $success = flash 'success' ) {
|
||||
<div class="alert alert-success" role="alert">
|
||||
<strong>Success!</strong> <%= $success %>
|
||||
</div>
|
||||
% }
|
||||
<div class="list-group list-group-flush">
|
||||
% for my $transaction ( $transactions->all ) {
|
||||
<li class="list-group-item">
|
||||
<div class="container">
|
||||
<a href="<%= url_for . '/' . $transaction->id %>" class="list-group-item list-group-item-action">
|
||||
<div class="row text-center">
|
||||
<div class="col">From: <%= $transaction->buyer->name %></div>
|
||||
<div class="col">To: <%= $transaction->seller->name %></div>
|
||||
<div class="col">Value: <%= $transaction->value %></div>
|
||||
<div class="col">Submitted At: <%= $transaction->submitted_at %></div>
|
||||
<div class="col">Purchase Time: <%= $transaction->purchase_time %></div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
% }
|
||||
<li class="list-group-item">
|
||||
<div class="container">
|
||||
%= bootstrap_pagination( $c->param('page') || 1, $transactions->pager->last_page, { class => 'justify-content-center' } );
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
38
templates/admin/transactions/read.html.ep
Normal file
38
templates/admin/transactions/read.html.ep
Normal file
|
@ -0,0 +1,38 @@
|
|||
% layout 'admin';
|
||||
% title 'Transactions';
|
||||
% content_for javascript => begin
|
||||
% end
|
||||
% if ( my $error = flash 'error' ) {
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error!</strong> <%= $error %>
|
||||
</div>
|
||||
% } elsif ( my $success = flash 'success' ) {
|
||||
<div class="alert alert-success" role="alert">
|
||||
<strong>Success!</strong> <%= $success %>
|
||||
</div>
|
||||
% }
|
||||
<form action="<%= url_for %>" method="post">
|
||||
<div class="form-group">
|
||||
<label for="email">Buyer</label>
|
||||
<input id="buyer" type="text" class="form-control" placeholder="Buyer ID" name="buyer" value="<%= $transaction->buyer->name %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Seller</label>
|
||||
<input id="seller" type="text" class="form-control" placeholder="Seller ID" name="seller" value="<%= $transaction->seller->name %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Value</label>
|
||||
<input id="value" type="text" class="form-control" placeholder="Value" name="value" value="<%= $transaction->value %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Submitted At</label>
|
||||
<input id="submitted_at" type="text" class="form-control" placeholder="Submitted At" name="submitted_at" value="<%= $transaction->submitted_at %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Purchase Time</label>
|
||||
<input id="purchase_time" type="text" class="form-control" placeholder="Purchase Time" name="purchase_time" value="<%= $transaction->purchase_time %>" disabled>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<img src="<%= url_for . '/image' %>"/>
|
||||
</div>
|
||||
</form>
|
|
@ -94,6 +94,7 @@
|
|||
% for my $transaction ( $transactions->all ) {
|
||||
<li class="list-group-item">
|
||||
<div class="container">
|
||||
<a href="<%= url_for '/admin/transactions/' . $transaction->id %>" class="list-group-item list-group-item-action">
|
||||
<div class="row text-center">
|
||||
<div class="col">From: <%= $transaction->buyer->name %></div>
|
||||
<div class="col">To: <%= $transaction->seller->name %></div>
|
||||
|
@ -101,6 +102,7 @@
|
|||
<div class="col">Submitted At: <%= $transaction->submitted_at %></div>
|
||||
<div class="col">Purchase Time: <%= $transaction->purchase_time %></div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
% }
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<div class="navbar-nav ml-auto">
|
||||
<a class="nav-item nav-link<%= title eq 'Feedback' ? ' active' : '' %>" href="<%= url_for '/admin/feedback' %>">Feedback</a>
|
||||
<a class="nav-item nav-link<%= title eq 'Tokens' ? ' active' : '' %>" href="<%= url_for '/admin/tokens' %>">Tokens</a>
|
||||
<a class="nav-item nav-link<%= title eq 'Transactions' ? ' active' : '' %>" href="<%= url_for '/admin/transactions' %>">Transactions</a>
|
||||
<a class="nav-item nav-link<%= title eq 'Users' ? ' active' : '' %>" href="<%= url_for '/admin/users' %>">Users</a>
|
||||
<a class="nav-item nav-link<%= title eq 'Organisations' ? ' active' : '' %>" href="<%= url_for '/admin/organisations' %>">Organisations</a>
|
||||
<a class="nav-item nav-link" href="<%= url_for '/admin/logout' %>">Logout</a>
|
||||
|
|
Reference in a new issue