Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified the Robotics academy electron app #2173

Open
wants to merge 2 commits into
base: old_manager
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/InstructionsForDevelopers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ source env/bin/activate
pip install django
pip install djangorestframework
pip install django-webpack-loader
pip install django-cors-headers
pip install pylint
```

4) Install dependencies for REACT (with Yarn or npm, required Node.JS >= 14.16)
Expand Down
92 changes: 92 additions & 0 deletions electron/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock
.DS_Store

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Webpack
.webpack/

# Vite
.vite/

# Electron-Forge
out/
30 changes: 30 additions & 0 deletions electron/forge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {},
},
{
name: '@electron-forge/maker-rpm',
config: {},
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
],
};
32 changes: 32 additions & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "electron",
"productName": "electron",
"version": "1.0.0",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "Prakhar-commits",
"email": "[email protected]"
},
"license": "MIT",
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
},
"devDependencies": {
"@electron-forge/cli": "^6.2.1",
"@electron-forge/maker-deb": "^6.2.1",
"@electron-forge/maker-rpm": "^6.2.1",
"@electron-forge/maker-squirrel": "^6.2.1",
"@electron-forge/maker-zip": "^6.2.1",
"@electron-forge/plugin-auto-unpack-natives": "^6.2.1",
"electron": "25.3.0"
}
}
58 changes: 58 additions & 0 deletions electron/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
const { spawn } = require('child_process');

if (require('electron-squirrel-startup')) {
app.quit();
}

const rootPath = path.resolve(__dirname, '../../')

let childProcess;

createDjangoServer = () => {
const activateCommand = `source ${rootPath}/env/bin/activate && `;
const command = `python3 ${rootPath}/manage.py runserver`;

const fullCommand = activateCommand + command;
const fullArgs = ['-c', fullCommand];

childProcess = spawn('bash', fullArgs);
}

const killDjangoServer = () => {
if (childProcess) {
childProcess.kill();
}
};

const createWindow = () => {
const mainWindow = new BrowserWindow({
width: 1280,
height: 720,
webPreferences: {
nodeIntegration: true,
},
});
mainWindow.loadURL('http://127.0.0.1:8000/');
};

app.on('ready', () => {
createDjangoServer()
setTimeout(() => {
createWindow()
}, 5000);
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
killDjangoServer()
}
});

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
Loading