added status and renamed components

This commit is contained in:
proddy
2024-03-20 23:57:19 +01:00
parent 863bc04c21
commit 24ea975575
53 changed files with 633 additions and 536 deletions

View File

@@ -1,9 +1,9 @@
import Schema from 'async-validator';
import { IP_ADDRESS_VALIDATOR } from './shared';
import type { APSettings } from 'types';
import { isAPEnabled } from 'framework/ap/APSettingsForm';
import type { APSettingsType } from 'types';
import { isAPEnabled } from 'framework/ap/APSettings';
export const createAPSettingsValidator = (apSettings: APSettings) =>
export const createAPSettingsValidator = (apSettings: APSettingsType) =>
new Schema({
provision_mode: { required: true, message: 'Please provide a provision mode' },
...(isAPEnabled(apSettings) && {

View File

@@ -1,8 +1,8 @@
import Schema from 'async-validator';
import { IP_OR_HOSTNAME_VALIDATOR } from './shared';
import type { MqttSettings } from 'types';
import type { MqttSettingsType } from 'types';
export const createMqttSettingsValidator = (mqttSettings: MqttSettings) =>
export const createMqttSettingsValidator = (mqttSettings: MqttSettingsType) =>
new Schema({
...(mqttSettings.enabled && {
host: [{ required: true, message: 'Host is required' }, IP_OR_HOSTNAME_VALIDATOR],

View File

@@ -1,8 +1,8 @@
import Schema from 'async-validator';
import { HOSTNAME_VALIDATOR, IP_ADDRESS_VALIDATOR } from './shared';
import type { NetworkSettings } from 'types';
import type { NetworkSettingsType } from 'types';
export const createNetworkSettingsValidator = (networkSettings: NetworkSettings) =>
export const createNetworkSettingsValidator = (networkSettings: NetworkSettingsType) =>
new Schema({
ssid: [{ type: 'string', max: 32, message: 'SSID must be 32 characters or less' }],
bssid: [{ type: 'string', max: 17, message: 'BSSID must be 17 characters or empty' }],

View File

@@ -1,6 +1,6 @@
import Schema from 'async-validator';
import type { InternalRuleItem } from 'async-validator';
import type { User } from 'types';
import type { UserType } from 'types';
export const SECURITY_SETTINGS_VALIDATOR = new Schema({
jwt_secret: [
@@ -9,7 +9,7 @@ export const SECURITY_SETTINGS_VALIDATOR = new Schema({
]
});
export const createUniqueUsernameValidator = (users: User[]) => ({
export const createUniqueUsernameValidator = (users: UserType[]) => ({
validator(rule: InternalRuleItem, username: string, callback: (error?: string) => void) {
if (username && users.find((u) => u.username === username)) {
callback('Username already in use');
@@ -19,7 +19,7 @@ export const createUniqueUsernameValidator = (users: User[]) => ({
}
});
export const createUserValidator = (users: User[], creating: boolean) =>
export const createUserValidator = (users: UserType[], creating: boolean) =>
new Schema({
username: [
{ required: true, message: 'Username is required' },