Pull request #2231: ADG-8368 Frontend rewritten in TypeScript, added Node 18 support

Merge in DNS/adguard-home from ADG-8368-typescript-node-18 to master

Squashed commit of the following:

commit daa288ae0d76178af24595cc807055902e6f09ab
Merge: 4c89cf720 1085d59a6
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Mon Jun 10 17:22:20 2024 +0200

    merge

commit 4c89cf7209
Author: Ildar Kamalov <ik@adguard.com>
Date:   Thu Jun 6 13:27:18 2024 +0300

    remove install from initial state

commit b943f2011f
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 23:10:55 2024 +0200

    frontend production build fix

commit cd1be2d66d
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 20:23:14 2024 +0200

    production build quickfix

commit 7b8ac01fc2
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Jun 5 19:57:31 2024 +0300

    all: upd node docker

commit 02afed66d5
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 18:23:12 2024 +0200

    changelog fixes

commit 9c0f736f0c
Merge: 62c4fbf1e e04775c4f
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 18:18:29 2024 +0200

    merge

commit 62c4fbf1e3
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 16:22:22 2024 +0200

    empty line in changelog

commit 76b1e44a93
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 16:20:37 2024 +0200

    changelog

commit f783e90040
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 16:19:13 2024 +0200

    filters.js -> filters.ts

commit 3d4ce6554c
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 16:18:03 2024 +0200

    generated file removed

commit e35ba58f2a
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 15:45:21 2024 +0200

    rollback unwanted changes

commit 1f30d4216d
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 15:27:36 2024 +0200

    review fix

commit 6cd4e44f07
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 11:55:39 2024 +0200

    missing generated file restoresd

commit 2ab738b303
Author: Igor Lobanov <bniwredyc@gmail.com>
Date:   Wed Jun 5 11:40:32 2024 +0200

    Frontend rewritten in TypeScript, added Node 18 support
This commit is contained in:
Igor Lobanov
2024-06-10 18:42:23 +03:00
parent 1085d59a65
commit 1afe226ce8
296 changed files with 32122 additions and 32651 deletions

View File

@@ -1,56 +0,0 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/access';
const access = handleActions(
{
[actions.getAccessListRequest]: (state) => ({ ...state, processing: true }),
[actions.getAccessListFailure]: (state) => ({ ...state, processing: false }),
[actions.getAccessListSuccess]: (state, { payload }) => {
const {
allowed_clients,
disallowed_clients,
blocked_hosts,
} = payload;
const newState = {
...state,
allowed_clients: allowed_clients?.join('\n') || '',
disallowed_clients: disallowed_clients?.join('\n') || '',
blocked_hosts: blocked_hosts?.join('\n') || '',
processing: false,
};
return newState;
},
[actions.setAccessListRequest]: (state) => ({ ...state, processingSet: true }),
[actions.setAccessListFailure]: (state) => ({ ...state, processingSet: false }),
[actions.setAccessListSuccess]: (state) => ({ ...state, processingSet: false }),
[actions.toggleClientBlockRequest]: (state) => ({ ...state, processingSet: true }),
[actions.toggleClientBlockFailure]: (state) => ({ ...state, processingSet: false }),
[actions.toggleClientBlockSuccess]: (state, { payload }) => {
const {
allowed_clients,
disallowed_clients,
blocked_hosts,
} = payload;
const newState = {
...state,
allowed_clients: allowed_clients?.join('\n') || '',
disallowed_clients: disallowed_clients?.join('\n') || '',
blocked_hosts: blocked_hosts?.join('\n') || '',
processingSet: false,
};
return newState;
},
},
{
processing: true,
processingSet: false,
allowed_clients: '',
disallowed_clients: '',
blocked_hosts: '',
},
);
export default access;

View File

@@ -0,0 +1,69 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/access';
const access = handleActions(
{
[actions.getAccessListRequest.toString()]: (state: any) => ({
...state,
processing: true,
}),
[actions.getAccessListFailure.toString()]: (state: any) => ({
...state,
processing: false,
}),
[actions.getAccessListSuccess.toString()]: (state: any, { payload }: any) => {
const { allowed_clients, disallowed_clients, blocked_hosts } = payload;
const newState = {
...state,
allowed_clients: allowed_clients?.join('\n') || '',
disallowed_clients: disallowed_clients?.join('\n') || '',
blocked_hosts: blocked_hosts?.join('\n') || '',
processing: false,
};
return newState;
},
[actions.setAccessListRequest.toString()]: (state: any) => ({
...state,
processingSet: true,
}),
[actions.setAccessListFailure.toString()]: (state: any) => ({
...state,
processingSet: false,
}),
[actions.setAccessListSuccess.toString()]: (state: any) => ({
...state,
processingSet: false,
}),
[actions.toggleClientBlockRequest.toString()]: (state: any) => ({
...state,
processingSet: true,
}),
[actions.toggleClientBlockFailure.toString()]: (state: any) => ({
...state,
processingSet: false,
}),
[actions.toggleClientBlockSuccess.toString()]: (state: any, { payload }: any) => {
const { allowed_clients, disallowed_clients, blocked_hosts } = payload;
const newState = {
...state,
allowed_clients: allowed_clients?.join('\n') || '',
disallowed_clients: disallowed_clients?.join('\n') || '',
blocked_hosts: blocked_hosts?.join('\n') || '',
processingSet: false,
};
return newState;
},
},
{
processing: true,
processingSet: false,
allowed_clients: '',
disallowed_clients: '',
blocked_hosts: '',
},
);
export default access;

View File

@@ -1,63 +0,0 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/clients';
const clients = handleActions({
[actions.addClientRequest]: (state) => ({ ...state, processingAdding: true }),
[actions.addClientFailure]: (state) => ({ ...state, processingAdding: false }),
[actions.addClientSuccess]: (state) => {
const newState = {
...state,
processingAdding: false,
};
return newState;
},
[actions.deleteClientRequest]: (state) => ({ ...state, processingDeleting: true }),
[actions.deleteClientFailure]: (state) => ({ ...state, processingDeleting: false }),
[actions.deleteClientSuccess]: (state) => {
const newState = {
...state,
processingDeleting: false,
};
return newState;
},
[actions.updateClientRequest]: (state) => ({ ...state, processingUpdating: true }),
[actions.updateClientFailure]: (state) => ({ ...state, processingUpdating: false }),
[actions.updateClientSuccess]: (state) => {
const newState = {
...state,
processingUpdating: false,
};
return newState;
},
[actions.toggleClientModal]: (state, { payload }) => {
if (payload) {
const newState = {
...state,
modalType: payload.type || '',
modalClientName: payload.name || '',
isModalOpen: !state.isModalOpen,
};
return newState;
}
const newState = {
...state,
isModalOpen: !state.isModalOpen,
};
return newState;
},
}, {
processing: true,
processingAdding: false,
processingDeleting: false,
processingUpdating: false,
isModalOpen: false,
modalClientName: '',
modalType: '',
});
export default clients;

View File

