From eb1556f3e8879a27dac2a5ebcc0e8c56e1020149 Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 12 Feb 2014 21:14:06 +0100 Subject: [PATCH] Add filter on database manage page --- couchpotato/core/database.py | 11 ++-- couchpotato/static/style/api.css | 89 +++++++++++++++++------------ couchpotato/templates/database.html | 26 ++++++++- 3 files changed, 82 insertions(+), 44 deletions(-) diff --git a/couchpotato/core/database.py b/couchpotato/core/database.py index 39c7ba15..ee27e37e 100644 --- a/couchpotato/core/database.py +++ b/couchpotato/core/database.py @@ -21,13 +21,6 @@ class Database(object): addEvent('database.setup_index', self.setupIndex) - def test(): - time.sleep(1) - self.listDocuments() - - addEvent('app.load', test) - - def getDB(self): if not self.db: @@ -103,6 +96,10 @@ class Database(object): for document in db.all('id'): key = document.get('_t', 'unknown') + + if kwargs.get('show') and key != kwargs.get('show'): + continue + if not results.get(key): results[key] = [] results[key].append(document) diff --git a/couchpotato/static/style/api.css b/couchpotato/static/style/api.css index f8d49afa..3d6952d6 100644 --- a/couchpotato/static/style/api.css +++ b/couchpotato/static/style/api.css @@ -94,50 +94,69 @@ pre { width: 700px; } -.database table { - font-size: 11px; +.database { + padding: 20px; + margin: 0; } - .database table th { - text-align: left; + .database * { + margin: 0; + padding: 0; } - .database table tr:hover { - position: relative; - z-index: 20; + .database .nav { + } + .database .nav li { + display: inline-block; + } + .database .nav li a { + padding: 5px; + } + + .database table { + font-size: 11px; } - .database table td { - vertical-align: top; + .database table th { + text-align: left; + } + + .database table tr:hover { position: relative; + z-index: 20; } - .database table .id { - width: 100px; - } - - .database table ._rev { - width: 60px; - } - - .database table ._t { - width: 60px; - } - - .database table .form { - width: 600px; - } - - .database table form { - width: 600px; - } - - .database textarea { - font-size: 12px; - width: 100%; - height: 200px; + .database table td { + vertical-align: top; + position: relative; } - .database input[type=submit] { - display: block; + .database table .id { + width: 100px; } + + .database table ._rev { + width: 60px; + } + + .database table ._t { + width: 60px; + } + + .database table .form { + width: 600px; + } + + .database table form { + width: 600px; + } + + .database textarea { + font-size: 12px; + width: 100%; + height: 200px; + } + + .database input[type=submit] { + display: block; + } diff --git a/couchpotato/templates/database.html b/couchpotato/templates/database.html index 02a6d561..b12ad23e 100644 --- a/couchpotato/templates/database.html +++ b/couchpotato/templates/database.html @@ -91,12 +91,34 @@ } }); + var show_split = document.location.search.split('show='), + show = show_split.length > 1 ? show_split[1] : null; + new Request.JSON({ 'url': api_base + 'database.list_documents', + 'data': show ? 'show='+show : null, 'method': 'get', 'onSuccess': function(data){ + var nav = new Element('ul.nav').grab( + new Element('li').grab( + new Element('a', { + 'href': './', + 'text': 'All' + }) + ) + ).inject(c, 'before'); + Object.each(data, function(documents, name){ + + if(documents.length > 0) + new Element('li').grab( + new Element('a', { + 'href': './?show=' + name, + 'text': name + }) + ).inject(nav) + var list = createList(name, documents); if(list) list.inject(c); @@ -113,10 +135,10 @@ Document Manager - +

Documents

-
+