Cleanup and default charts

This commit is contained in:
Ruud
2014-04-04 15:50:20 +02:00
parent 5d5cf5cf29
commit ff0de896c4
6 changed files with 80 additions and 62 deletions
@@ -1 +1,34 @@
from .main import Charts
def autoload():
return Charts()
config = [{
'name': 'charts',
'groups': [
{
'label': 'Charts',
'description': 'Displays selected charts on the home page',
'type': 'list',
'name': 'charts_providers',
'tab': 'display',
'options': [
{
'name': 'max_items',
'default': 5,
'type': 'int',
'description': 'Maximum number of items displayed from each chart.',
},
{
'name': 'update_interval',
'default': 12,
'type': 'int',
'advanced': True,
'description': '(hours)',
},
],
},
],
}]
+3 -32
View File
@@ -1,13 +1,13 @@
import time import time
from couchpotato import tryInt
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.api import addApiView from couchpotato.api import addApiView
from couchpotato.core.event import addEvent,fireEvent from couchpotato.core.event import addEvent,fireEvent
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
log = CPLog(__name__)
autoload = 'Charts' log = CPLog(__name__)
class Charts(Plugin): class Charts(Plugin):
@@ -51,39 +51,10 @@ class Charts(Plugin):
try: try:
self.update_in_progress = True self.update_in_progress = True
charts = fireEvent('automation.get_chart_list', merge = True) charts = fireEvent('automation.get_chart_list', merge = True)
self.setCache('charts_cached', charts, timeout = 2*3600*self.conf('update_interval', default = 12)) self.setCache('charts_cached', charts, timeout = 7200 * tryInt(self.conf('update_interval', default = 12)))
except: except:
log.error('Failed refreshing charts') log.error('Failed refreshing charts')
self.update_in_progress = False self.update_in_progress = False
return charts return charts
config = [{
'name': 'charts',
'groups': [
{
'label': 'Charts',
'description': 'Displays selected charts on the home page',
'type': 'list',
'name': 'charts_providers',
'tab': 'display',
'options': [
{
'name': 'max_items',
'default': 10,
'type': 'int',
'description': 'Maximum number of items displayed from each chart.',
},
{
'name': 'update_interval',
'default': 12,
'type': 'int',
'advanced': True,
'description': '(hours)',
},
],
},
],
}]
@@ -15,7 +15,6 @@
.charts div.refresh { .charts div.refresh {
margin-top: 10px; margin-top: 10px;
clear:both; clear:both;
background-color: rgba(255,255,255,0.1);
text-align:center; text-align:center;
} }
@@ -169,14 +168,10 @@
color: white; color: white;
position: absolute; position: absolute;
top: 0; top: 0;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.3);
padding: 10px; padding: 10px;
border-bottom-left-radius: 6px;
border-top-left-radius: 6px;
font: bold 2em/1em Helvetica, Sans-Serif; font: bold 2em/1em Helvetica, Sans-Serif;
width: 50px; width: 50px;
height: 60px; height: 100%;
} }
.charts .chart .media_result div.chart_number.chart_in_wanted { .charts .chart .media_result div.chart_number.chart_in_wanted {
@@ -220,18 +215,19 @@
display: block; display: block;
width: 50%; width: 50%;
float: left; float: left;
color: #fff; color: rgba(255,255,255,.6);
border-bottom: 1px solid rgba(255, 255, 255, 0.0666667); border-bottom: 1px solid rgba(255, 255, 255, 0.0666667);
text-align: center;
} }
.toggle_menu a:hover { .toggle_menu a:hover {
border-color: #047792; border-color: #047792;
border-width: 4px; border-width: 4px;
color: #fff;
} }
.toggle_menu a.active { .toggle_menu a.active {
border-bottom: 4px solid #04bce6; border-bottom: 4px solid #04bce6;
color: #fff;
} }
.toggle_menu a:last-child { .toggle_menu a:last-child {
@@ -12,25 +12,43 @@ var Charts = new Class({
create: function(){ create: function(){
var self = this; var self = this;
self.el_refreshing_text = new Element('span.refreshing', {'text': 'Refreshing charts...'}); self.el_refreshing_text = new Element('span.refreshing', {
self.el_refresh_link = new Element('a.refresh', { 'href': '#', 'text': 'Refresh charts', 'events': { 'click': function(e) { 'text': 'Refreshing charts...'
e.preventDefault(); });
self.el.getChildren('div.chart').destroy();
self.el_refreshing_text.show(); self.el_refresh_link = new Element('a.refresh', {
self.el_refresh_link.hide(); 'href': '#',
self.api_request = Api.request('charts.view', { 'text': 'Refresh charts',
'data': { 'force_update': 1 }, 'events': {
'onComplete': self.fill.bind(self) 'click': function(e) {
}); e.preventDefault();
}}}).hide(); self.el.getChildren('div.chart').destroy();
self.el_refresh_container = new Element('div.refresh').grab( self.el_refreshing_text ).grab( self.el_refresh_link ); self.el_refreshing_text.show();
self.el_no_charts_enabled = new Element('p.no_charts_enabled', { self.el_refresh_link.hide();
'html':'Hey, it looks like you have no charts enabled at the moment. If you\'d like some great movie suggestions you can go to <a href="' + App.createUrl('settings/display') + '">settings</a> and turn on some charts of your choice.' self.api_request = Api.request('charts.view', {
'data': { 'force_update': 1 },
'onComplete': self.fill.bind(self)
});
}
}
}).hide(); }).hide();
self.el = new Element('div.charts').grab(self.el_no_charts_enabled).grab( self.el_refresh_container ); self.el_refresh_container = new Element('div.refresh').grab(
self.el_refreshing_text
).grab(self.el_refresh_link);
if( Cookie.read('suggestions_charts_menu_selected') === 'charts') self.el.show(); else self.el.hide(); self.el_no_charts_enabled = new Element('p.no_charts_enabled', {
'html': 'Hey, it looks like you have no charts enabled at the moment. If you\'d like some great movie suggestions you can go to <a href="' + App.createUrl('settings/display') + '">settings</a> and turn on some charts of your choice.'
}).hide();
self.el = new Element('div.charts').grab(
self.el_no_charts_enabled
).grab(self.el_refresh_container);
if( Cookie.read('suggestions_charts_menu_selected') === 'charts')
self.el.show();
else
self.el.hide();
self.api_request = Api.request('charts.view', { self.api_request = Api.request('charts.view', {
'onComplete': self.fill.bind(self) 'onComplete': self.fill.bind(self)
@@ -50,8 +68,7 @@ var Charts = new Class({
self.el_refresh_link.show(); self.el_refresh_link.show();
self.el_refreshing_text.hide(); self.el_refreshing_text.hide();
} }
else else {
{
self.el_no_charts_enabled.hide(); self.el_no_charts_enabled.hide();
json.charts.sort(function(a, b) { json.charts.sort(function(a, b) {
@@ -136,8 +153,9 @@ var Charts = new Class({
afterAdded: function(m, movie){ afterAdded: function(m, movie){
var self = this; var self = this;
$(m).getElement('div.chart_number').addClass('chart_in_wanted').setProperty('title','Movie in wanted list'); $(m).getElement('div.chart_number')
.addClass('chart_in_wanted')
.set('title', 'Movie in wanted list');
}, },
@@ -138,7 +138,7 @@ config = [{
'options': [ 'options': [
{ {
'name': 'chart_display_enabled', 'name': 'chart_display_enabled',
'default': False, 'default': True,
'type': 'enabler', 'type': 'enabler',
}, },
], ],
@@ -265,7 +265,7 @@ config = [{
'options': [ 'options': [
{ {
'name': 'chart_display_enabled', 'name': 'chart_display_enabled',
'default': False, 'default': True,
'type': 'enabler', 'type': 'enabler',
}, },
{ {