@@ -0,0 +1,84 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/clients';
const clients = handleActions(
{
[actions.addClientRequest.toString()]: (state: any) => ({
...state,
processingAdding: true,
}),
[actions.addClientFailure.toString()]: (state: any) => ({
...state,
processingAdding: false,
}),
[actions.addClientSuccess.toString()]: (state: any) => {
const newState = {
...state,
processingAdding: false,
};
return newState;
},
[actions.deleteClientRequest.toString()]: (state: any) => ({
...state,
processingDeleting: true,
}),
[actions.deleteClientFailure.toString()]: (state: any) => ({
...state,
processingDeleting: false,
}),
[actions.deleteClientSuccess.toString()]: (state: any) => {
const newState = {
...state,
processingDeleting: false,
};
return newState;
},
[actions.updateClientRequest.toString()]: (state: any) => ({
...state,
processingUpdating: true,
}),
[actions.updateClientFailure.toString()]: (state: any) => ({
...state,
processingUpdating: false,
}),
[actions.updateClientSuccess.toString()]: (state: any) => {
const newState = {
...state,
processingUpdating: false,
};
return newState;
},
[actions.toggleClientModal.toString()]: (state: any, { payload }: any) => {
if (payload) {
const newState = {
...state,
modalType: payload.type || '',
modalClientName: payload.name || '',
isModalOpen: !state.isModalOpen,
};
return newState;
}
const newState = {
...state,
isModalOpen: !state.isModalOpen,
};
return newState;
},
},
{
processing: true,
processingAdding: false,
processingDeleting: false,
processingUpdating: false,
isModalOpen: false,
modalClientName: '',
modalType: '',
},
);
export default clients;

View File

