Merge pull request #10 from Sakimori/frontend-base

Frontend base
This commit is contained in:
Sakimori 2022-07-05 19:40:11 -04:00 committed by GitHub
commit 71845520b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 35465 additions and 1 deletions

1
.gitignore vendored
View file

@ -368,3 +368,4 @@ env/
GroundControlFiles/ GroundControlFiles/
SatFiles/ SatFiles/
/test.png /test.png
/bosloo_env

View file

@ -11,7 +11,7 @@
<OutputPath>.</OutputPath> <OutputPath>.</OutputPath>
<Name>BoSLOO</Name> <Name>BoSLOO</Name>
<RootNamespace>BoSLOO</RootNamespace> <RootNamespace>BoSLOO</RootNamespace>
<InterpreterId>MSBuild|BoSLOOenv|$(MSBuildProjectFullPath)</InterpreterId> <InterpreterId>MSBuild|bosloo_env|$(MSBuildProjectFullPath)</InterpreterId>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -28,6 +28,15 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Interpreter Include="bosloo_env\">
<Id>bosloo_env</Id>
<Version>3.10</Version>
<Description>bosloo_env (Python 3.10 (64-bit))</Description>
<InterpreterPath>Scripts\python.exe</InterpreterPath>
<WindowsInterpreterPath>Scripts\pythonw.exe</WindowsInterpreterPath>
<PathEnvironmentVariable>PYTHONPATH</PathEnvironmentVariable>
<Architecture>X64</Architecture>
</Interpreter>
<Interpreter Include="env\BoSLOOenv\"> <Interpreter Include="env\BoSLOOenv\">
<Id>BoSLOOenv</Id> <Id>BoSLOOenv</Id>
<Version>3.8</Version> <Version>3.8</Version>
@ -41,6 +50,14 @@
<ItemGroup> <ItemGroup>
<Folder Include="Assets\" /> <Folder Include="Assets\" />
<Folder Include="Assets\Sphere\" /> <Folder Include="Assets\Sphere\" />
<Folder Include="GroundControl\" />
<Folder Include="GroundControl\Assets\" />
<Folder Include="GroundControl\frontend\" />
<Folder Include="GroundControl\frontend\public\" />
<Folder Include="GroundControl\frontend\public\Assets\" />
<Folder Include="GroundControl\frontend\public\Assets\image\" />
<Folder Include="GroundControl\frontend\public\Assets\sound\" />
<Folder Include="GroundControl\frontend\src\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Assets\Sphere\0001.png" /> <Content Include="Assets\Sphere\0001.png" />
@ -93,6 +110,26 @@
<Content Include="Assets\Sphere\0048.png" /> <Content Include="Assets\Sphere\0048.png" />
<Content Include="Assets\Sphere\0049.png" /> <Content Include="Assets\Sphere\0049.png" />
<Content Include="Assets\Sphere\0050.png" /> <Content Include="Assets\Sphere\0050.png" />
<Content Include="GroundControl\frontend\public\Assets\image\BoSLOO logo.txt" />
<Content Include="GroundControl\frontend\public\Assets\image\testMap.png" />
<Content Include="GroundControl\frontend\public\Assets\sound\apricot-rustle-boot.wav" />
<Content Include="GroundControl\frontend\public\Assets\sound\disc-seek-test.mp3" />
<Content Include="GroundControl\frontend\src\BoSLOO logo.json" />
<Content Include="GroundControl\frontend\.gitignore" />
<Content Include="GroundControl\frontend\package-lock.json" />
<Content Include="GroundControl\frontend\package.json" />
<Content Include="GroundControl\frontend\public\favicon.ico" />
<Content Include="GroundControl\frontend\public\index.html" />
<Content Include="GroundControl\frontend\public\logo192.png" />
<Content Include="GroundControl\frontend\public\logo512.png" />
<Content Include="GroundControl\frontend\public\manifest.json" />
<Content Include="GroundControl\frontend\public\robots.txt" />
<Content Include="GroundControl\frontend\README.md" />
<Content Include="GroundControl\frontend\src\commands.js" />
<Content Include="GroundControl\frontend\src\index.css" />
<Content Include="GroundControl\frontend\src\index.js" />
<Content Include="GroundControl\frontend\src\statusbar.js" />
<Content Include="GroundControl\frontend\src\terminal.js" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
<!-- Uncomment the CoreCompile target to enable the Build command in <!-- Uncomment the CoreCompile target to enable the Build command in

