Убрал rollupOptions из vite.config. Убрал equipments. Скорректировал route. Декомпозировал EdgeDetailPage.
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
import { BrowserRouter, Navigate, Route, Routes, useNavigate } from 'react-router-dom';
|
||||
import { EdgeCurrentPage } from '../features/edge-detail/EdgeCurrentPage';
|
||||
import { EdgeDetailPage } from '../features/edge-detail/EdgeDetailPage';
|
||||
import { EdgeHistoryPage } from '../features/edge-detail/EdgeHistoryPage';
|
||||
import { EdgesDashboard } from '../features/edges-dashboard/EdgesDashboard';
|
||||
|
||||
function DashboardRoute() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<EdgesDashboard
|
||||
onOpenEdge={(edgeId) => navigate(`/edges/${encodeURIComponent(edgeId)}`)}
|
||||
onOpenEquipment={(edgeId) => navigate(`/edges/${encodeURIComponent(edgeId)}/equipment`)}
|
||||
/>
|
||||
);
|
||||
return <EdgesDashboard onOpenEdge={(edgeId) => navigate(`/edges/${encodeURIComponent(edgeId)}`)} />;
|
||||
}
|
||||
|
||||
export function AppRouter() {
|
||||
@@ -19,12 +16,9 @@ export function AppRouter() {
|
||||
<Routes>
|
||||
<Route path="/" element={<Navigate to="/edges" replace />} />
|
||||
<Route path="/edges" element={<DashboardRoute />} />
|
||||
<Route path="/edges/:edgeId" element={<EdgeDetailPage view="overview" />} />
|
||||
<Route path="/edges/:edgeId/archive" element={<EdgeDetailPage view="archive" />} />
|
||||
<Route path="/edges/:edgeId/indicators" element={<EdgeDetailPage view="indicators" />} />
|
||||
<Route path="/edges/:edgeId/equipment" element={<EdgeDetailPage view="equipment" />} />
|
||||
{/* Электросхемы временно скрыты до готовности опубликованных схем и diagram-service. */}
|
||||
{/* <Route path="/edges/:edgeId/electrical" element={<EdgeDetailPage view="electrical" />} /> */}
|
||||
<Route path="/edges/:edgeId" element={<EdgeDetailPage />} />
|
||||
<Route path="/edges/:edgeId/archive" element={<EdgeHistoryPage />} />
|
||||
<Route path="/edges/:edgeId/indicators" element={<EdgeCurrentPage />} />
|
||||
<Route path="*" element={<Navigate to="/edges" replace />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getCurrent } from '../../entities/current/api';
|
||||
|
||||
export function useCurrentQuery(edgeId: string, eventsConnected: boolean) {
|
||||
return useQuery({
|
||||
queryKey: ['current', edgeId],
|
||||
queryFn: () => getCurrent(edgeId),
|
||||
enabled: Boolean(edgeId),
|
||||
refetchInterval: eventsConnected ? false : 1_000,
|
||||
});
|
||||
}
|
||||
49
src/features/edge-detail/EdgeCurrentPage.tsx
Normal file
49
src/features/edge-detail/EdgeCurrentPage.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { getCurrent } from '../../entities/current/api';
|
||||
import { createCurrentTagLabels, filterCurrentItems } from '../current/model';
|
||||
import { useCurrentEvents } from '../current/useCurrentEvents';
|
||||
import { EdgePageLayout } from './components/EdgePageLayout';
|
||||
import { IndicatorsView } from './components/IndicatorsView';
|
||||
|
||||
export function EdgeCurrentPage() {
|
||||
const { edgeId = '' } = useParams();
|
||||
const [search, setSearch] = useState('');
|
||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||
const currentEventsConnected = useCurrentEvents(edgeId);
|
||||
const current = useQuery({
|
||||
queryKey: ['current', edgeId],
|
||||
queryFn: () => getCurrent(edgeId),
|
||||
enabled: Boolean(edgeId),
|
||||
refetchInterval: currentEventsConnected ? false : 1_000,
|
||||
});
|
||||
const currentItems = useMemo(() => current.data?.items ?? [], [current.data?.items]);
|
||||
const tagLabels = useMemo(() => createCurrentTagLabels(currentItems), [currentItems]);
|
||||
const getTagLabel = (tag: string) => tagLabels[tag] ?? tag;
|
||||
const visibleItems = useMemo(() => filterCurrentItems(currentItems, search), [currentItems, search]);
|
||||
|
||||
const toggleTag = (tag: string) => {
|
||||
setSelectedTags((prev) => (prev.includes(tag) ? prev.filter((selected) => selected !== tag) : [...prev, tag]));
|
||||
};
|
||||
|
||||
return (
|
||||
<EdgePageLayout
|
||||
currentEventsConnected={currentEventsConnected}
|
||||
edgeId={edgeId}
|
||||
view="indicators"
|
||||
onRefresh={() => void current.refetch()}
|
||||
>
|
||||
<IndicatorsView
|
||||
items={visibleItems}
|
||||
search={search}
|
||||
isError={current.isError}
|
||||
error={current.error}
|
||||
selectedTags={selectedTags}
|
||||
getTagLabel={getTagLabel}
|
||||
onSearchChange={setSearch}
|
||||
onToggleTag={toggleTag}
|
||||
/>
|
||||
</EdgePageLayout>
|
||||
);
|
||||
}
|
||||
@@ -1,137 +1,45 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useAuth } from '../../auth/authContext';
|
||||
import { getCurrent } from '../../entities/current/api';
|
||||
import {
|
||||
countLiveCurrentItems,
|
||||
createCurrentTagLabels,
|
||||
filterCurrentItems,
|
||||
getLatestCurrentUpdatedAt,
|
||||
} from '../current/model';
|
||||
import { useCurrentEvents } from '../current/useCurrentEvents';
|
||||
import { useCurrentQuery } from '../current/useCurrentQuery';
|
||||
import { createRange } from '../history/dateRange';
|
||||
import { useHistoryQuery } from '../history/useHistoryQuery';
|
||||
import { ArchiveView } from './components/ArchiveView';
|
||||
import { EdgeSidebar } from './components/EdgeSidebar';
|
||||
import { EdgeTopbar } from './components/EdgeTopbar';
|
||||
import { EquipmentView } from './components/EquipmentView';
|
||||
import { IndicatorsView } from './components/IndicatorsView';
|
||||
import { EdgePageLayout } from './components/EdgePageLayout';
|
||||
import { OverviewView } from './components/OverviewView';
|
||||
import type { DetailView } from './types';
|
||||
|
||||
type EdgeDetailPageProps = {
|
||||
view: DetailView;
|
||||
};
|
||||
|
||||
/** Собирает раздел выбранной буровой из вкладок текущих данных, архива и оборудования. */
|
||||
export function EdgeDetailPage({ view }: EdgeDetailPageProps) {
|
||||
export function EdgeDetailPage() {
|
||||
const navigate = useNavigate();
|
||||
const auth = useAuth();
|
||||
const { edgeId = '' } = useParams();
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
||||
const [search, setSearch] = useState('');
|
||||
const [range, setRange] = useState(() => createRange(24));
|
||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||
|
||||
const edgePath = `/edges/${encodeURIComponent(edgeId)}`;
|
||||
const currentEventsConnected = useCurrentEvents(edgeId);
|
||||
const current = useCurrentQuery(edgeId, currentEventsConnected);
|
||||
const current = useQuery({
|
||||
queryKey: ['current', edgeId],
|
||||
queryFn: () => getCurrent(edgeId),
|
||||
enabled: Boolean(edgeId),
|
||||
refetchInterval: currentEventsConnected ? false : 1_000,
|
||||
});
|
||||
const currentItems = useMemo(() => current.data?.items ?? [], [current.data?.items]);
|
||||
|
||||
const tagLabels = useMemo(() => createCurrentTagLabels(currentItems), [currentItems]);
|
||||
const getTagLabel = (tag: string) => tagLabels[tag] ?? tag;
|
||||
const visibleItems = useMemo(() => filterCurrentItems(currentItems, search), [currentItems, search]);
|
||||
const latestUpdatedAt = useMemo(() => getLatestCurrentUpdatedAt(currentItems), [currentItems]);
|
||||
const liveCount = countLiveCurrentItems(currentItems);
|
||||
const { query: history, granularity: historyGranularity } = useHistoryQuery(edgeId, selectedTags[0], range);
|
||||
|
||||
const toggleTag = (tag: string) => {
|
||||
setSelectedTags((prev) => (prev.includes(tag) ? [] : [tag]));
|
||||
};
|
||||
|
||||
const selectFirstTags = () => {
|
||||
setSelectedTags(visibleItems[0] ? [visibleItems[0].tag] : []);
|
||||
};
|
||||
|
||||
const selectVisibleTags = () => {
|
||||
setSelectedTags(visibleItems[0] ? [visibleItems[0].tag] : []);
|
||||
};
|
||||
|
||||
const clearVisibleTags = () => {
|
||||
const visibleTags = new Set(visibleItems.map((item) => item.tag));
|
||||
setSelectedTags((prev) => prev.filter((tag) => !visibleTags.has(tag)));
|
||||
};
|
||||
|
||||
return (
|
||||
<main className={`app-shell ${sidebarCollapsed ? 'app-shell--sidebar-collapsed' : ''}`}>
|
||||
<EdgeSidebar
|
||||
collapsed={sidebarCollapsed}
|
||||
edgePath={edgePath}
|
||||
view={view}
|
||||
onNavigate={navigate}
|
||||
onToggleCollapsed={() => setSidebarCollapsed((collapsed) => !collapsed)}
|
||||
<EdgePageLayout
|
||||
currentEventsConnected={currentEventsConnected}
|
||||
edgeId={edgeId}
|
||||
view="overview"
|
||||
onRefresh={() => void current.refetch()}
|
||||
>
|
||||
<OverviewView
|
||||
edgeId={edgeId}
|
||||
totalTags={currentItems.length}
|
||||
liveCount={liveCount}
|
||||
latestUpdatedAt={latestUpdatedAt}
|
||||
onOpenArchive={() => navigate(`${edgePath}/archive`)}
|
||||
onOpenIndicators={() => navigate(`${edgePath}/indicators`)}
|
||||
/>
|
||||
|
||||
<section className={`workspace workspace--${view}`}>
|
||||
<EdgeTopbar
|
||||
authEnabled={auth.enabled}
|
||||
currentEventsConnected={currentEventsConnected}
|
||||
edgeId={edgeId}
|
||||
onBack={() => navigate('/edges')}
|
||||
onLogout={() => void auth.logout()}
|
||||
onRefresh={() => void current.refetch()}
|
||||
/>
|
||||
|
||||
{view === 'overview' ? (
|
||||
<OverviewView
|
||||
edgeId={edgeId}
|
||||
totalTags={currentItems.length}
|
||||
liveCount={liveCount}
|
||||
latestUpdatedAt={latestUpdatedAt}
|
||||
selectedCount={selectedTags.length}
|
||||
onOpenArchive={() => navigate(`${edgePath}/archive`)}
|
||||
onOpenIndicators={() => navigate(`${edgePath}/indicators`)}
|
||||
onOpenEquipment={() => navigate(`${edgePath}/equipment`)}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{view === 'archive' ? (
|
||||
<ArchiveView
|
||||
items={visibleItems}
|
||||
search={search}
|
||||
selectedTags={selectedTags}
|
||||
history={history.data}
|
||||
historyLoading={history.isPending && selectedTags.length > 0}
|
||||
historyGranulate={history.data?.granulate ?? historyGranularity.granulate}
|
||||
historyAxis={historyGranularity}
|
||||
range={range}
|
||||
onSearchChange={setSearch}
|
||||
onRangeChange={setRange}
|
||||
onToggleTag={toggleTag}
|
||||
onSelectFirstTags={selectFirstTags}
|
||||
onSelectVisibleTags={selectVisibleTags}
|
||||
onClearVisibleTags={clearVisibleTags}
|
||||
onClearTags={() => setSelectedTags([])}
|
||||
getTagLabel={getTagLabel}
|
||||
tagLabels={tagLabels}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{view === 'indicators' ? (
|
||||
<IndicatorsView
|
||||
items={visibleItems}
|
||||
search={search}
|
||||
isError={current.isError}
|
||||
error={current.error}
|
||||
selectedTags={selectedTags}
|
||||
getTagLabel={getTagLabel}
|
||||
onSearchChange={setSearch}
|
||||
onToggleTag={toggleTag}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{view === 'equipment' ? <EquipmentView /> : null}
|
||||
</section>
|
||||
</main>
|
||||
</EdgePageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
96
src/features/edge-detail/EdgeHistoryPage.tsx
Normal file
96
src/features/edge-detail/EdgeHistoryPage.tsx
Normal file
@@ -0,0 +1,96 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { getCurrent } from '../../entities/current/api';
|
||||
import { getHistory } from '../../entities/history/api';
|
||||
import { toIsoFromInput } from '../../utils/format';
|
||||
import { getHistoryGranularity } from '../../utils/historyGranularity';
|
||||
import { createCurrentTagLabels, filterCurrentItems } from '../current/model';
|
||||
import { useCurrentEvents } from '../current/useCurrentEvents';
|
||||
import { createRange } from '../history/dateRange';
|
||||
import { ArchiveView } from './components/ArchiveView';
|
||||
import { EdgePageLayout } from './components/EdgePageLayout';
|
||||
|
||||
export function EdgeHistoryPage() {
|
||||
const { edgeId = '' } = useParams();
|
||||
const [search, setSearch] = useState('');
|
||||
const [range, setRange] = useState(() => createRange(24));
|
||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||
const currentEventsConnected = useCurrentEvents(edgeId);
|
||||
const current = useQuery({
|
||||
queryKey: ['current', edgeId],
|
||||
queryFn: () => getCurrent(edgeId),
|
||||
enabled: Boolean(edgeId),
|
||||
refetchInterval: currentEventsConnected ? false : 1_000,
|
||||
});
|
||||
const currentItems = useMemo(() => current.data?.items ?? [], [current.data?.items]);
|
||||
const tagLabels = useMemo(() => createCurrentTagLabels(currentItems), [currentItems]);
|
||||
const getTagLabel = (tag: string) => tagLabels[tag] ?? tag;
|
||||
const visibleItems = useMemo(() => filterCurrentItems(currentItems, search), [currentItems, search]);
|
||||
const from = toIsoFromInput(range.from) as string;
|
||||
const to = toIsoFromInput(range.to) as string;
|
||||
const historyGranularity = useMemo(() => getHistoryGranularity(from, to), [from, to]);
|
||||
const selectedTag = selectedTags[0];
|
||||
const history = useQuery({
|
||||
queryKey: ['history', edgeId, selectedTag, from, to, historyGranularity.granulate],
|
||||
queryFn: () =>
|
||||
getHistory({
|
||||
edge: edgeId,
|
||||
tag: selectedTag as string,
|
||||
from,
|
||||
to,
|
||||
granulate: historyGranularity.granulate,
|
||||
}),
|
||||
enabled: Boolean(edgeId && selectedTag),
|
||||
refetchInterval: false,
|
||||
});
|
||||
|
||||
const toggleTag = (tag: string) => {
|
||||
setSelectedTags((prev) => (prev.includes(tag) ? [] : [tag]));
|
||||
};
|
||||
|
||||
const selectFirstTags = () => {
|
||||
setSelectedTags(visibleItems[0] ? [visibleItems[0].tag] : []);
|
||||
};
|
||||
|
||||
const selectVisibleTags = () => {
|
||||
setSelectedTags(visibleItems[0] ? [visibleItems[0].tag] : []);
|
||||
};
|
||||
|
||||
const clearVisibleTags = () => {
|
||||
const visibleTags = new Set(visibleItems.map((item) => item.tag));
|
||||
setSelectedTags((prev) => prev.filter((tag) => !visibleTags.has(tag)));
|
||||
};
|
||||
|
||||
return (
|
||||
<EdgePageLayout
|
||||
currentEventsConnected={currentEventsConnected}
|
||||
edgeId={edgeId}
|
||||
view="archive"
|
||||
onRefresh={() => {
|
||||
void current.refetch();
|
||||
void history.refetch();
|
||||
}}
|
||||
>
|
||||
<ArchiveView
|
||||
items={visibleItems}
|
||||
search={search}
|
||||
selectedTags={selectedTags}
|
||||
history={history.data}
|
||||
historyLoading={history.isPending && selectedTags.length > 0}
|
||||
historyGranulate={history.data?.granulate ?? historyGranularity.granulate}
|
||||
historyAxis={historyGranularity}
|
||||
range={range}
|
||||
onSearchChange={setSearch}
|
||||
onRangeChange={setRange}
|
||||
onToggleTag={toggleTag}
|
||||
onSelectFirstTags={selectFirstTags}
|
||||
onSelectVisibleTags={selectVisibleTags}
|
||||
onClearVisibleTags={clearVisibleTags}
|
||||
onClearTags={() => setSelectedTags([])}
|
||||
getTagLabel={getTagLabel}
|
||||
tagLabels={tagLabels}
|
||||
/>
|
||||
</EdgePageLayout>
|
||||
);
|
||||
}
|
||||
53
src/features/edge-detail/components/EdgePageLayout.tsx
Normal file
53
src/features/edge-detail/components/EdgePageLayout.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAuth } from '../../../auth/authContext';
|
||||
import { EdgeSidebar } from './EdgeSidebar';
|
||||
import { EdgeTopbar } from './EdgeTopbar';
|
||||
import type { DetailView } from '../types';
|
||||
|
||||
type EdgePageLayoutProps = {
|
||||
children: ReactNode;
|
||||
currentEventsConnected: boolean;
|
||||
edgeId: string;
|
||||
onRefresh: () => void;
|
||||
view: DetailView;
|
||||
};
|
||||
|
||||
export function EdgePageLayout({
|
||||
children,
|
||||
currentEventsConnected,
|
||||
edgeId,
|
||||
onRefresh,
|
||||
view,
|
||||
}: EdgePageLayoutProps) {
|
||||
const navigate = useNavigate();
|
||||
const auth = useAuth();
|
||||
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
||||
const edgePath = `/edges/${encodeURIComponent(edgeId)}`;
|
||||
|
||||
return (
|
||||
<main className={`app-shell ${sidebarCollapsed ? 'app-shell--sidebar-collapsed' : ''}`}>
|
||||
<EdgeSidebar
|
||||
collapsed={sidebarCollapsed}
|
||||
edgePath={edgePath}
|
||||
view={view}
|
||||
onNavigate={navigate}
|
||||
onToggleCollapsed={() => setSidebarCollapsed((collapsed) => !collapsed)}
|
||||
/>
|
||||
|
||||
<section className={`workspace workspace--${view}`}>
|
||||
<EdgeTopbar
|
||||
authEnabled={auth.enabled}
|
||||
currentEventsConnected={currentEventsConnected}
|
||||
edgeId={edgeId}
|
||||
onBack={() => navigate('/edges')}
|
||||
onLogout={() => void auth.logout()}
|
||||
onRefresh={onRefresh}
|
||||
/>
|
||||
|
||||
{children}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Activity, BarChart3, Gauge, Menu, PanelLeftClose, PanelLeftOpen, Wrench } from 'lucide-react';
|
||||
import { Activity, BarChart3, Gauge, Menu, PanelLeftClose, PanelLeftOpen } from 'lucide-react';
|
||||
import type { DetailView } from '../types';
|
||||
|
||||
type EdgeSidebarProps = {
|
||||
@@ -56,14 +56,6 @@ export function EdgeSidebar({ collapsed, edgePath, view, onNavigate, onToggleCol
|
||||
<Activity size={18} />
|
||||
<span className="nav-label">Показатели</span>
|
||||
</button>
|
||||
<button
|
||||
className={`nav-item nav-item--button ${view === 'equipment' ? 'nav-item--active' : ''}`}
|
||||
type="button"
|
||||
onClick={() => onNavigate(`${edgePath}/equipment`)}
|
||||
>
|
||||
<Wrench size={18} />
|
||||
<span className="nav-label">Оборудование</span>
|
||||
</button>
|
||||
</nav>
|
||||
</aside>
|
||||
);
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { useState } from 'react';
|
||||
import { ToirLightIframe } from '../../../components/ToirLightIframe';
|
||||
|
||||
const ACTIVE_EQUIPMENT_PATH =
|
||||
'/equipment?filter=%7B%22status%22%3A%5B%22Active%22%5D%7D&displayedFilters=%7B%22status%22%3Atrue%7D';
|
||||
|
||||
export function EquipmentView() {
|
||||
const [iframeLoaded, setIframeLoaded] = useState(false);
|
||||
|
||||
return (
|
||||
<section className="equipment-section" aria-label="Активное оборудование">
|
||||
<div className="equipment-frame-shell" aria-busy={!iframeLoaded}>
|
||||
{!iframeLoaded ? (
|
||||
<div className="equipment-frame-loading" role="status" aria-live="polite">
|
||||
<span className="equipment-frame-loading__ring" aria-hidden />
|
||||
<span>Загрузка интерфейса управления оборудованием...</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<ToirLightIframe
|
||||
className="equipment-frame"
|
||||
path={ACTIVE_EQUIPMENT_PATH}
|
||||
title="ТОиР light: управление активным оборудованием"
|
||||
onLoad={() => setIframeLoaded(true)}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
import { Activity, BarChart3, CalendarClock, Wrench } from 'lucide-react';
|
||||
import { Activity, BarChart3, CalendarClock } from 'lucide-react';
|
||||
import { formatDateTime } from '../../../utils/format';
|
||||
|
||||
type OverviewViewProps = {
|
||||
edgeId: string;
|
||||
latestUpdatedAt?: Date;
|
||||
liveCount: number;
|
||||
selectedCount: number;
|
||||
totalTags: number;
|
||||
onOpenArchive: () => void;
|
||||
onOpenEquipment: () => void;
|
||||
onOpenIndicators: () => void;
|
||||
};
|
||||
|
||||
@@ -16,10 +14,8 @@ export function OverviewView({
|
||||
edgeId,
|
||||
latestUpdatedAt,
|
||||
liveCount,
|
||||
selectedCount,
|
||||
totalTags,
|
||||
onOpenArchive,
|
||||
onOpenEquipment,
|
||||
onOpenIndicators,
|
||||
}: OverviewViewProps) {
|
||||
return (
|
||||
@@ -34,8 +30,8 @@ export function OverviewView({
|
||||
<strong>{liveCount}</strong>
|
||||
</div>
|
||||
<div className="summary-card">
|
||||
<span>Выбрано для графика</span>
|
||||
<strong>{selectedCount}</strong>
|
||||
<span>Архив</span>
|
||||
<strong>1</strong>
|
||||
</div>
|
||||
<div className="summary-card">
|
||||
<span>Последнее обновление</span>
|
||||
@@ -57,10 +53,6 @@ export function OverviewView({
|
||||
<BarChart3 size={18} />
|
||||
Архив и график
|
||||
</button>
|
||||
<button type="button" onClick={onOpenEquipment}>
|
||||
<Wrench size={18} />
|
||||
Состояние оборудования
|
||||
</button>
|
||||
<button type="button">
|
||||
<CalendarClock size={18} />
|
||||
Техническое обслуживание
|
||||
|
||||
@@ -1 +1 @@
|
||||
export type DetailView = 'overview' | 'archive' | 'indicators' | 'equipment';
|
||||
export type DetailView = 'overview' | 'archive' | 'indicators';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { ArrowRight, Clock3, Gauge, LogOut, RefreshCw, Search, ShieldAlert, Wrench } from 'lucide-react';
|
||||
import { ArrowRight, Clock3, Gauge, LogOut, RefreshCw, Search, ShieldAlert } from 'lucide-react';
|
||||
import edgeImage from '../../assets/edge.png';
|
||||
import { getEdges } from '../../entities/edge/api';
|
||||
import type { EdgeItem } from '../../entities/edge/types';
|
||||
@@ -8,7 +8,6 @@ import { useAuth } from '../../auth/authContext';
|
||||
|
||||
type EdgesDashboardProps = {
|
||||
onOpenEdge: (edgeId: string) => void;
|
||||
onOpenEquipment: (edgeId: string) => void;
|
||||
};
|
||||
|
||||
function getEdgeTitle(edge: EdgeItem): string {
|
||||
@@ -21,7 +20,7 @@ function filterEdges(edges: EdgeItem[], search: string): EdgeItem[] {
|
||||
}
|
||||
|
||||
/** Отображает список буровых без расчетов по текущим значениям. */
|
||||
export function EdgesDashboard({ onOpenEdge, onOpenEquipment }: EdgesDashboardProps) {
|
||||
export function EdgesDashboard({ onOpenEdge }: EdgesDashboardProps) {
|
||||
const [search, setSearch] = useState('');
|
||||
const auth = useAuth();
|
||||
const edges = useQuery({
|
||||
@@ -70,7 +69,6 @@ export function EdgesDashboard({ onOpenEdge, onOpenEquipment }: EdgesDashboardPr
|
||||
key={edge.id}
|
||||
edge={edge}
|
||||
onOpenEdge={onOpenEdge}
|
||||
onOpenEquipment={onOpenEquipment}
|
||||
/>
|
||||
))}
|
||||
</section>
|
||||
@@ -103,11 +101,9 @@ function StatBlock({
|
||||
function EdgeCard({
|
||||
edge,
|
||||
onOpenEdge,
|
||||
onOpenEquipment,
|
||||
}: {
|
||||
edge: EdgeItem;
|
||||
onOpenEdge: (edgeId: string) => void;
|
||||
onOpenEquipment: (edgeId: string) => void;
|
||||
}) {
|
||||
const title = getEdgeTitle(edge);
|
||||
|
||||
@@ -124,10 +120,6 @@ function EdgeCard({
|
||||
</header>
|
||||
|
||||
<div className="edge-card__actions" aria-label={`Разделы ${title}`}>
|
||||
<button type="button" onClick={() => onOpenEquipment(edge.id)}>
|
||||
<Wrench size={15} />
|
||||
Оборудование
|
||||
</button>
|
||||
<button type="button">
|
||||
<Gauge size={15} />
|
||||
Состояние байпасов
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getHistory } from '../../entities/history/api';
|
||||
import { toIsoFromInput } from '../../utils/format';
|
||||
import { getHistoryGranularity } from '../../utils/historyGranularity';
|
||||
import type { DateRangeState } from './dateRange';
|
||||
|
||||
export function useHistoryQuery(edgeId: string, selectedTag: string | undefined, range: DateRangeState) {
|
||||
const from = toIsoFromInput(range.from) as string;
|
||||
const to = toIsoFromInput(range.to) as string;
|
||||
const granularity = useMemo(() => getHistoryGranularity(from, to), [from, to]);
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['history', edgeId, selectedTag, from, to, granularity.granulate],
|
||||
queryFn: () =>
|
||||
getHistory({
|
||||
edge: edgeId,
|
||||
tag: selectedTag as string,
|
||||
from,
|
||||
to,
|
||||
granulate: granularity.granulate,
|
||||
}),
|
||||
enabled: Boolean(edgeId && selectedTag),
|
||||
refetchInterval: false,
|
||||
});
|
||||
|
||||
return { query, from, to, granularity };
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export { EdgeDetailPage } from '../features/edge-detail/EdgeDetailPage';
|
||||
export type { DetailView } from '../features/edge-detail/types';
|
||||
export { EdgeCurrentPage } from '../features/edge-detail/EdgeCurrentPage';
|
||||
export { EdgeHistoryPage } from '../features/edge-detail/EdgeHistoryPage';
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
@import './detail/overview.css';
|
||||
@import './detail/indicators.css';
|
||||
@import './detail/archive.css';
|
||||
@import './detail/equipment.css';
|
||||
@import './detail/electrical.css';
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
.equipment-section {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.equipment-frame-shell {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(88, 103, 121, 0.5);
|
||||
border-radius: 8px;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 32%),
|
||||
repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 11px),
|
||||
rgba(2, 6, 23, 0.58);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.08),
|
||||
inset 0 -1px 0 rgba(0, 0, 0, 0.52);
|
||||
}
|
||||
|
||||
.equipment-frame-loading {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 2;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
gap: 12px;
|
||||
align-content: center;
|
||||
color: #cbd5e1;
|
||||
background: rgba(2, 6, 23, 0.74);
|
||||
}
|
||||
|
||||
.equipment-frame-loading__ring {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border: 3px solid rgba(212, 165, 116, 0.22);
|
||||
border-top-color: var(--accent-soft);
|
||||
border-radius: 999px;
|
||||
animation: equipmentFrameSpin 900ms linear infinite;
|
||||
}
|
||||
|
||||
.equipment-frame {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
background: #05080d;
|
||||
}
|
||||
|
||||
@keyframes equipmentFrameSpin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@@ -146,23 +146,12 @@
|
||||
}
|
||||
|
||||
.workspace--archive,
|
||||
.workspace--equipment,
|
||||
.workspace--electrical {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.workspace--equipment {
|
||||
overflow: hidden;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.workspace--equipment .topbar {
|
||||
flex: 0 0 auto;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.topbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
Reference in New Issue
Block a user