Compare commits

..

36 Commits
v0.2.0 ... main

Author SHA1 Message Date
8c1c43e4df Fixed the cookie/filter thing
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-05-25 11:47:57 -04:00
94c1c26e94 Added code to retain filter status when re-visiting the dashboard
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-05-25 11:36:12 -04:00
Gregory Ballantine
2c0520ff4b Version bump to v0.3.0
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-05-24 13:10:16 -04:00
Gregory Ballantine
8122bfa08f [Issue #9] - Updated z-index of nav bar to display over content
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-05-24 13:08:43 -04:00
Gregory Ballantine
09c464ccbb Fixed typo in search limiter
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-05-24 12:52:58 -04:00
Gregory Ballantine
43f0800f91 Passed filters back to home view
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-24 12:49:04 -04:00
Gregory Ballantine
c652e089d5 Fixed search limiter
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-24 12:47:57 -04:00
Gregory Ballantine
d95be2e185 Added ability to limit dashboard results
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-24 12:35:01 -04:00
Gregory Ballantine
93afda6d10 Fixed errors caught by linter
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-05-24 12:09:09 -04:00
Gregory Ballantine
6d8965ada1 Added README with installation instructions
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-24 07:44:43 -04:00
Gregory Ballantine
62788ccad3 Fixed typo on Twig length filter
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:34:05 -04:00
Gregory Ballantine
6171a968c1 Added licenses to search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:33:07 -04:00
Gregory Ballantine
f44b0e217a Added a search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:25:46 -04:00
Gregory Ballantine
ca26858e51 Added a search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:24:36 -04:00
Gregory Ballantine
be408865cf Added a search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:23:46 -04:00
Gregory Ballantine
1118283cb7 Added a search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:23:17 -04:00
Gregory Ballantine
3e88dab7da Added a search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:22:44 -04:00
Gregory Ballantine
43e70e243c Added a search page
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:20:54 -04:00
Gregory Ballantine
4cfffbd219 Fixed search button positioning
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:06:37 -04:00
Gregory Ballantine
ce63940635 Moved search button out of the form to avoid adding unnecessary input parameters
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 10:03:47 -04:00
Gregory Ballantine
f4850c33ea Fixed some weirdness with the search button
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 09:58:57 -04:00
Gregory Ballantine
2a928f96ad Fixed search input styles
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 09:56:19 -04:00
Gregory Ballantine
d543426428 Fixed search button styles
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 09:53:05 -04:00
Gregory Ballantine
7a1f1bae9d Added search field in navbar
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 09:51:44 -04:00
Gregory Ballantine
4c367c2416 Added search field in navbar
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 09:44:57 -04:00
Gregory Ballantine
c7e30c9ed1 Added search field in navbar
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 09:42:12 -04:00
Gregory Ballantine
82c2b91090 Removed activities table; this will be handled after users are implemented
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-05-21 09:35:39 -04:00
8119f49b4d Added migrations and disabled auto-migrations to better protect users' databases
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-12-13 18:58:14 -05:00
b8700c1ba3 Added activity model to keep track of changes to items
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2022-12-04 01:05:24 -05:00
6024a1fe7f Added option to enable/disable redis session store; fixed the checks for username, password, and database number when setting up the Redis connection
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-23 22:17:36 -05:00
30bf9beea5 Added way to track license seats
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-14 10:54:44 -05:00
6db18f63d6 Version bump to v0.2.2
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-09 14:34:30 -05:00
e33b23d88e Updated some styles on the home page
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-09 14:33:58 -05:00
c86546af82 Version bump to v0.2.1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2022-11-06 11:41:14 -05:00
6c046dde81 Added license view and edit functions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-06 11:40:45 -05:00
4167130f0c Started work on adding license tracking
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-11-06 01:37:56 -05:00
23 changed files with 1520 additions and 247 deletions

View File

@ -1,3 +1,36 @@
# overseer # overseer
Self-hosted inventory tracker Self-hosted inventory tracker
## Installation/Deployment
`git clone https://git.metaunix.net/BitGoblin/overseer`
`npm install --no-dev`
`npm run sequelize db:migrate`
`npm run grunt`
`npm run prod`
## Development
Feel free to clone this project and submit Merge Requests or just fork it and make it your own!
You will need the following tools/libraries to develop Overseer:
* node.js
* NPM
* Grunt.js
* Git (not strictly required but ideal)
Other than that, you should be good to go! You can start the development server with `nodemon` to auto-reload changes:
`npm run nodemon`
And to auto-compile asset changes (e.g. SASS and JS):
`npm run grunt watch`
If all went well, you should be able to visit http://localhost:3000/ in your browser and see the dashboard.

View File

@ -1,3 +1,14 @@
$(document).ready(function() { $(document).ready(function() {
console.log('Document is ready!'); $('#filter-limit').on('change', () => {
$.cookie('filter_limit', $('#filter-limit').val());
$('#filter-form').submit();
});
// check state of limit filter
var cookie_limit = $.cookie('filter_limit');
// if limit is different than what's selected
var active_limit = $('#filter-limit').val();
if ((cookie_limit) && (cookie_limit != active_limit)) {
$('#filter-limit').val(cookie_limit).trigger('change');
}
}); });

View File

@ -34,7 +34,10 @@ input[type="submit"].button-primary{
} }
.container.fluid{ .container.fluid{
width: calc(100% - 60px);
max-width: 100%; max-width: 100%;
margin-left: 30px;
margin-right: 30px;
} }
#nav-bar{ #nav-bar{
@ -46,10 +49,14 @@ input[type="submit"].button-primary{
background: #212121; background: #212121;
box-shadow: $box-shadow-1; box-shadow: $box-shadow-1;
color: white; color: white;
z-index: 100;
.nav-bar-left{ .nav-bar-left{
float: left; float: left;
} }
.nav-bar-right{
float: right;
}
ul{ ul{
list-style: none; list-style: none;
@ -70,6 +77,38 @@ input[type="submit"].button-primary{
padding-left: 35px; padding-left: 35px;
font-weight: bold; font-weight: bold;
} }
#search-form{
display: inline-block;
padding: 10px 0;
li{
display: inline-block;
}
input{
display: inline-block;
width: 256px;
}
}
#search-button{
display: inline-block;
margin-left: 0;
margin-right: 35px;
padding: 0 10px;
background: $primary-color;
border: 1px solid white;
color: white;
font-size: 1.5rem;
font-weight: bold;
transition: all 200ms ease-in-out;
&:hover{
background: $primary-color-highlight;
color: #eee;
}
}
} }
#main-content{ #main-content{
@ -86,7 +125,8 @@ input[type="submit"].button-primary{
} }
} }
#item-header{ #item-header,
#license-header{
margin-bottom: 25px; margin-bottom: 25px;
h1, h1,
@ -96,7 +136,9 @@ input[type="submit"].button-primary{
} }
.item-added-date, .item-added-date,
.item-updated-date{ .item-updated-date,
.license-added-date,
.license-updated-date{
margin-bottom: 5px; margin-bottom: 5px;
color: #666; color: #666;
font-size: 1.6rem; font-size: 1.6rem;

View File

@ -36,6 +36,9 @@ fi
chown -R overseer:overseer /opt/overseer chown -R overseer:overseer /opt/overseer
chown -R overseer:overseer /etc/overseer chown -R overseer:overseer /etc/overseer
# Reload systemd unit files
systemctl daemon-reload
#DEBHELPER# #DEBHELPER#
exit 0 exit 0

20
config/config.json Normal file
View File

@ -0,0 +1,20 @@
{
"development": {
"storage": "./data/overseer.db",
"dialect": "sqlite"
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "mysql"
},
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "mysql"
}
}

View File

@ -7,6 +7,7 @@
"driver": "sqlite", "driver": "sqlite",
"connection_string": "data/overseer.db" "connection_string": "data/overseer.db"
}, },
"use_redis": false,
"redis": { "redis": {
"host": "192.168.1.10", "host": "192.168.1.10",
"port": 6379, "port": 6379,

View File

@ -1,32 +1,36 @@
const express = require('express'); const express = require('express');
const session = require('express-session'); const session = require('express-session');
const RedisStore = require('connect-redis')(session); const RedisStore = require('connect-redis')(session);
// const flash = require('express-flasher'); // const flash = require('@bitgoblin/express-flasher');
// instantiate new express.js app // instantiate new express.js app
const app = express(); const app = express();
const config = require('config'); const config = require('config');
// initialize database connection // initialize database connection
(async () => { require('./src/models');
const db = require('./src/models');
await db.sequelize.sync({
alter: true,
});
})();
// initialize Redis store for session data if (config.get('use_redis')) {
const redisClient = require('./src/redis'); // initialize Redis store for session data
const redisClient = require('./src/redis');
// initialize express.js session w/ Redis datastore // initialize express.js session w/ Redis datastore
app.use(session({ app.use(session({
store: new RedisStore({ store: new RedisStore({
client: redisClient, client: redisClient,
}), // use Redis datastore }), // use Redis datastore
resave: false, // don't save session if unmodified resave: false, // don't save session if unmodified
saveUninitialized: false, // don't create session until something stored saveUninitialized: false, // don't create session until something stored
secret: 'lord of the rings', secret: 'lord of the rings',
})); }));
} else {
// initialize express.js session w/ Redis datastore
app.use(session({
resave: false, // don't save session if unmodified
saveUninitialized: false, // don't create session until something stored
secret: 'lord of the rings',
}));
}
// setup flash messaging // setup flash messaging
// app.use(flash.flash()); // app.use(flash.flash());
@ -47,6 +51,8 @@ app.use(express.static('public'));
// load route handlers // load route handlers
const homeRoutes = require('./src/routes/home'); const homeRoutes = require('./src/routes/home');
const itemRoutes = require('./src/routes/item'); const itemRoutes = require('./src/routes/item');
const licenseRoutes = require('./src/routes/license');
const searchRoutes = require('./src/routes/search');
// register route handlers // register route handlers
app.get('/', homeRoutes.getIndex); app.get('/', homeRoutes.getIndex);
@ -55,6 +61,12 @@ app.post('/item/add', itemRoutes.postAdd);
app.get('/item/:id', itemRoutes.getItem); app.get('/item/:id', itemRoutes.getItem);
app.get('/item/:id/edit', itemRoutes.getItemEdit); app.get('/item/:id/edit', itemRoutes.getItemEdit);
app.post('/item/:id/edit', itemRoutes.postItemEdit); app.post('/item/:id/edit', itemRoutes.postItemEdit);
app.get('/license/add', licenseRoutes.getAdd);
app.post('/license/add', licenseRoutes.postAdd);
app.get('/license/:id', licenseRoutes.getLicense);
app.get('/license/:id/edit', licenseRoutes.getEdit);
app.post('/license/:id/edit', licenseRoutes.postEdit);
app.get('/search', searchRoutes.getSearch);
// start app // start app
app.listen(config.get('server.port'), config.get('server.address'), () => { app.listen(config.get('server.port'), config.get('server.address'), () => {

View File

@ -0,0 +1,28 @@
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('items', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
manufacturer: Sequelize.DataTypes.STRING,
serialNumber: Sequelize.DataTypes.STRING,
skuNumber: Sequelize.DataTypes.STRING,
type: Sequelize.DataTypes.STRING,
purchasedFrom: Sequelize.DataTypes.STRING,
purchasedAt: Sequelize.DataTypes.DATE,
createdAt: Sequelize.DataTypes.DATE,
updatedAt: Sequelize.DataTypes.DATE,
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('items');
}
};

View File

@ -0,0 +1,37 @@
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('licenses', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
key: {
type: Sequelize.DataTypes.STRING,
allowNull: false,
},
manufacturer: Sequelize.DataTypes.STRING,
seatsUsed: {
type: Sequelize.DataTypes.NUMBER,
defaultValue: 0,
},
seatsTotal: {
type: Sequelize.DataTypes.NUMBER,
defaultValue: 1,
},
purchasedFrom: Sequelize.DataTypes.STRING,
purchasedAt: Sequelize.DataTypes.DATE,
createdAt: Sequelize.DataTypes.DATE,
updatedAt: Sequelize.DataTypes.DATE,
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('licenses');
}
};

1001
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
{ {
"name": "overseer", "name": "overseer",
"version": "0.2.0", "version": "0.3.0",
"description": "Self-hosted inventory tracker", "description": "Self-hosted inventory tracker",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"grunt": "grunt", "grunt": "grunt",
"nodemon": "nodemon index.js", "nodemon": "nodemon index.js",
"sequelize": "sequelize-cli",
"lint": "eslint index.js src/**/*.js", "lint": "eslint index.js src/**/*.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
@ -49,6 +50,7 @@
"pg-hstore": "^2.3.4", "pg-hstore": "^2.3.4",
"redis": "^4.4.0", "redis": "^4.4.0",
"sequelize": "^6.25.3", "sequelize": "^6.25.3",
"sequelize-cli": "^6.5.2",
"sqlite3": "^5.1.2", "sqlite3": "^5.1.2",
"twig": "^1.15.4" "twig": "^1.15.4"
} }

View File

@ -9,6 +9,7 @@ db.Sequelize = Sequelize;
db.sequelize = sequelize; db.sequelize = sequelize;
db.items = require('./item.js')(sequelize, Sequelize); db.items = require('./item.js')(sequelize, Sequelize);
db.licenses = require('./license.js')(sequelize, Sequelize);
module.exports = db; module.exports = db;

37
src/models/license.js Normal file
View File

@ -0,0 +1,37 @@
module.exports = (sequelize, Sequelize) => {
const License = sequelize.define('license', {
name: {
type: Sequelize.STRING,
},
key: {
type: Sequelize.STRING,
},
manufacturer: {
type: Sequelize.STRING,
},
seatsUsed: {
type: Sequelize.NUMBER,
default: 0,
},
seatsTotal: {
type: Sequelize.NUMBER,
default: 1,
},
purchasedFrom: {
type: Sequelize.STRING,
},
purchasedAt: {
type: Sequelize.DATE,
},
});
return License;
};

View File

@ -4,11 +4,11 @@ exports.default = function() {
let redisUrl = 'redis://'; let redisUrl = 'redis://';
// add the redis username if defined // add the redis username if defined
if (typeof redisConfig.get('username') !== 'undefined') { if (redisConfig.has('username')) {
redisUrl += redisConfig.get('username'); redisUrl += redisConfig.get('username');
} }
// add the user password if defined // add the user password if defined
if (typeof redisConfig.get('password') !== 'undefined') { if (redisConfig.has('password')) {
redisUrl += ':' + redisConfig.get('password') + '@'; redisUrl += ':' + redisConfig.get('password') + '@';
} }
// add redis host URL // add redis host URL
@ -16,7 +16,7 @@ exports.default = function() {
// add redis host port // add redis host port
redisUrl += ':' + redisConfig.get('port'); redisUrl += ':' + redisConfig.get('port');
// add redis database number if defined // add redis database number if defined
if (typeof redisConfig.get('number') !== 'undefined') { if (redisConfig.has('number')) {
redisUrl += redisConfig.get('number'); redisUrl += redisConfig.get('number');
} }

View File

@ -1,10 +1,26 @@
const db = require('../models'); const db = require('../models');
const Item = db.items; const Item = db.items;
const License = db.licenses;
// GET - / // GET - /
exports.getIndex = async function(req, res) { exports.getIndex = async function(req, res) {
// check if there's a limit set
let limit = 10; // default to 10 results
if ('limit' in req.query) {
limit = req.query.limit;
}
// fetch inventory items from database
const items = await Item.findAll({ const items = await Item.findAll({
limit: 10, limit: limit,
order: [
['updatedAt', 'DESC'],
],
});
// fetch licenses from database
const licenses = await License.findAll({
limit: limit,
order: [ order: [
['updatedAt', 'DESC'], ['updatedAt', 'DESC'],
], ],
@ -14,5 +30,9 @@ exports.getIndex = async function(req, res) {
res.render('index.twig', { res.render('index.twig', {
inventory: items, inventory: items,
licenses: licenses,
filters: {
limit: limit,
},
}); });
}; };

78
src/routes/license.js Normal file
View File

@ -0,0 +1,78 @@
const db = require('../models');
const License = db.licenses;
// GET - /license/add
exports.getAdd = async function(req, res) {
res.render('license/add.twig');
};
// POST - /license/add
exports.postAdd = async function(req, res) {
const license = await License.create({
name: req.body.license_name,
key: req.body.license_key,
manufacturer: req.body.license_manufacturer,
seatsUsed: req.body.license_seats_used,
seatsTotal: req.body.license_seats_total,
purchasedFrom: req.body.license_purchase_from,
purchasedAt: req.body.license_purchase_date,
});
console.log(`Saved license ${license.name} to the database.`);
res.redirect('/');
};
// GET - /license/{id}
exports.getLicense = async function(req, res) {
const license = await License.findAll({
where: {
id: req.params.id,
},
});
res.render('license/view.twig', {
license: license[0],
});
};
// GET - /license/{id}/edit
exports.getEdit = async function(req, res) {
const license = await License.findAll({
where: {
id: req.params.id,
},
});
res.render('license/edit.twig', {
license: license[0],
});
};
// POST - /license/{id}/edit
exports.postEdit = async function(req, res) {
// fetch license from DB
const licenseSearch = await License.findAll({
where: {
id: req.params.id,
},
});
// retrieve the license record from the array for ease of use
const license = licenseSearch[0];
// update license attributes
license.name = req.body.license_name;
license.key = req.body.license_key;
license.manufacturer = req.body.license_manufacturer;
license.seatsUsed = req.body.license_seats_used;
license.seatsTotal = req.body.license_seats_total;
license.purchasedFrom = req.body.license_purchase_from;
license.purchasedAt = req.body.license_purchase_date;
// save attribute changes
await license.save();
// redirect user to license page
res.redirect('/license/' + license.id);
};

42
src/routes/search.js Normal file
View File

@ -0,0 +1,42 @@
const db = require('../models');
const Item = db.items;
const License = db.licenses;
const {Op} = require('sequelize');
// GET - /search
exports.getSearch = async function(req, res) {
// decode URL search query
const query = req.query.query;
// fetch inventory items from database based on search query
const itemResults = await Item.findAll({
where: {
name: {
[Op.like]: '%' + query + '%',
},
},
limit: 10,
order: [
['updatedAt', 'DESC'],
],
});
// fetch licenses from database based on search query
const licenseResults = await License.findAll({
where: {
name: {
[Op.like]: '%' + query + '%',
},
},
limit: 10,
order: [
['updatedAt', 'DESC'],
],
});
res.render('search.twig', {
query: query,
itemResults: itemResults,
licenseResults: licenseResults,
});
};

View File

@ -12,13 +12,19 @@
</header> </header>
<section id="record-actions" class="row"> <section id="record-actions" class="row">
<div class="columns six"> <div class="columns four">
<a href="/item/add"> <a href="/item/add">
<p><i class="fa-solid fa-plus"></i> Add Item</p> <p><i class="fa-solid fa-plus"></i> Add Item</p>
</a> </a>
</div> </div>
<div class="columns six"> <div class="columns four">
<a href="/license/add">
<p><i class="fa-solid fa-plus"></i> Add License</p>
</a>
</div>
<div class="columns four">
<a href="/item/search"> <a href="/item/search">
<p><i class="fa-solid fa-search"></i> Search</p> <p><i class="fa-solid fa-search"></i> Search</p>
</a> </a>
@ -29,31 +35,66 @@
<section class="row"> <section class="row">
<div class="columns twelve"> <div class="columns twelve">
<h3>Recently updated records:</h3> <h3>Recently updated hardware:</h3>
<table class="u-full-width">
<thead>
<tr>
<th>Name</th>
<th>Manufacturer</th>
<th>Type</th>
<th>Updated at</th>
</tr>
</thead>
<tbody>
{% for item in inventory %}
<tr>
<td><a href="/item/{{ item.id }}">{{ item.name }}</a></td>
<td>{{ item.manufacturer }}</td>
<td>{{ item.type }}</td>
<td>{{ item.updatedAt | date("m/d/Y h:i:s A") }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div> </div>
</section> </section>
<section class="row"> <section class="row">
<table class="columns twelve"> <div class="columns twelve">
<thead> <h3>Recently updated licenses:</h3>
<tr> <table class="u-full-width">
<th>Name</th> <thead>
<th>Manufacturer</th>
<th>Type</th>
<th>Updated at</th>
</tr>
</thead>
<tbody>
{% for item in inventory %}
<tr> <tr>
<td><a href="/item/{{ item.id }}">{{ item.name }}</a></td> <th>Name</th>
<td>{{ item.manufacturer }}</td> <th>Manufacturer</th>
<td>{{ item.type }}</td> <th>Updated at</th>
<td>{{ item.updatedAt | date("m/d/Y h:i:s A") }}</td>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> {% for license in licenses %}
<tr>
<td><a href="/license/{{ 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>
<section class="row">
<div class="columns twelve">
<form id="filter-form" class="u-full-width" action="/" method="GET">
<select id="filter-limit" name="limit">
<option {% if filters['limit'] == 5 %}selected{% endif %} value="5">5</option>
<option {% if filters['limit'] == 10 %}selected{% endif %} value="10">10</option>
<option {% if filters['limit'] == 20 %}selected{% endif %} value="20">20</option>
<option {% if filters['limit'] == 35 %}selected{% endif %} value="35">35</option>
<option {% if filters['limit'] == 50 %}selected{% endif %} value="50">50</option>
</select>
</form>
</div>
</section> </section>
{% endblock %} {% endblock %}

View File

@ -8,7 +8,8 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<link rel="stylesheet" href="/css/gargoyle.css"> <link rel="stylesheet" href="/css/gargoyle.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js" charset="utf-8"></script>
<script src="/js/nechryael.min.js"></script> <script src="/js/nechryael.min.js"></script>
</head> </head>
<body> <body>
@ -18,8 +19,20 @@
<ul> <ul>
<li class="site-logo">Overseer</li> <li class="site-logo">Overseer</li>
<li class="nav-link"><a href="/">Home</a></li> <li class="nav-link"><a href="/">Home</a></li>
<li class="nav-link"><a href="/item/search">Search</a></li>
<li class="nav-link"><a href="/item/add">Add Item</a></li> <li class="nav-link"><a href="/item/add">Add Item</a></li>
<li class="nav-link"><a href="/license/add">Add License</a></li>
</ul>
</div>
<div class="nav-bar-right">
<ul>
<li>
<form id="search-form" action="/search" method="GET">
<input type="text" name="query" placeholder="enter a search query...">
</form>
<button id="search-button" type="submit" for="search-form"><i class="fa-solid fa-magnifying-glass"></i></button>
</li>
</ul> </ul>
</div> </div>
</nav> </nav>
@ -35,4 +48,4 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
</body> </body>
</html> </html>

65
views/license/add.twig Normal file
View File

@ -0,0 +1,65 @@
{% extends 'layout.twig' %}
{% block title %}Add New License{% endblock %}
{% block content %}
<!-- page header -->
<header class="row">
<div class="columns twelve">
<h1>Add new license</h1>
</div>
</header>
<section class="row">
<div class="columns twelve">
<form action="/license/add" method="POST">
<div class="row">
<div class="columns twelve">
<label for="license_name">License name:</label>
<input class="u-full-width" type="text" placeholder="My new license" id="license_name" name="license_name" required>
</div>
</div>
<div class="row">
<div class="six columns">
<label for="license_key">License key:</label>
<input class="u-full-width" type="text" placeholder="ABCD-EFGH-1234-5678" id="license_key" name="license_key" required>
</div>
<div class="six columns">
<label for="license_manufacturer">Manufacturer:</label>
<input class="u-full-width" type="text" placeholder="Manufacturer" id="license_manufacturer" name="license_manufacturer">
</div>
</div>
<div class="row">
<div class="six columns">
<label for="license_seats_used">Seats in use:</label>
<input class="u-full-width" type="number" placeholder="0" id="license_seats_used" name="license_seats_used" required value="0">
</div>
<div class="six columns">
<label for="license_seats_total">Seats total:</label>
<input class="u-full-width" type="number" placeholder="1" id="license_seats_total" name="license_seats_total" required value="1">
</div>
</div>
<div class="row">
<div class="six columns">
<label for="license_purchase_from">Purchased from:</label>
<input class="u-full-width" type="text" placeholder="Newegg" id="license_purchase_from" name="license_purchase_from">
</div>
<div class="six columns">
<label for="license_purchase_date">Purchased at:</label>
<input class="u-full-width" type="datetime-local" id="license_purchase_date" name="license_purchase_date">
</div>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
</section>
{% endblock %}

65
views/license/edit.twig Normal file
View File

@ -0,0 +1,65 @@
{% extends 'layout.twig' %}
{% block title %}Edit License{% endblock %}
{% block content %}
<!-- page header -->
<header class="row">
<div class="columns twelve">
<h1>Editing "{{ license.name }}"</h1>
</div>
</header>
<section class="row">
<div class="columns twelve">
<form action="/license/{{ license.id }}/edit" method="POST">
<div class="row">
<div class="columns twelve">
<label for="license_name">License name:</label>
<input class="u-full-width" type="text" placeholder="My new license" id="license_name" name="license_name" value="{{ license.name }}" required>
</div>
</div>
<div class="row">
<div class="six columns">
<label for="license_key">License key:</label>
<input class="u-full-width" type="text" placeholder="ABCD-EFGH-1234-5678" id="license_key" name="license_key" value="{{ license.key }}" required>
</div>
<div class="six columns">
<label for="license_manufacturer">Manufacturer:</label>
<input class="u-full-width" type="text" placeholder="Manufacturer" id="license_manufacturer" name="license_manufacturer" value="{{ license.manufacturer }}">
</div>
</div>
<div class="row">
<div class="six columns">
<label for="license_seats_used">Seats in use:</label>
<input class="u-full-width" type="number" placeholder="0" id="license_seats_used" name="license_seats_used" required value="{{ license.seatsUsed }}">
</div>
<div class="six columns">
<label for="license_seats_total">Seats total:</label>
<input class="u-full-width" type="number" placeholder="1" id="license_seats_total" name="license_seats_total" required value="{{ license.seatsTotal }}">
</div>
</div>
<div class="row">
<div class="six columns">
<label for="license_purchase_from">Purchased from:</label>
<input class="u-full-width" type="text" placeholder="Newegg" id="license_purchase_from" name="license_purchase_from" value="{{ license.purchasedFrom }}">
</div>
<div class="six columns">
<label for="license_purchase_date">Purchased at:</label>
<input class="u-full-width" type="datetime-local" id="license_purchase_date" name="license_purchase_date" value="{{ license.purchasedAt }}">
</div>
</div>
<input class="button-primary u-full-width" type="submit" value="Submit">
</form>
</div>
</section>
{% endblock %}

47
views/license/view.twig Normal file
View File

@ -0,0 +1,47 @@
{% extends 'layout.twig' %}
{% block title %}{{ license.name }}{% endblock %}
{% block content %}
<!-- page header -->
<header id="license-header" class="row">
<div class="columns twelve">
<span>
<h1>{{ license.name }}</h1>
<p><a href="/license/{{ license.id }}/edit"><i class="fa-solid fa-pen-to-square"></i> Edit</a></p>
</span>
<h4 class="license-added-date">license added at: {{ license.createdAt }}</h4>
<h4 class="license-updated-date">Last updated at: {{ license.updatedAt }}</h4>
</div>
</header>
<!-- license information -->
<section class="row">
<table class="columns twelve">
<thead>
<tr>
<th>Product name</th>
<th>License key</th>
<th>Manufacturer</th>
<th>Seats used</th>
<th>Total seats</th>
<th>Seller</th>
<th>Purchase date</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ license.name }}</td>
<td>{{ license.key ? license.key : 'N/a' }}</td>
<td>{{ license.manufacturer ? license.manufacturer : 'N/a' }}</td>
<td>{{ license.seatsUsed }}</td>
<td>{{ license.seatsTotal }}</td>
<td>{{ license.purchasedFrom ? license.purchasedFrom : 'N/a' }}</td>
<td>{{ license.purchasedAt | date("m/d/Y h:i:s A") }}</td>
</tr>
</tbody>
</table>
</section>
{% endblock %}

66
views/search.twig Normal file
View File

@ -0,0 +1,66 @@
{% extends 'layout.twig' %}
{% block title %}Search{% endblock %}
{% block content %}
<!-- page header -->
<header class="row">
<div class="columns twelve">
<h1>Searching for "{{ query }}"</h1>
</div>
</header>
{% if itemResults|length > 0 %}
<section id="search-results" class="row">
<div class="columns twelve">
<h3>Hardware components:</h3>
<table class="u-full-width">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Updated at</th>
</tr>
</thead>
<tbody>
{% for item in itemResults %}
<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 licenseResults|length > 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 licenseResults %}
<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 %}