23
GroundControl/frontend/.gitignore vendored Normal file
View file

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View file

@ -0,0 +1,70 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

34800
GroundControl/frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,43 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"babel-runtime": "^6.26.0",
"react": "^18.2.0",
"react-animated-text": "^0.1.4",
"react-clickable-div": "^1.0.0",
"react-dom": "^18.2.0",
"react-keyboard-event-handler": "^1.5.4",
"react-scripts": "5.0.1",
"react-typing-animation": "^1.6.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View file

@ -0,0 +1,14 @@
┌──────────┐ ┌─────────┐ ┌─┐ ┌─┬───────┬┐ ┌─┬───────┬┐
│┼┼───────┼│ │┼┼───────┘ │┼│ │┼│ ││ │┼│ ││
│┼│ ││ │┼│ │┼│ │┼│ ││ │┼│ ││
│┼│ ││ │┼│ │┼│ │┼│ ││ │┼│ ││
│┼│ ││ │┼│ │┼│ │┼│ ││ │┼│ ││
│┼│ ││ │┼│ │┼│ │┼│ ││ │┼│ ││
│┼│ ││ │┼│ │┼│ │┼│ ││ │┼│ ││
│┼┼───────┴┘ ┌────────┐ └─┴──────┬┐ │┼│ │┼│ ││ │┼│ ││
│┼│ \\ │┼┼─────┼│ ││ │┼│ │┼│ ││ │┼│ ││
│┼│ \\ │┼│ ││ ││ │┼│ │┼│ ││ │┼│ ││
│┼│ ┌┐ │┼│ ││ ││ │┼│ │┼│ ││ │┼│ ││
│┼│ ││ │┼│ ││ ││ │┼│ │┼│ ││ │┼│ ││
│┼┼───────┼│ │┼┼─────┼│ ┌────────┼│ │┼┼───────┐ │┼│ ││ │┼│ ││
└──────────┘ └────────┘ └─────────┘ └─────────┘ └─┴───────┴┘ └─┴───────┴┘

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
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.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<audio id="boot-sound" src="./Assets/sound/disc-seek-test.mp3">Your browser does not support audio.</audio>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View file

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View file

@ -0,0 +1,3 @@
{
"logo": " ______ _______ _____ _______ _______ \n| __ \\.-----.| __|| |_ | || |\n| __ <| _ ||__ || || - || - |\n|______/|_____||_______||_______||_______||_______|"
}

View file

@ -0,0 +1,68 @@
import Typing from 'react-typing-animation';
import React from 'react';
class Command {
constructor(keyword, fullName) {
this.keyword = keyword;
this.fullName = fullName;
this.helpString = "No help text for this command. Vivian, please be sure to fix this before deploying."
}
call(body) {
return 'This command exists, but does nothing. Vivian, please be sure to fix this before deploying.';
}
}
class helpCommand extends Command{
constructor() {
super('help','help');
this.helpString = "This contains basic help and usage instructions for all commands."
}
call(body) {
if (body === "") {
var commands = "";
for (let command of commandList) {
commands += command.keyword + " ";
}
return (commands);
} else {
for (let command of commandList) {
if (body === command.keyword || body === command.fullName) {
return (command.helpString);
}
}
return ("Unrecognized command. Use without arguments to see full list.")
}
}
}
class loremCommand extends Command {
constructor() {
super('lorem', 'loremipsum');
this.helpString = 'Prints a lorem string.'
}
call(body) {
return ('Space, the final frontier. These are the voyages of the Starship Enterprise. Its five-year mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before. Many say exploration is part of our destiny, but it is actually our duty to future generations and their quest to ensure the survival of the human species.');
}
}
const commandList = [new helpCommand(), new loremCommand()];
function sentCommand(sentCommand) {
var commandId = sentCommand.split(" ")[0]
var commandBody = sentCommand.split(" ").slice(1).join(' ')
for (let command of commandList) {
if (commandId === command.keyword || commandId === command.fullName) {
return (<Typing className='typed-line' speed={5}>{command.call(commandBody.trim())}</Typing>);
}
}
return (<Typing className='typed-line' speed={5}>Unrecognized command.</Typing>);
}
export default sentCommand

