Compare commits
2 Commits
f3e970ab1b
...
421539f38c
Author | SHA1 | Date | |
---|---|---|---|
421539f38c | |||
4c9d46f875 |
@ -8,6 +8,13 @@ body{
|
||||
padding-left: $nav-width;
|
||||
}
|
||||
|
||||
.card{
|
||||
padding: 20px 30px;
|
||||
background: white;
|
||||
border-radius: 5px;
|
||||
box-shadow: $box-shadow-2;
|
||||
}
|
||||
|
||||
#main-nav{
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@ -53,13 +60,31 @@ body{
|
||||
}
|
||||
}
|
||||
|
||||
#main-actions{
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin-top: 0;
|
||||
margin-bottom: 25px;
|
||||
|
||||
form,
|
||||
input{
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
#main-wrapper{
|
||||
max-width: 1200px;
|
||||
margin-top: 25px;
|
||||
padding: 20px 30px;
|
||||
background: white;
|
||||
border-radius: 5px;
|
||||
box-shadow: $box-shadow-2;
|
||||
}
|
||||
|
||||
#main-wrapper.container.fluid{
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#site-header{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#item-header,
|
||||
|
@ -3,3 +3,5 @@ require_relative 'routes/index.rb'
|
||||
require_relative 'routes/item.rb'
|
||||
|
||||
require_relative 'routes/license.rb'
|
||||
|
||||
require_relative 'routes/search.rb'
|
||||
|
@ -2,9 +2,11 @@ namespace '/' do
|
||||
|
||||
get '' do
|
||||
items = Item.reverse(:updated_at).limit(10).all()
|
||||
licenses = License.reverse(:updated_at).limit(10).all()
|
||||
erb :index, :locals => {
|
||||
:title => 'Dashboard',
|
||||
:items => items
|
||||
:items => items,
|
||||
:licenses => licenses
|
||||
}
|
||||
end
|
||||
|
||||
|
14
lib/routes/search.rb
Normal file
14
lib/routes/search.rb
Normal file
@ -0,0 +1,14 @@
|
||||
namespace '/search' do
|
||||
get '' do
|
||||
search_parameter = params[:query]
|
||||
items = Item.where(Sequel.ilike(:name, "%#{search_parameter}%")).all()
|
||||
licenses = License.where(Sequel.ilike(:name, "%#{search_parameter}%")).all()
|
||||
|
||||
erb :'search/list', :locals => {
|
||||
:title => 'Search Results',
|
||||
:items => items,
|
||||
:licenses => licenses,
|
||||
:query => search_parameter
|
||||
}
|
||||
end
|
||||
end
|
@ -1,11 +1,57 @@
|
||||
<p>This is a test.</p>
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
<h1 id="site-header">Welcome to Raven</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if items.length > 0 %>
|
||||
<ul>
|
||||
<hr>
|
||||
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<h3>Recent inventory updates</h3>
|
||||
<% if items.length > 0 %>
|
||||
<table class="u-full-width">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item name</th>
|
||||
<th>Updated at</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% items.each do |item| %>
|
||||
<li><%= item.name %></li>
|
||||
<tr>
|
||||
<td><%= item.name %></td>
|
||||
<td><%= date_format(item.updated_at) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p>There are no items to display.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<h3>Recent license updates</h3>
|
||||
<% if licenses.length > 0 %>
|
||||
<table class="u-full-width">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>License name</th>
|
||||
<th>Updated at</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% licenses.each do |license| %>
|
||||
<tr>
|
||||
<td><%= license.name %></td>
|
||||
<td><%= date_format(license.updated_at) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p>There are no licenses to display.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,9 +11,12 @@
|
||||
</head>
|
||||
<body>
|
||||
<!-- Main navigation -->
|
||||
<%= erb :'layout/navbar' %>
|
||||
<%= erb :'layout/navbar', :locals => locals %>
|
||||
|
||||
<div id="main-wrapper" class="container">
|
||||
<!-- Inventory search/actions bar -->
|
||||
<%= erb :'layout/actions', :locals => locals %>
|
||||
|
||||
<div id="main-wrapper" class="container fluid card">
|
||||
<%= yield %>
|
||||
</div>
|
||||
</body>
|
||||
|
9
views/layout/actions.erb
Normal file
9
views/layout/actions.erb
Normal file
@ -0,0 +1,9 @@
|
||||
<div id="main-actions" class="container fluid card">
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<form action="/search" class="u-full-width">
|
||||
<input id="search-field" class="u-full-width" type="text" placeholder="Search your inventory..." name="query" required <%= defined?(query) ? 'value="' + query + '"' : '' %>>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
25
views/search/list.erb
Normal file
25
views/search/list.erb
Normal file
@ -0,0 +1,25 @@
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
<h4>Matching hardware:</h4>
|
||||
<% if items.length > 0 %>
|
||||
<ul class="u-full-width">
|
||||
<% items.each do |r| %>
|
||||
<li><a href="/item/<%= r.id %>"><%= r.name %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p>Sorry, nothing in your hardware inventory matches that search term.</p>
|
||||
<% end %>
|
||||
|
||||
<h4>Matching licenses:</h4>
|
||||
<% if licenses.length > 0 %>
|
||||
<ul class="u-full-width">
|
||||
<% licenses.each do |r| %>
|
||||
<li><a href="/item/<%= r.id %>"><%= r.name %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p>Sorry, nothing in your license inventory matches that search term.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user