Merge pull request #2129 from glassez/webui

WebUI Fixes
This commit is contained in:
sledgehammer999 2014-11-09 01:21:00 +02:00
commit f5c93e0b4d
5 changed files with 21 additions and 12 deletions

View file

@ -50,7 +50,7 @@ HttpResponse AbstractRequestHandler::run()
if (isBanned())
{
status(403, "Forbidden");
print(QObject::tr("Your IP address has been banned after too many failed authentication attempts."));
print(QObject::tr("Your IP address has been banned after too many failed authentication attempts."), CONTENT_TYPE_TXT);
}
else
{

View file

@ -65,7 +65,8 @@ static const char *__TRANSLATIONS__[] = {
QT_TRANSLATE_NOOP("HttpServer", "Invalid Username or Password."),
QT_TRANSLATE_NOOP("HttpServer", "Password"),
QT_TRANSLATE_NOOP("HttpServer", "Login"),
QT_TRANSLATE_NOOP("HttpServer", "qBittorrent web User Interface")
QT_TRANSLATE_NOOP("HttpServer", "qBittorrent web User Interface"),
QT_TRANSLATE_NOOP("HttpServer", "Upload Failed!")
};
static const struct { const char *source; const char *comment; } __COMMENTED_TRANSLATIONS__[] = {

View file

@ -40,12 +40,12 @@ const QString HEADER_CONTENT_TYPE = "Content-Type";
const QString HEADER_CONTENT_ENCODING = "Content-Encoding";
const QString HEADER_CONTENT_LENGTH = "Content-Length";
const QString CONTENT_TYPE_CSS = "text/css";
const QString CONTENT_TYPE_CSS = "text/css; charset=UTF-8";
const QString CONTENT_TYPE_GIF = "image/gif";
const QString CONTENT_TYPE_HTML = "text/html";
const QString CONTENT_TYPE_JS = "text/javascript";
const QString CONTENT_TYPE_HTML = "text/html; charset=UTF-8";
const QString CONTENT_TYPE_JS = "text/javascript; charset=UTF-8";
const QString CONTENT_TYPE_PNG = "image/png";
const QString CONTENT_TYPE_TXT = "text/plain";
const QString CONTENT_TYPE_TXT = "text/plain; charset=UTF-8";
struct HttpEnvironment
{

View file

@ -263,11 +263,12 @@ void RequestHandler::action_command_upload()
QBtSession::instance()->addTorrent(filePath);
// Clean up
fsutils::forceRemove(filePath);
print(QLatin1String("<script type=\"text/javascript\">window.parent.hideAll();</script>"));
}
else
{
qWarning() << "I/O Error: Could not create temporary file";
status(500, "Internal Server Error");
print(QObject::tr("I/O Error: Could not create temporary file."), CONTENT_TYPE_TXT);
}
}
}

View file

@ -9,10 +9,15 @@
function stateChangeHandler() {
if (this.readyState == this.DONE) {
if (this.status == 200)
if (this.status == 200) {
window.parent.closeWindows();
else
alert("Upload Failed!");
} else {
if (this.responseText != "") {
alert(this.responseText);
} else {
alert("_(Upload Failed!)");
}
}
}
}
@ -44,7 +49,9 @@ window.addEvent('load', function() {
// is XHR2 available?
var xhr = new XMLHttpRequest();
if (xhr.upload)
$('submitbutton').addClass("invisible");
$('submitbutton').addClass("invisible");
else
$('upload_frame').addEvent('load', function(e) { window.parent.closeWindows(); });
});
</script>
</head>
@ -55,7 +62,7 @@ window.addEvent('load', function() {
<input type="file" id="fileselect" name="fileselect[]" multiple="multiple" /><br/>
<div id="submitbutton">
<button type="submit">_(Upload Torrents)</button>
</div
</div>
</form>
</body>
</html>