react-webdist-app: @mui initial integration
This commit is contained in:
parent
3190fbbceb
commit
b576c12bc4
6177
react-webdist-app/package-lock.json
generated
6177
react-webdist-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,11 @@
|
|||||||
"proxy": "http://buildvm01:5000",
|
"proxy": "http://buildvm01:5000",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@emotion/hash": "^0.9.0",
|
||||||
|
"@emotion/react": "^11.10.4",
|
||||||
|
"@emotion/styled": "^11.10.4",
|
||||||
|
"@mui/icons-material": "^5.10.9",
|
||||||
|
"@mui/material": "^5.10.9",
|
||||||
"@testing-library/jest-dom": "^5.16.5",
|
"@testing-library/jest-dom": "^5.16.5",
|
||||||
"@testing-library/react": "^13.4.0",
|
"@testing-library/react": "^13.4.0",
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
@ -13,6 +18,8 @@
|
|||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-bootstrap": "^2.5.0",
|
"react-bootstrap": "^2.5.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
"react-is": "^18.2.0",
|
||||||
|
"react-router-dom": "^6.4.2",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
},
|
},
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||||
-->
|
-->
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
<!--
|
<!-- for MaterialUI -->
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /> <!--
|
||||||
Notice the use of %PUBLIC_URL% in the tags above.
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
It will be replaced with the URL of the `public` folder during the build.
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
Only files inside the `public` folder can be referenced from the HTML.
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
82
react-webdist-app/src/App.js
vendored
82
react-webdist-app/src/App.js
vendored
@ -1,29 +1,67 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import AppBar from '@mui/material/AppBar';
|
||||||
|
import Toolbar from '@mui/material/Toolbar';
|
||||||
|
import TypoGraphy from '@mui/material/Typography';
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import MenuIcon from "@mui/icons-material/Menu";
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import Latest from "./Latest"
|
import Latest from "./Latest"
|
||||||
|
import NavBar from "./NavBar"
|
||||||
|
|
||||||
function App() {
|
|
||||||
const [placeholder, setPlaceholder] = useState({});
|
|
||||||
|
|
||||||
useEffect(() => {
|
class App extends Component {
|
||||||
fetch('/api/v1/latest').then(res => res.json()).then(data => {
|
constructor(props){
|
||||||
setPlaceholder(data.result);
|
super(props)
|
||||||
});
|
// Set initial state
|
||||||
}, []);
|
this.state = { menuState: 0 }
|
||||||
|
// Binding this keyword
|
||||||
// var parse = require('html-react-parser');
|
this.showLatest = this.showLatest.bind(this)
|
||||||
// var parsed = parse(placeholder);
|
this.showHome = this.showHome.bind(this)
|
||||||
|
}
|
||||||
return (
|
|
||||||
<div className="App">
|
showLatest() {
|
||||||
<div className="container-fluid">
|
this.setState({ menuState: 1 })
|
||||||
<h2>Welcome To WebDist</h2>
|
}
|
||||||
<a href="/">Home</a> | <a href="/latest">Latest packages</a>
|
|
||||||
<hr/>
|
showHome() {
|
||||||
<Latest name={placeholder} />
|
this.setState({ menuState: 0 })
|
||||||
</div>
|
}
|
||||||
</div>
|
|
||||||
);
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="App">
|
||||||
|
<AppBar color="primary" position="static">
|
||||||
|
<Toolbar>
|
||||||
|
<IconButton
|
||||||
|
edge="start"
|
||||||
|
style={{
|
||||||
|
marginRight: 20,
|
||||||
|
}}
|
||||||
|
color="inherit"
|
||||||
|
aria-label="menu">
|
||||||
|
<MenuIcon />
|
||||||
|
</IconButton>
|
||||||
|
<TypoGraphy variant="h6" color="inherit">
|
||||||
|
WebDist
|
||||||
|
</TypoGraphy>
|
||||||
|
<NavBar showLatest={this.showLatest} showHome={this.showHome} />
|
||||||
|
</Toolbar>
|
||||||
|
</AppBar>
|
||||||
|
<br/>
|
||||||
|
<div>
|
||||||
|
<Button color="primary" variant="contained" onClick={this.showLatest}>
|
||||||
|
Click Me
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="container-fluid">
|
||||||
|
<hr/>
|
||||||
|
{this.state.menuState === 1 && <Latest />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
48
react-webdist-app/src/Latest.js
vendored
48
react-webdist-app/src/Latest.js
vendored
@ -1,24 +1,32 @@
|
|||||||
import React from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
|
||||||
export default class Latest extends React.Component {
|
function Latest() {
|
||||||
render() {
|
|
||||||
return (
|
const [placeholder, setPlaceholder] = useState({});
|
||||||
<div className="row align-items-start">
|
|
||||||
<h1>Latest packages</h1>
|
useEffect(() => {
|
||||||
{Object.entries(this.props.name).map(([repo,pkgs])=>(
|
fetch('/api/v1/latest').then(res => res.json()).then(data => {
|
||||||
<div className="col align-items-start" key={repo}>
|
setPlaceholder(data.result);
|
||||||
<h2 key={repo}>{repo}</h2>
|
});
|
||||||
{pkgs.map(pkg =>(
|
}, []);
|
||||||
<div key={pkg['name']}>
|
return (
|
||||||
{format(Date.parse(pkg['buildtime']), 'MM/dd')} <strong>{pkg['name']}</strong> {pkg['version']}-{pkg['release']}<br/>
|
<div className="row align-items-start">
|
||||||
<small>{pkg['summary']}</small>
|
<h1>Latest packages</h1>
|
||||||
</div>
|
{Object.entries(placeholder).map(([repo,pkgs])=>(
|
||||||
))}
|
<div className="col align-items-start" key={repo}>
|
||||||
</div>
|
<h2 key={repo}>{repo}</h2>
|
||||||
))}
|
{pkgs.map(pkg =>(
|
||||||
</div>
|
<div key={pkg['name']}>
|
||||||
);
|
{format(Date.parse(pkg['buildtime']), 'MM/dd')} <strong>{pkg['name']}</strong> {pkg['version']}-{pkg['release']}<br/>
|
||||||
}
|
<small>{pkg['summary']}</small>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default Latest;
|
31
react-webdist-app/src/NavBar.js
vendored
Normal file
31
react-webdist-app/src/NavBar.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import List from '@mui/material/List';
|
||||||
|
import ListItem from '@mui/material/ListItem';
|
||||||
|
import ListItemButton from '@mui/material/ListItemButton';
|
||||||
|
import TypoGraphy from '@mui/material/Typography'
|
||||||
|
|
||||||
|
|
||||||
|
function NavBar(props) {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<List component="nav">
|
||||||
|
<ListItem component="div">
|
||||||
|
<ListItemButton onClick={props.showHome}>
|
||||||
|
<TypoGraphy color="inherit" variant="h6">
|
||||||
|
Home
|
||||||
|
</TypoGraphy>
|
||||||
|
</ListItemButton>
|
||||||
|
|
||||||
|
<ListItemButton onClick={props.showLatest}>
|
||||||
|
<TypoGraphy color="inherit" variant="h6">
|
||||||
|
Latest
|
||||||
|
</TypoGraphy>
|
||||||
|
</ListItemButton>
|
||||||
|
|
||||||
|
</ListItem >
|
||||||
|
|
||||||
|
</List>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NavBar;
|
Loading…
Reference in New Issue
Block a user