View file

@ -0,0 +1,126 @@
@import url('https://fonts.googleapis.com/css?family=VT323');
body {
font: 18px "VT323", "Courier New", monospace;
background-color: black;
background-image: radial-gradient(at bottom right, rgb(30 30 30), black);
height: 100vh;
overflow: hidden;
color: #02d300;
text-shadow: 0 0 6px #73ff71;
}
body::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 99vh;
background: repeating-linear-gradient( 0deg, rgb(0 0 0 / 0.20), rgb(0 0 0 / 0.15) 3px, transparent 2px, transparent 6px);
pointer-events: none;
}
::selection{
background: #793d71;
text-shadow: none;
}
.power-on-container {
height: 90vh;
align-items:center;
justify-items:center;
text-align: center;
}
.power-on-box {
position: relative;
justify-self: center;
margin-top: 20vh;
}
#start-text {
font-size: 30px;
border: ridge;
padding: 2em 6em;
box-shadow: 0 0 3px 1px rgb(49 255 0 / 0.70);
}
.console {
padding-top: 15vh;
height: 70vh;
overflow: hidden;
display: flex;
flex-direction: column;
}
.logo {
white-space: pre-wrap;
}
.fail-text {
color: #d82222;
text-shadow: 0 0 6px #ff1111;
}
.power-on-self-test{
padding-left: 4em;
}
.terminal-window {
}
.power-on-self-test, .terminal-window {
border:groove;
margin-left: 5vw;
margin-top: -5vh;
padding-bottom: 1em;
padding-right: 2em;
width: 60vw;
overflow-y: auto;
overflow-x: hidden;
flex-grow: 1;
display: flex;
flex-direction: column-reverse;
box-sizing: border-box;
box-shadow: 0 0 3px 1px rgb(49 255 0 / 0.70);
}
.terminal{
}
.active-line{
outline: none;
width: 2em;
resize:horizontal;
}
.blink-text {
animation: blinker 1s step-start infinite;
}
.typed-line{
display: inline;
}
.terminal-line th{
text-align: right;
vertical-align: top;
padding-right: 0.2em;
width: 4em;
}
.terminal-line td{
text-align: left;
}
@keyframes blinker {
50% {
opacity: 0;
}
}

View file

@ -0,0 +1,98 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import Typing from 'react-typing-animation';
import ClickableDiv from 'react-clickable-div';
import KeyboardEventHandler from 'react-keyboard-event-handler'
import './index.css';
import logos from './BoSLOO logo.json';
import Terminal from './terminal.js';
import StatusBar from './statusbar.js';
const nominal = <Terminal />;
class Console extends React.Component {
constructor(props) {
super(props);
this.swapper = this.swapper.bind(this);
this.state = {
bodyObj: <PowerOn onClick={this.swapper} />,
init: 0,
}
}
swapper(key, e) {
if (this.state.init === 0) {
this.replaceBody(<SelfTest />);
this.playSound();
} else if (this.state.init === 1) {
this.replaceBody(nominal);
}
this.setState({ init: this.state.init + 1 });
}
appendToBody(newContent) {
let bodyObj = JSON.parse(JSON.stringify(this.state.bodyObj)) + newContent;
this.setState({
bodyObj: bodyObj
});
}
replaceBody(newContent) {
this.setState({
bodyObj: newContent
});
}
playSound() {
var sound = document.getElementById("boot-sound")
sound.volume = 0.1;
sound.play();
}
render() {
return (
<div className='console'>
<KeyboardEventHandler handleKeys={['all']} onKeyEvent={this.swapper} />
{this.state.bodyObj}
{this.state.init >= 2 ? <StatusBar/> : null}
</div>
);
}
}
class SelfTest extends React.Component {
constructor(props) {
super(props);
this.state = {
logodisplay: false
}
}
render() {
const final = <span className='logo'>{logos.logo} < br /><br /><br /><Typing speed={5}>Press any key to continue...<br /><span>{'>'} <span className='blink-text'>_</span></span></Typing></span>;
return (
<div className='power-on-self-test'>
{this.state.logodisplay ? final : null}
<Typing speed={30} onFinishedTyping={() => this.setState({ logodisplay: true })}>
BoSLOO ACPI BIOS v0.1<br />
Sakimori Ind. 2022<br />
<Typing.Speed ms={ 5}/>Initializing cache.................................<Typing.Speed ms={200} />...<Typing.Speed ms={5} /> OK!<br />
Initializing network.........<Typing.Speed ms={500} />....<Typing.Speed ms={5} />.................<Typing.Speed ms={300} />....<Typing.Speed ms={5} /> OK!<br />
Initializing GPU...................................<Typing.Speed ms={1000} />...<Typing.Speed ms={5} /> <span className='fail-text'>FAIL!</span><br />
<br />
</Typing>
</div>
)
}
}
function PowerOn(props) {
return (
<div className="power-on-container"><div className='power-on-box'><span id='start-text' onClick={props.onClick}><span className='blink-text'>START</span></span></div></div>
);
}
// =========================================
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<Console />);

