| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import axios from 'axios';
- import { getAuthToken } from 'src/utils/token';
- const BASE_URL = window.location.origin;
- const usersUri = '/api/v1/list/firewall/index.php';
- const addFirewallUri = '/api/v1/add/firewall/index.php';
- const firewallInfoUri = '/api/v1/edit/firewall/index.php';
- const updateFirewallUri = '/api/v1/edit/firewall/index.php';
- const addBanIpsUri = '/api/v1/add/firewall/banlist/index.php';
- const banListUri = '/api/v1/list/firewall/banlist/index.php';
- export const getFirewallList = () => {
- return axios.get(BASE_URL + usersUri);
- }
- export const getBanList = () => {
- return axios.get(BASE_URL + banListUri);
- }
- export const bulkAction = (action, firewalls) => {
- const formData = new FormData();
- formData.append("action", action);
- formData.append("token", getAuthToken());
- firewalls.forEach(firewall => {
- formData.append("rule[]", firewall);
- });
- return axios.post(BASE_URL + '/api/v1/bulk/firewall/', formData);
- };
- export const handleAction = uri => {
- return axios.get(BASE_URL + uri, {
- params: {
- token: getAuthToken()
- }
- });
- }
- export const getBanIps = data => {
- let formDataObject = new FormData();
- for (let key in data) {
- formDataObject.append(key, data[key]);
- }
- return axios.get(BASE_URL + addBanIpsUri, {
- params: {
- token: getAuthToken()
- }
- });
- }
- export const addBanIp = (data) => {
- let formDataObject = new FormData();
- for (let key in data) {
- formDataObject.append(key, data[key]);
- }
- return axios.get(BASE_URL + addBanIpsUri, {
- params: {
- token: getAuthToken()
- }
- });
- }
- export const addFirewall = data => {
- let formDataObject = new FormData();
- for (let key in data) {
- formDataObject.append(key, data[key]);
- }
- return axios.post(BASE_URL + addFirewallUri, formDataObject);
- }
- export const getFirewallInfo = rule => {
- return axios.get(BASE_URL + firewallInfoUri, {
- params: {
- rule,
- token: getAuthToken()
- }
- });
- }
- export const updateFirewall = (data, rule) => {
- let formDataObject = new FormData();
- for (let key in data) {
- formDataObject.append(key, data[key]);
- }
- return axios.post(BASE_URL + updateFirewallUri, formDataObject, {
- params: {
- rule,
- token: getAuthToken()
- }
- });
- }
|