diff --git a/migrations/001-initial.sql b/migrations/001-initial.sql index 48e3410..294c1e7 100644 --- a/migrations/001-initial.sql +++ b/migrations/001-initial.sql @@ -21,6 +21,7 @@ CREATE TABLE PlaylistEntry ( id INTEGER PRIMARY KEY, playlistId INTEGER, trackId INTEGER, + indx INTEGER, CONSTRAINT PE_fk_playlistId FOREIGN KEY (playlistId) REFERENCES Playlist (id) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT PE_fk_trackId FOREIGN KEY (trackId) diff --git a/package.json b/package.json index fe506d8..48c154b 100644 --- a/package.json +++ b/package.json @@ -13,16 +13,18 @@ "dependencies": { "@babel/runtime": "^7.7.6", "bcrypt": "^3.0.7", - "bluebird": "^3.5.2", - "connect-redis": "^3.4.1", - "express": "^4.16.3", - "express-async-errors": "^3.0.0", - "express-session": "^1.16.2", + "bluebird": "^3.7.2", + "body-parser": "^1.19.0", + "connect-redis": "^3.4.2", + "express": "^4.17.1", + "express-async-errors": "^3.1.1", + "express-session": "^1.17.0", "fluent-ffmpeg": "^2.1.2", - "fs-extra": "^7.0.0", + "fs-extra": "^7.0.1", "oauth-libre": "^0.9.17", - "socket.io": "^2.1.1", - "sqlite": "^3.0.2", + "redis": "^2.8.0", + "socket.io": "^2.3.0", + "sqlite": "^3.0.3", "sqlite3": "^4.1.1" }, "devDependencies": { diff --git a/public/index.css b/public/index.css index 58da77a..dac9600 100644 --- a/public/index.css +++ b/public/index.css @@ -177,7 +177,7 @@ tr.external td { width: 0%; background-color: #00b7ff; } -.ctx-menu { +.ctx-menu, .ctx-sub-items { position: absolute; background-color: #0c2233; border: 2px solid #031421; @@ -200,6 +200,17 @@ tr.external td { .ctx-item:hover, .dropdown-content div:hover { background-color: #0c273c; } +.ctx-multi { + position: relative; +} +.ctx-multi:hover > .ctx-sub-items { + display: block !important; +} +.ctx-sub-items { + left: 100%; + top: 0; + display: none !important; +} .inline-flex { display: flex; flex-direction: row; @@ -210,6 +221,9 @@ tr.external td { flex-grow: 1; min-width: 0; } +.player .inline-flex { + overflow: hidden; +} #search-clear { display: none; } diff --git a/public/index.html b/public/index.html index 690c26e..b2d0404 100644 --- a/public/index.html +++ b/public/index.html @@ -72,6 +72,10 @@
OK
') @@ -231,12 +284,17 @@ router.get('/serve/by-id/:id', userMiddleware, async (req, res, next) => { res.redirect('/file/track' + fpath.substring(values.directory.length)) }) +// ---------- // +// ERROR SINK // +// ---------- // + router.use((err, req, res, next) => { - console.error(err) - res.status(404).jsonp({error: 404}) + let msg = err.message + dev && console.error(err.stack) + res.status(msg.indexOf('404') !== -1 ? 404 : 400).jsonp({ error: err.message, stack: dev ? err.stack.toString() : undefined }) }) -app.use('/user', user(dbPromise, values.oauth, values.registrations === true)) +app.use('/user', user(values.oauth, values.registrations === true)) app.use('/api', router) app.use('/file/track', express.static(path.resolve(values.directory))) diff --git a/src/user.js b/src/user.js index 017d96d..332172f 100644 --- a/src/user.js +++ b/src/user.js @@ -2,10 +2,12 @@ import express from 'express' import bcrypt from 'bcrypt' import { PromiseOAuth2 } from 'oauth-libre' import crypto from 'crypto' +import { dbPromise } from './database' const router = express.Router() -async function userInfoPublic (db, id) { +async function userInfoPublic (id) { + let db = await dbPromise let u = await db.get('SELECT id, username, image FROM User WHERE id = ?', id) if (!u) return {} return { @@ -15,7 +17,8 @@ async function userInfoPublic (db, id) { } } -export async function userInfo (db, id) { +export async function userInfo (id) { + let db = await dbPromise return db.get('SELECT * FROM User WHERE id = ?', id) } @@ -24,14 +27,14 @@ export function userMiddleware (req, res, next) { next() } -export function user (dbPromise, oauth, registrations) { +export function user (oauth, registrations) { router.get('/info', userMiddleware, async (req, res) => { - res.jsonp(await userInfoPublic(await dbPromise, req.session.user)) + res.jsonp(await userInfoPublic(req.session.user)) }) router.get('/info/:id', userMiddleware, async (req, res) => { if (isNaN(parseInt(req.params.id))) throw new Error('Invalid user ID!') - res.jsonp(await userInfoPublic(await dbPromise, parseInt(req.params.id))) + res.jsonp(await userInfoPublic(parseInt(req.params.id))) }) if (!oauth) return router