mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-24 10:16:00 +03:00
WebUI: Support updating RSS feed URL
PR #21371. Signed-off-by: Thomas Piccirello <thomas@piccirello.com>
This commit is contained in:
parent
3888b465d8
commit
50acb670b0
3 changed files with 114 additions and 1 deletions
91
src/webui/www/private/editfeedurl.html
Normal file
91
src/webui/www/private/editfeedurl.html
Normal file
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="${LANG}">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>QBT_TR(Please type a RSS feed URL)QBT_TR[CONTEXT=RSSWidget]</title>
|
||||
<link rel="stylesheet" href="css/style.css?v=${CACHEID}" type="text/css">
|
||||
<script src="scripts/lib/MooTools-Core-1.6.0-compat-compressed.js"></script>
|
||||
<script src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
|
||||
<script src="scripts/misc.js?locale=${LANG}&v=${CACHEID}"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
new Keyboard({
|
||||
defaultEventType: "keydown",
|
||||
events: {
|
||||
"Enter": (event) => {
|
||||
event.preventDefault();
|
||||
$("submitButton").click();
|
||||
},
|
||||
"Escape": (event) => {
|
||||
event.preventDefault();
|
||||
window.parent.qBittorrent.Client.closeWindow("editFeedURL");
|
||||
},
|
||||
"Esc": (event) => {
|
||||
event.preventDefault();
|
||||
window.parent.qBittorrent.Client.closeWindow("editFeedURL");
|
||||
}
|
||||
}
|
||||
}).activate();
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
const currentUrl = new URI().getData("url");
|
||||
|
||||
$("url").value = currentUrl;
|
||||
$("url").focus();
|
||||
$("url").setSelectionRange(0, currentUrl.length);
|
||||
|
||||
$("submitButton").addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// check field
|
||||
const newUrl = $("url").value.trim();
|
||||
if (newUrl === "") {
|
||||
alert("QBT_TR(URL cannot be empty)QBT_TR[CONTEXT=RSSWidget]");
|
||||
return;
|
||||
}
|
||||
|
||||
if (newUrl === currentUrl) {
|
||||
alert("QBT_TR(URL is unchanged)QBT_TR[CONTEXT=RSSWidget]");
|
||||
return;
|
||||
}
|
||||
|
||||
$("submitButton").disabled = true;
|
||||
|
||||
new Request({
|
||||
url: "api/v2/rss/setFeedURL",
|
||||
method: "post",
|
||||
data: {
|
||||
path: new URI().getData("path"),
|
||||
url: newUrl
|
||||
},
|
||||
onSuccess: (response) => {
|
||||
window.parent.qBittorrent.Rss.updateRssFeedList();
|
||||
window.parent.qBittorrent.Client.closeWindow("editFeedURL");
|
||||
},
|
||||
onFailure: (response) => {
|
||||
if (response.status === 409)
|
||||
alert(response.responseText);
|
||||
else
|
||||
alert("QBT_TR(Unable to update URL)QBT_TR[CONTEXT=RSSWidget]");
|
||||
$("submitButton").disabled = false;
|
||||
}
|
||||
}).send();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="padding: 10px 10px 0px 10px;">
|
||||
<label for="url" style="font-weight: bold;">QBT_TR(Feed URL:)QBT_TR[CONTEXT=RSSWidget]</label>
|
||||
<input type="text" id="url" style="width: 320px;">
|
||||
<div style="text-align: center; padding-top: 10px;">
|
||||
<input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id="submitButton">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -156,6 +156,7 @@
|
|||
<li><a href="#update"><img src="images/view-refresh.svg" alt="QBT_TR(Update)QBT_TR[CONTEXT=RSSWidget]"> QBT_TR(Update)QBT_TR[CONTEXT=RSSWidget]</a></li>
|
||||
<li><a href="#markRead"><img src="images/task-complete.svg" alt="QBT_TR(Mark items read)QBT_TR[CONTEXT=RSSWidget]"> QBT_TR(Mark items read)QBT_TR[CONTEXT=RSSWidget]</a></li>
|
||||
<li class="separator"><a href="#rename"><img src="images/edit-rename.svg" alt="QBT_TR(Rename...)QBT_TR[CONTEXT=RSSWidget]"> QBT_TR(Rename...)QBT_TR[CONTEXT=RSSWidget]</a></li>
|
||||
<li><a href="#edit"><img src="images/edit-rename.svg" alt="QBT_TR(Edit feed URL...)QBT_TR[CONTEXT=RSSWidget]"> QBT_TR(Edit feed URL...)QBT_TR[CONTEXT=RSSWidget]</a></li>
|
||||
<li><a href="#delete"><img src="images/edit-clear.svg" alt="QBT_TR(Delete)QBT_TR[CONTEXT=RSSWidget]"> QBT_TR(Delete)QBT_TR[CONTEXT=RSSWidget]</a></li>
|
||||
|
||||
<li class="separator"><a href="#newSubscription"><img src="images/list-add.svg" alt="QBT_TR(New subscription...)QBT_TR[CONTEXT=RSSWidget]"> QBT_TR(New subscription...)QBT_TR[CONTEXT=RSSWidget]</a></li>
|
||||
|
@ -236,6 +237,10 @@
|
|||
rename: (el) => {
|
||||
moveItem(rssFeedTable.getRow(rssFeedTable.selectedRows[0]).full_data.dataPath);
|
||||
},
|
||||
edit: (el) => {
|
||||
const data = rssFeedTable.getRow(rssFeedTable.selectedRows[0]).full_data;
|
||||
editUrl(data.dataPath, data.dataUrl);
|
||||
},
|
||||
delete: (el) => {
|
||||
const selectedDatapaths = rssFeedTable.selectedRows
|
||||
.filter((rowID) => rowID !== "0")
|
||||
|
@ -499,7 +504,8 @@
|
|||
match = true;
|
||||
for (let i = 0; i < flattenedResp.length; ++i) {
|
||||
if (((flattenedResp[i].uid ? flattenedResp[i].uid : "") !== rssFeedRows[i + 1].full_data.dataUid)
|
||||
|| (flattenedResp[i].fullName !== rssFeedRows[i + 1].full_data.dataPath)) {
|
||||
|| (flattenedResp[i].fullName !== rssFeedRows[i + 1].full_data.dataPath)
|
||||
|| (flattenedResp[i].url !== rssFeedRows[i + 1].full_data.dataUrl)) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
|
@ -729,6 +735,21 @@
|
|||
});
|
||||
};
|
||||
|
||||
const editUrl = (path, url) => {
|
||||
new MochaUI.Window({
|
||||
id: "editFeedURL",
|
||||
icon: "images/qbittorrent-tray.svg",
|
||||
title: "QBT_TR(Please type a RSS feed URL)QBT_TR[CONTEXT=RSSWidget]",
|
||||
loadMethod: "iframe",
|
||||
contentURL: new URI("editfeedurl.html").setData("path", path).setData("url", url).toString(),
|
||||
scrollbars: false,
|
||||
resizable: false,
|
||||
maximizable: false,
|
||||
width: 350,
|
||||
height: 100
|
||||
});
|
||||
};
|
||||
|
||||
const removeItem = (paths) => {
|
||||
const encodedPaths = paths.map((path) => encodeURIComponent(path));
|
||||
new MochaUI.Window({
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<file>private/css/Window.css</file>
|
||||
<file>private/download.html</file>
|
||||
<file>private/downloadlimit.html</file>
|
||||
<file>private/editfeedurl.html</file>
|
||||
<file>private/edittracker.html</file>
|
||||
<file>private/editwebseed.html</file>
|
||||
<file>private/images/3-state-checkbox.gif</file>
|
||||
|
|
Loading…
Reference in a new issue