From 4c2527e5129d484f8798c1100061fa0048865ffc Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 3 Jun 2018 17:52:17 -0400 Subject: [PATCH 1/3] Convert Wildlist into Regexlist - Added `placeholder` as a parameter for `DomainInput` (and therefore `ListPage` - Added a few new strings to support the new list Signed-off-by: Mcat12 --- make-fake-data.js | 8 ++++---- src/components/DomainInput.js | 3 ++- src/components/ListPage.js | 2 ++ src/components/QueryLog.js | 2 +- src/components/Sidebar.js | 4 ++-- src/containers/Full.js | 4 ++-- src/routes.js | 2 +- src/utils.js | 12 ++++++------ src/views/Blacklist.js | 1 + src/views/{Wildlist.js => Regexlist.js} | 20 ++++++++------------ src/views/Whitelist.js | 3 ++- 11 files changed, 31 insertions(+), 30 deletions(-) rename src/views/{Wildlist.js => Regexlist.js} (57%) diff --git a/make-fake-data.js b/make-fake-data.js index 0bae6b5..a23ba83 100644 --- a/make-fake-data.js +++ b/make-fake-data.js @@ -211,7 +211,7 @@ console.log("Deleting old fake API data..."); remove("public/fakeAPI/dns/whitelist"); remove("public/fakeAPI/dns/blacklist"); -remove("public/fakeAPI/dns/wildlist"); +remove("public/fakeAPI/dns/regexlist"); remove("public/fakeAPI/dns/status"); remove("public/fakeAPI/stats/overTime/history"); remove("public/fakeAPI/stats/overTime/forward_destinations"); @@ -224,9 +224,9 @@ remove("public/fakeAPI/stats/top_clients"); console.log("Generating new fake API data..."); -write("public/fakeAPI/dns/whitelist", list("white")); -write("public/fakeAPI/dns/blacklist", list("black")); -write("public/fakeAPI/dns/wildlist", list("wild")); +write("public/fakeAPI/dns/whitelist", list()); +write("public/fakeAPI/dns/blacklist", list()); +write("public/fakeAPI/dns/regexlist", list()); write("public/fakeAPI/dns/status", status()); write("public/fakeAPI/stats/overTime/history", historyOverTime(144)); write("public/fakeAPI/stats/overTime/forward_destinations", forwardDestOverTime(144, 3)); diff --git a/src/components/DomainInput.js b/src/components/DomainInput.js index 55857e6..a91be8d 100644 --- a/src/components/DomainInput.js +++ b/src/components/DomainInput.js @@ -49,7 +49,7 @@ class DomainInput extends Component { return (
e.charCode === 13 ? this.onAdd() : null} onChange={this.handleChange} disabled={!api.loggedIn} @@ -72,6 +72,7 @@ class DomainInput extends Component { } DomainInput.propTypes = { + placeholder: PropTypes.string.isRequired, domains: PropTypes.array.isRequired, onAdding: PropTypes.func.isRequired, onAlreadyAdded: PropTypes.func.isRequired, diff --git a/src/components/ListPage.js b/src/components/ListPage.js index 8d4637b..af0ab9c 100644 --- a/src/components/ListPage.js +++ b/src/components/ListPage.js @@ -100,6 +100,7 @@ class ListPage extends Component {

{this.props.title}


({ "1": t("Blocked"), "2": t("Allowed (forwarded)"), "3": t("Allowed (cached)"), - "4": t("Blocked (wildcard)"), + "4": t("Blocked (regex)"), "5": t("Blocked (blacklist)") }); diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index 72eaf22..8d5cd4d 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -49,8 +49,8 @@ const nav = { auth: false }, { - name: 'Wildcard', - url: '/wildlist', + name: 'Regex', + url: '/regexlist', icon: 'fa fa-ban', auth: false } diff --git a/src/containers/Full.js b/src/containers/Full.js index a574571..3e746be 100644 --- a/src/containers/Full.js +++ b/src/containers/Full.js @@ -19,7 +19,7 @@ import Dashboard from '../views/Dashboard'; import QueryLog from '../components/QueryLog'; import Whitelist from "../views/Whitelist"; import Blacklist from "../views/Blacklist"; -import Wildlist from "../views/Wildlist"; +import Regexlist from "../views/Regexlist"; import Login from "../views/Login"; import Logout from "../views/Logout"; import { api } from "../utils"; @@ -38,7 +38,7 @@ export default props => ( - + diff --git a/src/routes.js b/src/routes.js index b06e93a..9649200 100644 --- a/src/routes.js +++ b/src/routes.js @@ -13,7 +13,7 @@ export default { '/query-log': 'Query Log', '/whitelist': 'Whitelist', '/blacklist': 'Blacklist (Exact)', - '/wildlist': 'Blacklist (Wildcard)', + '/regexlist': 'Blacklist (Regex)', '/login': 'Login', '/logout': 'Logout' }; diff --git a/src/utils.js b/src/utils.js index 1735aba..c58c67e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -96,8 +96,8 @@ export const api = { getBlacklist() { return api.get("dns/blacklist"); }, - getWildlist() { - return api.get("dns/wildlist"); + getRegexlist() { + return api.get("dns/regexlist"); }, addWhitelist(domain) { return api.post("dns/whitelist", { "domain": domain }); @@ -105,8 +105,8 @@ export const api = { addBlacklist(domain) { return api.post("dns/blacklist", { "domain": domain }); }, - addWildlist(domain) { - return api.post("dns/wildlist", { "domain": domain }); + addRegexlist(domain) { + return api.post("dns/regexlist", { "domain": domain }); }, removeWhitelist(domain) { return api.delete("dns/whitelist/" + domain); @@ -114,8 +114,8 @@ export const api = { removeBlacklist(domain) { return api.delete("dns/blacklist/" + domain); }, - removeWildlist(domain) { - return api.delete("dns/wildlist/" + domain); + removeRegexlist(domain) { + return api.delete("dns/regexlist/" + encodeURIComponent(domain)); }, getStatus() { return api.get("dns/status") diff --git a/src/views/Blacklist.js b/src/views/Blacklist.js index 9b9e8aa..3ebc757 100644 --- a/src/views/Blacklist.js +++ b/src/views/Blacklist.js @@ -19,6 +19,7 @@ const Blacklist = props => { return ( { +const Regexlist = props => { const { t } = props; return ( - {t("Note: Only the domain and subdomains of the blocked domain will be blocked.")} -

- )} - add={api.addWildlist} - remove={api.removeWildlist} - refresh={api.getWildlist} + title={`${t("Blacklist")} (${t("Regex")})`} + placeholder={t("Input a regular expression")} + add={api.addRegexlist} + remove={api.removeRegexlist} + refresh={api.getRegexlist} {...props} /> ); }; -export default translate(["location", "lists"])(Wildlist); +export default translate(["location", "lists"])(Regexlist); diff --git a/src/views/Whitelist.js b/src/views/Whitelist.js index 6c30b11..41a5b2e 100644 --- a/src/views/Whitelist.js +++ b/src/views/Whitelist.js @@ -19,7 +19,8 @@ const Whitelist = props => { return ( {t("Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.")}

} + note={

{t("Note: Whitelisting a subdomain of a regex blocked domain is not possible.")}

} + placeholder={t("Add a domain (example.com or sub.example.com)")} add={api.addWhitelist} remove={api.removeWhitelist} refresh={api.getWhitelist} From 3fcef9c66e66411cfbbff2a8d49a2fa71546853d Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 3 Jun 2018 22:36:57 -0400 Subject: [PATCH 2/3] Moved "Regex" from common namespace to location Also fixed Whitelist's note about wildcards. I plan on making it possible to whitelist a domain even if it falls under a regex, so I don't want to change the string if I don't have to. Signed-off-by: Mcat12 --- public/i18n/en/common.json | 3 +-- public/i18n/en/location.json | 3 ++- src/views/Login.js | 2 +- src/views/Whitelist.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/i18n/en/common.json b/public/i18n/en/common.json index ad505ce..21f2105 100644 --- a/public/i18n/en/common.json +++ b/public/i18n/en/common.json @@ -11,6 +11,5 @@ "Type": "Type", "Action": "Action", "Enabled": "Enabled", - "Disabled": "Disabled", - "Regex": "Regex" + "Disabled": "Disabled" } \ No newline at end of file diff --git a/public/i18n/en/location.json b/public/i18n/en/location.json index 4c9eaf0..d868287 100644 --- a/public/i18n/en/location.json +++ b/public/i18n/en/location.json @@ -6,5 +6,6 @@ "Exact": "Exact", "Wildcard": "Wildcard", "Login": "Login", - "Logout": "Logout" + "Logout": "Logout", + "Regex": "Regex" } \ No newline at end of file diff --git a/src/views/Login.js b/src/views/Login.js index d8655b7..2ff12a1 100644 --- a/src/views/Login.js +++ b/src/views/Login.js @@ -158,4 +158,4 @@ class Login extends Component { } } -export default translate(["common", "login"])(Login); \ No newline at end of file +export default translate(["login", "location"])(Login); \ No newline at end of file diff --git a/src/views/Whitelist.js b/src/views/Whitelist.js index 41a5b2e..ba0a786 100644 --- a/src/views/Whitelist.js +++ b/src/views/Whitelist.js @@ -19,7 +19,7 @@ const Whitelist = props => { return ( {t("Note: Whitelisting a subdomain of a regex blocked domain is not possible.")}

} + note={

{t("Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.")}

} placeholder={t("Add a domain (example.com or sub.example.com)")} add={api.addWhitelist} remove={api.removeWhitelist} From 599f8897f23205ab215db9e5fde1badf64a029b3 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 10 Jun 2018 22:33:18 -0400 Subject: [PATCH 3/3] Remove note about whitelisting wildcard domains This is now possible due to pi-hole/FTL#299 Signed-off-by: Mcat12 --- src/views/Whitelist.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/Whitelist.js b/src/views/Whitelist.js index ba0a786..f445d16 100644 --- a/src/views/Whitelist.js +++ b/src/views/Whitelist.js @@ -19,7 +19,6 @@ const Whitelist = props => { return ( {t("Note: Whitelisting a subdomain of a wildcard blocked domain is not possible.")}

} placeholder={t("Add a domain (example.com or sub.example.com)")} add={api.addWhitelist} remove={api.removeWhitelist}