Skip to content

Commit

Permalink
fix for build
Browse files Browse the repository at this point in the history
  • Loading branch information
Anchel123 committed Mar 20, 2024
1 parent 3bbe85c commit f7aca5a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
10 changes: 4 additions & 6 deletions app/api/monitor/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ export async function GET() {
const dataMemory = infoMemory.split('\r\n').map((item: string) => {
const name = item.split(':')[0]
const series = item.split(':')[1]
return { name, series: series }
}).filter((item: {name: string, series: string}) => {
return fileds.find(filed => filed == item.name)
})
return { name, series }
}).filter((item: {name: string, series: string}) => fileds.find(filed => filed === item.name))
const dataGraph: {name: string, series: number}[] = []
for (let i = 0; i < infoGraph.length; i += 2) {
const name = (infoGraph[i] as string).substring(2)
const series = infoGraph[i + 1] as string[]
dataGraph.push({name, series: series.length})
const series = (infoGraph[i + 1] as string[]).length
dataGraph.push({name, series})
}

return NextResponse.json({ memory: dataMemory, graph: dataGraph }, { status: 200 })
Expand Down
4 changes: 1 addition & 3 deletions app/monitor/MonitorView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ export default function MonitorView({ data, time }: Props) {
data: timeArr
}
})
console.log(myChart.getOption().series)
console.log(timeArr)
}
}, [data, time])
}, [data, time, timeArr, chartReady])

const options: EChartsOption = {
tooltip: {
Expand Down
30 changes: 14 additions & 16 deletions app/monitor/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
"use client"

import useSWR from 'swr'
import MonitorView from './MonitorView'
import React, { useState } from 'react'
import MonitorView from './MonitorView'

export default function Page() {

const [time, setTime] = useState<Date | null>(null)

const fetcher = (url: string) => {
return fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then((result) => {
if (result.status < 300) {
setTime(new Date())
return result.json()
}
return []
})
}
const fetcher = (url: string) => fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then((result) => {
if (result.status < 300) {
setTime(new Date())
return result.json()
}
return []
})

const { data } = useSWR(`/api/monitor/`, fetcher, { refreshInterval: 1000, onSuccess: (data) => console.log(data) })
const { data } = useSWR(`/api/monitor/`, fetcher, { refreshInterval: 1000 })
return (
<div className='flex flex-col items-center w-full h-full'>
<h1 className='p-5 text-6xl'>Monitor</h1>
Expand Down

0 comments on commit f7aca5a

Please sign in to comment.