ajout d'une datatables
This commit is contained in:
parent
590d567198
commit
7434538e37
6
README
6
README
@ -6,12 +6,14 @@ cd nom_du_projet
|
||||
npm install
|
||||
|
||||
//pour reprendre le projet depuis git
|
||||
sous debian: ln -s /usr/bin/nodejs /usr/local/bin/node
|
||||
npm install
|
||||
npm start
|
||||
ou sous debian: nodejs ./bin/www
|
||||
puis ouvrir localhost:3000
|
||||
|
||||
//pour installer plex (depuis un dockerfile)
|
||||
mkdir ~/plex-config
|
||||
sudo chown 797:797 -R ~/plex-config
|
||||
sudo docker run -d --restart=always -v ~/plex-config:/config -v ~/Movies:/media -p 32400:32400 wernight/plex-media-server
|
||||
sudo docker run -d --restart=always -v ~/plex-config:/config -v ~/Movies:/media/plex -p 32400:32400 wernight/plex-media-server
|
||||
sudo chmod 777 ~/plex-config/Plex\ Media\ Server/Plug-in\ Support/Databases/*
|
||||
sudo ln -s ~/Movies /media/plex
|
||||
|
@ -2,7 +2,7 @@ var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET users listing. */
|
||||
router.get('/:id', function (req, res, next) {
|
||||
router.get('/:id/:filename', function (req, res, next) {
|
||||
|
||||
var config = require('../config');
|
||||
var db = config.init_db();
|
||||
|
@ -7,7 +7,22 @@ router.get('/', function(req, res, next) {
|
||||
var config = require('../config');
|
||||
var db = config.init_db();
|
||||
|
||||
var html = "<html><head></head><body><h1>liste des fichiers</h1>";
|
||||
var html = "<html><head>"
|
||||
+"<script type='text/javascript' src='//code.jquery.com/jquery-1.11.3.min.js'></script>"
|
||||
+"<script type='text/javascript' src='https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js'></script>"
|
||||
+"<script type='text/javascript' src='https://cdn.datatables.net/1.10.9/js/dataTables.bootstrap.min.js'></script>"
|
||||
+"<link rel='stylesheet' type='text/css' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>"
|
||||
+"<link rel='stylesheet' type='text/css' href='https://cdn.datatables.net/1.10.9/css/dataTables.bootstrap.min.css'>"
|
||||
|
||||
|
||||
+"</head><body><h1>liste des fichiers</h1>"
|
||||
+ '<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">'
|
||||
+ ' <thead>'
|
||||
+ ' <tr>'
|
||||
+ ' <th>Nom</th>'
|
||||
+ ' </tr>'
|
||||
+ ' </thead>'
|
||||
+ ' <tbody>';
|
||||
|
||||
//on fais toute les opération de base a la suite
|
||||
db.serialize(function() {
|
||||
@ -19,13 +34,17 @@ router.get('/', function(req, res, next) {
|
||||
//}
|
||||
//stmt.finalize();
|
||||
|
||||
db.each("SELECT id, title FROM metadata_items", function(err, row) {
|
||||
html += "<a href='/file/"+ row.id + "'> " + row.title + "</a><br/>";
|
||||
db.each("SELECT i.id as id, i.title as title, p.file as file FROM metadata_items i, media_parts p WHERE p.media_item_id=i.id ORDER BY i.title ASC", function(err, row) {
|
||||
var tab = row.file.split('/');
|
||||
var filename = tab[tab.length -1];
|
||||
html += "<tr><td><a href='/file/"+ row.id + "/"+filename+"'> " + row.title + "</a></td></tr>";
|
||||
},
|
||||
//aprés toute les opération de la base
|
||||
function() {
|
||||
// All done fetching records, render response
|
||||
html += "</body></html>";
|
||||
html += "</tbody></table><script>$(document).ready(function() {"
|
||||
+ "$('#example').DataTable();"
|
||||
+ "} );</script></body></html>";
|
||||
res.end(html);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user