View file

@ -0,0 +1,9 @@
import React from 'react';
class StatusBar extends React.Component {
render() {
return null;
}
}
export default StatusBar

View file

@ -0,0 +1,100 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import * as KeyboardEventHandler from 'react-keyboard-event-handler';
import sentCommand from './commands.js'
class Terminal extends React.Component {
constructor(props) {
super(props);
this.state = {
lines: [<tr className='terminal-line' key={-20}><th>-20</th><td>Welcome to BoSLOO Ground Control Console.</td></tr>, <tr className='terminal-line' key={-10}><th>-10</th><td> Time of connection: {new Date().toLocaleString('en-US')}</td></tr>],
lastLine : '',
waitForUser: false,
lineNumber: 0,
controlHeld: false,
};
this.charIn = this.charIn.bind(this);
this.handleKey = this.handleKey.bind(this);
const window = document.getRootNode();
window.addEventListener('paste', (e) => {
e.preventDefault();
let paste = (e.clipboardData || window.clipboardData).getData('text');
this.appendText(paste);
});
}
addLines(newLinesArray) {
let currLines = this.state.lines
this.setState({
lines: currLines.concat(newLinesArray),
});
}
addCharacter(newChar) {
this.setState({
lastLine: JSON.parse(JSON.stringify(this.state.lastLine)) + newChar,
});
}
appendText(newText) {
this.setState({
lastLine: JSON.parse(JSON.stringify(this.state.lastLine)) + newText,
});
}
deleteCharacter() {
this.setState({
lastLine: this.state.lastLine.slice(0,-1),
});
}
finishLine() {
let commandBody = sentCommand(this.state.lastLine);
this.addLines([<tr className='terminal-line' key={this.state.lineNumber}><th>{this.state.lineNumber}</th><td>{'>'}{this.state.lastLine}</td></tr>,
<tr className='terminal-line' key={this.state.lineNumber + 10}><th>{this.state.lineNumber + 10}</th><td>{commandBody}</td></tr>]);
this.setState({ lastLine: '', lineNumber: this.state.lineNumber+20 });
}
charIn(newCharObj) {
this.setState({
lastLine: newCharObj.target.value,
});
}
handleKey(key, e) {
if (e.key === 'Enter') {
this.finishLine();
} else if (e.keyCode === 8) { /*backspace*/
this.deleteCharacter();
} else if (e.ctrlKey) {
return;
} else if (e.keyCode === 32) {
this.addCharacter(' ');
} else if (e.keyCode >= 40) {
this.addCharacter(e.key);
}
}
displayLines() {
return this.state.lines;
}
render() {
return (
<div className='terminal-window'>
<table className='terminal'>
<tbody>
<KeyboardEventHandler handleKeys={['all']} onKeyEvent={this.handleKey} />
{this.displayLines()}
<tr className='terminal-line'><th>{this.state.lineNumber}</th><td>{'>'}{this.state.lastLine}<span className='blink-text'>_</span></td></tr>
</tbody>
</table>
</div>
)
}
}
export default Terminal