Fixed errors caught by linter
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
6d8965ada1
commit
93afda6d10
2
index.js
2
index.js
@ -8,7 +8,7 @@ const app = express();
|
|||||||
const config = require('config');
|
const config = require('config');
|
||||||
|
|
||||||
// initialize database connection
|
// initialize database connection
|
||||||
const db = require('./src/models');
|
require('./src/models');
|
||||||
|
|
||||||
if (config.get('use_redis')) {
|
if (config.get('use_redis')) {
|
||||||
// initialize Redis store for session data
|
// initialize Redis store for session data
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
const db = require('../models');
|
const db = require('../models');
|
||||||
const Item = db.items;
|
const Item = db.items;
|
||||||
const License = db.licenses;
|
const License = db.licenses;
|
||||||
const { Op } = require('sequelize');
|
const {Op} = require('sequelize');
|
||||||
|
|
||||||
// GET - /search
|
// GET - /search
|
||||||
exports.getSearch = async function(req, res) {
|
exports.getSearch = async function(req, res) {
|
||||||
// decode URL search query
|
// decode URL search query
|
||||||
let query = req.query.query;
|
const query = req.query.query;
|
||||||
|
|
||||||
// fetch inventory items from database based on search query
|
// fetch inventory items from database based on search query
|
||||||
const item_results = await Item.findAll({
|
const itemResults = await Item.findAll({
|
||||||
where: {
|
where: {
|
||||||
name: {
|
name: {
|
||||||
[Op.like]: '%' + query + '%',
|
[Op.like]: '%' + query + '%',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
limit: 10,
|
limit: 10,
|
||||||
order: [
|
order: [
|
||||||
@ -22,11 +22,11 @@ exports.getSearch = async function(req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// fetch licenses from database based on search query
|
// fetch licenses from database based on search query
|
||||||
const license_results = await License.findAll({
|
const licenseResults = await License.findAll({
|
||||||
where: {
|
where: {
|
||||||
name: {
|
name: {
|
||||||
[Op.like]: '%' + query + '%',
|
[Op.like]: '%' + query + '%',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
limit: 10,
|
limit: 10,
|
||||||
order: [
|
order: [
|
||||||
@ -36,7 +36,7 @@ exports.getSearch = async function(req, res) {
|
|||||||
|
|
||||||
res.render('search.twig', {
|
res.render('search.twig', {
|
||||||
query: query,
|
query: query,
|
||||||
item_results: item_results,
|
itemResults: itemResults,
|
||||||
license_results: license_results,
|
licenseResults: licenseResults,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
{% if item_results|length > 0 %}
|
{% if itemResults|length > 0 %}
|
||||||
<section id="search-results" class="row">
|
<section id="search-results" class="row">
|
||||||
<div class="columns twelve">
|
<div class="columns twelve">
|
||||||
<h3>Hardware components:</h3>
|
<h3>Hardware components:</h3>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for item in item_results %}
|
{% for item in itemResults %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="/item/{{ item.id }}">{{ item.name }}</a></td>
|
<td><a href="/item/{{ item.id }}">{{ item.name }}</a></td>
|
||||||
<td>{{ item.type }}</td>
|
<td>{{ item.type }}</td>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if license_results|length > 0 %}
|
{% if licenseResults|length > 0 %}
|
||||||
<section id="search-results" class="row">
|
<section id="search-results" class="row">
|
||||||
<div class="columns twelve">
|
<div class="columns twelve">
|
||||||
<h3>Software licenses:</h3>
|
<h3>Software licenses:</h3>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for license in license_results %}
|
{% for license in licenseResults %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="/item/{{ license.id }}">{{ license.name }}</a></td>
|
<td><a href="/item/{{ license.id }}">{{ license.name }}</a></td>
|
||||||
<td>{{ license.manufacturer }}</td>
|
<td>{{ license.manufacturer }}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user