This commit is contained in:
		@@ -9,7 +9,20 @@ exports.getSearch = async function(req, res) {
 | 
			
		||||
  let query = req.query.query;
 | 
			
		||||
 | 
			
		||||
  // fetch inventory items from database based on search query
 | 
			
		||||
  const results = await Item.findAll({
 | 
			
		||||
  const item_results = await Item.findAll({
 | 
			
		||||
    where: {
 | 
			
		||||
      name: {
 | 
			
		||||
        [Op.like]: '%' + query + '%',
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    limit: 10,
 | 
			
		||||
    order: [
 | 
			
		||||
      ['updatedAt', 'DESC'],
 | 
			
		||||
    ],
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  // fetch licenses from database based on search query
 | 
			
		||||
  const license_results = await License.findAll({
 | 
			
		||||
    where: {
 | 
			
		||||
      name: {
 | 
			
		||||
        [Op.like]: '%' + query + '%',
 | 
			
		||||
@@ -23,6 +36,7 @@ exports.getSearch = async function(req, res) {
 | 
			
		||||
 | 
			
		||||
  res.render('search.twig', {
 | 
			
		||||
    query: query,
 | 
			
		||||
    results: results,
 | 
			
		||||
    item_results: item_results,
 | 
			
		||||
    license_results: license_results,
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -11,27 +11,56 @@
 | 
			
		||||
  </div>
 | 
			
		||||
</header>
 | 
			
		||||
 | 
			
		||||
<section id="search-results" class="row">
 | 
			
		||||
  <div class="columns twelve">
 | 
			
		||||
    <table class="u-full-width">
 | 
			
		||||
      <thead>
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th>Name</th>
 | 
			
		||||
          <th>Type</th>
 | 
			
		||||
          <th>Updated at</th>
 | 
			
		||||
        </tr>
 | 
			
		||||
      </thead>
 | 
			
		||||
      <tbody>
 | 
			
		||||
        {% for item in results %}
 | 
			
		||||
{% if item_results|len > 0 %}
 | 
			
		||||
  <section id="search-results" class="row">
 | 
			
		||||
    <div class="columns twelve">
 | 
			
		||||
      <h3>Hardware components:</h3>
 | 
			
		||||
      <table class="u-full-width">
 | 
			
		||||
        <thead>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <td><a href="/item/{{ item.id }}">{{ item.name }}</a></td>
 | 
			
		||||
            <td>{{ item.type }}</td>
 | 
			
		||||
            <td>{{ item.updatedAt | date("m/d/Y h:i:s A") }}</td>
 | 
			
		||||
            <th>Name</th>
 | 
			
		||||
            <th>Type</th>
 | 
			
		||||
            <th>Updated at</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
      </tbody>
 | 
			
		||||
    </table>
 | 
			
		||||
  </div>
 | 
			
		||||
</section>
 | 
			
		||||
        </thead>
 | 
			
		||||
        <tbody>
 | 
			
		||||
          {% for item in item_results %}
 | 
			
		||||
            <tr>
 | 
			
		||||
              <td><a href="/item/{{ item.id }}">{{ item.name }}</a></td>
 | 
			
		||||
              <td>{{ item.type }}</td>
 | 
			
		||||
              <td>{{ item.updatedAt | date("m/d/Y h:i:s A") }}</td>
 | 
			
		||||
            </tr>
 | 
			
		||||
          {% endfor %}
 | 
			
		||||
        </tbody>
 | 
			
		||||
      </table>
 | 
			
		||||
    </div>
 | 
			
		||||
  </section>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
{% if license_results|len > 0 %}
 | 
			
		||||
  <section id="search-results" class="row">
 | 
			
		||||
    <div class="columns twelve">
 | 
			
		||||
      <h3>Software licenses:</h3>
 | 
			
		||||
      <table class="u-full-width">
 | 
			
		||||
        <thead>
 | 
			
		||||
          <tr>
 | 
			
		||||
            <th>Name</th>
 | 
			
		||||
            <th>Vendor</th>
 | 
			
		||||
            <th>Updated at</th>
 | 
			
		||||
          </tr>
 | 
			
		||||
        </thead>
 | 
			
		||||
        <tbody>
 | 
			
		||||
          {% for license in license_results %}
 | 
			
		||||
            <tr>
 | 
			
		||||
              <td><a href="/item/{{ license.id }}">{{ license.name }}</a></td>
 | 
			
		||||
              <td>{{ license.manufacturer }}</td>
 | 
			
		||||
              <td>{{ license.updatedAt | date("m/d/Y h:i:s A") }}</td>
 | 
			
		||||
            </tr>
 | 
			
		||||
          {% endfor %}
 | 
			
		||||
        </tbody>
 | 
			
		||||
      </table>
 | 
			
		||||
    </div>
 | 
			
		||||
  </section>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user