Compare commits
14 Commits
e5c7bdedc1
...
v0.1.0
Author | SHA1 | Date | |
---|---|---|---|
5e895aa3ca | |||
bfb8d751b8 | |||
cb5083d0d7 | |||
6c64e6c9a1 | |||
01149d8da7 | |||
5f00cf0edd | |||
6751d832fd | |||
4a0241dd2b | |||
1b46e7c3fb | |||
12770a995d | |||
182356c685 | |||
aa980948d8 | |||
3c0ebc7001 | |||
53e0a557a3 |
14
.eslintrc.json
Normal file
14
.eslintrc.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"env": {
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "google",
|
||||
"overrides": [
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest"
|
||||
},
|
||||
"rules": {
|
||||
}
|
||||
}
|
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,7 +1,10 @@
|
||||
# ---> Composer
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# ---> NPM modules (mainly for Gulp.js)
|
||||
# NPM modules (mainly for Gulp.js)
|
||||
node_modules/
|
||||
|
||||
# Compiled CSS and JS assets
|
||||
public/css/
|
||||
public/js/
|
||||
|
||||
# Local data storage
|
||||
data/
|
||||
|
||||
|
20
.woodpecker.yml
Normal file
20
.woodpecker.yml
Normal file
@ -0,0 +1,20 @@
|
||||
pipeline:
|
||||
setup:
|
||||
image: node:18
|
||||
commands:
|
||||
- npm install
|
||||
|
||||
lint:
|
||||
image: node:18
|
||||
commands:
|
||||
- npm run lint
|
||||
|
||||
gitea_release:
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_api_key
|
||||
base_url: https://git.metaunix.net
|
||||
title: "${CI_COMMIT_TAG}"
|
||||
when:
|
||||
event: tag
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright (c) <year> <owner>
|
||||
Copyright (c) 2022 Bit Goblin
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
|
@ -1,10 +1,42 @@
|
||||
$nav-bar-height: 50px;
|
||||
$primary-color: orangered;
|
||||
$primary-color-highlight: darken($primary-color, 10%);
|
||||
$box-shadow-1: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
|
||||
$box-shadow-2: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
|
||||
|
||||
$nav-bar-height: 60px;
|
||||
|
||||
body{
|
||||
padding: $nav-bar-height 0 0;
|
||||
background: lightgrey;
|
||||
}
|
||||
|
||||
a{
|
||||
color: $primary-color;
|
||||
transition: all 230ms ease-in-out;
|
||||
|
||||
&:hover{
|
||||
color: $primary-color-highlight;
|
||||
}
|
||||
}
|
||||
|
||||
.button.button-primary,
|
||||
button.button-primary,
|
||||
input[type="button"].button-primary,
|
||||
input[type="reset"].button-primary,
|
||||
input[type="submit"].button-primary{
|
||||
background-color: $primary-color;
|
||||
color: white;
|
||||
transition: all 230ms ease-in-out;
|
||||
|
||||
&:hover{
|
||||
background-color: $primary-color-highlight;
|
||||
}
|
||||
}
|
||||
|
||||
.container.fluid{
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
#nav-bar{
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@ -12,7 +44,8 @@ body{
|
||||
width: 100%;
|
||||
height: $nav-bar-height;
|
||||
background: #212121;
|
||||
box-shadow: 0 2px 1px rgba(0, 0, 0, .25);
|
||||
box-shadow: $box-shadow-1;
|
||||
color: white;
|
||||
|
||||
.nav-bar-left{
|
||||
float: left;
|
||||
@ -26,12 +59,47 @@ body{
|
||||
}
|
||||
}
|
||||
|
||||
.site-logo,
|
||||
.nav-link a{
|
||||
color: teal;
|
||||
transition: all 230ms ease-in-out;
|
||||
padding: 10px 12px;
|
||||
font-size: 2.5rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:hover{
|
||||
color: green;
|
||||
}
|
||||
.site-logo{
|
||||
padding-left: 35px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
#main-content{
|
||||
margin-top: 25px;
|
||||
padding: 20px 32px;
|
||||
background: white;
|
||||
box-shadow: $box-shadow-2;
|
||||
}
|
||||
|
||||
#record-actions{
|
||||
p{
|
||||
margin-bottom: 0;
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
#item-header{
|
||||
margin-bottom: 25px;
|
||||
|
||||
h1,
|
||||
p{
|
||||
display: inline-block;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.item-added-date,
|
||||
.item-updated-date{
|
||||
margin-bottom: 5px;
|
||||
color: #666;
|
||||
font-size: 1.6rem;
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# start a local instance of the app using PHP's built-in webserver
|
||||
php -S localhost:8080 -t public/ public/index.php
|
@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "bitgoblin/overseer",
|
||||
"description": "Self-hosted inventory tracking web app",
|
||||
"type": "project",
|
||||
"license": "BSD-2-Clause",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"BitGoblin\\Overseer\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gregory Ballantine",
|
||||
"email": "gballantine@bitgoblin.tech"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"require": {
|
||||
"slim/slim": "^4.10",
|
||||
"slim/psr7": "^1.5",
|
||||
"php-di/php-di": "^6.4",
|
||||
"slim/twig-view": "^3.3"
|
||||
}
|
||||
}
|
1387
composer.lock
generated
1387
composer.lock
generated
File diff suppressed because it is too large
Load Diff
6
config/default.json
Normal file
6
config/default.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"database": {
|
||||
"driver": "sqlite",
|
||||
"connection_string": "data/overseer.db"
|
||||
}
|
||||
}
|
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
42
index.js
Normal file
42
index.js
Normal file
@ -0,0 +1,42 @@
|
||||
const express = require('express');
|
||||
|
||||
// instantiate new express.js app
|
||||
const app = express();
|
||||
const port = 3000;
|
||||
|
||||
// initialize database connection
|
||||
(async () => {
|
||||
const db = require('./src/models');
|
||||
await db.sequelize.sync({
|
||||
alter: true,
|
||||
});
|
||||
})();
|
||||
|
||||
// set up body POST parameters
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({
|
||||
extended: true,
|
||||
}));
|
||||
|
||||
// load the template engine
|
||||
app.set('view engine', 'twig');
|
||||
|
||||
// enable static file serving
|
||||
app.use(express.static('public'));
|
||||
|
||||
// load route handlers
|
||||
const homeRoutes = require('./src/routes/home');
|
||||
const itemRoutes = require('./src/routes/item');
|
||||
|
||||
// register route handlers
|
||||
app.get('/', homeRoutes.getIndex);
|
||||
app.get('/item/add', itemRoutes.getAdd);
|
||||
app.post('/item/add', itemRoutes.postAdd);
|
||||
app.get('/item/:id', itemRoutes.getItem);
|
||||
app.get('/item/:id/edit', itemRoutes.getItemEdit);
|
||||
app.post('/item/:id/edit', itemRoutes.postItemEdit);
|
||||
|
||||
// start app
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening on port ${port}`);
|
||||
});
|
9
nodemon.json
Normal file
9
nodemon.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"verbose": true,
|
||||
"ext": "js,json,twig",
|
||||
"ignore": [
|
||||
"*.test.js",
|
||||
"assets/",
|
||||
"data/"
|
||||
]
|
||||
}
|
5581
package-lock.json
generated
5581
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -4,7 +4,10 @@
|
||||
"description": "Self-hosted inventory tracker",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"gulp": "gulp",
|
||||
"nodemon": "nodemon index.js",
|
||||
"lint": "eslint index.js src/**/*.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
@ -18,8 +21,18 @@
|
||||
"author": "Gregory Ballanine <gballantine@bitgoblin.tech>",
|
||||
"license": "BSD-2-Clause",
|
||||
"devDependencies": {
|
||||
"eslint": "^8.26.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-sass": "^5.1.0",
|
||||
"nodemon": "^2.0.20",
|
||||
"sass": "^1.55.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"config": "^3.3.8",
|
||||
"express": "^4.18.2",
|
||||
"sequelize": "^6.25.3",
|
||||
"sqlite3": "^5.1.2",
|
||||
"twig": "^1.15.4"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
# rewrite rules
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^ index.php [QSA,L]
|
@ -1 +0,0 @@
|
||||
body{padding:50px 0 0;background:#d3d3d3}#nav-bar{position:fixed;top:0;left:0;width:100%;height:50px;background:#212121;box-shadow:0 2px 1px rgba(0,0,0,.25)}#nav-bar .nav-bar-left{float:left}#nav-bar ul{list-style:none}#nav-bar ul li{display:inline-block}#nav-bar .nav-link a{color:teal;transition:all 230ms ease-in-out}#nav-bar .nav-link a:hover{color:green}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
// if we're looking for static files in dev, return false so they can be served.
|
||||
if (PHP_SAPI == 'cli-server') {
|
||||
$url = parse_url($_SERVER['REQUEST_URI']);
|
||||
$file = __DIR__ . $url['path'];
|
||||
|
||||
// check the file types, only serve standard files
|
||||
if (preg_match('/\.(?:png|js|jpg|jpeg|gif|css)$/', $file)) {
|
||||
// does the file exist? If so, return it
|
||||
if (is_file($file))
|
||||
return false;
|
||||
|
||||
// file does not exist. return a 404
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||
printf('"%s" does not exist', $_SERVER['REQUEST_URI']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../src/app.php';
|
||||
|
||||
$app->run();
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BitGoblin\Overseer\Controllers;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class Controller {
|
||||
|
||||
protected $container;
|
||||
|
||||
public function __construct(ContainerInterface $container) {
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function get(string $name) {
|
||||
return $this->container->get($name);
|
||||
}
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace BitGoblin\Overseer\Controllers;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Views\Twig;
|
||||
|
||||
class HomeController extends Controller {
|
||||
|
||||
public function getIndex(Request $request, Response $response): Response {
|
||||
$view = Twig::fromRequest($request);
|
||||
return $view->render($response, 'index.twig');
|
||||
}
|
||||
|
||||
}
|
25
src/app.php
25
src/app.php
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
use DI\Container;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Views\TwigMiddleware;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// Create new container object and add our config object to it
|
||||
$container = new Container();
|
||||
|
||||
// Set container to create App with on AppFactory
|
||||
AppFactory::setContainer($container);
|
||||
$app = AppFactory::create();
|
||||
|
||||
// create Twig instance
|
||||
$twig = Twig::create('views', ['cache' => false]);
|
||||
// add Twig-View Middleware
|
||||
$app->add(TwigMiddleware::create($app, $twig));
|
||||
|
||||
// load routes
|
||||
require_once __DIR__ . '/routes.php';
|
||||
|
||||
// app starts in public/index.php
|
16
src/models/index.js
Normal file
16
src/models/index.js
Normal file
@ -0,0 +1,16 @@
|
||||
const dbConfig = require('config').get('database');
|
||||
const Sequelize = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize({
|
||||
dialect: dbConfig.get('driver'),
|
||||
storage: dbConfig.get('connection_string'),
|
||||
});
|
||||
|
||||
const db = {};
|
||||
|
||||
db.Sequelize = Sequelize;
|
||||
db.sequelize = sequelize;
|
||||
|
||||
db.items = require('./item.js')(sequelize, Sequelize);
|
||||
|
||||
module.exports = db;
|
35
src/models/item.js
Normal file
35
src/models/item.js
Normal file
@ -0,0 +1,35 @@
|
||||
module.exports = (sequelize, Sequelize) => {
|
||||
const Item = sequelize.define('item', {
|
||||
|
||||
name: {
|
||||
type: Sequelize.STRING,
|
||||
},
|
||||
|
||||
manufacturer: {
|
||||
type: Sequelize.STRING,
|
||||
},
|
||||
|
||||
serialNumber: {
|
||||
type: Sequelize.STRING,
|
||||
},
|
||||
|
||||
skuNumber: {
|
||||
type: Sequelize.STRING,
|
||||
},
|
||||
|
||||
type: {
|
||||
type: Sequelize.STRING,
|
||||
},
|
||||
|
||||
purchasedFrom: {
|
||||
type: Sequelize.STRING,
|
||||
},
|
||||
|
||||
purchasedAt: {
|
||||
type: Sequelize.DATE,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
return Item;
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
// index GET route - this page should welcome the user and direct them to the available actions
|
||||
$app->get('/', '\\BitGoblin\\Overseer\\Controllers\\HomeController:getIndex')->setName('index');
|
16
src/routes/home.js
Normal file
16
src/routes/home.js
Normal file
@ -0,0 +1,16 @@
|
||||
const db = require('../models');
|
||||
const Item = db.items;
|
||||
|
||||
// GET - /
|
||||
exports.getIndex = async function(req, res) {
|
||||
const items = await Item.findAll({
|
||||
limit: 10,
|
||||
order: [
|
||||
['updatedAt', 'DESC'],
|
||||
],
|
||||
});
|
||||
|
||||
res.render('index.twig', {
|
||||
inventory: items,
|
||||
});
|
||||
};
|
78
src/routes/item.js
Normal file
78
src/routes/item.js
Normal file
@ -0,0 +1,78 @@
|
||||
const db = require('../models');
|
||||
const Item = db.items;
|
||||
|
||||
// GET - /item/add
|
||||
exports.getAdd = async function(req, res) {
|
||||
res.render('item/add.twig');
|
||||
};
|
||||
|
||||
// POST - /item/add
|
||||
exports.postAdd = async function(req, res) {
|
||||
const item = await Item.create({
|
||||
name: req.body.item_name,
|
||||
serialNumber: req.body.item_serial,
|
||||
skuNumber: req.body.item_sku,
|
||||
purchasedFrom: req.body.item_purchase_from,
|
||||
purchasedAt: req.body.item_purchase_date,
|
||||
manufacturer: req.body.item_manufacturer,
|
||||
type: req.body.item_type,
|
||||
});
|
||||
|
||||
console.log(`Saved item ${item.name} to the database.`);
|
||||
|
||||
res.redirect('/');
|
||||
};
|
||||
|
||||
// GET - /item/{id}
|
||||
exports.getItem = async function(req, res) {
|
||||
const item = await Item.findAll({
|
||||
where: {
|
||||
id: req.params.id,
|
||||
},
|
||||
});
|
||||
|
||||
res.render('item/view.twig', {
|
||||
item: item[0],
|
||||
});
|
||||
};
|
||||
|
||||
// GET - /item/{id}/edit
|
||||
exports.getItemEdit = async function(req, res) {
|
||||
const item = await Item.findAll({
|
||||
where: {
|
||||
id: req.params.id,
|
||||
},
|
||||
});
|
||||
|
||||
res.render('item/edit.twig', {
|
||||
item: item[0],
|
||||
});
|
||||
};
|
||||
|
||||
// POST - /item/{id}/edit
|
||||
exports.postItemEdit = async function(req, res) {
|
||||
// fetch item from DB
|
||||
const itemSearch = await Item.findAll({
|
||||
where: {
|
||||
id: req.params.id,
|
||||
},
|
||||
});
|
||||
|
||||
// retrieve the item record from the array for ease of use
|
||||
const item = itemSearch[0];
|
||||
|
||||
// update item attributes
|
||||
item.name = req.body.item_name;
|
||||
item.serialNumber = req.body.item_serial;
|
||||
item.skuNumber = req.body.item_sku;
|
||||
item.purchasedFrom = req.body.item_purchase_from;
|
||||
item.purchasedAt = req.body.item_purchase_date;
|
||||
item.manufacturer = req.body.item_manufacturer;
|
||||
item.type = req.body.item_type;
|
||||
|
||||
// save attribute changes
|
||||
await item.save();
|
||||
|
||||
// redirect user to item page
|
||||
res.redirect('/item/' + item.id);
|
||||
};
|
@ -1,5 +1,7 @@
|
||||
{% extends 'layout.twig' %}
|
||||
|
||||
{% block title %}Home{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<!-- page header -->
|
||||
@ -9,4 +11,49 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section id="record-actions" class="row">
|
||||
<div class="columns six">
|
||||
<a href="/item/add">
|
||||
<p><i class="fa-solid fa-plus"></i> Add Item</p>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="columns six">
|
||||
<a href="/item/search">
|
||||
<p><i class="fa-solid fa-search"></i> Search</p>
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<hr>
|
||||
|
||||
<section class="row">
|
||||
<div class="columns twelve">
|
||||
<h3>Recently updated records:</h3>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="row">
|
||||
<table class="columns twelve">
|
||||
<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>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
|
73
views/item/add.twig
Normal file
73
views/item/add.twig
Normal file
@ -0,0 +1,73 @@
|
||||
{% extends 'layout.twig' %}
|
||||
|
||||
{% block title %}Add New Item{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<!-- page header -->
|
||||
<header class="row">
|
||||
<div class="columns twelve">
|
||||
<h1>Add new item</h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="row">
|
||||
<div class="columns twelve">
|
||||
<form action="/item/add" method="POST">
|
||||
<div class="row">
|
||||
<div class="columns twelve">
|
||||
<label for="item_name">Item name:</label>
|
||||
<input class="u-full-width" type="text" placeholder="My new item" id="item_name" name="item_name" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<label for="item_serial">Serial number:</label>
|
||||
<input class="u-full-width" type="text" placeholder="0123456789" id="item_serial" name="item_serial">
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<label for="item_sku">SKU number:</label>
|
||||
<input class="u-full-width" type="text" placeholder="ABC12345678" id="item_sku" name="item_sku">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<label for="item_purchase_from">Purchased from:</label>
|
||||
<input class="u-full-width" type="text" placeholder="Newegg" id="item_purchase_from" name="item_purchase_from">
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<label for="item_purchase_date">Purchased at:</label>
|
||||
<input class="u-full-width" type="datetime-local" id="item_purchase_date" name="item_purchase_date">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<label for="item_manufacturer">Manufacturer:</label>
|
||||
<input class="u-full-width" type="text" placeholder="Manufacturer" id="item_manufacturer" name="item_manufacturer">
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<label for="item_type">Item type</label>
|
||||
<select class="u-full-width" id="item_type" name="item_type">
|
||||
<option value="cpu">Processor</option>
|
||||
<option value="motherboard">Motherboard</option>
|
||||
<option value="memory">Memory (RAM)</option>
|
||||
<option value="psu">Power Supply</option>
|
||||
<option value="case">Case</option>
|
||||
<option value="storage">Storage Device</option>
|
||||
<option value="gpu">Graphics Card</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input class="button-primary u-full-width" type="submit" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
73
views/item/edit.twig
Normal file
73
views/item/edit.twig
Normal file
@ -0,0 +1,73 @@
|
||||
{% extends 'layout.twig' %}
|
||||
|
||||
{% block title %}Edit Item{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<!-- page header -->
|
||||
<header class="row">
|
||||
<div class="columns twelve">
|
||||
<h1>Editing "{{ item.name }}"</h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="row">
|
||||
<div class="columns twelve">
|
||||
<form action="/item/{{ item.id }}/edit" method="POST">
|
||||
<div class="row">
|
||||
<div class="columns twelve">
|
||||
<label for="item_name">Item name:</label>
|
||||
<input class="u-full-width" type="text" placeholder="My new item" id="item_name" name="item_name" value="{{ item.name }}" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<label for="item_serial">Serial number:</label>
|
||||
<input class="u-full-width" type="text" placeholder="0123456789" id="item_serial" name="item_serial" value="{{ item.serialNumber }}">
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<label for="item_sku">SKU number:</label>
|
||||
<input class="u-full-width" type="text" placeholder="ABC12345678" id="item_sku" name="item_sku" value="{{ item.skuNumber }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<label for="item_purchase_from">Purchased from:</label>
|
||||
<input class="u-full-width" type="text" placeholder="Newegg" id="item_purchase_from" name="item_purchase_from" value="{{ item.purchasedFrom }}">
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<label for="item_purchase_date">Purchased at:</label>
|
||||
<input class="u-full-width" type="datetime-local" id="item_purchase_date" name="item_purchase_date" value="{{ item.purchasedAt }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="six columns">
|
||||
<label for="item_manufacturer">Manufacturer:</label>
|
||||
<input class="u-full-width" type="text" placeholder="Manufacturer" id="item_manufacturer" name="item_manufacturer" value="{{ item.manufacturer }}">
|
||||
</div>
|
||||
|
||||
<div class="six columns">
|
||||
<label for="item_type">Item type</label>
|
||||
<select class="u-full-width" id="item_type" name="item_type" value="{{ item.type }}">
|
||||
<option value="cpu">Processor</option>
|
||||
<option value="motherboard">Motherboard</option>
|
||||
<option value="memory">Memory (RAM)</option>
|
||||
<option value="psu">Power Supply</option>
|
||||
<option value="case">Case</option>
|
||||
<option value="storage">Storage Device</option>
|
||||
<option value="gpu">Graphics Card</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input class="button-primary u-full-width" type="submit" value="Submit">
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
47
views/item/view.twig
Normal file
47
views/item/view.twig
Normal file
@ -0,0 +1,47 @@
|
||||
{% extends 'layout.twig' %}
|
||||
|
||||
{% block title %}{{ item.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<!-- page header -->
|
||||
<header id="item-header" class="row">
|
||||
<div class="columns twelve">
|
||||
<span>
|
||||
<h1>{{ item.name }}</h1>
|
||||
<p><a href="/item/{{ item.id }}/edit"><i class="fa-solid fa-pen-to-square"></i> Edit</a></p>
|
||||
</span>
|
||||
<h4 class="item-added-date">Item added at: {{ item.createdAt }}</h4>
|
||||
<h4 class="item-updated-date">Last updated at: {{ item.updatedAt }}</h4>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- item information -->
|
||||
<section class="row">
|
||||
<table class="columns twelve">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Product name</th>
|
||||
<th>Serial number</th>
|
||||
<th>SKU Number</th>
|
||||
<th>Manufacturer</th>
|
||||
<th>Type</th>
|
||||
<th>Seller</th>
|
||||
<th>Purchase date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ item.name }}</td>
|
||||
<td>{{ item.serialNumber ? item.serialNumber : 'N/a' }}</td>
|
||||
<td>{{ item.skuNumber ? item.skuNumber : 'N/a' }}</td>
|
||||
<td>{{ item.manufacturer ? item.manufacturer : 'N/a' }}</td>
|
||||
<td>{{ item.type }}</td>
|
||||
<td>{{ item.purchasedFrom ? item.purchasedFrom : 'N/a' }}</td>
|
||||
<td>{{ item.purchasedAt | date("m/d/Y h:i:s A") }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
@ -18,14 +18,14 @@
|
||||
<ul>
|
||||
<li class="site-logo">Overseer</li>
|
||||
<li class="nav-link"><a href="/">Home</a></li>
|
||||
<li class="nav-link"><a href="/search">Search</a></li>
|
||||
<li class="nav-link"><a href="/add">Add Item</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>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- main content -->
|
||||
<div id="main-content" class="container">
|
||||
<div id="main-content" class="container fluid">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user