Vue.js 3 based frontend
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
body {
|
||||
background-color: #eafaf9;
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useSSE, SSEProvider } from 'react-hooks-sse';
|
||||
import './App.css';
|
||||
import EventList from '../eventList/EventList.js';
|
||||
|
||||
|
||||
import './App.css';
|
||||
|
||||
|
||||
const Component = () => {
|
||||
const event = useSSE('log-entry')
|
||||
const [events, setEvents] = useState([])
|
||||
|
||||
useEffect(() =>{
|
||||
console.info(event);
|
||||
if (event) {
|
||||
for (var j = 0; j < events.length; j++) {
|
||||
if (events[j].timestamp <= event.timestamp) {
|
||||
if (events[j]._id == event._id) {
|
||||
setEvents([...events.slice(0, j), event, ...events.slice(j+1)]);
|
||||
return;
|
||||
} else {
|
||||
setEvents([...events.slice(0, j), event, ...events.slice(j)]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setEvents([event, ...events]);
|
||||
}
|
||||
}, [event])
|
||||
return <EventList data={events} />
|
||||
}
|
||||
|
||||
function App() {
|
||||
return (
|
||||
|
||||
<SSEProvider endpoint="/events" >
|
||||
<Component />
|
||||
|
||||
|
||||
</SSEProvider>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
export default App;
|
@@ -1,18 +0,0 @@
|
||||
.eventDiv {
|
||||
background-color: aliceblue;
|
||||
border: 2px solid #26A69A;
|
||||
border-radius: 15px;
|
||||
text-align: left;
|
||||
padding: 5px;
|
||||
max-width: fit-content;
|
||||
font-family: apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
|
||||
color: #092a26;
|
||||
margin: 7px 0px;
|
||||
}
|
||||
|
||||
.eventPic {
|
||||
border-radius: 15px;
|
||||
border: 1px groove #d5f6f2;
|
||||
max-width:100%;
|
||||
max-height:100%;
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
import React from "react";
|
||||
import "./Event.css";
|
||||
|
||||
function Event(props) {
|
||||
|
||||
let imgArray = [];
|
||||
|
||||
if (props.data.hasOwnProperty('screenshots')) {
|
||||
props.data.screenshots.forEach(element => {
|
||||
imgArray = [...imgArray, (<a href={element.orig} target="_blank"><img src={element.url} className="eventPic"></img></a>)]
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="eventDiv">
|
||||
{JSON.stringify(props.data.source)}
|
||||
<br></br>
|
||||
{[...imgArray]}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Event;
|
@@ -1,11 +0,0 @@
|
||||
.eventListUl {
|
||||
background-color: #c1f1ec;
|
||||
max-width: 75%;
|
||||
padding: 5px;
|
||||
border: 5px solid #26A69A;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.eventListLi {
|
||||
list-style: none;
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
import React from 'react';
|
||||
import Event from '../event/Event.js';
|
||||
import './EventList.css';
|
||||
|
||||
function EventList(props) {
|
||||
return (
|
||||
<ul className="eventListUl">
|
||||
{props.data.map((event) => {
|
||||
return <li className="eventListLi"><Event data={event} /></li>
|
||||
})}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
export default EventList;
|
@@ -1,3 +0,0 @@
|
||||
body {
|
||||
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './components/app/App.js';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
@@ -1,13 +0,0 @@
|
||||
const reportWebVitals = onPerfEntry => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
@@ -1,5 +0,0 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
Reference in New Issue
Block a user