Skip to content

Commit

Permalink
luci-app-banip: more feed editor improvements
Browse files Browse the repository at this point in the history
* add more 'upload' and 'save' safeguards
* save only keys with values in exported JSON structure/file

Signed-off-by: Dirk Brenken <dev@brenken.org>
  • Loading branch information
dibdot committed Apr 28, 2023
1 parent 0944811 commit d25d5c2
Show file tree
Hide file tree
Showing 37 changed files with 846 additions and 798 deletions.
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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();
});
Expand Down
45 changes: 23 additions & 22 deletions applications/luci-app-banip/po/ar/banip.po
Expand Up @@ -181,7 +181,7 @@ msgstr ""
msgid "Changes on this tab needs a banIP service restart to take effect."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:276
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:288
msgid "Clear Custom Feeds"
msgstr ""

Expand All @@ -198,7 +198,7 @@ msgstr ""
msgid "Countries"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:162
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:174
msgid "Custom Feed Editor"
msgstr ""

Expand All @@ -216,7 +216,7 @@ msgstr ""
msgid "Default Block Policy"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:217
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:229
msgid "Description"
msgstr "الوصف"

Expand All @@ -234,7 +234,7 @@ msgstr ""
msgid "Don't check SSL server certificates during download."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:249
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:261
msgid "Download Custom Feeds"
msgstr ""

Expand Down Expand Up @@ -294,8 +294,8 @@ msgstr ""
msgid "Elements"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:183
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:221
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:195
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:233
msgid "Empty field not allowed"
msgstr ""

Expand Down Expand Up @@ -323,27 +323,27 @@ msgstr ""
msgid "Expiry time for auto added blocklist set members."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:178
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:190
msgid "Feed Name"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js:546
msgid "Feed Selection"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:267
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:279
msgid "Fill Custom Feeds"
msgstr ""

#: applications/luci-app-banip/root/usr/share/luci/menu.d/luci-app-banip.json:68
msgid "Firewall Log"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:226
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:238
msgid "Flag"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:233
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:245
msgid "Flag not supported"
msgstr ""

Expand Down Expand Up @@ -389,11 +389,11 @@ msgstr ""
msgid "Information"
msgstr "معلومة"

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:186
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:198
msgid "Invalid characters"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:114
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:119
msgid "Invalid input values, unable to save modifications."
msgstr ""

Expand Down Expand Up @@ -571,8 +571,8 @@ msgstr ""
msgid "Profile used by 'msmtp' for banIP notification E-Mails."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:197
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:210
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:209
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:222
msgid "Protocol/URL format not supported"
msgstr ""

Expand Down Expand Up @@ -615,11 +615,11 @@ msgstr ""
msgid "Result"
msgstr "نتيجة"

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:202
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:214
msgid "Rulev4"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:215
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:227
msgid "Rulev6"
msgstr ""

Expand All @@ -631,7 +631,7 @@ msgstr "تشغيل الإشارات"
msgid "Run Information"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:285
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:297
msgid "Save Custom Feeds"
msgstr ""

Expand Down Expand Up @@ -812,11 +812,11 @@ msgstr "تأخير الزناد"
msgid "Trigger action on ifup interface events."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:191
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:203
msgid "URLv4"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:204
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:216
msgid "URLv6"
msgstr ""

Expand All @@ -825,12 +825,13 @@ msgstr ""
msgid "Unable to save modifications: %s"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:258
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:270
msgid "Upload Custom Feeds"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:72
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:80
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:78
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:85
msgid "Upload of the custom feed file failed."
msgstr ""

Expand Down Expand Up @@ -860,7 +861,7 @@ msgstr ""
msgid "WAN-Input Chain"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:162
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:174
msgid ""
"With this editor you can upload your local custom feed file or fill up an "
"initial one (a 1:1 copy of the version shipped with the package). The file "
Expand Down
45 changes: 23 additions & 22 deletions applications/luci-app-banip/po/bg/banip.po
Expand Up @@ -180,7 +180,7 @@ msgstr ""
msgid "Changes on this tab needs a banIP service restart to take effect."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:276
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:288
msgid "Clear Custom Feeds"
msgstr ""

Expand All @@ -197,7 +197,7 @@ msgstr ""
msgid "Countries"
msgstr "Държави"

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:162
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:174
msgid "Custom Feed Editor"
msgstr ""

Expand All @@ -215,7 +215,7 @@ msgstr ""
msgid "Default Block Policy"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:217
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:229
msgid "Description"
msgstr "Описание"

Expand All @@ -233,7 +233,7 @@ msgstr ""
msgid "Don't check SSL server certificates during download."
msgstr "Не проверявай SSL сертификати по време на сваляне."

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:249
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:261
msgid "Download Custom Feeds"
msgstr ""

Expand Down Expand Up @@ -293,8 +293,8 @@ msgstr ""
msgid "Elements"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:183
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:221
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:195
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:233
msgid "Empty field not allowed"
msgstr ""

Expand Down Expand Up @@ -322,27 +322,27 @@ msgstr ""
msgid "Expiry time for auto added blocklist set members."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:178
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:190
msgid "Feed Name"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/overview.js:546
msgid "Feed Selection"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:267
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:279
msgid "Fill Custom Feeds"
msgstr ""

#: applications/luci-app-banip/root/usr/share/luci/menu.d/luci-app-banip.json:68
msgid "Firewall Log"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:226
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:238
msgid "Flag"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:233
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:245
msgid "Flag not supported"
msgstr ""

Expand Down Expand Up @@ -388,11 +388,11 @@ msgstr ""
msgid "Information"
msgstr "Информация"

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:186
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:198
msgid "Invalid characters"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:114
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:119
msgid "Invalid input values, unable to save modifications."
msgstr ""

Expand Down Expand Up @@ -570,8 +570,8 @@ msgstr ""
msgid "Profile used by 'msmtp' for banIP notification E-Mails."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:197
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:210
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:209
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:222
msgid "Protocol/URL format not supported"
msgstr ""

Expand Down Expand Up @@ -614,11 +614,11 @@ msgstr ""
msgid "Result"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:202
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:214
msgid "Rulev4"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:215
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:227
msgid "Rulev6"
msgstr ""

Expand All @@ -630,7 +630,7 @@ msgstr ""
msgid "Run Information"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:285
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:297
msgid "Save Custom Feeds"
msgstr ""

Expand Down Expand Up @@ -811,11 +811,11 @@ msgstr ""
msgid "Trigger action on ifup interface events."
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:191
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:203
msgid "URLv4"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:204
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:216
msgid "URLv6"
msgstr ""

Expand All @@ -824,12 +824,13 @@ msgstr ""
msgid "Unable to save modifications: %s"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:258
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:270
msgid "Upload Custom Feeds"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:72
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:80
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:78
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:85
msgid "Upload of the custom feed file failed."
msgstr ""

Expand Down Expand Up @@ -859,7 +860,7 @@ msgstr ""
msgid "WAN-Input Chain"
msgstr ""

#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:162
#: applications/luci-app-banip/htdocs/luci-static/resources/view/banip/feeds.js:174
msgid ""
"With this editor you can upload your local custom feed file or fill up an "
"initial one (a 1:1 copy of the version shipped with the package). The file "
Expand Down

0 comments on commit d25d5c2

Please sign in to comment.