Archived
Initial commit
This commit is contained in:
commit
d882df512f
22 files changed
+17474
No files matched your search
@@ -0,0 +1,38 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import React, { Component } from 'react';
|
||||
import './App.css';
|
||||
import Migrations from './Migrations/Migrations';
|
||||
import SideMigrations from './Migrations/SideMigrations';
|
||||
|
||||
class App extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
migs1: {
|
||||
type: 'top-headlines',
|
||||
query: 'country=au'
|
||||
},
|
||||
migs2: {
|
||||
type: 'top-headlines',
|
||||
query: 'country=us&category=business'
|
||||
},
|
||||
migs3: {
|
||||
type: 'top-headlines',
|
||||
query: 'sources=bbc-news'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="container-fluid">
|
||||
<div className="navbar-fixed">
|
||||
<nav>
|
||||
<div className="nav-wrapper indigo lighten-4">
|
||||
<a href="/" className="bran-logo" center>My Feed</a>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col s8">
|
||||
<Migrations migs={this.state.migs1} />
|
||||
<Migrations migs={this.state.migs2} />
|
||||
</div>
|
||||
<div className="col s4">
|
||||
<SideMigrations migs={this.state.migs3} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,8 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import React from 'react'
|
||||
|
||||
const Error = () => (
|
||||
<div>
|
||||
<h1>There was an error fetching news</h1>
|
||||
</div>
|
||||
)
|
||||
|
||||
export default Error;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
|
||||
const MigrationSingle = ({ item }) => (
|
||||
<div className="col s4">
|
||||
<div className="card">
|
||||
<div className="card-image">
|
||||
<slian className="card-title">{item.migration_status}</slian>
|
||||
</div>
|
||||
<div className="card-content">
|
||||
<li>{item.id}</li>
|
||||
<li>{item.submit_time}</li>
|
||||
<li>{item.domain}</li>
|
||||
<li>{item.booked_time}</li>
|
||||
<li>{item.original_server}</li>
|
||||
<li>{item.new_server}</li>
|
||||
<li>{item.username}</li>
|
||||
<li>{item.brand}</li>
|
||||
<li>{item.ticket_id}</li>
|
||||
<li>{item.migration_status}</li>
|
||||
<li>{item.agent_booked}</li>
|
||||
<li>{item.migration_type}</li>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default MigrationSingle;
|
||||
@@ -0,0 +1,52 @@
|
||||
import React, { Component } from 'react';
|
||||
import MigrationSingle from './MigrationSingle';
|
||||
import Error from './Error';
|
||||
|
||||
class Migrations extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
migs: [],
|
||||
error: false,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const url = `http://benjamyn.love:8000/migrations/`;
|
||||
|
||||
fetch(url)
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
this.setState({
|
||||
migs: data
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setState({
|
||||
error: true
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
renderItems() {
|
||||
if (!this.state.error) {
|
||||
return this.state.migs.map((item) => (
|
||||
<MigrationSingle key={item.id} item={item} />
|
||||
));
|
||||
} else {
|
||||
return <Error />
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="row">
|
||||
{this.renderItems()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Migrations;
|
||||
@@ -0,0 +1,51 @@
|
||||
import React, { Component } from 'react';
|
||||
import axios from 'axios';
|
||||
|
||||
import SingleSide from './SingleSide';
|
||||
import Error from './Error';
|
||||
|
||||
class SideMigrations extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
sidemigs: [],
|
||||
error: false,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const url = `https://newsapi.org/v2/${this.props.migs.type}?${this.props.migs.query}&apiKey=f42b951fc64d4ec7b891bcdc23666a34`;
|
||||
|
||||
axios.get(url)
|
||||
.then((response) => {
|
||||
this.setState({
|
||||
sidemigs: response.data.articles
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setState({
|
||||
error: true
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
renderItems() {
|
||||
if (!this.state.error) {
|
||||
return this.state.sidemigs.map((item) => (
|
||||
<SingleSide key={item.url} item={item} />
|
||||
));
|
||||
} else {
|
||||
return <Error />
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.renderItems()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SideMigrations;
|
||||
@@ -0,0 +1,16 @@
|
||||
import React from 'react'
|
||||
|
||||
const SingleSide = ({ item }) => (
|
||||
<div>
|
||||
<div className="divider"></div>
|
||||
<a href={item.url} target="_blank" rel="noreferrer">
|
||||
<div className="section">
|
||||
<h5>{item.source.name}</h5>
|
||||
<p>{item.title}</p>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
);
|
||||
|
||||
export default SingleSide;
|
||||
@@ -0,0 +1,13 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './components/App';
|
||||
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();
|
||||
@@ -0,0 +1,13 @@
|
||||
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;
|
||||
@@ -0,0 +1,5 @@
|
||||
// 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