From 7540c9881d628d1f3868599cf22222eb8bd2333b Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 28 Oct 2021 22:36:05 +0300 Subject: [PATCH] Fixed Packages, Firewall and Server tabs. --- .../src/ControlPanelService/Firewalls.js | 13 ++-- .../react/src/ControlPanelService/Updates.js | 4 +- .../AddItemLayout/AddItemLayout.scss | 2 +- .../components/Firewall/Add/AddFirewall.scss | 2 +- .../components/Firewall/Add/Banlist/index.jsx | 9 ++- .../src/components/Firewall/Ban/index.jsx | 7 +- .../components/Firewall/Edit/EditFirewall.jsx | 39 +++++----- .../src/components/Firewall/Firewall.jsx | 7 +- web/js/react/src/components/Log/Log.scss | 2 +- .../MailAccount/Add/AddMailAccount.scss | 2 +- .../components/MainNav/Toolbar/Toolbar.scss | 2 +- .../components/Package/Add/AddPackage.scss | 2 +- .../components/Server/Edit/Bind9/Bind9.scss | 2 +- .../Server/Edit/Dovecot/Dovecot.scss | 2 +- .../components/Server/Edit/EditServer.scss | 2 +- .../Server/Edit/Httpd/EditHttpd.scss | 4 +- .../components/Server/Edit/Mysql/Mysql.scss | 2 +- .../Server/Edit/Nginx/EditServerNginx.scss | 4 +- .../components/Server/Edit/PHP/EditPhp.scss | 4 +- .../Server/Edit/Postgresql/Postgresql.scss | 2 +- .../Server/Edit/Service/Service.scss | 2 +- .../WebDomain/Edit/SslSupport/SslSupport.scss | 2 +- .../containers/Firewalls/Banlist/index.jsx | 24 +++--- .../containers/Firewalls/Banlist/styles.scss | 11 +++ web/js/react/src/containers/RRDs/RRDs.scss | 2 +- .../src/containers/Statistics/Statistics.scss | 2 +- .../react/src/containers/Updates/Updates.jsx | 74 +++++++++++++++++-- 27 files changed, 151 insertions(+), 79 deletions(-) diff --git a/web/js/react/src/ControlPanelService/Firewalls.js b/web/js/react/src/ControlPanelService/Firewalls.js index e882c67e1..3b2e003fd 100644 --- a/web/js/react/src/ControlPanelService/Firewalls.js +++ b/web/js/react/src/ControlPanelService/Firewalls.js @@ -17,16 +17,17 @@ export const getBanList = () => { return axios.get(BASE_URL + banListUri); } -export const bulkAction = (action, firewalls) => { +export const bulkAction = (action, ips, banIps) => { const formData = new FormData(); formData.append("action", action); formData.append("token", getAuthToken()); - firewalls.forEach(firewall => { - formData.append("rule[]", firewall); + ips.forEach(ip => { + const banIp = banIps.find(banIp => banIp.NAME === ip); + formData.append("ipchain[]", `${ip}:${banIp['CHAIN']}`); }); - return axios.post(BASE_URL + '/api/v1/bulk/firewall/', formData); + return axios.post(BASE_URL + '/api/v1/bulk/firewall/banlist/', formData); }; export const handleAction = uri => { @@ -54,11 +55,13 @@ export const getBanIps = data => { export const addBanIp = (data) => { let formDataObject = new FormData(); + formDataObject.append('token', getAuthToken()); + for (let key in data) { formDataObject.append(key, data[key]); } - return axios.get(BASE_URL + addBanIpsUri, { + return axios.post(BASE_URL + addBanIpsUri, formDataObject, { params: { token: getAuthToken() } diff --git a/web/js/react/src/ControlPanelService/Updates.js b/web/js/react/src/ControlPanelService/Updates.js index 334cf7d26..be5478e4c 100644 --- a/web/js/react/src/ControlPanelService/Updates.js +++ b/web/js/react/src/ControlPanelService/Updates.js @@ -1,8 +1,8 @@ import axios from "axios"; import { getAuthToken } from "src/utils/token"; -const deleteAutoUpdateUri = '/delete/cron/autoupdate/'; -const addAutoUpdateUri = '/add/cron/autoupdate/'; +const deleteAutoUpdateUri = '/api/v1/delete/cron/autoupdate/'; +const addAutoUpdateUri = '/api/v1/add/cron/autoupdate/'; const webApiUri = '/api/v1/list/updates/index.php'; const BASE_URL = window.location.origin; diff --git a/web/js/react/src/components/ControlPanel/AddItemLayout/AddItemLayout.scss b/web/js/react/src/components/ControlPanel/AddItemLayout/AddItemLayout.scss index b4c255476..e3b839798 100644 --- a/web/js/react/src/components/ControlPanel/AddItemLayout/AddItemLayout.scss +++ b/web/js/react/src/components/ControlPanel/AddItemLayout/AddItemLayout.scss @@ -207,7 +207,7 @@ $errorColor: #BE5ABF; label.label-wrapper { display: flex; align-items: flex-end; - width: fit-content; + width: max-content; span { font-weight: normal; diff --git a/web/js/react/src/components/Firewall/Add/AddFirewall.scss b/web/js/react/src/components/Firewall/Add/AddFirewall.scss index aff53e9fd..05d56dc08 100644 --- a/web/js/react/src/components/Firewall/Add/AddFirewall.scss +++ b/web/js/react/src/components/Firewall/Add/AddFirewall.scss @@ -1,6 +1,6 @@ .content .edit-template.add-firewall { .toolbar .search-toolbar-name { - width: fit-content; + width: max-content; } label.label-wrapper[for=ip] span { diff --git a/web/js/react/src/components/Firewall/Add/Banlist/index.jsx b/web/js/react/src/components/Firewall/Add/Banlist/index.jsx index 66d3d7136..35c75b2ce 100644 --- a/web/js/react/src/components/Firewall/Add/Banlist/index.jsx +++ b/web/js/react/src/components/Firewall/Add/Banlist/index.jsx @@ -43,15 +43,18 @@ const AddBanIP = () => { } if (Object.keys(newUser).length !== 0 && newUser.constructor === Object) { + setState({ ...state, loading: true }); addBanIp(newUser) .then(result => { if (result.status === 200) { const { error_msg, ok_msg } = result.data; if (error_msg) { - setState({ ...state, errorMessage: error_msg, okMessage: '' }); + setState({ ...state, errorMessage: error_msg, okMessage: '', loading: false }); } else if (ok_msg) { - setState({ ...state, errorMessage: '', okMessage: ok_msg }); + setState({ ...state, errorMessage: '', okMessage: ok_msg, loading: false }); + } else { + setState({ ...state, loading: false }); } } }) @@ -81,6 +84,8 @@ const AddBanIP = () => { {state.loading ? :
submitFormHandler(event)} id="add-user"> + +