임지영

프로젝트 폴더 추가

Showing 49 changed files with 3919 additions and 0 deletions
# image-editor
Online Image Editor
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
node: true,
},
extends: [
'airbnb-base',
],
parserOptions: {
ecmaVersion: 12,
},
rules: {
},
};
# dependencies
/node_modules
config
.env
const express = require('express');
const path = require('path');
const session = require('express-session');
const cors = require('cors');
const logger = require('morgan');
const passport = require('passport');
const { sequelize } = require('./models');
const passportConfig = require('./modules/passport');
const router = require('./routes');
const app = express();
sequelize.sync();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(session({ secret: 'keyboard cat' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(cors({
origin: 'http://localhost:3000',
credentials: true,
}));
passportConfig();
app.use('/', router);
module.exports = app;
#!/usr/bin/env node
/**
* Module dependencies.
*/
const app = require('../app');
const debug = require('debug')('backend:server');
const http = require('http');
/**
* Get port from environment and store in Express.
*/
const port = normalizePort(process.env.PORT || '9000');
app.set('port', port);
/**
* Create HTTP server.
*/
const server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
const port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
const bind = typeof port === 'string'
? `Pipe ${port}`
: `Port ${port}`;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(`${bind} requires elevated privileges`);
process.exit(1);
break;
case 'EADDRINUSE':
console.error(`${bind} is already in use`);
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
const addr = server.address();
const bind = typeof addr === 'string'
? `pipe ${addr}`
: `port ${addr.port}`;
debug(`Listening on ${bind}`);
}
module.exports = (sequelize, DataType) => sequelize.define('project', {
id: {
type: DataType.INTEGER,
autoIncrement: true,
primaryKey: true,
unique: true,
},
name: {
type: DataType.STRING(50),
allowNull: false,
unique: true,
},
imageUrl: {
type: DataType.STRING,
allowNull: false,
},
});
module.exports = (sequelize, DataType) => sequelize.define('user', {
id: {
type: DataType.INTEGER,
autoIncrement: true,
primaryKey: true,
unique: true,
},
email: {
type: DataType.STRING,
allowNull: false,
unique: true,
},
name: {
type: DataType.STRING(20),
allowNull: false,
},
password: {
type: DataType.STRING,
allowNull: true,
},
loginType: {
type: DataType.STRING,
allowNull: false,
defaultValue: 'local',
},
});
const Sequelize = require('sequelize');
const env = process.env.NODE_ENV || 'development';
const config = require('../config/config.json')[env];
const db = {};
const sequelize = new Sequelize(config.database, config.username, config.password, config);
db.sequelize = sequelize;
db.Sequelize = Sequelize;
db.User = require('./User')(sequelize, Sequelize);
db.Project = require('./Project')(sequelize, Sequelize);
db.User.hasMany(db.Project);
db.Project.belongsTo(db.User);
module.exports = db;
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;
const bcrypt = require('bcrypt');
const { User } = require('../models');
module.exports = () => {
passport.serializeUser((user, done) => {
done(null, user.id);
});
passport.deserializeUser(async (id, done) => {
try {
const user = await User.findOne({ where: { id } });
done(null, user);
} catch (err) {
done(err);
}
});
passport.use(new LocalStrategy({
usernameField: 'email',
passwordField: 'password',
},
async (email, password, done) => {
try {
const user = await User.findOne({ where: { email } });
if (!user) {
return done(null, false, { message: 'Incorrect email.' });
}
const isSamePassword = await bcrypt.compare(password, user.password);
if (!isSamePassword) {
return done(null, false, { message: 'Incorrect password.' });
}
return done(null, user);
} catch (err) {
return done(err);
}
}));
};
This diff could not be displayed because it is too large.
{
"name": "backend",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"lint": "eslint . --fix"
},
"dependencies": {
"bcrypt": "^5.0.0",
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
"debug": "~2.6.9",
"dotenv": "^8.2.0",
"express": "~4.16.1",
"express-session": "^1.17.1",
"morgan": "~1.9.1",
"mysql2": "^2.2.5",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"sequelize": "^6.3.5"
},
"devDependencies": {
"eslint": "^7.11.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.1"
}
}
<html>
<head>
<title>Express</title>
<link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>
<h1>Express</h1>
<p>Welcome to Express</p>
</body>
</html>
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
a {
color: #00B7FF;
}
const bcrypt = require('bcrypt');
const passport = require('passport');
const { User } = require('../../models');
exports.signup = async (req, res, next) => {
const { email, name, password } = req.body;
try {
const existUser = await User.findOne({ where: { email } });
if (existUser) {
res.status(409).json({ ok: false, message: 'already exists' });
return;
}
const hash = await bcrypt.hash(password, 10);
await User.create({ email, password: hash, name });
res.json({ ok: true });
} catch (err) {
next(err);
}
};
exports.login = (req, res, next) => {
passport.authenticate('local', (err, user, info) => {
if (err) return next(err);
if (!user) return res.status(401).json({ ok: false, ...info });
req.logIn(user, (loginErr) => {
if (loginErr) next(loginErr);
res.json({ ok: true, user: req.user });
});
})(req, res, next);
};
const express = require('express');
const authCtrl = require('./authController');
const auth = express.Router();
auth.post('/signup', authCtrl.signup);
auth.post('/login', authCtrl.login);
module.exports = auth;
const express = require('express');
const authRouter = require('./auth');
const projectRouter = require('./project');
const router = express.Router();
router.use('/auth', authRouter);
router.use('/projects', projectRouter);
module.exports = router;
const express = require('express');
const projectCtrl = require('./projectController');
const router = express.Router();
router.get('/', projectCtrl.list);
module.exports = router;
const { Project } = require('../../models');
exports.list = async (req, res, next) => {
try {
const { id: userId } = req.user;
const projects = await Project.findAll({ where: { userId } });
res.json({ ok: true, projects });
} catch (err) {
next(err);
}
};
# 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*
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `yarn start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `yarn test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `yarn build`
Builds the app for production to the `build` folder.<br />
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.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `yarn 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
### Analyzing the Bundle Size
This section has moved here: 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
### Advanced Configuration
This section has moved here: 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
### `yarn build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
This diff could not be displayed because it is too large.
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@toast-ui/react-image-editor": "^1.2.0",
"axios": "^0.21.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
<!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>
<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>
{
"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"
}
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
import React, { createContext, useState} from 'react';
import Routes from './routes';
import HeaderContainer from './container/common/HeaderContainer';
import { HashRouter as Router } from 'react-router-dom';
import userContext from './utils/context';
function App() {
const [state, setState] = useState({
userName: '',
editingImageUrl: '',
});
const contextProps = {
data: state,
setData: setState,
};
return (
<Router>
<userContext.Provider value={contextProps}>
<HeaderContainer/>
<Routes />
</userContext.Provider>
</Router>
);
}
export default App;
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
const useStyles = makeStyles({
root: {
maxWidth: 345,
margin: 10,
},
media: {
height: 140,
},
});
const MediaCard = (props) => {
const classes = useStyles();
const { title, imageUrl, onClick } = props;
return (
<Card className={classes.root} onClick={onClick}>
<CardActionArea>
<CardMedia
className={classes.media}
image={imageUrl}
title="Contemplative Reptile"
/>
<CardContent>
<Typography gutterBottom variant="h6">
{title}
</Typography>
</CardContent>
</CardActionArea>
</Card>
);
}
export default MediaCard;
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Card from "@material-ui/core/Card";
import CardActionArea from "@material-ui/core/CardActionArea";
import CardActions from "@material-ui/core/CardActions";
import CardContent from "@material-ui/core/CardContent";
import CardMedia from "@material-ui/core/CardMedia";
import Button from "@material-ui/core/Button";
import Typography from "@material-ui/core/Typography";
import { Link } from "react-router-dom";
const useStyles = makeStyles({
root: {
maxWidth: 345,
margin: 10,
},
media: {
height: 140,
},
});
const NewCard = (props) => {
const classes = useStyles();
return (
<Link to="/editor">
<Card className={classes.root}>
<CardContent>
<Typography> + 새로운 프로젝트 생성</Typography>
</CardContent>
</Card>
</Link>
);
};
export default NewCard;
import React from 'react';
import { PropTypes } from 'prop-types';
import { Link as RouterLink } from 'react-router-dom';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import Link from '@material-ui/core/Link';
import Button from '@material-ui/core/Button';
import { pathUri } from '../../constants/path';
const useStyles = makeStyles((theme) => ({
header: {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
height: '60px',
padding: `0 ${theme.spacing(3)}px`,
backgroundColor: 'whitesmoke',
},
}));
const Header = (props) => {
const classes = useStyles();
//const theme = useTheme();
const { userName, handlelogout } = props;
return (
<header className={classes.header}>
<div> Image Editor </div>
<div>
{
userName !== ''
? <Button onClick={handlelogout}>{userName}</Button>
: <Link component={RouterLink} to={pathUri.signin}>Sign in</Link>
}
</div>
</header>
);
};
// Header.propTypes = {
// data: PropTypes.object,
// handlelogout: PropTypes.func,
// };
export default Header;
\ No newline at end of file
import React from 'react';
import { PropTypes } from 'prop-types';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Grid from '@material-ui/core/Grid';
const FormField = (props) => {
const {
loginState, login, guestLogin
} = props;
const [state, setState] = React.useState({
loginState,
userName: '',
email: '',
password: '',
confirmPassword: '',
});
const handleChange = (event) => {
const { name } = event.target;
const value = event.target.value;
setState({ ...state, [name]: value });
};
return (
<>
<Grid
container
spacing={3}
direction="column"
justify="center"
alignItems="center"
>
<Grid item xs={12}>
Image Editor
</Grid>
{(!state.loginState)
&& (
<Grid item xs={12}>
<TextField
required
id="userName"
label="Name"
variant="filled"
name="userName"
onChange={handleChange}
/>
</Grid>
)}
<Grid item xs={12}>
<TextField
required
id="email"
label="Email"
variant="filled"
name="email"
onChange={handleChange}
/>
</Grid>
<Grid item xs={12}>
<TextField
required
id="password"
label="Password"
type="password"
autoComplete="current-password"
variant="filled"
name="password"
onChange={handleChange}
/>
</Grid>
{(!state.loginState)
&& (
<Grid item xs={12}>
<TextField
required
id="confirmPassword"
label="confirmPassword"
type="password"
variant="filled"
name="confirmPassword"
onChange={handleChange}
/>
</Grid>
)}
<Grid item xs={12}>
<Button
variant="contained"
color="primary"
onClick={(e) => { login(state); }}
>
{state.loginState ? 'Sign in' : 'Sign up'}
</Button>
</Grid>
<Grid item xs={12}>
<Button onClick={guestLogin}>
Sign in as a guest
</Button>
</Grid>
</Grid>
</>
);
};
// FormField.propTypes = {
// login: PropTypes.bool.isRequired,
// onChange: PropTypes.func,
// onSubmit: PropTypes.func,
// remember: PropTypes.bool,
// };
export default FormField;
\ No newline at end of file
export const pathUri = {
home: '/',
signin: '/signin',
signup: '/signup',
board: '/board',
editor: '/editor',
};
\ No newline at end of file
import React, { useContext } from 'react';
import Header from '../../components/common/Header';
import userContext from '../../utils/context';
const HeaderContainer = (props) => {
const { data } = useContext(userContext);
return (
<Header userName={data.userName}/>
);
};
export default HeaderContainer;
\ No newline at end of file
import React, { useContext, useEffect } from "react";
import "tui-image-editor/dist/tui-image-editor.css";
import ImageEditor from "@toast-ui/react-image-editor";
import userContext from "../../utils/context";
import whitetheme from "../../utils/theme";
const ImageEditorContainer = () => {
const editorRef = React.createRef();
const { data, setData } = useContext(userContext);
const { editingImageUrl } = data;
const sampleImageUrl =
"https://kr.object.ncloudstorage.com/image-editor/sample.jpg";
return (
<ImageEditor
ref={editorRef}
includeUI={{
loadImage: {
path: editingImageUrl ? editingImageUrl : sampleImageUrl,
name: "image",
},
theme: whitetheme,
menu: [
"crop",
"flip",
"rotate",
"draw",
"shape",
"icon",
"text",
"mask",
"filter",
],
initMenu: "filter",
uiSize: {
width: "100%",
height: "800px",
},
menuBarPosition: "bottom",
}}
cssMaxHeight={500}
cssMaxWidth={700}
selectionStyle={{
cornerSize: 20,
rotatingPointOffset: 70,
}}
usageStatistics={true}
/>
);
};
export default ImageEditorContainer;
import React, { useContext } from 'react';
import { withRouter } from 'react-router-dom';
import { SignApi } from '../../utils/api';
import userContext from '../../utils/context';
import FormField from '../../components/signin/FormField';
import { pathUri } from '../../constants/path';
const SignInContainer = (props) => {
const { history } = props;
const { data, setData } = useContext(userContext);
const login = async (state) => {
const data = {
email: state.email,
password: state.password,
};
try {
const { user } = await SignApi('http://localhost:9000/auth/login', { data });
handleSuccess(user);
} catch(err) {
console.log(err);
}
}
const guestLogin = () => {
history.push(pathUri.editor);
}
const handleSuccess = (user) => {
setData({
...data, userName: user.name
})
history.push(pathUri.board);
};
return (
<>
<FormField
loginState={true}
login={login}
guestLogin={guestLogin}
/>
</>
);
};
export default withRouter(SignInContainer);
\ No newline at end of file
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
import React, { useState, useEffect, useContext } from "react";
import { SignApi } from "../utils/api";
import { useHistory } from "react-router-dom";
import Container from "@material-ui/core/Container";
import MediaCard from "../components/board/Card";
import NewCard from "../components/board/NewCard";
import { makeStyles } from "@material-ui/core/styles";
import userContext from "../utils/context";
const useStyles = makeStyles((theme) => ({
container: {
display: "grid",
gridTemplateColumns: "1fr 1fr 1fr 1fr",
background: "white",
marginTop: "40px",
},
}));
const Board = () => {
const classes = useStyles();
const [projects, setProjects] = useState([]);
const { data, setData } = useContext(userContext);
const history = useHistory();
const handleClick = (imageUrl) => {
history.push("editor");
setData({ ...data, editingImageUrl: imageUrl });
};
const getInitialData = async () => {
const { projects } = await SignApi("http://localhost:9000/projects", {
method: "GET",
});
setProjects(projects);
};
useEffect(() => {
getInitialData();
}, []);
return (
<Container maxWidth="lg" className={classes.container}>
<NewCard />
{projects.map(({ id, name, imageUrl }) => (
<MediaCard
key={id}
title={name}
imageUrl={imageUrl}
onClick={() => handleClick(imageUrl)}
/>
))}
</Container>
);
};
export default Board;
import React from 'react';
import ImageEditorContainer from '../container/editor/ImageEditorContainer';
const Editor = () => {
return (
<ImageEditorContainer />
);
};
export default Editor;
\ No newline at end of file
import React from 'react';
import Container from '@material-ui/core/Container';
import SignInContainer from '../container/signin/SignInContainer';
import { makeStyles } from "@material-ui/core/styles"
const useStyles = makeStyles((theme) => ({
container: {
background: 'white',
marginTop: '40px',
},
}))
const SignIn = () => {
const classes = useStyles()
return (
<Container maxWidth="lg" className={classes.container}>
<SignInContainer/>
</Container>
);
};
export default SignIn;
\ No newline at end of file
import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';
import Editor from './pages/Editor';
import SignIn from './pages/SignIn';
import Board from './pages/Board';
import { pathUri } from './constants/path';
const routes = () => (
<Switch>
<Route path={pathUri.home} component={SignIn} exact />
<Route path={pathUri.signin} component={SignIn} />
<Route path={pathUri.board} component={Board} />
<Route path={pathUri.editor} component={Editor} />
<Route component={() => <Redirect to={pathUri.home} />} />
</Switch>
);
export default routes;
\ No newline at end of file
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then(registration => {
registration.unregister();
})
.catch(error => {
console.error(error.message);
});
}
}
// 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/extend-expect';
import axios from 'axios';
export const requestOptions = {
baseURL: 'http://localhost:3000/',
method: 'POST',
withCredentials: true,
headers: {
'Content-Type': 'application/json',
},
};
export const SignApi = (url, option) => {
const options = { ...requestOptions, ...option };
return new Promise((resolve, reject) => {
axios(url, options)
.then((response) => resolve(response.data))
.catch((error) => reject(error));
});
};
\ No newline at end of file
import React from 'react';
const userContext = React.createContext(null); // Create a context object
export default userContext;
\ No newline at end of file
const whiteTheme = {
"common.bi.image": "https://imgur.com/EaA2e9g.png",
"common.bisize.width": "251px",
"common.bisize.height": "21px",
"common.backgroundImage": "./img/bg.png",
"common.backgroundColor": "#fff",
"common.border": "1px solid #c1c1c1",
// header
"header.backgroundImage": "none",
"header.backgroundColor": "transparent",
"header.border": "0px",
// load button
"loadButton.backgroundColor": "#fff",
"loadButton.border": "1px solid #ddd",
"loadButton.color": "#C799DC",
"loadButton.fontFamily": "'Noto Sans', sans-serif",
"loadButton.fontSize": "12px",
// download button
"downloadButton.backgroundColor": "#C799DC",
"downloadButton.border": "1px solid #C799DC",
"downloadButton.color": "#fff",
"downloadButton.fontFamily": "'Noto Sans', sans-serif",
"downloadButton.fontSize": "12px",
// main icons
"menu.normalIcon.color": "#8a8a8a",
"menu.activeIcon.color": "#555555",
"menu.disabledIcon.color": "#434343",
"menu.hoverIcon.color": "#e9e9e9",
"menu.iconSize.width": "24px",
"menu.iconSize.height": "24px",
// submenu icons
"submenu.normalIcon.color": "#8a8a8a",
"submenu.activeIcon.color": "#555555",
"submenu.iconSize.width": "32px",
"submenu.iconSize.height": "32px",
// submenu primary color
"submenu.backgroundColor": "transparent",
"submenu.partition.color": "#e5e5e5",
// submenu labels
"submenu.normalLabel.color": "#858585",
"submenu.normalLabel.fontWeight": "normal",
"submenu.activeLabel.color": "#000",
"submenu.activeLabel.fontWeight": "normal",
// checkbox style
"checkbox.border": "1px solid #ccc",
"checkbox.backgroundColor": "#fff",
// rango style
"range.pointer.color": "#333",
"range.bar.color": "#ccc",
"range.subbar.color": "#606060",
"range.disabledPointer.color": "#d3d3d3",
"range.disabledBar.color": "rgba(85,85,85,0.06)",
"range.disabledSubbar.color": "rgba(51,51,51,0.2)",
"range.value.color": "#000",
"range.value.fontWeight": "normal",
"range.value.fontSize": "11px",
"range.value.border": "0",
"range.value.backgroundColor": "#f5f5f5",
"range.title.color": "#000",
"range.title.fontWeight": "lighter",
// colorpicker style
"colorpicker.button.border": "0px",
"colorpicker.title.color": "#000",
};
export default whiteTheme;
This diff could not be displayed because it is too large.