From cde1451f9b4b0c30bcc662f86acaa4cfa561f05c Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 10 Sep 2010 11:58:59 +0200 Subject: [PATCH] path cleanup, add volumes --- pandora/backend/models.py | 2 +- pandora/static/js/pandora.local.js | 50 +++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/pandora/backend/models.py b/pandora/backend/models.py index e6510b78b..6c7f158d4 100644 --- a/pandora/backend/models.py +++ b/pandora/backend/models.py @@ -250,7 +250,7 @@ class Movie(models.Model): def frame(self, position, width=128): stream = self.streams.filter(profile=settings.VIDEO_PROFILE+'.webm')[0] - path = os.path.join(settings.MEDIA_ROOT, 'frame', self.movieId, "%d"%width, "%s.jpg"%position) + path = os.path.join(settings.MEDIA_ROOT, movieid_path(self.movieId), 'frame', "%d"%width, "%s.jpg"%position) if not os.path.exists(path): extract.frame(stream.video.path, path, position, width) return path diff --git a/pandora/static/js/pandora.local.js b/pandora/static/js/pandora.local.js index 9bab40685..32d6eae72 100644 --- a/pandora/static/js/pandora.local.js +++ b/pandora/static/js/pandora.local.js @@ -1,5 +1,6 @@ if(typeof(app.afterLaunch) == "undefined") app.afterLaunch = []; + app.afterLaunch.push(function() { if (typeof(OxFF) == 'undefined') return; @@ -55,7 +56,6 @@ app.afterLaunch.push(function() { if(!cb) return null; return function(result) { - Ox.print("you called upload", result); var data = JSON.parse(result); cb(data) } @@ -81,16 +81,20 @@ app.afterLaunch.push(function() { } }, loadVolumes: function() { + var _this = this; Ox.print("load volumes"); var $section = new Ox.CollapsePanel({ id: 'volumes', size: 'small', title: 'Volumes' }); + app.$ui.sections.push($section); app.local.volumes(function(data) { Ox.print("got volumes", data); + var volumes = 0; $.each(data, function(name, info) { + volumes ++; Ox.print("add volume", name, info); var status = info.available?"online":"offline"; var $line = $('
').css({ height: '20px' }).append( @@ -112,7 +116,30 @@ app.afterLaunch.push(function() { }); $section.$content.append($line); }); + + add_button = new Ox.Button({ + id: 'add_volume', + title: 'add', + width: 32 + }).bindEvent('click', function(event, data) { + if(_this.api.setLocation("Volume "+(volumes+1))) _this.loadVolumes(); + }); + var update_button = new Ox.Button({ + id: 'update_archive', + title: 'update', + width: 48 + }).bindEvent('click', function(event, data) { + update_button.options({disabled: true}); + _this.api.update(function() { + update_button.options({disabled: false}); + }) + }); app.$ui.lists.replaceWith(app.constructLists()); + $section.find('.OxBar').append($('
') + .css({'text-align': 'right', 'margin': '2px'}) + .append(update_button.$element) + .append(add_button.$element) + ); }); }, uploadVideos: function(ids, done, progress, total) { @@ -164,8 +191,12 @@ app.afterLaunch.push(function() { } ); }, + cancel: function(oshash) { + Ox.print('this function needs to be implemented: cancel ', oshash); + }, constructFileList: function(name) { - var $list = new Ox.TextList({ + var _this = this, + $list = new Ox.TextList({ columns: [ { align: "left", @@ -231,14 +262,25 @@ app.afterLaunch.push(function() { width: 48 }).bindEvent('click', function(fid) { return function(event, data) { Ox.print(videos[fid]); + $($('#'+fid).find('.OxCell')[1]).html(function(fid) { + var button = new Ox.Button({ + title: 'Cancel', + width: 48 + }).bindEvent('click', function(event, data) { + $.each(videos[fid], function(i, oshash) { + _this.cancel(oshash); + }); + }); + return button.$element; + }(fid)); //$($('#'+fid).find('.OxCell')[2]).html('extracting data...'); app.local.uploadVideos( videos[fid], function(data) { $($('#'+fid).find('.OxCell')[2]).html('done'); }, - function(data) { - $($('#'+fid).find('.OxCell')[2]).html(data.status +': '+ data.progress); + function(data) { + $($('#'+fid).find('.OxCell')[2]).html(parseInt(data.progress*100)); } ); }}(i));