Mask app on restart and shutdown

This commit is contained in:
Ruud
2011-11-11 17:38:52 +01:00
parent 668b95353f
commit dc58859596
5 changed files with 59 additions and 11 deletions
+7
View File
@@ -1,6 +1,7 @@
from couchpotato import app
from couchpotato.api import addApiView
from couchpotato.core.event import fireEvent, addEvent
from couchpotato.core.helpers.request import jsonified
from couchpotato.core.helpers.variable import cleanHost
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
@@ -21,6 +22,7 @@ class Core(Plugin):
def __init__(self):
addApiView('app.shutdown', self.shutdown)
addApiView('app.restart', self.restart)
addApiView('app.available', self.available)
addEvent('app.crappy_restart', self.crappyRestart)
addEvent('app.load', self.launchBrowser, priority = 100)
@@ -28,6 +30,11 @@ class Core(Plugin):
self.removeRestartFile()
def available(self):
return jsonified({
'succes': True
})
def crappyRestart(self):
ctx = app.test_request_context()
ctx.push()
+1 -1
View File
@@ -113,7 +113,7 @@ class Plugin(object):
data = urllib2.urlopen(request).read()
except IOError:
log.error('Failed opening url: %s' % (traceback.format_exc(1)))
log.error('Failed opening url: %s %s' % (url, traceback.format_exc(1)))
raise
self.http_last_use[host] = time.time()
+46 -1
View File
@@ -109,11 +109,56 @@ var CouchPotato = new Class({
},
shutdown: function(){
Api.request('app.shutdown');
var self = this;
self.blockPage('You have shutdown. This is what suppose to happen ;)');
Api.request('app.shutdown', {
'onComplete': self.blockPage.bind(self)
});
self.checkAvailable();
},
restart: function(){
var self = this;
self.blockPage('Restarting... please wait. If this takes to long, something must have gone wrong.');
Api.request('app.restart');
self.checkAvailable();
},
checkAvailable: function(){
var self = this;
Api.request('app.available', {
'onFailure': function(){
self.checkAvailable.delay(1000, self);
self.fireEvent('unload');
},
'onSuccess': function(){
self.unBlockPage();
self.fireEvent('load');
}
});
},
blockPage: function(message){
var self = this;
if(!self.mask){
var body = $(document.body);
self.mask = new Spinner(document.body, {
'message': new Element('div').adopt(
new Element('h1', {'text': 'Unavailable.'}),
new Element('div', {'text': message || 'Something must have crashed.. check the logs ;)'})
)
});
}
self.mask.show();
},
unBlockPage: function(){
var self = this;
self.mask.hide();
}
});
+2 -2
View File
@@ -95,8 +95,8 @@ var AboutSettingTab = new Class({
)
);
self.fillVersion(Updater.getInfo());
Updater.addEvent('loaded', self.fillVersion.bind(self))
if(!self.fillVersion(Updater.getInfo()))
Updater.addEvent('loaded', self.fillVersion.bind(self))
self.settings.createGroup({
'name': 'actions'
+3 -7
View File
@@ -112,8 +112,9 @@ form {
margin:0;
}
.spinner{
background: #4e5969 url('../images/spinner.gif') no-repeat center;
body > .spinner, .mask{
background: rgba(0,0,0, 0.9);
z-index: 100;
}
.button {
@@ -380,11 +381,6 @@ form {
);
}
.mask {
background: rgba(0,0,0, 0.7);
z-index: 100;
}
.question {
display: block;
width: 600px;