Verified Commit 56b3ccfb authored by Marek Veselý's avatar Marek Veselý
Browse files

feat: add test api and iframe access to opensearch

parent 98cae298
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
import { useEffect, useState } from 'react'

const Home = () => {
  const [data, setData] = useState([])

  useEffect(() => {
    const url =
      'https://localhost:9200/opensearch-logstash-docker-2025.03.24/_search?pretty'
    const username = 'admin'
    const password = 'v&ery6#7st*ong78288732-pass889329word-aVUfg9'

    const headers = {
      Authorization: `Basic ${btoa(`${username}:${password}`)}`,
    }

    fetch(url, {
      method: 'GET',
      headers: headers,
    })
      .then(response => response.json())
      .then(data => {
        // Process the data for the timeline
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        const hits = data.hits.hits.map((hit: any) => ({
          timestamp: new Date(hit._source['@timestamp']).toLocaleString(),
          command: hit._source['process.title'],
        }))
        setData(hits)
      })
      .catch(error => console.error('Error:', error))
  }, [])

  return <div>{JSON.stringify(data)}</div>
}

export default Home
+10 −0
Original line number Diff line number Diff line
const Home = () => (
  // eslint-disable-next-line react/iframe-missing-sandbox
  <iframe
    src='https://localhost:5602/app/visualize#/edit/f6053590-08fd-11f0-8631-33f374a55138?embed=true&_g=%28filters%3A%21%28%29%2CrefreshInterval%3A%28pause%3A%21t%2Cvalue%3A0%29%2Ctime%3A%28from%3A%272025-03-24T19%3A06%3A37.623Z%27%2Cto%3A%272025-03-24T23%3A47%3A36.160Z%27%29%29'
    height='600'
    width='800'
  />
)

export default Home
+2 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ export type Path =
  | `/instructor/:exerciseId/:teamId/file/:fileId`
  | `/instructor/:exerciseId/:teamId/learning-objectives`
  | `/instructor/:exerciseId/select`
  | `/opensearch/api`
  | `/opensearch/iframe`
  | `/settings`
  | `/staff`
  | `/trainee`