Browse Source

Merge pull request #2129 from glassez/webui

WebUI Fixes
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
f5c93e0b4d
  1. 2
      src/webui/abstractrequesthandler.cpp
  2. 3
      src/webui/extra_translations.h
  3. 8
      src/webui/httptypes.h
  4. 3
      src/webui/requesthandler.cpp
  5. 17
      src/webui/www/public/upload.html

2
src/webui/abstractrequesthandler.cpp

@ -50,7 +50,7 @@ HttpResponse AbstractRequestHandler::run() @@ -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
{

3
src/webui/extra_translations.h

@ -65,7 +65,8 @@ static const char *__TRANSLATIONS__[] = { @@ -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__[] = {

8
src/webui/httptypes.h

@ -40,12 +40,12 @@ const QString HEADER_CONTENT_TYPE = "Content-Type"; @@ -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
{

3
src/webui/requesthandler.cpp

@ -263,11 +263,12 @@ void RequestHandler::action_command_upload() @@ -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);
}
}
}

17
src/webui/www/public/upload.html

@ -9,10 +9,15 @@ @@ -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() { @@ -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() { @@ -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>

Loading…
Cancel
Save