Added apply button and handling
This commit is contained in:
parent
0a7e9ade4e
commit
538275cb37
@ -18,12 +18,22 @@ CREATE TABLE IF NOT EXISTS "read" (
|
||||
"_id" INTEGER NOT NULL UNIQUE,
|
||||
"rid" INTEGER UNIQUE,
|
||||
"d" INTEGER NOT NULL,
|
||||
FOREIGN KEY("rid") REFERENCES "jobs"("_id"),
|
||||
PRIMARY KEY("_id" AUTOINCREMENT)
|
||||
PRIMARY KEY("_id" AUTOINCREMENT),
|
||||
FOREIGN KEY("rid") REFERENCES "jobs"("_id")
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS "applied" (
|
||||
"_id" INTEGER NOT NULL UNIQUE,
|
||||
"aid" INTEGER UNIQUE,
|
||||
"a" INTEGER NOT NULL,
|
||||
PRIMARY KEY("_id" AUTOINCREMENT),
|
||||
FOREIGN KEY("aid") REFERENCES "jobs"("_id")
|
||||
);
|
||||
|
||||
DROP VIEW IF EXISTS "jobsList";
|
||||
CREATE VIEW jobsList as
|
||||
select jobs._id, jobs.title, jobs.site, jobs.company, jobs.timestamp, read.d from jobs
|
||||
select jobs._id, jobs.title, jobs.site, jobs.company, jobs.timestamp, read.d, applied.a from jobs
|
||||
left join read on read.rid = jobs._id
|
||||
left join applied on applied.aid = jobs._id
|
||||
|
||||
order by jobs._id desc;
|
||||
COMMIT;
|
||||
|
4
dist/build/bundle.css
vendored
4
dist/build/bundle.css
vendored
File diff suppressed because one or more lines are too long
6
dist/build/bundle.css.map
vendored
6
dist/build/bundle.css.map
vendored
File diff suppressed because one or more lines are too long
2
dist/build/bundle.js
vendored
2
dist/build/bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/build/bundle.js.map
vendored
2
dist/build/bundle.js.map
vendored
File diff suppressed because one or more lines are too long
25
dist/gfx/star.svg
vendored
Normal file
25
dist/gfx/star.svg
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg viewBox="0 0 282.3 270.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="a" gradientUnits="userSpaceOnUse" x1="338.9" x2="322.8" y1="292.1" y2="203.1">
|
||||
<stop offset="0" stop-color="#e6d82f"/>
|
||||
<stop offset="1" stop-color="#faf26f"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="b" gradientUnits="userSpaceOnUse" x1="391.9" x2="341.2" y1="310.6" y2="310.6">
|
||||
<stop offset="0" stop-color="#d2c308"/>
|
||||
<stop offset="1" stop-color="#e8da34"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g fill-rule="evenodd" transform="translate(-198.9 -145.7)">
|
||||
<path d="m340.1 292.8l-.4-140.5-32.16 98.6z" fill="url(#a)"/>
|
||||
<path d="m340.2 152.4l31.45 97.64-31.04 42.7z" fill="#d2c308"/>
|
||||
<path d="m341.1 292.4l133.8-42.39-103.6-.01z" fill="#faf26f"/>
|
||||
<path d="m341 293.1l50.85 17.34 83.1-60.32z" fill="#a29910"/>
|
||||
<path d="m289.1 310.6l50.32-17.12-134.2-43.5z" fill="#d2c308"/>
|
||||
<path d="m339.6 293.8l-82.67 116.1 32.22-99.1z" fill="#faf26f"/>
|
||||
<path d="m341.1 293.6l50.78 16.82 31.72 97.69z" fill="url(#b)"/>
|
||||
<path d="m340.2 348.6l83.08 59.65-82.56-114.4z" fill="#a29910"/>
|
||||
<path d="m306.9 251.2l33.56 42.72-135.6-43.9z" fill="#faf26f"/>
|
||||
<path d="m340.2 348.6l-82.9 59.3 83.03-114.5z" fill="#a29910"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
@ -51,7 +51,7 @@ exports.getList = () => {
|
||||
};
|
||||
|
||||
exports.getOne = (id) => {
|
||||
const sql = 'SELECT * FROM jobs WHERE _id = ?';
|
||||
const sql = 'SELECT jobs.*, applied.a FROM jobs left join applied on applied.aid = jobs._id WHERE jobs._id == ?';
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
db.get(sql, [id], (err, row) => {
|
||||
@ -80,4 +80,21 @@ exports.touchOne = (data) => {
|
||||
});
|
||||
};
|
||||
|
||||
exports.appliedOne = (data) => {
|
||||
const sql = 'INSERT INTO applied VALUES (?,?,?)';
|
||||
|
||||
const { aid, a } = data;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
db.run(sql, [null, aid, a], function(err) {
|
||||
if (err && err.errno !== 19) {
|
||||
console.log(err);
|
||||
reject(err);
|
||||
}
|
||||
|
||||
resolve({});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// select _id, title, site, company, timestamp from jobs order by _id desc;
|
||||
|
34
server/controllers/apply.controller.js
Normal file
34
server/controllers/apply.controller.js
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Created by WebStorm.
|
||||
* User: martin
|
||||
* Date: 25/05/2020
|
||||
* Time: 13:36
|
||||
|
||||
*/
|
||||
const dbmanager = require('../../lib/dbmanager');
|
||||
|
||||
exports.markApplied = (req, res) => {
|
||||
console.log('>markApplied req', req.params);
|
||||
|
||||
if(!req.params.id)
|
||||
return res.status(500).send({
|
||||
'message': 'Job id missing'
|
||||
});
|
||||
|
||||
const aid = req.params.id;
|
||||
const a = new Date().getTime();
|
||||
|
||||
// touchOne
|
||||
|
||||
dbmanager.appliedOne({ aid, a })
|
||||
.then((data) => {
|
||||
console.log(data);
|
||||
|
||||
res.status(200).end();
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(500).send({
|
||||
'message': err.message || 'Some error occurred while querying the database.'
|
||||
});
|
||||
});
|
||||
};
|
14
server/routes/apply.route.js
Normal file
14
server/routes/apply.route.js
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Created by WebStorm.
|
||||
* User: martin
|
||||
* Date: 25/05/2020
|
||||
* Time: 13:36
|
||||
|
||||
*/
|
||||
|
||||
const apply = require('../controllers/apply.controller');
|
||||
|
||||
module.exports = (app) => {
|
||||
app.route('/apply/:id')
|
||||
.put(apply.markApplied);
|
||||
};
|
@ -38,6 +38,7 @@ app.use(bodyParser.urlencoded({ 'extended': true }));
|
||||
app.use(bodyParser.json());
|
||||
|
||||
require('./routes/jobs.route')(app);
|
||||
require('./routes/apply.route')(app);
|
||||
|
||||
app.listen(serverPort, () => {
|
||||
console.log(`Server is listening on port ${serverPort}`);
|
||||
|
Loading…
Reference in New Issue
Block a user