Ver código fonte

feat(ui): add a linear view to the WAN traffic chart

Linear interpolates between buckets, between the stepped Line and Bars. Line stays the default and the choice is remembered per browser.

Part of #1975
Nacho 3 semanas atrás
pai
commit
0c17abeba2

+ 2 - 0
CHANGELOG.md

@@ -9,6 +9,8 @@ y este proyecto se adhiere a [Versionado Semántico](https://semver.org/lang/es/
 
 ### Added
 
+- The WAN traffic chart alternates Line, Linear and Bars (#1975). Line keeps its stepped shape, Linear interpolates between buckets for a continuous curve, and the choice is remembered per browser next to the existing Bars view.
+
 - A Send test button next to the push switch (#1973). Turning notifications on could not be checked: a push only leaves when a real urgent alert fires, so a broken setup stayed silent until an alert was missed. The button sends one notification to this device through the same path as real alerts and reports what the push service answered, including the reason on a rejection. An expired subscription is removed and the switch turns off. One test per user every ten seconds.
 
 - The WAN traffic chart can draw bars instead of the line (#1975). A switch next to the range selector picks Line or Bars and remembers the choice in the browser. Line stays the default and nothing changes on the server.

+ 1 - 0
app/public/locales/en/translation.json

@@ -661,6 +661,7 @@
       "uploadMbps": "Upload (Mbps)",
       "viewBars": "Bars",
       "viewLine": "Line",
+      "viewLinear": "Linear",
       "viewAria": "Traffic chart view",
       "contracted": "Contracted: ↓ {{down}} / ↑ {{up}} Mbps",
       "contractedLine": "↓ {{mbps}} Mbps",

+ 1 - 0
app/public/locales/es/translation.json

@@ -661,6 +661,7 @@
       "uploadMbps": "Subida (Mbps)",
       "viewBars": "Barras",
       "viewLine": "Línea",
+      "viewLinear": "Lineal",
       "viewAria": "Vista del gráfico de tráfico",
       "contracted": "Contratado: ↓ {{down}} / ↑ {{up}} Mbps",
       "contractedLine": "↓ {{mbps}} Mbps",

+ 10 - 6
app/src/sections/WanTraffic.tsx

@@ -57,14 +57,17 @@ export function WanTraffic() {
   const { t } = useTranslation()
   const { traffic: trafficByRange, wan, isDemo } = useNetPulse()
   const [range, setRange] = useState<TimeRange>('24h')
-  const [view, setView] = useState<'line' | 'bars'>(() => {
+  // #1975: Line es escalonada (stepAfter); Linear interpola entre puntos;
+  // Bars pinta una barra por bucket. La eleccion se recuerda por navegador.
+  const [view, setView] = useState<'line' | 'linear' | 'bars'>(() => {
     try {
-      return localStorage.getItem('netpulse.trafficView') === 'bars' ? 'bars' : 'line'
+      const saved = localStorage.getItem('netpulse.trafficView')
+      return saved === 'bars' || saved === 'linear' ? saved : 'line'
     } catch {
       return 'line'
     }
   })
-  const setTrafficView = (v: 'line' | 'bars') => {
+  const setTrafficView = (v: 'line' | 'linear' | 'bars') => {
     setView(v)
     try {
       localStorage.setItem('netpulse.trafficView', v)
@@ -143,10 +146,11 @@ export function WanTraffic() {
           <SegmentedControl
             options={[
               { value: 'line', label: t('home.traffic.viewLine') },
+              { value: 'linear', label: t('home.traffic.viewLinear') },
               { value: 'bars', label: t('home.traffic.viewBars') },
             ]}
             value={view}
-            onChange={(v) => setTrafficView(v as 'line' | 'bars')}
+            onChange={(v) => setTrafficView(v as 'line' | 'linear' | 'bars')}
             size="sm"
             ariaLabel={t('home.traffic.viewAria')}
           />
@@ -213,7 +217,7 @@ export function WanTraffic() {
             ) : (
               <>
                 <Area
-                  type="stepAfter"
+                  type={view === 'linear' ? 'linear' : 'stepAfter'}
                   dataKey="down"
                   stroke="#22D3EE"
                   strokeWidth={2}
@@ -224,7 +228,7 @@ export function WanTraffic() {
                   animationEasing="ease-out"
                 />
                 <Area
-                  type="stepAfter"
+                  type={view === 'linear' ? 'linear' : 'stepAfter'}
                   dataKey="up"
                   stroke="#A78BFA"
                   strokeWidth={2}