@@ -1,25 +1,24 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions';
import { areEqualVersions } from '../helpers/version';
import { STANDARD_DNS_PORT, STANDARD_WEB_PORT } from '../helpers/constants';
const dashboard = handleActions(
{
[actions.setDnsRunningStatus]: (state, { payload }) => (
{
...state,
isCoreRunning: payload,
}
),
[actions.dnsStatusRequest]: (state) => ({
[actions.setDnsRunningStatus.toString()]: (state, { payload }: any) => ({
...state,
isCoreRunning: payload,
}),
[actions.dnsStatusRequest.toString()]: (state: any) => ({
...state,
processing: true,
}),
[actions.dnsStatusFailure]: (state) => ({
[actions.dnsStatusFailure.toString()]: (state: any) => ({
...state,
processing: false,
}),
[actions.dnsStatusSuccess]: (state, { payload }) => {
[actions.dnsStatusSuccess.toString()]: (state: any, { payload }: any) => {
const {
version,
dns_port: dnsPort,
@@ -44,11 +43,9 @@ const dashboard = handleActions(
return newState;
},
[actions.timerStatusSuccess]: (state, { payload }) => {
const {
protection_enabled: protectionEnabled,
protection_disabled_duration: protectionDisabledDuration,
} = payload;
[actions.timerStatusSuccess.toString()]: (state: any, { payload }: any) => {
const { protection_enabled: protectionEnabled, protection_disabled_duration: protectionDisabledDuration } =
payload;
const newState = {
...state,
protectionEnabled,
@@ -58,15 +55,15 @@ const dashboard = handleActions(
return newState;
},
[actions.getVersionRequest]: (state) => ({
[actions.getVersionRequest.toString()]: (state: any) => ({
...state,
processingVersion: true,
}),
[actions.getVersionFailure]: (state) => ({
[actions.getVersionFailure.toString()]: (state: any) => ({
...state,
processingVersion: false,
}),
[actions.getVersionSuccess]: (state, { payload }) => {
[actions.getVersionSuccess.toString()]: (state: any, { payload }: any) => {
const currentVersion = state.dnsVersion === 'undefined' ? 0 : state.dnsVersion;
if (!payload.disabled && !areEqualVersions(currentVersion, payload.new_version)) {
@@ -95,15 +92,15 @@ const dashboard = handleActions(
};
},
[actions.getUpdateRequest]: (state) => ({
[actions.getUpdateRequest.toString()]: (state: any) => ({
...state,
processingUpdate: true,
}),
[actions.getUpdateFailure]: (state) => ({
[actions.getUpdateFailure.toString()]: (state: any) => ({
...state,
processingUpdate: false,
}),
[actions.getUpdateSuccess]: (state) => {
[actions.getUpdateSuccess.toString()]: (state: any) => {
const newState = {
...state,
processingUpdate: false,
@@ -111,15 +108,15 @@ const dashboard = handleActions(
return newState;
},
[actions.toggleProtectionRequest]: (state) => ({
[actions.toggleProtectionRequest.toString()]: (state: any) => ({
...state,
processingProtection: true,
}),
[actions.toggleProtectionFailure]: (state) => ({
[actions.toggleProtectionFailure.toString()]: (state: any) => ({
...state,
processingProtection: false,
}),
[actions.toggleProtectionSuccess]: (state, { payload }) => {
[actions.toggleProtectionSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
protectionEnabled: !state.protectionEnabled,
@@ -130,20 +127,20 @@ const dashboard = handleActions(
return newState;
},
[actions.setDisableDurationTime]: (state, { payload }) => ({
[actions.setDisableDurationTime.toString()]: (state, { payload }: any) => ({
...state,
protectionDisabledDuration: payload.timeToEnableProtection,
}),
[actions.getClientsRequest]: (state) => ({
[actions.getClientsRequest.toString()]: (state: any) => ({
...state,
processingClients: true,
}),
[actions.getClientsFailure]: (state) => ({
[actions.getClientsFailure.toString()]: (state: any) => ({
...state,
processingClients: false,
}),
[actions.getClientsSuccess]: (state, { payload }) => {
[actions.getClientsSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
...payload,
@@ -152,21 +149,21 @@ const dashboard = handleActions(
return newState;
},
[actions.getProfileRequest]: (state) => ({
[actions.getProfileRequest.toString()]: (state: any) => ({
...state,
processingProfile: true,
}),
[actions.getProfileFailure]: (state) => ({
[actions.getProfileFailure.toString()]: (state: any) => ({
...state,
processingProfile: false,
}),
[actions.getProfileSuccess]: (state, { payload }) => ({
[actions.getProfileSuccess.toString()]: (state, { payload }: any) => ({
...state,
name: payload.name,
theme: payload.theme,
processingProfile: false,
}),
[actions.changeThemeSuccess]: (state, { payload }) => ({
[actions.changeThemeSuccess.toString()]: (state, { payload }: any) => ({
...state,
theme: payload.theme,
}),

View File

@@ -1,18 +1,20 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions';
import { enrichWithConcatenatedIpAddresses } from '../helpers/helpers';
const dhcp = handleActions(
{
[actions.getDhcpStatusRequest]: (state) => ({
[actions.getDhcpStatusRequest.toString()]: (state: any) => ({
...state,
processing: true,
}),
[actions.getDhcpStatusFailure]: (state) => ({
[actions.getDhcpStatusFailure.toString()]: (state: any) => ({
...state,
processing: false,
}),
[actions.getDhcpStatusSuccess]: (state, { payload }) => {
[actions.getDhcpStatusSuccess.toString()]: (state: any, { payload }: any) => {
const { static_leases: staticLeases, ...values } = payload;
const newState = {
@@ -25,15 +27,15 @@ const dhcp = handleActions(
return newState;
},
[actions.getDhcpInterfacesRequest]: (state) => ({
[actions.getDhcpInterfacesRequest.toString()]: (state: any) => ({
...state,
processingInterfaces: true,
}),
[actions.getDhcpInterfacesFailure]: (state) => ({
[actions.getDhcpInterfacesFailure.toString()]: (state: any) => ({
...state,
processingInterfaces: false,
}),
[actions.getDhcpInterfacesSuccess]: (state, { payload }) => {
[actions.getDhcpInterfacesSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
interfaces: enrichWithConcatenatedIpAddresses(payload),
@@ -42,15 +44,15 @@ const dhcp = handleActions(
return newState;
},
[actions.findActiveDhcpRequest]: (state) => ({
[actions.findActiveDhcpRequest.toString()]: (state: any) => ({
...state,
processingStatus: true,
}),
[actions.findActiveDhcpFailure]: (state) => ({
[actions.findActiveDhcpFailure.toString()]: (state: any) => ({
...state,
processingStatus: false,
}),
[actions.findActiveDhcpSuccess]: (state, { payload }) => {
[actions.findActiveDhcpSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
check: payload,
@@ -59,15 +61,15 @@ const dhcp = handleActions(
return newState;
},
[actions.toggleDhcpRequest]: (state) => ({
[actions.toggleDhcpRequest.toString()]: (state: any) => ({
...state,
processingDhcp: true,
}),
[actions.toggleDhcpFailure]: (state) => ({
[actions.toggleDhcpFailure.toString()]: (state: any) => ({
...state,
processingDhcp: false,
}),
[actions.toggleDhcpSuccess]: (state) => {
[actions.toggleDhcpSuccess.toString()]: (state: any) => {
const { enabled } = state;
const newState = {
...state,
@@ -78,15 +80,15 @@ const dhcp = handleActions(
return newState;
},
[actions.setDhcpConfigRequest]: (state) => ({
[actions.setDhcpConfigRequest.toString()]: (state: any) => ({
...state,
processingConfig: true,
}),
[actions.setDhcpConfigFailure]: (state) => ({
[actions.setDhcpConfigFailure.toString()]: (state: any) => ({
...state,
processingConfig: false,
}),
[actions.setDhcpConfigSuccess]: (state, { payload }) => {
[actions.setDhcpConfigSuccess.toString()]: (state: any, { payload }: any) => {
const { v4, v6 } = state;
const newConfigV4 = { ...v4, ...payload.v4 };
const newConfigV6 = { ...v6, ...payload.v6 };
@@ -102,15 +104,15 @@ const dhcp = handleActions(
return newState;
},
[actions.resetDhcpRequest]: (state) => ({
[actions.resetDhcpRequest.toString()]: (state: any) => ({
...state,
processingReset: true,
}),
[actions.resetDhcpFailure]: (state) => ({
[actions.resetDhcpFailure.toString()]: (state: any) => ({
...state,
processingReset: false,
}),
[actions.resetDhcpSuccess]: (state) => ({
[actions.resetDhcpSuccess.toString()]: (state: any) => ({
...state,
processingReset: false,
enabled: false,
@@ -118,13 +120,13 @@ const dhcp = handleActions(
v6: {},
interface_name: '',
}),
[actions.resetDhcpLeasesSuccess]: (state) => ({
[actions.resetDhcpLeasesSuccess.toString()]: (state: any) => ({
...state,
leases: [],
staticLeases: [],
}),
[actions.toggleLeaseModal]: (state, { payload }) => {
[actions.toggleLeaseModal.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
isModalOpen: !state.isModalOpen,
@@ -134,15 +136,15 @@ const dhcp = handleActions(
return newState;
},
[actions.addStaticLeaseRequest]: (state) => ({
[actions.addStaticLeaseRequest.toString()]: (state: any) => ({
...state,
processingAdding: true,
}),
[actions.addStaticLeaseFailure]: (state) => ({
[actions.addStaticLeaseFailure.toString()]: (state: any) => ({
...state,
processingAdding: false,
}),
[actions.addStaticLeaseSuccess]: (state, { payload }) => {
[actions.addStaticLeaseSuccess.toString()]: (state: any, { payload }: any) => {
const { ip, mac, hostname } = payload;
const newLease = {
ip,
@@ -158,17 +160,17 @@ const dhcp = handleActions(
return newState;
},
[actions.removeStaticLeaseRequest]: (state) => ({
[actions.removeStaticLeaseRequest.toString()]: (state: any) => ({
...state,
processingDeleting: true,
}),
[actions.removeStaticLeaseFailure]: (state) => ({
[actions.removeStaticLeaseFailure.toString()]: (state: any) => ({
...state,
processingDeleting: false,
}),
[actions.removeStaticLeaseSuccess]: (state, { payload }) => {
[actions.removeStaticLeaseSuccess.toString()]: (state: any, { payload }: any) => {
const leaseToRemove = payload.ip;
const leases = state.staticLeases.filter((item) => item.ip !== leaseToRemove);
const leases = state.staticLeases.filter((item: any) => item.ip !== leaseToRemove);
const newState = {
...state,
staticLeases: leases,
@@ -177,9 +179,15 @@ const dhcp = handleActions(
return newState;
},
[actions.updateStaticLeaseRequest]: (state) => ({ ...state, processingUpdating: true }),
[actions.updateStaticLeaseFailure]: (state) => ({ ...state, processingUpdating: false }),
[actions.updateStaticLeaseSuccess]: (state) => {
[actions.updateStaticLeaseRequest.toString()]: (state: any) => ({
...state,
processingUpdating: true,
}),
[actions.updateStaticLeaseFailure.toString()]: (state: any) => ({
...state,
processingUpdating: false,
}),
[actions.updateStaticLeaseSuccess.toString()]: (state: any) => {
const newState = {
...state,
processingUpdating: false,

View File

@@ -3,14 +3,20 @@ import { handleActions } from 'redux-actions';
import * as actions from '../actions/dnsConfig';
import { ALL_INTERFACES_IP, BLOCKING_MODES, DNS_REQUEST_OPTIONS } from '../helpers/constants';
const DEFAULT_BLOCKING_IPV4 = ALL_INTERFACES_IP;
const DEFAULT_BLOCKING_IPV6 = '::';
export const DEFAULT_BLOCKING_IPV4 = ALL_INTERFACES_IP;
export const DEFAULT_BLOCKING_IPV6 = '::';
const dnsConfig = handleActions(
{
[actions.getDnsConfigRequest]: (state) => ({ ...state, processingGetConfig: true }),
[actions.getDnsConfigFailure]: (state) => ({ ...state, processingGetConfig: false }),
[actions.getDnsConfigSuccess]: (state, { payload }) => {
[actions.getDnsConfigRequest.toString()]: (state: any) => ({
...state,
processingGetConfig: true,
}),
[actions.getDnsConfigFailure.toString()]: (state: any) => ({
...state,
processingGetConfig: false,
}),
[actions.getDnsConfigSuccess.toString()]: (state: any, { payload }: any) => {
const {
blocking_ipv4,
blocking_ipv6,
@@ -38,9 +44,15 @@ const dnsConfig = handleActions(
};
},
[actions.setDnsConfigRequest]: (state) => ({ ...state, processingSetConfig: true }),
[actions.setDnsConfigFailure]: (state) => ({ ...state, processingSetConfig: false }),
[actions.setDnsConfigSuccess]: (state, { payload }) => ({
[actions.setDnsConfigRequest.toString()]: (state: any) => ({
...state,
processingSetConfig: true,
}),
[actions.setDnsConfigFailure.toString()]: (state: any) => ({
...state,
processingSetConfig: false,
}),
[actions.setDnsConfigSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
processingSetConfig: false,

View File

@@ -1,89 +0,0 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/encryption';
const encryption = handleActions({
[actions.getTlsStatusRequest]: (state) => ({ ...state, processing: true }),
[actions.getTlsStatusFailure]: (state) => ({ ...state, processing: false }),
[actions.getTlsStatusSuccess]: (state, { payload }) => {
const newState = {
...state,
...payload,
/* TODO: handle property delete on api refactor */
server_name: payload.server_name || '',
processing: false,
};
return newState;
},
[actions.setTlsConfigRequest]: (state) => ({ ...state, processingConfig: true }),
[actions.setTlsConfigFailure]: (state) => ({ ...state, processingConfig: false }),
[actions.setTlsConfigSuccess]: (state, { payload }) => {
const newState = {
...state,
...payload,
server_name: payload.server_name || '',
processingConfig: false,
};
return newState;
},
[actions.validateTlsConfigRequest]: (state) => ({ ...state, processingValidate: true }),
[actions.validateTlsConfigFailure]: (state) => ({ ...state, processingValidate: false }),
[actions.validateTlsConfigSuccess]: (state, { payload }) => {
const {
issuer = '',
key_type = '',
not_after = '',
not_before = '',
subject = '',
warning_validation = '',
dns_names = '',
...values
} = payload;
const newState = {
...state,
...values,
issuer,
key_type,
not_after,
not_before,
subject,
warning_validation,
dns_names,
server_name: payload.server_name || '',
processingValidate: false,
};
return newState;
},
}, {
processing: true,
processingConfig: false,
processingValidate: false,
enabled: false,
serve_plain_dns: false,
dns_names: null,
force_https: false,
issuer: '',
key_type: '',
not_after: '',
not_before: '',
port_dns_over_tls: '',
port_https: '',
subject: '',
valid_chain: false,
valid_key: false,
valid_cert: false,
valid_pair: false,
status_cert: '',
status_key: '',
certificate_chain: '',
private_key: '',
server_name: '',
warning_validation: '',
certificate_path: '',
private_key_path: '',
});
export default encryption;

View File

@@ -0,0 +1,110 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/encryption';
const encryption = handleActions(
{
[actions.getTlsStatusRequest.toString()]: (state: any) => ({
...state,
processing: true,
}),
[actions.getTlsStatusFailure.toString()]: (state: any) => ({
...state,
processing: false,
}),
[actions.getTlsStatusSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
...payload,
/* TODO: handle property delete on api refactor */
server_name: payload.server_name || '',
processing: false,
};
return newState;
},
[actions.setTlsConfigRequest.toString()]: (state: any) => ({
...state,
processingConfig: true,
}),
[actions.setTlsConfigFailure.toString()]: (state: any) => ({
...state,
processingConfig: false,
}),
[actions.setTlsConfigSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
...payload,
server_name: payload.server_name || '',
processingConfig: false,
};
return newState;
},
[actions.validateTlsConfigRequest.toString()]: (state: any) => ({
...state,
processingValidate: true,
}),
[actions.validateTlsConfigFailure.toString()]: (state: any) => ({
...state,
processingValidate: false,
}),
[actions.validateTlsConfigSuccess.toString()]: (state: any, { payload }: any) => {
const {
issuer = '',
key_type = '',
not_after = '',
not_before = '',
subject = '',
warning_validation = '',
dns_names = '',
...values
} = payload;
const newState = {
...state,
...values,
issuer,
key_type,
not_after,
not_before,
subject,
warning_validation,
dns_names,
server_name: payload.server_name || '',
processingValidate: false,
};
return newState;
},
},
{
processing: true,
processingConfig: false,
processingValidate: false,
enabled: false,
serve_plain_dns: false,
dns_names: null,
force_https: false,
issuer: '',
key_type: '',
not_after: '',
not_before: '',
port_dns_over_tls: '',
port_https: '',
subject: '',
valid_chain: false,
valid_key: false,
valid_cert: false,
valid_pair: false,
status_cert: '',
status_key: '',
certificate_chain: '',
private_key: '',
server_name: '',
warning_validation: '',
certificate_path: '',
private_key_path: '',
},
);
export default encryption;

View File

@@ -1,118 +0,0 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/filtering';
const filtering = handleActions(
{
[actions.setRulesRequest]: (state) => ({ ...state, processingRules: true }),
[actions.setRulesFailure]: (state) => ({ ...state, processingRules: false }),
[actions.setRulesSuccess]: (state) => ({ ...state, processingRules: false }),
[actions.handleRulesChange]: (state, { payload }) => {
const { userRules } = payload;
return { ...state, userRules };
},
[actions.getFilteringStatusRequest]: (state) => ({
...state,
processingFilters: true,
check: {},
}),
[actions.getFilteringStatusFailure]: (state) => ({ ...state, processingFilters: false }),
[actions.getFilteringStatusSuccess]: (state, { payload }) => ({
...state,
...payload,
processingFilters: false,
}),
[actions.addFilterRequest]: (state) => ({
...state,
processingAddFilter: true,
isFilterAdded: false,
}),
[actions.addFilterFailure]: (state) => ({
...state,
processingAddFilter: false,
isFilterAdded: false,
}),
[actions.addFilterSuccess]: (state) => ({
...state,
processingAddFilter: false,
isFilterAdded: true,
}),
[actions.toggleFilteringModal]: (state, { payload }) => {
if (payload) {
const newState = {
...state,
isModalOpen: !state.isModalOpen,
isFilterAdded: false,
modalType: payload.type || '',
modalFilterUrl: payload.url || '',
};
return newState;
}
const newState = {
...state,
isModalOpen: !state.isModalOpen,
isFilterAdded: false,
modalType: '',
};
return newState;
},
[actions.toggleFilterRequest]: (state) => ({ ...state, processingConfigFilter: true }),
[actions.toggleFilterFailure]: (state) => ({ ...state, processingConfigFilter: false }),
[actions.toggleFilterSuccess]: (state) => ({ ...state, processingConfigFilter: false }),
[actions.editFilterRequest]: (state) => ({ ...state, processingConfigFilter: true }),
[actions.editFilterFailure]: (state) => ({ ...state, processingConfigFilter: false }),
[actions.editFilterSuccess]: (state) => ({ ...state, processingConfigFilter: false }),
[actions.refreshFiltersRequest]: (state) => ({ ...state, processingRefreshFilters: true }),
[actions.refreshFiltersFailure]: (state) => ({ ...state, processingRefreshFilters: false }),
[actions.refreshFiltersSuccess]: (state) => ({ ...state, processingRefreshFilters: false }),
[actions.removeFilterRequest]: (state) => ({ ...state, processingRemoveFilter: true }),
[actions.removeFilterFailure]: (state) => ({ ...state, processingRemoveFilter: false }),
[actions.removeFilterSuccess]: (state) => ({ ...state, processingRemoveFilter: false }),
[actions.setFiltersConfigRequest]: (state) => ({ ...state, processingSetConfig: true }),
[actions.setFiltersConfigFailure]: (state) => ({ ...state, processingSetConfig: false }),
[actions.setFiltersConfigSuccess]: (state, { payload }) => ({
...state,
...payload,
processingSetConfig: false,
}),
[actions.checkHostRequest]: (state) => ({ ...state, processingCheck: true }),
[actions.checkHostFailure]: (state) => ({ ...state, processingCheck: false }),
[actions.checkHostSuccess]: (state, { payload }) => ({
...state,
check: payload,
processingCheck: false,
}),
},
{
isModalOpen: false,
processingFilters: false,
processingRules: false,
processingAddFilter: false,
processingRefreshFilters: false,
processingConfigFilter: false,
processingRemoveFilter: false,
processingSetConfig: false,
processingCheck: false,
isFilterAdded: false,
filters: [],
whitelistFilters: [],
userRules: '',
interval: 24,
enabled: true,
modalType: '',
modalFilterUrl: '',
check: {},
},
);
export default filtering;

View File

@@ -0,0 +1,178 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/filtering';
const filtering = handleActions(
{
[actions.setRulesRequest.toString()]: (state: any) => ({
...state,
processingRules: true,
}),
[actions.setRulesFailure.toString()]: (state: any) => ({
...state,
processingRules: false,
}),
[actions.setRulesSuccess.toString()]: (state: any) => ({
...state,
processingRules: false,
}),
[actions.handleRulesChange.toString()]: (state: any, { payload }: any) => {
const { userRules } = payload;
return { ...state, userRules };
},
[actions.getFilteringStatusRequest.toString()]: (state: any) => ({
...state,
processingFilters: true,
check: {},
}),
[actions.getFilteringStatusFailure.toString()]: (state: any) => ({
...state,
processingFilters: false,
}),
[actions.getFilteringStatusSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
processingFilters: false,
}),
[actions.addFilterRequest.toString()]: (state: any) => ({
...state,
processingAddFilter: true,
isFilterAdded: false,
}),
[actions.addFilterFailure.toString()]: (state: any) => ({
...state,
processingAddFilter: false,
isFilterAdded: false,
}),
[actions.addFilterSuccess.toString()]: (state: any) => ({
...state,
processingAddFilter: false,
isFilterAdded: true,
}),
[actions.toggleFilteringModal.toString()]: (state: any, { payload }: any) => {
if (payload) {
const newState = {
...state,
isModalOpen: !state.isModalOpen,
isFilterAdded: false,
modalType: payload.type || '',
modalFilterUrl: payload.url || '',
};
return newState;
}
const newState = {
...state,
isModalOpen: !state.isModalOpen,
isFilterAdded: false,
modalType: '',
};
return newState;
},
[actions.toggleFilterRequest.toString()]: (state: any) => ({
...state,
processingConfigFilter: true,
}),
[actions.toggleFilterFailure.toString()]: (state: any) => ({
...state,
processingConfigFilter: false,
}),
[actions.toggleFilterSuccess.toString()]: (state: any) => ({
...state,
processingConfigFilter: false,
}),
[actions.editFilterRequest.toString()]: (state: any) => ({
...state,
processingConfigFilter: true,
}),
[actions.editFilterFailure.toString()]: (state: any) => ({
...state,
processingConfigFilter: false,
}),
[actions.editFilterSuccess.toString()]: (state: any) => ({
...state,
processingConfigFilter: false,
}),
[actions.refreshFiltersRequest.toString()]: (state: any) => ({
...state,
processingRefreshFilters: true,
}),
[actions.refreshFiltersFailure.toString()]: (state: any) => ({
...state,
processingRefreshFilters: false,
}),
[actions.refreshFiltersSuccess.toString()]: (state: any) => ({
...state,
processingRefreshFilters: false,
}),
[actions.removeFilterRequest.toString()]: (state: any) => ({
...state,
processingRemoveFilter: true,
}),
[actions.removeFilterFailure.toString()]: (state: any) => ({
...state,
processingRemoveFilter: false,
}),
[actions.removeFilterSuccess.toString()]: (state: any) => ({
...state,
processingRemoveFilter: false,
}),
[actions.setFiltersConfigRequest.toString()]: (state: any) => ({
...state,
processingSetConfig: true,
}),
[actions.setFiltersConfigFailure.toString()]: (state: any) => ({
...state,
processingSetConfig: false,
}),
[actions.setFiltersConfigSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
processingSetConfig: false,
}),
[actions.checkHostRequest.toString()]: (state: any) => ({
...state,
processingCheck: true,
}),
[actions.checkHostFailure.toString()]: (state: any) => ({
...state,
processingCheck: false,
}),
[actions.checkHostSuccess.toString()]: (state, { payload }: any) => ({
...state,
check: payload,
processingCheck: false,
}),
},
{
isModalOpen: false,
processingFilters: false,
processingRules: false,
processingAddFilter: false,
processingRefreshFilters: false,
processingConfigFilter: false,
processingRemoveFilter: false,
processingSetConfig: false,
processingCheck: false,
isFilterAdded: false,
filters: [],
whitelistFilters: [],
userRules: '',
interval: 24,
enabled: true,
modalType: '',
modalFilterUrl: '',
check: {},
},
);
export default filtering;

View File

@@ -1,5 +1,6 @@
import { combineReducers } from 'redux';
import { loadingBarReducer } from 'react-redux-loading-bar';
import { reducer as formReducer } from 'redux-form';
import toasts from './toasts';
import encryption from './encryption';

View File

@@ -1,80 +0,0 @@
import { combineReducers } from 'redux';
import { handleActions } from 'redux-actions';
import { reducer as formReducer } from 'redux-form';
import * as actions from '../actions/install';
import toasts from './toasts';
import {
ALL_INTERFACES_IP, INSTALL_FIRST_STEP, STANDARD_DNS_PORT, STANDARD_WEB_PORT,
} from '../helpers/constants';
const install = handleActions({
[actions.getDefaultAddressesRequest]: (state) => ({ ...state, processingDefault: true }),
[actions.getDefaultAddressesFailure]: (state) => ({ ...state, processingDefault: false }),
[actions.getDefaultAddressesSuccess]: (state, { payload }) => {
const { interfaces, version } = payload;
const web = { ...state.web, port: payload.web_port };
const dns = { ...state.dns, port: payload.dns_port };
const newState = {
...state,
web,
dns,
interfaces,
processingDefault: false,
dnsVersion: version,
};
return newState;
},
[actions.nextStep]: (state) => ({ ...state, step: state.step + 1 }),
[actions.prevStep]: (state) => ({ ...state, step: state.step - 1 }),
[actions.setAllSettingsRequest]: (state) => ({ ...state, processingSubmit: true }),
[actions.setAllSettingsFailure]: (state) => ({ ...state, processingSubmit: false }),
[actions.setAllSettingsSuccess]: (state) => ({ ...state, processingSubmit: false }),
[actions.checkConfigRequest]: (state) => ({ ...state, processingCheck: true }),
[actions.checkConfigFailure]: (state) => ({ ...state, processingCheck: false }),
[actions.checkConfigSuccess]: (state, { payload }) => {
const web = { ...state.web, ...payload.web };
const dns = { ...state.dns, ...payload.dns };
const staticIp = { ...state.staticIp, ...payload.static_ip };
const newState = {
...state, web, dns, staticIp, processingCheck: false,
};
return newState;
},
}, {
step: INSTALL_FIRST_STEP,
processingDefault: true,
processingSubmit: false,
processingCheck: false,
web: {
ip: ALL_INTERFACES_IP,
port: STANDARD_WEB_PORT,
status: '',
can_autofix: false,
},
dns: {
ip: ALL_INTERFACES_IP,
port: STANDARD_DNS_PORT,
status: '',
can_autofix: false,
},
staticIp: {
static: '',
ip: '',
error: '',
},
interfaces: {},
dnsVersion: '',
});
export default combineReducers({
install,
toasts,
form: formReducer,
});

View File

@@ -0,0 +1,114 @@
import { combineReducers } from 'redux';
import { handleActions } from 'redux-actions';
import { reducer as formReducer } from 'redux-form';
import * as actions from '../actions/install';
import toasts from './toasts';
import { ALL_INTERFACES_IP, INSTALL_FIRST_STEP, STANDARD_DNS_PORT, STANDARD_WEB_PORT } from '../helpers/constants';
const install = handleActions(
{
[actions.getDefaultAddressesRequest.toString().toString()]: (state: any) => ({
...state,
processingDefault: true,
}),
[actions.getDefaultAddressesFailure.toString().toString()]: (state: any) => ({
...state,
processingDefault: false,
}),
[actions.getDefaultAddressesSuccess.toString().toString()]: (state: any, { payload }: any) => {
const { interfaces, version } = payload;
const web = { ...state.web, port: payload.web_port };
const dns = { ...state.dns, port: payload.dns_port };
const newState = {
...state,
web,
dns,
interfaces,
processingDefault: false,
dnsVersion: version,
};
return newState;
},
[actions.nextStep.toString().toString()]: (state: any) => ({
...state,
step: state.step + 1,
}),
[actions.prevStep.toString().toString()]: (state: any) => ({
...state,
step: state.step - 1,
}),
[actions.setAllSettingsRequest.toString().toString()]: (state: any) => ({
...state,
processingSubmit: true,
}),
[actions.setAllSettingsFailure.toString().toString()]: (state: any) => ({
...state,
processingSubmit: false,
}),
[actions.setAllSettingsSuccess.toString().toString()]: (state: any) => ({
...state,
processingSubmit: false,
}),
[actions.checkConfigRequest.toString().toString()]: (state: any) => ({
...state,
processingCheck: true,
}),
[actions.checkConfigFailure.toString().toString()]: (state: any) => ({
...state,
processingCheck: false,
}),
[actions.checkConfigSuccess.toString().toString()]: (state: any, { payload }: any) => {
const web = { ...state.web, ...payload.web };
const dns = { ...state.dns, ...payload.dns };
const staticIp = { ...state.staticIp, ...payload.static_ip };
const newState = {
...state,
web,
dns,
staticIp,
processingCheck: false,
};
return newState;
},
},
{
step: INSTALL_FIRST_STEP,
processingDefault: true,
processingSubmit: false,
processingCheck: false,
web: {
ip: ALL_INTERFACES_IP,
port: STANDARD_WEB_PORT,
status: '',
can_autofix: false,
},
dns: {
ip: ALL_INTERFACES_IP,
port: STANDARD_DNS_PORT,
status: '',
can_autofix: false,
},
staticIp: {
static: '',
ip: '',
error: '',
},
interfaces: {},
dnsVersion: '',
},
);
export default combineReducers({
install,
toasts,
form: formReducer,
});

View File

@@ -1,24 +0,0 @@
import { combineReducers } from 'redux';
import { handleActions } from 'redux-actions';
import { reducer as formReducer } from 'redux-form';
import * as actions from '../actions/login';
import toasts from './toasts';
const login = handleActions({
[actions.processLoginRequest]: (state) => ({ ...state, processingLogin: true }),
[actions.processLoginFailure]: (state) => ({ ...state, processingLogin: false }),
[actions.processLoginSuccess]: (state, { payload }) => ({
...state, ...payload, processingLogin: false,
}),
}, {
processingLogin: false,
email: '',
password: '',
});
export default combineReducers({
login,
toasts,
form: formReducer,
});

View File

@@ -0,0 +1,37 @@
import { combineReducers } from 'redux';
import { handleActions } from 'redux-actions';
import { reducer as formReducer } from 'redux-form';
import * as actions from '../actions/login';
import toasts from './toasts';
const login = handleActions(
{
[actions.processLoginRequest.toString()]: (state: any) => ({
...state,
processingLogin: true,
}),
[actions.processLoginFailure.toString()]: (state: any) => ({
...state,
processingLogin: false,
}),
[actions.processLoginSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
processingLogin: false,
}),
},
{
processingLogin: false,
email: '',
password: '',
},
);
export default combineReducers({
login,
toasts,
form: formReducer,
});

View File

@@ -1,107 +0,0 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/queryLogs';
import {
DEFAULT_LOGS_FILTER, DAY, QUERY_LOG_INTERVALS_DAYS, HOUR,
} from '../helpers/constants';
const queryLogs = handleActions(
{
[actions.setFilteredLogsRequest]: (state) => ({ ...state, processingGetLogs: true }),
[actions.setFilteredLogsFailure]: (state) => ({ ...state, processingGetLogs: false }),
[actions.toggleDetailedLogs]: (state, { payload }) => ({
...state,
isDetailed: payload,
}),
[actions.setFilteredLogsSuccess]: (state, { payload }) => {
const { logs, oldest, filter } = payload;
const isFiltered = filter && Object.keys(filter).some((key) => filter[key]);
return {
...state,
oldest,
filter,
isFiltered,
logs,
isEntireLog: logs.length < 1,
processingGetLogs: false,
};
},
[actions.setLogsFilterRequest]: (state, { payload }) => ({ ...state, filter: payload }),
[actions.getLogsRequest]: (state) => ({ ...state, processingGetLogs: true }),
[actions.getLogsFailure]: (state) => ({ ...state, processingGetLogs: false }),
[actions.getLogsSuccess]: (state, { payload }) => {
const {
logs, oldest, older_than,
} = payload;
return {
...state,
oldest,
logs: older_than ? [...state.logs, ...logs] : logs,
isEntireLog: logs.length < 1,
processingGetLogs: false,
};
},
[actions.clearLogsRequest]: (state) => ({ ...state, processingClear: true }),
[actions.clearLogsFailure]: (state) => ({ ...state, processingClear: false }),
[actions.clearLogsSuccess]: (state) => ({
...state,
logs: [],
processingClear: false,
}),
[actions.getLogsConfigRequest]: (state) => ({ ...state, processingGetConfig: true }),
[actions.getLogsConfigFailure]: (state) => ({ ...state, processingGetConfig: false }),
[actions.getLogsConfigSuccess]: (state, { payload }) => ({
...state,
...payload,
customInterval: !QUERY_LOG_INTERVALS_DAYS.includes(payload.interval)
? payload.interval / HOUR
: null,
processingGetConfig: false,
}),
[actions.setLogsConfigRequest]: (state) => ({ ...state, processingSetConfig: true }),
[actions.setLogsConfigFailure]: (state) => ({ ...state, processingSetConfig: false }),
[actions.setLogsConfigSuccess]: (state, { payload }) => ({
...state,
...payload,
processingSetConfig: false,
}),
[actions.getAdditionalLogsRequest]: (state) => ({
...state, processingAdditionalLogs: true, processingGetLogs: true,
}),
[actions.getAdditionalLogsFailure]: (state) => ({
...state, processingAdditionalLogs: false, processingGetLogs: false,
}),
[actions.getAdditionalLogsSuccess]: (state) => ({
...state, processingAdditionalLogs: false, processingGetLogs: false, isEntireLog: true,
}),
},
{
processingGetLogs: true,
processingClear: false,
processingGetConfig: false,
processingSetConfig: false,
processingAdditionalLogs: false,
interval: DAY,
logs: [],
enabled: true,
oldest: '',
filter: DEFAULT_LOGS_FILTER,
isFiltered: false,
anonymize_client_ip: false,
isDetailed: true,
isEntireLog: false,
customInterval: null,
},
);
export default queryLogs;

View File

@@ -0,0 +1,143 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/queryLogs';
import { DEFAULT_LOGS_FILTER, DAY, QUERY_LOG_INTERVALS_DAYS, HOUR } from '../helpers/constants';
const queryLogs = handleActions(
{
[actions.setFilteredLogsRequest.toString()]: (state: any) => ({
...state,
processingGetLogs: true,
}),
[actions.setFilteredLogsFailure.toString()]: (state: any) => ({
...state,
processingGetLogs: false,
}),
[actions.toggleDetailedLogs.toString()]: (state, { payload }: any) => ({
...state,
isDetailed: payload,
}),
[actions.setFilteredLogsSuccess.toString()]: (state: any, { payload }: any) => {
const { logs, oldest, filter } = payload;
const isFiltered = filter && Object.keys(filter).some((key) => filter[key]);
return {
...state,
oldest,
filter,
isFiltered,
logs,
isEntireLog: logs.length < 1,
processingGetLogs: false,
};
},
[actions.setLogsFilterRequest.toString()]: (state, { payload }: any) => ({
...state,
filter: payload,
}),
[actions.getLogsRequest.toString()]: (state: any) => ({
...state,
processingGetLogs: true,
}),
[actions.getLogsFailure.toString()]: (state: any) => ({
...state,
processingGetLogs: false,
}),
[actions.getLogsSuccess.toString()]: (state: any, { payload }: any) => {
const { logs, oldest, older_than } = payload;
return {
...state,
oldest,
logs: older_than ? [...state.logs, ...logs] : logs,
isEntireLog: logs.length < 1,
processingGetLogs: false,
};
},
[actions.clearLogsRequest.toString()]: (state: any) => ({
...state,
processingClear: true,
}),
[actions.clearLogsFailure.toString()]: (state: any) => ({
...state,
processingClear: false,
}),
[actions.clearLogsSuccess.toString()]: (state: any) => ({
...state,
logs: [],
processingClear: false,
}),
[actions.getLogsConfigRequest.toString()]: (state: any) => ({
...state,
processingGetConfig: true,
}),
[actions.getLogsConfigFailure.toString()]: (state: any) => ({
...state,
processingGetConfig: false,
}),
[actions.getLogsConfigSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
customInterval: !QUERY_LOG_INTERVALS_DAYS.includes(payload.interval) ? payload.interval / HOUR : null,
processingGetConfig: false,
}),
[actions.setLogsConfigRequest.toString()]: (state: any) => ({
...state,
processingSetConfig: true,
}),
[actions.setLogsConfigFailure.toString()]: (state: any) => ({
...state,
processingSetConfig: false,
}),
[actions.setLogsConfigSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
processingSetConfig: false,
}),
[actions.getAdditionalLogsRequest.toString()]: (state: any) => ({
...state,
processingAdditionalLogs: true,
processingGetLogs: true,
}),
[actions.getAdditionalLogsFailure.toString()]: (state: any) => ({
...state,
processingAdditionalLogs: false,
processingGetLogs: false,
}),
[actions.getAdditionalLogsSuccess.toString()]: (state: any) => ({
...state,
processingAdditionalLogs: false,
processingGetLogs: false,
isEntireLog: true,
}),
},
{
processingGetLogs: true,
processingClear: false,
processingGetConfig: false,
processingSetConfig: false,
processingAdditionalLogs: false,
interval: DAY,
logs: [],
enabled: true,
oldest: '',
filter: DEFAULT_LOGS_FILTER,
isFiltered: false,
anonymize_client_ip: false,
isDetailed: true,
isEntireLog: false,
customInterval: null,
},
);
export default queryLogs;

View File

@@ -1,73 +0,0 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/rewrites';
const rewrites = handleActions(
{
[actions.getRewritesListRequest]: (state) => ({ ...state, processing: true }),
[actions.getRewritesListFailure]: (state) => ({ ...state, processing: false }),
[actions.getRewritesListSuccess]: (state, { payload }) => {
const newState = {
...state,
list: payload,
processing: false,
};
return newState;
},
[actions.addRewriteRequest]: (state) => ({ ...state, processingAdd: true }),
[actions.addRewriteFailure]: (state) => ({ ...state, processingAdd: false }),
[actions.addRewriteSuccess]: (state, { payload }) => {
const newState = {
...state,
list: [...state.list, payload],
processingAdd: false,
};
return newState;
},
[actions.deleteRewriteRequest]: (state) => ({ ...state, processingDelete: true }),
[actions.deleteRewriteFailure]: (state) => ({ ...state, processingDelete: false }),
[actions.deleteRewriteSuccess]: (state) => ({ ...state, processingDelete: false }),
[actions.updateRewriteRequest]: (state) => ({ ...state, processingUpdate: true }),
[actions.updateRewriteFailure]: (state) => ({ ...state, processingUpdate: false }),
[actions.updateRewriteSuccess]: (state) => {
const newState = {
...state,
processingUpdate: false,
};
return newState;
},
[actions.toggleRewritesModal]: (state, { payload }) => {
if (payload) {
const newState = {
...state,
modalType: payload.type || '',
isModalOpen: !state.isModalOpen,
currentRewrite: payload.currentRewrite,
};
return newState;
}
const newState = {
...state,
isModalOpen: !state.isModalOpen,
};
return newState;
},
},
{
processing: true,
processingAdd: false,
processingDelete: false,
processingUpdate: false,
isModalOpen: false,
modalType: '',
currentRewrite: {},
list: [],
},
);
export default rewrites;

View File

@@ -0,0 +1,100 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/rewrites';
const rewrites = handleActions(
{
[actions.getRewritesListRequest.toString()]: (state: any) => ({
...state,
processing: true,
}),
[actions.getRewritesListFailure.toString()]: (state: any) => ({
...state,
processing: false,
}),
[actions.getRewritesListSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
list: payload,
processing: false,
};
return newState;
},
[actions.addRewriteRequest.toString()]: (state: any) => ({
...state,
processingAdd: true,
}),
[actions.addRewriteFailure.toString()]: (state: any) => ({
...state,
processingAdd: false,
}),
[actions.addRewriteSuccess.toString()]: (state: any, { payload }: any) => {
const newState = {
...state,
list: [...state.list, payload],
processingAdd: false,
};
return newState;
},
[actions.deleteRewriteRequest.toString()]: (state: any) => ({
...state,
processingDelete: true,
}),
[actions.deleteRewriteFailure.toString()]: (state: any) => ({
...state,
processingDelete: false,
}),
[actions.deleteRewriteSuccess.toString()]: (state: any) => ({
...state,
processingDelete: false,
}),
[actions.updateRewriteRequest.toString()]: (state: any) => ({
...state,
processingUpdate: true,
}),
[actions.updateRewriteFailure.toString()]: (state: any) => ({
...state,
processingUpdate: false,
}),
[actions.updateRewriteSuccess.toString()]: (state: any) => {
const newState = {
...state,
processingUpdate: false,
};
return newState;
},
[actions.toggleRewritesModal.toString()]: (state: any, { payload }: any) => {
if (payload) {
const newState = {
...state,
modalType: payload.type || '',
isModalOpen: !state.isModalOpen,
currentRewrite: payload.currentRewrite,
};
return newState;
}
const newState = {
...state,
isModalOpen: !state.isModalOpen,
};
return newState;
},
},
{
processing: true,
processingAdd: false,
processingDelete: false,
processingUpdate: false,
isModalOpen: false,
modalType: '',
currentRewrite: {},
list: [],
},
);
export default rewrites;

View File

@@ -1,39 +0,0 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/services';
const services = handleActions(
{
[actions.getBlockedServicesRequest]: (state) => ({ ...state, processing: true }),
[actions.getBlockedServicesFailure]: (state) => ({ ...state, processing: false }),
[actions.getBlockedServicesSuccess]: (state, { payload }) => ({
...state,
list: payload,
processing: false,
}),
[actions.getAllBlockedServicesRequest]: (state) => ({ ...state, processingAll: true }),
[actions.getAllBlockedServicesFailure]: (state) => ({ ...state, processingAll: false }),
[actions.getAllBlockedServicesSuccess]: (state, { payload }) => ({
...state,
allServices: payload.blocked_services,
processingAll: false,
}),
[actions.updateBlockedServicesRequest]: (state) => ({ ...state, processingSet: true }),
[actions.updateBlockedServicesFailure]: (state) => ({ ...state, processingSet: false }),
[actions.updateBlockedServicesSuccess]: (state) => ({
...state,
processingSet: false,
}),
},
{
processing: true,
processingAll: true,
processingSet: false,
list: {},
allServices: [],
},
);
export default services;

View File

@@ -0,0 +1,57 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/services';
const services = handleActions(
{
[actions.getBlockedServicesRequest.toString()]: (state: any) => ({
...state,
processing: true,
}),
[actions.getBlockedServicesFailure.toString()]: (state: any) => ({
...state,
processing: false,
}),
[actions.getBlockedServicesSuccess.toString()]: (state, { payload }: any) => ({
...state,
list: payload,
processing: false,
}),
[actions.getAllBlockedServicesRequest.toString()]: (state: any) => ({
...state,
processingAll: true,
}),
[actions.getAllBlockedServicesFailure.toString()]: (state: any) => ({
...state,
processingAll: false,
}),
[actions.getAllBlockedServicesSuccess.toString()]: (state, { payload }: any) => ({
...state,
allServices: payload.blocked_services,
processingAll: false,
}),
[actions.updateBlockedServicesRequest.toString()]: (state: any) => ({
...state,
processingSet: true,
}),
[actions.updateBlockedServicesFailure.toString()]: (state: any) => ({
...state,
processingSet: false,
}),
[actions.updateBlockedServicesSuccess.toString()]: (state: any) => ({
...state,
processingSet: false,
}),
},
{
processing: true,
processingAll: true,
processingSet: false,
list: {},
allServices: [],
},
);
export default services;

View File

@@ -1,17 +1,18 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions';
const settings = handleActions(
{
[actions.initSettingsRequest]: (state) => ({
[actions.initSettingsRequest.toString()]: (state: any) => ({
...state,
processing: true,
}),
[actions.initSettingsFailure]: (state) => ({
[actions.initSettingsFailure.toString()]: (state: any) => ({
...state,
processing: false,
}),
[actions.initSettingsSuccess]: (state, { payload }) => {
[actions.initSettingsSuccess.toString()]: (state: any, { payload }: any) => {
const { settingsList } = payload;
const newState = {
...state,
@@ -20,7 +21,7 @@ const settings = handleActions(
};
return newState;
},
[actions.toggleSettingStatus]: (state, { payload }) => {
[actions.toggleSettingStatus.toString()]: (state: any, { payload }: any) => {
const { settingsList } = state;
const { settingKey, value } = payload;
@@ -39,15 +40,15 @@ const settings = handleActions(
settingsList: newSettingsList,
};
},
[actions.testUpstreamRequest]: (state) => ({
[actions.testUpstreamRequest.toString()]: (state: any) => ({
...state,
processingTestUpstream: true,
}),
[actions.testUpstreamFailure]: (state) => ({
[actions.testUpstreamFailure.toString()]: (state: any) => ({
...state,
processingTestUpstream: false,
}),
[actions.testUpstreamSuccess]: (state) => ({
[actions.testUpstreamSuccess.toString()]: (state: any) => ({
...state,
processingTestUpstream: false,
}),

View File

@@ -1,11 +1,7 @@
import { handleActions } from 'redux-actions';
import { normalizeTopClients } from '../helpers/helpers';
import {
DAY,
HOUR,
STATS_INTERVALS_DAYS,
TIME_UNITS,
} from '../helpers/constants';
import { DAY, HOUR, STATS_INTERVALS_DAYS, TIME_UNITS } from '../helpers/constants';
import * as actions from '../actions/stats';
@@ -28,28 +24,46 @@ const defaultStats = {
const stats = handleActions(
{
[actions.getStatsConfigRequest]: (state) => ({ ...state, processingGetConfig: true }),
[actions.getStatsConfigFailure]: (state) => ({ ...state, processingGetConfig: false }),
[actions.getStatsConfigSuccess]: (state, { payload }) => ({
[actions.getStatsConfigRequest.toString()]: (state: any) => ({
...state,
processingGetConfig: true,
}),
[actions.getStatsConfigFailure.toString()]: (state: any) => ({
...state,
processingGetConfig: false,
}),
[actions.getStatsConfigSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
customInterval: !STATS_INTERVALS_DAYS.includes(payload.interval)
? payload.interval / HOUR
: null,
customInterval: !STATS_INTERVALS_DAYS.includes(payload.interval) ? payload.interval / HOUR : null,
processingGetConfig: false,
}),
[actions.setStatsConfigRequest]: (state) => ({ ...state, processingSetConfig: true }),
[actions.setStatsConfigFailure]: (state) => ({ ...state, processingSetConfig: false }),
[actions.setStatsConfigSuccess]: (state, { payload }) => ({
[actions.setStatsConfigRequest.toString()]: (state: any) => ({
...state,
processingSetConfig: true,
}),
[actions.setStatsConfigFailure.toString()]: (state: any) => ({
...state,
processingSetConfig: false,
}),
[actions.setStatsConfigSuccess.toString()]: (state, { payload }: any) => ({
...state,
...payload,
processingSetConfig: false,
}),
[actions.getStatsRequest]: (state) => ({ ...state, processingStats: true }),
[actions.getStatsFailure]: (state) => ({ ...state, processingStats: false }),
[actions.getStatsSuccess]: (state, { payload }) => {
[actions.getStatsRequest.toString()]: (state: any) => ({
...state,
processingStats: true,
}),
[actions.getStatsFailure.toString()]: (state: any) => ({
...state,
processingStats: false,
}),
[actions.getStatsSuccess.toString()]: (state: any, { payload }: any) => {
const {
dns_queries: dnsQueries,
blocked_filtering: blockedFiltering,
@@ -94,9 +108,15 @@ const stats = handleActions(
return newState;
},
[actions.resetStatsRequest]: (state) => ({ ...state, processingReset: true }),
[actions.resetStatsFailure]: (state) => ({ ...state, processingReset: false }),
[actions.resetStatsSuccess]: (state) => ({
[actions.resetStatsRequest.toString()]: (state: any) => ({
...state,
processingReset: true,
}),
[actions.resetStatsFailure.toString()]: (state: any) => ({
...state,
processingReset: false,
}),
[actions.resetStatsSuccess.toString()]: (state: any) => ({
...state,
...defaultStats,
processingReset: false,

View File

@@ -1,53 +0,0 @@
import { handleActions } from 'redux-actions';
import { nanoid } from 'nanoid';
import {
addErrorToast, addNoticeToast, addSuccessToast,
} from '../actions/toasts';
import { removeToast } from '../actions';
import { TOAST_TYPES } from '../helpers/constants';
const toasts = handleActions({
[addErrorToast]: (state, { payload }) => {
const message = payload.error.toString();
console.error(payload.error);
const errorToast = {
id: nanoid(),
message,
options: payload.options,
type: TOAST_TYPES.ERROR,
};
const newState = { ...state, notices: [...state.notices, errorToast] };
return newState;
},
[addSuccessToast]: (state, { payload }) => {
const successToast = {
id: nanoid(),
message: payload,
type: TOAST_TYPES.SUCCESS,
};
const newState = { ...state, notices: [...state.notices, successToast] };
return newState;
},
[addNoticeToast]: (state, { payload }) => {
const noticeToast = {
id: nanoid(),
message: payload.error.toString(),
options: payload.options,
type: TOAST_TYPES.NOTICE,
};
const newState = { ...state, notices: [...state.notices, noticeToast] };
return newState;
},
[removeToast]: (state, { payload }) => {
const filtered = state.notices.filter((notice) => notice.id !== payload);
const newState = { ...state, notices: filtered };
return newState;
},
}, { notices: [] });
export default toasts;

View File

@@ -0,0 +1,54 @@
import { handleActions } from 'redux-actions';
import { nanoid } from 'nanoid';
import { addErrorToast, addNoticeToast, addSuccessToast } from '../actions/toasts';
import { removeToast } from '../actions';
import { TOAST_TYPES } from '../helpers/constants';
const toasts = handleActions(
{
[addErrorToast.toString()]: (state: any, { payload }: any) => {
const message = payload.error.toString();
console.error(payload.error);
const errorToast = {
id: nanoid(),
message,
options: payload.options,
type: TOAST_TYPES.ERROR,
};
const newState = { ...state, notices: [...state.notices, errorToast] };
return newState;
},
[addSuccessToast.toString()]: (state: any, { payload }: any) => {
const successToast = {
id: nanoid(),
message: payload,
type: TOAST_TYPES.SUCCESS,
};
const newState = { ...state, notices: [...state.notices, successToast] };
return newState;
},
[addNoticeToast.toString()]: (state: any, { payload }: any) => {
const noticeToast = {
id: nanoid(),
message: payload.error.toString(),
options: payload.options,
type: TOAST_TYPES.NOTICE,
};
const newState = { ...state, notices: [...state.notices, noticeToast] };
return newState;
},
[removeToast.toString()]: (state: any, { payload }: any) => {
const filtered = state.notices.filter((notice: any) => notice.id !== payload);
const newState = { ...state, notices: filtered };
return newState;
},
},
{ notices: [] },
);
export default toasts;