summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-banip/htdocs/luci-static/resources/view/banip
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2023-04-28 11:38:12 +0200
committerDirk Brenken <dev@brenken.org>2023-04-28 11:38:12 +0200
commitd25d5c28b7daddd9cfdf650b15642f1e89b2c2e5 (patch)
tree63897fe83fa85260e8b3257115bee36eda9581fc /applications/luci-app-banip/htdocs/luci-static/resources/view/banip
parent0944811fbcfa2471946c4fecdac277494000b1a4 (diff)
luci-app-banip: more feed editor improvements
* add more 'upload' and 'save' safeguards * save only keys with values in exported JSON structure/file Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-banip/htdocs/luci-static/resources/view/banip')
-rw-r--r--applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js b/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js
index 690fa4d1a5..84384ebad3 100644
--- a/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js
+++ b/applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js
@@ -73,6 +73,11 @@ function handleEdit(ev) {
});
return;
}
+ } else {
+ fs.write('/etc/banip/banip.custom.feeds', null).then(function () {
+ ui.addNotification(null, E('p', _('Upload of the custom feed file failed.')), 'error');
+ });
+ return;
}
location.reload();
} else {
@@ -122,6 +127,9 @@ function handleEdit(ev) {
for (const element of elements) {
let key = element.id.split('.')[4];
let value = element.value || "";
+ if (value === "") {
+ continue;
+ }
switch (key) {
case 'url_4':
subElements.url_4 = value;
@@ -143,9 +151,13 @@ function handleEdit(ev) {
break;
}
}
- sumSubElements.push(nodeKeys[i].value, subElements);
+ if (nodeKeys[i].value !== "" && subElements.descr !== "") {
+ sumSubElements.push(nodeKeys[i].value, subElements);
+ }
+ }
+ if (sumSubElements.length > 0) {
+ exportJson = JSON.stringify(sumSubElements).replace(/^\[/, '{\n').replace(/\}]$/, '\n\t}\n}\n').replace(/,{"/g, ':{\n\t"').replace(/"},"/g, '"\n\t},\n"').replace(/","/g, '",\n\t"');
}
- exportJson = JSON.stringify(sumSubElements).replace(/^\[/, '{\n').replace(/\}]$/, '\n\t}\n}\n').replace(/,{"/g, ':{\n\t"').replace(/"},"/g, '"\n\t},\n"').replace(/","/g, '",\n\t"');
return fs.write('/etc/banip/banip.custom.feeds', exportJson).then(function () {
location.reload();
});