forked from ddrilling/asb_cloud_front
* Исправлена работа TelemetryMerger
* к константам добавлен Readonly
This commit is contained in:
parent
43e97750e4
commit
0db0984ba7
@ -35,7 +35,7 @@ export const TelemetryInfo = memo(({ info, danger, ...other }) => (
|
|||||||
export const TelemetryMerger = memo(() => {
|
export const TelemetryMerger = memo(() => {
|
||||||
const [primary, setPrimary] = useState(null)
|
const [primary, setPrimary] = useState(null)
|
||||||
const [secondary, setSecondary] = useState(null)
|
const [secondary, setSecondary] = useState(null)
|
||||||
const [telemetry, setTelemetry] = useState([])
|
const [telemetry, setTelemetry] = useState(null)
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [isMerging, setIsMerging] = useState(false)
|
const [isMerging, setIsMerging] = useState(false)
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export const TelemetryMerger = memo(() => {
|
|||||||
primary?.info?.deposit !== secondary?.info?.deposit && 'deposit',
|
primary?.info?.deposit !== secondary?.info?.deposit && 'deposit',
|
||||||
], [primary, secondary])
|
], [primary, secondary])
|
||||||
|
|
||||||
const updateTelemetry = useCallback(async () => await invokeWebApiWrapperAsync(
|
const updateTelemetry = useCallback(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
const telemetry = arrayOrDefault(await AdminTelemetryService.getAll())
|
const telemetry = arrayOrDefault(await AdminTelemetryService.getAll())
|
||||||
setTelemetry(telemetry)
|
setTelemetry(telemetry)
|
||||||
@ -59,22 +59,23 @@ export const TelemetryMerger = memo(() => {
|
|||||||
|
|
||||||
const mergeTelemetry = useCallback(() => invokeWebApiWrapperAsync(
|
const mergeTelemetry = useCallback(() => invokeWebApiWrapperAsync(
|
||||||
async () => {
|
async () => {
|
||||||
|
if (!secondary?.id || !primary?.id) return
|
||||||
await AdminTelemetryService.mergeTelemetries(secondary.id, primary.id)
|
await AdminTelemetryService.mergeTelemetries(secondary.id, primary.id)
|
||||||
await updateTelemetry()
|
updateTelemetry()
|
||||||
},
|
},
|
||||||
setIsMerging,
|
setIsMerging,
|
||||||
'Не удалось объединить телеметрии',
|
'Не удалось объединить телеметрии',
|
||||||
'Объединение телеметрий',
|
'Объединение телеметрий',
|
||||||
), [updateTelemetry, secondary.id, primary.id])
|
), [updateTelemetry, secondary, primary])
|
||||||
|
|
||||||
useEffect(() => updateTelemetry(), [updateTelemetry])
|
useEffect(updateTelemetry, [updateTelemetry])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const query = new URLSearchParams(location.search)
|
const query = new URLSearchParams(location.search)
|
||||||
const primaryId = parseInt(query.get('primary') ?? null)
|
const primaryId = parseInt(query.get('primary') ?? null)
|
||||||
const secondaryId = parseInt(query.get('secondary') ?? null)
|
const secondaryId = parseInt(query.get('secondary') ?? null)
|
||||||
const primary = isNaN(primaryId) ? null : telemetry.find((t) => t.id === primaryId)
|
const primary = isNaN(primaryId) ? null : telemetry.find((t) => t?.id === primaryId)
|
||||||
const secondary = isNaN(secondaryId) ? null : telemetry.find((t) => t.id === secondaryId)
|
const secondary = isNaN(secondaryId) ? null : telemetry.find((t) => t?.id === secondaryId)
|
||||||
setPrimary(primary)
|
setPrimary(primary)
|
||||||
setSecondary(secondary)
|
setSecondary(secondary)
|
||||||
}, [location, telemetry])
|
}, [location, telemetry])
|
||||||
|
@ -4,7 +4,7 @@ import { SimpleTimezoneDto } from '@api'
|
|||||||
|
|
||||||
export type RawDate = number | string | Date
|
export type RawDate = number | string | Date
|
||||||
|
|
||||||
export const defaultFormat: string = 'DD.MM.YYYY HH:mm'
|
export const defaultFormat: Readonly<string> = 'DD.MM.YYYY HH:mm'
|
||||||
|
|
||||||
export enum timeInS {
|
export enum timeInS {
|
||||||
millisecond = 0.001,
|
millisecond = 0.001,
|
||||||
@ -52,7 +52,7 @@ export const fractionalSum = (date: unknown, value: number, type: keyof typeof t
|
|||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rawTimezones = {
|
export const rawTimezones = Object.freeze({
|
||||||
'Калининград': 2,
|
'Калининград': 2,
|
||||||
'Москва': 3,
|
'Москва': 3,
|
||||||
'Самара': 4,
|
'Самара': 4,
|
||||||
@ -68,7 +68,7 @@ export const rawTimezones = {
|
|||||||
'Среднеколымск': 11,
|
'Среднеколымск': 11,
|
||||||
'Анадырь': 12,
|
'Анадырь': 12,
|
||||||
'Петропавловск-Камчатский': 12,
|
'Петропавловск-Камчатский': 12,
|
||||||
}
|
})
|
||||||
|
|
||||||
export type TimezoneId = keyof typeof rawTimezones
|
export type TimezoneId = keyof typeof rawTimezones
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { OperationStatService, WellOperationDto, WellOperationDtoPlanFactPredictBase } from '@api'
|
import { OperationStatService, WellOperationDto, WellOperationDtoPlanFactPredictBase } from '@api'
|
||||||
|
|
||||||
const maxPrefix: string = 'isMax'
|
const maxPrefix: Readonly<string> = 'isMax'
|
||||||
const minPrefix: string = 'isMin'
|
const minPrefix: Readonly<string> = 'isMin'
|
||||||
|
|
||||||
export const getPrecision = (number: number): string => Number.isFinite(number) ? number.toFixed(2) : '-'
|
export const getPrecision = (number: number): string => Number.isFinite(number) ? number.toFixed(2) : '-'
|
||||||
|
|
||||||
export type KeyType = number | string
|
export type KeyType = number | string
|
||||||
|
|
||||||
export const nwtIdCategory: number = 1043
|
export const nwtIdCategory: Readonly<number> = 1043
|
||||||
|
|
||||||
export type SaubData = WellOperationDto & {
|
export type SaubData = WellOperationDto & {
|
||||||
/** Относится ли операция к НПВ */
|
/** Относится ли операция к НПВ */
|
||||||
|
@ -3,7 +3,7 @@ export type { RawDate, timeInS } from './datetime'
|
|||||||
|
|
||||||
export { MimeTypes } from './mimeTypes'
|
export { MimeTypes } from './mimeTypes'
|
||||||
|
|
||||||
export const headerHeight: number = 64
|
export const headerHeight: Readonly<number> = 64
|
||||||
|
|
||||||
export const mainFrameSize = () => ({
|
export const mainFrameSize = () => ({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export const MimeTypes = {
|
export const MimeTypes = Object.freeze({
|
||||||
BMP: 'image/bmp',
|
BMP: 'image/bmp',
|
||||||
CSV: 'text/csv',
|
CSV: 'text/csv',
|
||||||
CSV1: 'application/csv',
|
CSV1: 'application/csv',
|
||||||
@ -29,6 +29,6 @@ export const MimeTypes = {
|
|||||||
XLSB: 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
XLSB: 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||||
XLSM: 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
XLSM: 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||||
XLSX: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
XLSX: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
}
|
})
|
||||||
|
|
||||||
export default MimeTypes
|
export default MimeTypes
|
||||||
|
@ -62,9 +62,9 @@ export const isURLAvailable = (path: string, userPermissions?: Permission[]) =>
|
|||||||
return sectionAvailable(perms, userPerms)
|
return sectionAvailable(perms, userPerms)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PermissionRecord extends Record<string, string[] | PermissionRecord | null> {}
|
export interface PermissionRecord extends Record<string, string[] | PermissionRecord | null> {}
|
||||||
|
|
||||||
export const requirements: PermissionRecord = {
|
export const requirements: Readonly<PermissionRecord> = {
|
||||||
'': [],
|
'': [],
|
||||||
login: [], // ['Auth.edit']
|
login: [], // ['Auth.edit']
|
||||||
register: [], // ['Auth.edit']
|
register: [], // ['Auth.edit']
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
import { Rule } from 'rc-field-form/lib/interface'
|
import { Rule } from 'rc-field-form/lib/interface'
|
||||||
|
|
||||||
const _min1: Rule = {
|
const _min1: Readonly<Rule> = {
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 255,
|
max: 255,
|
||||||
message: 'Допустимая длина 1-255 символов',
|
message: 'Допустимая длина 1-255 символов',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const min1: Rule[] = [_min1]
|
export const min1: Readonly<Rule[]> = [_min1]
|
||||||
|
|
||||||
export const createLoginRules: Rule[] = [_min1, {
|
export const createLoginRules: Readonly<Rule[]> = [_min1, {
|
||||||
pattern: /^\s*[A-zА-яЁё][A-zА-яЁё\w.-]+\s*$/,
|
pattern: /^\s*[A-zА-яЁё][A-zА-яЁё\w.-]+\s*$/,
|
||||||
message: 'Логин должен начинаться с русской или латинской буквы и содержать только символы (А-яA-z0-9_-.)!'
|
message: 'Логин должен начинаться с русской или латинской буквы и содержать только символы (А-яA-z0-9_-.)!'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
export const loginRules: Rule[] = [...createLoginRules, {
|
export const loginRules: Readonly<Rule[]> = [...createLoginRules, {
|
||||||
required: true,
|
required: true,
|
||||||
message: 'Пожалуйста, введите логин',
|
message: 'Пожалуйста, введите логин',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
export const nameRules: Rule[] = [_min1, {
|
export const nameRules: Readonly<Rule[]> = [_min1, {
|
||||||
pattern: /^[A-zА-яЁё][A-zА-яЁё-]*$/,
|
pattern: /^[A-zА-яЁё][A-zА-яЁё-]*$/,
|
||||||
message: 'Допустимые символы: А-яA-z-',
|
message: 'Допустимые символы: А-яA-z-',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
export const phoneRules: Rule[] = [{
|
export const phoneRules: Readonly<Rule[]> = [{
|
||||||
pattern: /^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$/,
|
pattern: /^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$/,
|
||||||
message: 'Номер телефона должен иметь вид: +7 (xxx) xxx-xx-xx',
|
message: 'Номер телефона должен иметь вид: +7 (xxx) xxx-xx-xx',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
export const emailRules: Rule[] = [{
|
export const emailRules: Readonly<Rule[]> = [{
|
||||||
type: 'email',
|
type: 'email',
|
||||||
message: 'E-mail должен иметь вид: "user@site.domain"',
|
message: 'E-mail должен иметь вид: "user@site.domain"',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
export const passwordRules: Rule[] = [{
|
export const passwordRules: Readonly<Rule[]> = [{
|
||||||
required: true,
|
required: true,
|
||||||
message: 'Пожалуйста, введите пароль!',
|
message: 'Пожалуйста, введите пароль!',
|
||||||
}]
|
}]
|
||||||
|
|
||||||
export const createPasswordRules: Rule[] = [{
|
export const createPasswordRules: Readonly<Rule[]> = [{
|
||||||
min: 8,
|
min: 8,
|
||||||
max: 255,
|
max: 255,
|
||||||
message: 'Допустимая длина пароля 8-255',
|
message: 'Допустимая длина пароля 8-255',
|
||||||
|
Loading…
Reference in New Issue
Block a user