forked from ddrilling/asb_cloud_front
Улучшено отображение при переходе в архив
This commit is contained in:
parent
d56810700f
commit
fe52116a9b
@ -72,6 +72,8 @@ const makeSubjectSubsription = (subject$, handler) => {
|
||||
return () => subscribtion.unsubscribe()
|
||||
}
|
||||
|
||||
const getRowDate = (row) => row && isRawDate(row.date) ? new Date(row.date) : null
|
||||
|
||||
const TelemetryView = memo(() => {
|
||||
const [well, updateWell] = useWell()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
@ -101,6 +103,10 @@ const TelemetryView = memo(() => {
|
||||
const dataSaub = normalizeData(data)
|
||||
const out = replace ? [...dataSaub] : [...prev, ...dataSaub]
|
||||
out.sort(dateSorter)
|
||||
setLoadedDataRange({
|
||||
start: getRowDate(out.at(0)),
|
||||
end: getRowDate(out.at(-1)),
|
||||
})
|
||||
return out
|
||||
})
|
||||
}, [])
|
||||
@ -116,8 +122,6 @@ const TelemetryView = memo(() => {
|
||||
const onWheel = useCallback((e) => {
|
||||
if (!archiveMode && e.deltaY < 0) {
|
||||
setArchiveMode(true)
|
||||
setDataSaub([])
|
||||
setDataSpin([])
|
||||
} else if (archiveMode) {
|
||||
setEndDate((prevEndDate) => {
|
||||
const offset = e.deltaY / 100 * chartInterval * 0.15 // сдвиг в 15% интервала
|
||||
@ -127,7 +131,6 @@ const TelemetryView = memo(() => {
|
||||
const out = new Date(Math.max(firstPossibleDate, Math.min(nextEndDate, lastPossibleDate)))
|
||||
if (e.deltaY > 0 && +out >= lastPossibleDate) { // Автопереход к актуальным данным при прокручивании в самый низ
|
||||
setArchiveMode(false)
|
||||
setLoadedDataRange(null)
|
||||
}
|
||||
return out
|
||||
})
|
||||
@ -209,7 +212,10 @@ const TelemetryView = memo(() => {
|
||||
if (data) {
|
||||
data.forEach(elm => elm.date = new Date(elm.date))
|
||||
setDataSaub((prevDataSaub) => {
|
||||
const newData = [...prevDataSaub, ...normalizeData(data)]
|
||||
let newData = normalizeData(data)
|
||||
if (+loadingStartDate > +loadedDataRange.start || (+loadingStartDate + loadingInterval * 1000) < +loadedDataRange.end) {
|
||||
newData = [...prevDataSaub, ...newData]
|
||||
}
|
||||
newData.sort(dateSorter)
|
||||
return cutData(newData, loadedStartDate, loadedEndDate)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user