Skip to content

Commit

Permalink
Merge branch 'main' into feat/wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed Apr 2, 2024
2 parents 4347d4f + 89d9be4 commit 9726bb6
Show file tree
Hide file tree
Showing 105 changed files with 11,551 additions and 3,133 deletions.
27 changes: 0 additions & 27 deletions electron/docker.js

This file was deleted.

33 changes: 32 additions & 1 deletion electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const os = require('os');
const sudo = require('sudo-prompt');
const process = require('process');
const { spawnSync } = require('child_process');
const Docker = require('dockerode');


const OperateDirectory = `${os.homedir()}/.operate`;
Expand Down Expand Up @@ -143,7 +144,7 @@ function createVirtualEnvUbuntu(path) {
function installOperatePackageUnix(path) {
return runCmdUnix(
`${path}/venv/bin/python3.10`,
['-m', 'pip', 'install', 'olas-operate-middleware==0.1.0rc0']
['-m', 'pip', 'install', 'olas-operate-middleware==0.1.0rc1']
)
}

Expand Down Expand Up @@ -267,8 +268,38 @@ async function setupUbuntu(ipcChannel) {
await installOperateCli('/usr/local/bin')
}


async function startDocker(ipcChannel) {
const docker = new Docker();
let running = await new Promise((resolve, reject) => {
docker.ping((err) => {
resolve(!err)
});
});
if (!running) {
console.log(appendLog("Starting docker"))
ipcChannel.send("response", "Starting docker")
if (process.platform == "darwin") {
runCmdUnix("open", ["-a", "Docker"])
} else if (process.platform == "win32") {
// TODO
} else {
runSudoUnix("sudo", ["service", "docker", "restart"])
}
}
while (!running) {
running = await new Promise((resolve, reject) => {
docker.ping((err) => {
resolve(!err)
});
});
};
}


module.exports = {
setupDarwin,
startDocker,
setupUbuntu,
OperateDirectory,
OperateCmd,
Expand Down
8 changes: 4 additions & 4 deletions electron/loading/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<svg viewBox="0 0 1024 1024" focusable="false" data-icon="loading" width="1em" height="1em" fill="black" aria-hidden="true"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg>
</span>
</div>
<div id="text" class="text">Loading...</div>
<!-- <div id="text" class="text">Loading...</div> -->
</div>
</body>
<script>
const { ipcRenderer } = require("electron");
ipcRenderer.on("response", (event, arg) => {
document.getElementById("text").innerText = arg;
});
// ipcRenderer.on("response", (event, arg) => {
// document.getElementById("text").innerText = arg;
// });
ipcRenderer.send("check", "Starting check...");
</script>
</html>
4 changes: 2 additions & 2 deletions electron/loading/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ main {

img {
margin: 0 auto;
width: 250px !important;
height: 250px !important;
width: 150px !important;
height: 150px !important;
}
46 changes: 27 additions & 19 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ const {
BrowserWindow,
Tray,
Menu,
shell,
Notification,
ipcMain,
} = require('electron');
const { spawn, exec } = require('child_process');
const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');
const os = require('os');
const next = require('next');
const http = require('http');

const { isDockerRunning } = require('./docker');
const {
setupDarwin,
setupUbuntu,
OperateCmd,
OperateDirectory,
startDocker
} = require('./install');
const { killProcesses } = require('./processes');
const { isPortAvailable, findAvailablePort } = require('./ports');
Expand All @@ -34,8 +33,6 @@ if (!singleInstanceLock) app.quit();
const platform = os.platform();
const isDev = process.env.NODE_ENV === 'development';
let appConfig = {
width: 600,
height: 800,
ports: {
dev: {
operate: 8000,
Expand Down Expand Up @@ -109,8 +106,8 @@ const createTray = () => {
*/
const createSplashWindow = () => {
splashWindow = new BrowserWindow({
width: appConfig.width,
height: appConfig.height,
width: 420,
height: 420,
resizable: false,
show: true,
title: 'Olas Operate',
Expand All @@ -131,16 +128,19 @@ const createSplashWindow = () => {
*/
const createMainWindow = () => {
mainWindow = new BrowserWindow({
width: appConfig.width,
height: appConfig.height,
resizable: false,
title: 'Olas Operate',
});

// Ensure that external links are opened in native browser
mainWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url);
return { action: 'deny' };
resizable: false,
draggable: true,
frame: true,
transparent: true,
fullscreenable: false,
maximizable: false,
width: 420,
minHeight: 210,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
},
});

mainWindow.setMenuBarVisibility(false);
Expand All @@ -149,11 +149,12 @@ const createMainWindow = () => {
} else {
mainWindow.loadURL(`http://localhost:${appConfig.ports.prod.next}`);
}

mainWindow.webContents.on('did-fail-load', () => {
mainWindow.webContents.reloadIgnoringCache();
});

mainWindow.on('ready-to-show', () => {
mainWindow.webContents.on('ready-to-show', () => {
mainWindow.show();
});

Expand All @@ -169,8 +170,10 @@ const createMainWindow = () => {

async function launchDaemon() {
function appendLog(data) {
fs.appendFileSync(`${OperateDirectory}/logs.txt`, data.trim() + "\n", { "encoding": "utf-8" })
return data
fs.appendFileSync(`${OperateDirectory}/logs.txt`, data.trim() + '\n', {
encoding: 'utf-8',
});
return data;
}
const check = new Promise(function (resolve, reject) {
operateDaemon = spawn(OperateCmd, [
Expand Down Expand Up @@ -265,6 +268,9 @@ async function launchNextAppDev() {

ipcMain.on('check', async function (event, argument) {
try {



event.sender.send('response', 'Checking installation');
if (!isDev) {
if (platform === 'darwin') {
Expand All @@ -276,6 +282,8 @@ ipcMain.on('check', async function (event, argument) {
}
}

startDocker(event.sender)

if (isDev) {
event.sender.send(
'response',
Expand Down
9 changes: 9 additions & 0 deletions electron/public/happy-robot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions electron/public/sad-robot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
"prettier",
"react",
"react-hooks",
"unused-imports"
"unused-imports",
"simple-import-sort",
"import"
],
"rules": {
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"unused-imports/no-unused-imports": "error",
"no-console": "warn",
"no-unused-vars": "warn",
Expand Down
1 change: 1 addition & 0 deletions frontend/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type ServiceTemplate = {
image: string;
description: string;
configuration: ConfigurationTemplate;
deploy?: boolean;
};

export type ConfigurationTemplate = {
Expand Down
2 changes: 2 additions & 0 deletions frontend/common-util/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './copyToClipboard';
export * from './isDev';
1 change: 1 addition & 0 deletions frontend/common-util/isDev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isDev = process.env.NODE_ENV === 'development';
19 changes: 19 additions & 0 deletions frontend/components/Layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Flex } from 'antd';
import { PropsWithChildren } from 'react';

export const Header = ({ children }: PropsWithChildren) => {
return (
<Flex
style={{
borderBottom: '1px lightgrey solid',
padding: '10px 20px',
minHeight: 40,
maxHeight: 40,
alignItems: 'center',
gap: 10,
}}
>
{children}
</Flex>
);
};
12 changes: 0 additions & 12 deletions frontend/components/Layout/Layout.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions frontend/components/Layout/Navbar/Navbar.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions frontend/components/Layout/Navbar/NotificationButton.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions frontend/components/Layout/Navbar/SettingsButton.tsx

This file was deleted.

16 changes: 16 additions & 0 deletions frontend/components/Layout/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Flex } from 'antd';
import { PropsWithChildren } from 'react';

export const Wrapper = ({
children,
vertical,
}: PropsWithChildren & { vertical?: boolean }) => {
return (
<Flex
style={{ padding: 20, alignItems: 'center', gap: 10 }}
vertical={vertical}
>
{children}
</Flex>
);
};
2 changes: 2 additions & 0 deletions frontend/components/Layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './Header';
export * from './Wrapper';
13 changes: 13 additions & 0 deletions frontend/components/Login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Button, Typography } from 'antd';

import { Wrapper } from './Layout/Wrapper';

export const Login = () => {
return (
<Wrapper>
<Typography.Title>Login</Typography.Title>
<input type="text" placeholder="Enter your password" />
<Button>Login</Button>
</Wrapper>
);
};
Loading

0 comments on commit 9726bb6

Please sign in to comment.