Remove old backup dashboard
This commit is contained in:
parent
729f600e87
commit
1449180131
37 changed files with 0 additions and 8485 deletions
|
@ -1,13 +0,0 @@
|
|||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{js,json,css,html}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -1,9 +0,0 @@
|
|||
node_modules
|
||||
build
|
||||
cache
|
||||
lib
|
||||
dist
|
||||
webpack.*.js
|
||||
server.js
|
||||
build.js
|
||||
init.js
|
|
@ -1,37 +0,0 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"modules": true
|
||||
}
|
||||
},
|
||||
"plugins": [ "react" ],
|
||||
"rules": {
|
||||
"prefer-const": "warn",
|
||||
"no-console": "off",
|
||||
"no-loop-func": "warn",
|
||||
"new-cap": "off",
|
||||
"no-param-reassign": "warn",
|
||||
"func-names": "off",
|
||||
"no-unused-expressions" : "error",
|
||||
"block-scoped-var": "error",
|
||||
"react/prop-types": "off"
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"pragma": "React",
|
||||
"version": "16.2"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
}
|
||||
}
|
5
_Dashboard/.gitignore
vendored
5
_Dashboard/.gitignore
vendored
|
@ -1,5 +0,0 @@
|
|||
node_modules
|
||||
dist
|
||||
build
|
||||
.DS_Store
|
||||
*.log
|
|
@ -1,10 +0,0 @@
|
|||
# .prettierrc.yml
|
||||
# see: https://prettier.io/docs/en/options.html
|
||||
printWidth: 100
|
||||
semi: true
|
||||
singleQuote: true
|
||||
trailingComma: all
|
||||
bracketSpacing: true
|
||||
jsxBracketSameLine: true
|
||||
arrowParens: always
|
||||
proseWrap: always
|
|
@ -1,5 +0,0 @@
|
|||
//App preferences
|
||||
export const windowSize = { width: 620, height: 350 };
|
||||
export const windowOffset = 40;
|
||||
export const appIconPath = '../../dist-assets/icon.ico';
|
||||
export const trayIconPath = '../../dist-assets/tray.ico';
|
|
@ -1,109 +0,0 @@
|
|||
import path from 'path';
|
||||
import { app, BrowserWindow, Menu, Tray } from 'electron';
|
||||
import screenz from 'screenz';
|
||||
import els from 'electron-localshortcut';
|
||||
import { windowSize, windowOffset, appIconPath, trayIconPath } from './constants';
|
||||
|
||||
let mainWindow = null;
|
||||
let trayIcon = null;
|
||||
const isDevelopment = process.env.NODE_ENV === 'development';
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
app.allowRendererProcessReuse = false;
|
||||
|
||||
//Install chrome devtools extensions
|
||||
const installExtensions = async () => {
|
||||
const installer = require('electron-devtools-installer');
|
||||
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'];
|
||||
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
|
||||
for (const name of extensions) {
|
||||
try {
|
||||
await installer.default(installer[name], forceDownload);
|
||||
} catch (e) {
|
||||
console.log(`Error installing ${name} extension: ${e.message}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Force single app instance
|
||||
if (!gotTheLock) {
|
||||
app.quit();
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
app.on('ready', async () => {
|
||||
if (isDevelopment) {
|
||||
await installExtensions();
|
||||
}
|
||||
|
||||
//Initialize window
|
||||
mainWindow = new BrowserWindow({
|
||||
width: windowSize.width,
|
||||
height: windowSize.height,
|
||||
x: screenz.width - windowSize.width,
|
||||
y: screenz.height - windowSize.height - windowOffset,
|
||||
movable: false,
|
||||
resizable: false,
|
||||
frame: false,
|
||||
show: false,
|
||||
skipTaskbar: true,
|
||||
alwaysOnTop: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
},
|
||||
icon: path.join(__dirname, appIconPath),
|
||||
});
|
||||
|
||||
mainWindow.setMenu(null);
|
||||
mainWindow.loadFile(path.resolve(path.join(__dirname, '../renderer/index.html')));
|
||||
|
||||
//Register shortcut to open devtools
|
||||
els.register(mainWindow, 'Ctrl+Shift+I', () => {
|
||||
if (mainWindow.webContents.isDevToolsOpened()) {
|
||||
mainWindow.webContents.closeDevTools();
|
||||
} else {
|
||||
mainWindow.webContents.openDevTools();
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('did-frame-finish-load', () => {
|
||||
//Create tray icon with context menu
|
||||
trayIcon = createTray();
|
||||
|
||||
//Listen to tray icon onclick event
|
||||
trayIcon.on('click', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//Tray creation
|
||||
function createTray() {
|
||||
const trayIcon = new Tray(path.join(__dirname, trayIconPath));
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Show',
|
||||
click: () => {
|
||||
mainWindow.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Exit',
|
||||
click: () => {
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
trayIcon.setToolTip('Light Control');
|
||||
trayIcon.setContextMenu(contextMenu);
|
||||
return trayIcon;
|
||||
}
|
||||
|
||||
//Hide window when out of focus
|
||||
app.on('browser-window-blur', () => {
|
||||
mainWindow.hide();
|
||||
});
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import { createStore } from 'redux';
|
||||
import rootReducer from './store/reducers';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
|
||||
import { ThemeProvider } from '@material-ui/core/styles';
|
||||
import LampButtonList from './components/LampButtonList';
|
||||
import Header from './components/Header';
|
||||
|
||||
const store = createStore(
|
||||
rootReducer,
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
|
||||
);
|
||||
|
||||
const darkTheme = createMuiTheme({
|
||||
palette: {
|
||||
type: 'dark',
|
||||
primary: {
|
||||
main: '#23272A',
|
||||
},
|
||||
secondary: {
|
||||
main: '#7289DA',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const rootElement = document.querySelector(document.currentScript.getAttribute('data-container'));
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<ThemeProvider theme={darkTheme}>
|
||||
<CssBaseline />
|
||||
<Header error={false} />
|
||||
<LampButtonList />
|
||||
</ThemeProvider>
|
||||
</Provider>,
|
||||
rootElement,
|
||||
);
|
|
@ -1,53 +0,0 @@
|
|||
import React from 'react';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import SettingsIcon from '@material-ui/icons/Settings';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
import CheckCircleIcon from '@material-ui/icons/CheckCircle';
|
||||
import ErrorIcon from '@material-ui/icons/Error';
|
||||
import Tooltip from '@material-ui/core/Tooltip';
|
||||
import { useSelector } from 'react-redux/';
|
||||
|
||||
function ConnectionStatus({ error }) {
|
||||
if (error) {
|
||||
return <ErrorIcon />;
|
||||
} else {
|
||||
return <CheckCircleIcon />;
|
||||
}
|
||||
}
|
||||
|
||||
export default function Header() {
|
||||
const comConnectionStatus = useSelector((state) => state.comConnectionStatusReducer);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Box
|
||||
bgcolor="primary.main"
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
height: 30,
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
justifyItems: 'space-between',
|
||||
width: '100%',
|
||||
marginLeft: 10,
|
||||
marginRight: 10,
|
||||
}}>
|
||||
<Tooltip title={comConnectionStatus ? 'Click to reconnect' : 'Click to disconnect'}>
|
||||
<IconButton size="small">
|
||||
<ConnectionStatus error={comConnectionStatus} />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Open Settings">
|
||||
<IconButton size="small">
|
||||
<SettingsIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</Box>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
import React from 'react';
|
||||
import { useSelector } from 'react-redux/';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import EmojiObjectsIcon from '@material-ui/icons/EmojiObjects';
|
||||
|
||||
export default function LampButtonToggle(props) {
|
||||
//const comConnection = useSelector((state) => state.comConnectionReducer);
|
||||
const comConnection = null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
style={{ height: 130, width: 130, marginLeft: 10, marginRight: 10 }}
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
endIcon={<EmojiObjectsIcon />}
|
||||
onClick={() => {
|
||||
comConnection.port.write(props.title);
|
||||
}}>
|
||||
{props.title}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import React from 'react';
|
||||
import LampButtonToggle from './LampButtonToggle';
|
||||
import LampButtonAbsolute from './LampButtonAbsolute';
|
||||
|
||||
export default function LampButtonList() {
|
||||
return (
|
||||
<div style={{ margin: 20 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
||||
<LampButtonAbsolute title="on" />
|
||||
<LampButtonAbsolute title="off" />
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 20 }}>
|
||||
<LampButtonToggle lampnumber={0} />
|
||||
<LampButtonToggle lampnumber={1} />
|
||||
<LampButtonToggle lampnumber={2} />
|
||||
<LampButtonToggle lampnumber={3} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import { useSelector } from 'react-redux/';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import EmojiObjectsIcon from '@material-ui/icons/EmojiObjects';
|
||||
|
||||
export default function LampButtonToggle(props) {
|
||||
//const comConnection = useSelector((state) => state.comConnectionReducer);
|
||||
const comConnection = null;
|
||||
const [comData, setComData] = useState('');
|
||||
|
||||
const comDataListener = (data) => {
|
||||
setComData(data);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
comConnection.parser.on('data', comDataListener);
|
||||
return () => {
|
||||
comConnection.parser.removeListener('data', comDataListener);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const lampEnabled = comData[props.lampnumber] === '1';
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
style={{ height: 130, width: 130, marginLeft: 10, marginRight: 10 }}
|
||||
variant="contained"
|
||||
color={lampEnabled ? 'secondary' : 'primary'}
|
||||
endIcon={<EmojiObjectsIcon />}
|
||||
onClick={() => {
|
||||
comConnection.port.write(String(props.lampnumber));
|
||||
}}>
|
||||
{`Lamp ${props.lampnumber}`}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Light Control</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'" />
|
||||
<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" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./app.js" data-container="#app"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,10 +0,0 @@
|
|||
import SerialPort from 'serialport';
|
||||
const Readline = require('@serialport/parser-readline');
|
||||
|
||||
const port = new SerialPort('COM6', {
|
||||
baudRate: 9600,
|
||||
});
|
||||
|
||||
const parser = port.pipe(new Readline({ delimiter: '\r\n' }));
|
||||
|
||||
const initialState = { port, parser };
|
|
@ -1,4 +0,0 @@
|
|||
export const SET_CONNECTION_PARAMS = 'SET_CONNECTION_PARAMS';
|
||||
export const CONNECT = 'CONNECT';
|
||||
export const DISCONNECT = 'DISCONNECT';
|
||||
export const SET_CONNECTION_STATUS = 'SET_CONNECTION_STATUS';
|
|
@ -1,17 +0,0 @@
|
|||
import { SET_CONNECTION_STATUS } from '../actions/actionTypes';
|
||||
|
||||
const initialState = false;
|
||||
|
||||
export default (state = initialState, { type, payload }) => {
|
||||
switch (type) {
|
||||
case SET_CONNECTION_STATUS:
|
||||
if (typeof payload === 'boolean') {
|
||||
return payload;
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
|
@ -1,6 +0,0 @@
|
|||
import { combineReducers } from 'redux';
|
||||
import comConnectionStatusReducer from './comConnectionStatusReducer';
|
||||
|
||||
const rootReducer = combineReducers({ comConnectionStatusReducer });
|
||||
|
||||
export default rootReducer;
|
|
@ -1,17 +0,0 @@
|
|||
module.exports = {
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
electron: '6.0',
|
||||
},
|
||||
},
|
||||
],
|
||||
'@babel/preset-react',
|
||||
],
|
||||
plugins: [
|
||||
['@babel/plugin-proposal-decorators', { legacy: true }],
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
],
|
||||
};
|
Binary file not shown.
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
|
@ -1,43 +0,0 @@
|
|||
copyright: GHOSCHT
|
||||
productName: LightControl
|
||||
|
||||
asar: true
|
||||
|
||||
directories:
|
||||
buildResources: dist-assets/
|
||||
output: dist/
|
||||
|
||||
files:
|
||||
- package.json
|
||||
- init.js
|
||||
- build/
|
||||
- node_modules/
|
||||
- dist-assets/
|
||||
|
||||
dmg:
|
||||
contents:
|
||||
- type: link
|
||||
path: /Applications
|
||||
x: 410
|
||||
y: 150
|
||||
- type: file
|
||||
x: 130
|
||||
y: 150
|
||||
|
||||
mac:
|
||||
target: dmg
|
||||
category: public.app-category.tools
|
||||
|
||||
win:
|
||||
target: nsis
|
||||
|
||||
linux:
|
||||
target:
|
||||
- deb
|
||||
- AppImage
|
||||
|
||||
nsis:
|
||||
oneClick: false
|
||||
allowToChangeInstallationDirectory: true
|
||||
perMachine: false
|
||||
artifactName: ${productName}-Setup.${ext}
|
|
@ -1,16 +0,0 @@
|
|||
const { task, series } = require('gulp');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
const scripts = require('./tasks/scripts');
|
||||
const assets = require('./tasks/assets');
|
||||
const watch = require('./tasks/watch');
|
||||
const dist = require('./tasks/distribution');
|
||||
|
||||
task('clean', function (done) {
|
||||
rimraf('./build', done);
|
||||
});
|
||||
task('build', series('clean', assets.copyHtml, scripts.build));
|
||||
task('develop', series('clean', watch.start));
|
||||
task('pack-win', series('build', dist.packWin));
|
||||
task('pack-linux', series('build', dist.packLinux));
|
||||
task('pack-mac', series('build', dist.packMac));
|
|
@ -1 +0,0 @@
|
|||
require('./build/main');
|
|
@ -1,68 +0,0 @@
|
|||
{
|
||||
"name": "light-control",
|
||||
"version": "4.2.0",
|
||||
"main": "init.js",
|
||||
"author": {
|
||||
"name": "GHOSCHT"
|
||||
},
|
||||
"repository": "https://github.com/GHOSCHT/light-control",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/register": "^7.9.0",
|
||||
"@material-ui/core": "^4.11.0",
|
||||
"@material-ui/icons": "^4.9.1",
|
||||
"@serialport/parser-readline": "^9.0.0",
|
||||
"add": "^2.0.6",
|
||||
"connected-react-router": "^6.8.0",
|
||||
"electron-localshortcut": "^3.2.1",
|
||||
"history": "^4.10.1",
|
||||
"prop-types": "^15.7.2",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.0",
|
||||
"react-redux": "^7.2.0",
|
||||
"react-router": "^5.1.2",
|
||||
"redux": "^4.0.5",
|
||||
"redux-actions": "^2.6.5",
|
||||
"redux-localstorage": "^0.4.1",
|
||||
"redux-thunk": "^2.2.0",
|
||||
"screenz": "^1.0.0",
|
||||
"serialport": "^9.0.0",
|
||||
"yarn": "^1.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||
"@babel/plugin-proposal-decorators": "^7.8.3",
|
||||
"@babel/preset-env": "^7.9.5",
|
||||
"@babel/preset-react": "^7.9.4",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"browser-sync": "^2.26.7",
|
||||
"chai": "^4.1.0",
|
||||
"electron": "^8.2.2",
|
||||
"electron-builder": "^22.4.1",
|
||||
"electron-devtools-installer": "^3.0.0",
|
||||
"electron-mocha": "^8.2.1",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint-plugin-react": "^7.19.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-babel": "^8.0.0",
|
||||
"gulp-inject-string": "^1.1.2",
|
||||
"gulp-sourcemaps": "^2.6.5",
|
||||
"prettier": "^2.0.4",
|
||||
"redux-mock-store": "^1.5.4",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"develop": "gulp develop",
|
||||
"test": "electron-mocha --renderer -R spec --require @babel/register test/**/*.spec.js",
|
||||
"lint": "eslint --no-ignore tasks app test *.js",
|
||||
"format": "npm run private:format -- --write",
|
||||
"check-format": "npm run private:format -- --list-different",
|
||||
"pack:mac": "gulp pack-mac",
|
||||
"pack:win": "gulp pack-win",
|
||||
"pack:linux": "gulp pack-linux",
|
||||
"private:format": "prettier gulpfile.js babel.config.js \"tasks/*.js\" \"app/**/*.js\" \"test/**/*.js\""
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
const { src, dest } = require('gulp');
|
||||
|
||||
function copyHtml() {
|
||||
return src('app/renderer/index.html').pipe(dest('build/renderer'));
|
||||
}
|
||||
|
||||
copyHtml.displayName = 'copy-html';
|
||||
|
||||
exports.copyHtml = copyHtml;
|
|
@ -1,30 +0,0 @@
|
|||
const builder = require('electron-builder');
|
||||
|
||||
function packWin() {
|
||||
return builder.build({
|
||||
targets: builder.Platform.WINDOWS.createTarget(),
|
||||
publish: 'never',
|
||||
});
|
||||
}
|
||||
|
||||
function packMac() {
|
||||
return builder.build({
|
||||
targets: builder.Platform.MAC.createTarget(),
|
||||
publish: 'never',
|
||||
});
|
||||
}
|
||||
|
||||
function packLinux() {
|
||||
return builder.build({
|
||||
targets: builder.Platform.LINUX.createTarget(),
|
||||
publish: 'never',
|
||||
});
|
||||
}
|
||||
|
||||
packWin.displayName = 'builder-win';
|
||||
packMac.displayName = 'builder-mac';
|
||||
packLinux.displayName = 'builder-linux';
|
||||
|
||||
exports.packWin = packWin;
|
||||
exports.packMac = packMac;
|
||||
exports.packLinux = packLinux;
|
|
@ -1,23 +0,0 @@
|
|||
const { spawn } = require('child_process');
|
||||
const electron = require('electron');
|
||||
|
||||
let subprocess;
|
||||
|
||||
function startElectron(done) {
|
||||
subprocess = spawn(electron, ['.', '--no-sandbox'], {
|
||||
env: { ...process.env, NODE_ENV: 'development' },
|
||||
stdio: 'inherit',
|
||||
});
|
||||
done();
|
||||
}
|
||||
|
||||
function stopElectron() {
|
||||
subprocess.kill();
|
||||
return subprocess;
|
||||
}
|
||||
|
||||
startElectron.displayName = 'start-electron';
|
||||
stopElectron.displayName = 'stop-electron';
|
||||
|
||||
exports.start = startElectron;
|
||||
exports.stop = stopElectron;
|
|
@ -1,43 +0,0 @@
|
|||
const { series, src, dest } = require('gulp');
|
||||
const inject = require('gulp-inject-string');
|
||||
|
||||
const browserSync = require('browser-sync').create();
|
||||
|
||||
function startBrowserSync(done) {
|
||||
browserSync.init(
|
||||
{
|
||||
ui: false,
|
||||
localOnly: true,
|
||||
port: 35829,
|
||||
ghostMode: false,
|
||||
open: false,
|
||||
notify: false,
|
||||
logSnippet: false,
|
||||
},
|
||||
function (error) {
|
||||
done(error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function injectBrowserSync() {
|
||||
return src('app/renderer/index.html')
|
||||
.pipe(inject.before('</body>', browserSync.getOption('snippet')))
|
||||
.pipe(
|
||||
inject.after('script-src', " 'unsafe-eval' " + browserSync.getOption('urls').get('local')),
|
||||
)
|
||||
.pipe(dest('build/renderer'));
|
||||
}
|
||||
|
||||
function reloadBrowser(done) {
|
||||
browserSync.reload();
|
||||
done();
|
||||
}
|
||||
|
||||
startBrowserSync.displayName = 'start-hotreload';
|
||||
injectBrowserSync.displayName = 'inject-hotreload';
|
||||
reloadBrowser.displayName = 'reload-hotreload';
|
||||
|
||||
exports.start = series(startBrowserSync, injectBrowserSync);
|
||||
exports.inject = injectBrowserSync;
|
||||
exports.reload = reloadBrowser;
|
|
@ -1,25 +0,0 @@
|
|||
const { src, dest } = require('gulp');
|
||||
const babel = require('gulp-babel');
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const inject = require('gulp-inject-string');
|
||||
|
||||
function build() {
|
||||
return src('app/**/*.js')
|
||||
.pipe(babel())
|
||||
.pipe(inject.replace('process.env.NODE_ENV', '"production"'))
|
||||
.pipe(dest('build'));
|
||||
}
|
||||
|
||||
function developBuild() {
|
||||
return src('app/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(babel())
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(dest('build'));
|
||||
}
|
||||
|
||||
build.displayName = 'build-scripts';
|
||||
developBuild.displayName = 'dev-build-scripts';
|
||||
|
||||
exports.build = build;
|
||||
exports.developBuild = developBuild;
|
|
@ -1,32 +0,0 @@
|
|||
const { parallel, series, watch } = require('gulp');
|
||||
const electron = require('./electron');
|
||||
const hotreload = require('./hotreload');
|
||||
const assets = require('./assets');
|
||||
const scripts = require('./scripts');
|
||||
|
||||
function watchMainScripts() {
|
||||
return watch(['app/main/**/*.js'], series(scripts.developBuild, electron.stop, electron.start));
|
||||
}
|
||||
|
||||
function watchRendererScripts() {
|
||||
return watch(['app/renderer/**/*.js'], series(scripts.developBuild, hotreload.reload));
|
||||
}
|
||||
|
||||
function watchHtml() {
|
||||
return watch(
|
||||
['app/renderer/index.html'],
|
||||
series(assets.copyHtml, hotreload.inject, hotreload.reload),
|
||||
);
|
||||
}
|
||||
|
||||
watchMainScripts.displayName = 'watch-main-scripts';
|
||||
watchRendererScripts.displayName = 'watch-renderer-scripts';
|
||||
watchHtml.displayName = 'watch-html';
|
||||
|
||||
exports.start = series(
|
||||
assets.copyHtml,
|
||||
scripts.developBuild,
|
||||
hotreload.start,
|
||||
electron.start,
|
||||
parallel(watchMainScripts, watchRendererScripts, watchHtml),
|
||||
);
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"mocha": true
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
import { expect } from 'chai';
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
import actions from '../../app/renderer/actions/user';
|
||||
|
||||
const mockStore = configureMockStore([thunk]);
|
||||
|
||||
describe('actions', () => {
|
||||
describe('user', () => {
|
||||
it('should log in', () => {
|
||||
const store = mockStore({});
|
||||
const expectedActions = [
|
||||
{
|
||||
type: 'USER_LOGIN',
|
||||
payload: {
|
||||
username: 'John Doe',
|
||||
loggedIn: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
store.dispatch(
|
||||
actions.login({
|
||||
username: 'John Doe',
|
||||
loggedIn: true,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(store.getActions()).deep.equal(expectedActions);
|
||||
});
|
||||
|
||||
it('should logout', () => {
|
||||
const store = mockStore({});
|
||||
const expectedActions = [
|
||||
{
|
||||
type: 'USER_LOGOUT',
|
||||
payload: {
|
||||
username: '',
|
||||
loggedIn: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
store.dispatch(
|
||||
actions.logout({
|
||||
username: '',
|
||||
loggedIn: false,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(store.getActions()).deep.equal(expectedActions);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,30 +0,0 @@
|
|||
import { expect } from 'chai';
|
||||
import reducer from '../../app/renderer/reducers/user';
|
||||
|
||||
describe('reducers', () => {
|
||||
describe('user', () => {
|
||||
it('should handle USER_LOGIN', () => {
|
||||
const action = {
|
||||
type: 'USER_LOGIN',
|
||||
payload: {
|
||||
username: 'John Doe',
|
||||
loggedIn: true,
|
||||
},
|
||||
};
|
||||
const test = Object.assign({}, action.payload);
|
||||
expect(reducer({}, action)).to.deep.equal(test);
|
||||
});
|
||||
|
||||
it('should handle USER_LOGOUT', () => {
|
||||
const action = {
|
||||
type: 'USER_LOGOUT',
|
||||
payload: {
|
||||
username: '',
|
||||
loggedIn: false,
|
||||
},
|
||||
};
|
||||
const test = Object.assign({}, action.payload);
|
||||
expect(reducer({}, action)).to.deep.equal(test);
|
||||
});
|
||||
});
|
||||
});
|
7667
_Dashboard/yarn.lock
7667
_Dashboard/yarn.lock
File diff suppressed because it is too large
Load diff
Reference in a new issue