Skip to content

Commit c1b039f

Browse files
committed
Update
Signed-off-by: Aaron Huang <aaroms9733@gmail.com>
1 parent 1bf0344 commit c1b039f

File tree

13 files changed

+145
-105
lines changed

13 files changed

+145
-105
lines changed

src/App.less

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ body {
2727
padding: 24px;
2828
}
2929

30-
.tags-table, .images-table {
30+
.tags-table,
31+
.images-table {
3132
padding-left: 16px;
32-
.tags-row, .images-row {
33+
.tags-row,
34+
.images-row {
3335
.actionBtn {
3436
opacity: 0;
37+
color: @primary-color;
38+
border-color: @primary-color;
3539
}
3640
background: #fbfbfb;
3741
&:hover {
@@ -42,6 +46,16 @@ body {
4246
}
4347
}
4448

49+
.repo-table {
50+
.ant-tag {
51+
font-weight: 700;
52+
&.tag-public {
53+
border: 1px solid #244764;
54+
color: #244764;
55+
}
56+
}
57+
}
58+
4559
.primehub-alert {
4660
padding: 10px 10px 10px 15px;
4761
.ant-alert-message {

src/BuildImage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default function BuildImage() {
117117
);
118118

119119
const initialValues = {
120-
base_image_url: 'ubuntu:xenial',
120+
base_image_url: 'jupyter/base-notebook:latest',
121121
apt: `curl\ngit`,
122122
};
123123

src/ListImage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default function ListImage() {
9292
i.imageId = x.Id.split(':')[1].substring(0, 12);
9393
i.key = i.imageId;
9494
i.created = format(x.Created * 1000);
95-
i.size = filesize(x.Size, {round: 1});
95+
i.size = filesize(x.Size, { round: 1 });
9696
return i;
9797
});
9898
console.log(images);
@@ -138,7 +138,9 @@ export default function ListImage() {
138138
size='small'
139139
icon={<CloudUploadOutlined />}
140140
onClick={() => pushImage(record.name + ':' + record.tag)}
141-
>PUSH</Button>
141+
>
142+
PUSH
143+
</Button>
142144
),
143145
},
144146
];

src/ListRemoteImage.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,18 @@ export default function ListRemoteImages() {
8686
key: 'tag_status',
8787
align: 'center',
8888
width: '10%',
89-
render: (status) => <Tag color='cyan'>{status.toUpperCase()}</Tag>,
89+
render: (status) => (
90+
<Tag className='tag-status' color='cyan'>
91+
{status.toUpperCase()}
92+
</Tag>
93+
),
9094
},
9195
{
9296
title: 'SIZE',
9397
dataIndex: 'full_size',
9498
key: 'full_size',
9599
align: 'right',
96-
render: (value) => filesize(value, {round: 1}),
100+
render: (value) => filesize(value, { round: 1 }),
97101
width: '15%',
98102
},
99103
{
@@ -110,10 +114,7 @@ export default function ListRemoteImages() {
110114
align: 'center',
111115
width: '15%',
112116
render: (name, tag) => (
113-
<Tooltip
114-
placement='top'
115-
title='Add to PrimeHub'
116-
>
117+
<Tooltip placement='top' title='Add to PrimeHub'>
117118
<Button
118119
className='actionBtn'
119120
size='small'
@@ -122,8 +123,10 @@ export default function ListRemoteImages() {
122123
const tag = `${record.namespace}/${record.name}:${name}`;
123124
history.push(`/createPrimeHubImage?tag=${tag}`);
124125
}}
125-
>ADD</Button>
126-
</Tooltip>
126+
>
127+
ADD
128+
</Button>
129+
</Tooltip>
127130
),
128131
},
129132
];
@@ -222,7 +225,7 @@ export default function ListRemoteImages() {
222225
if (is_private) {
223226
return <Tag color='orange'>PRIVATE</Tag>;
224227
} else {
225-
return <Tag color='green'>PUBLIC</Tag>;
228+
return <Tag className='tag-public'>PUBLIC</Tag>;
226229
}
227230
},
228231
},
@@ -244,13 +247,14 @@ export default function ListRemoteImages() {
244247
{
245248
key: 'action',
246249
align: 'center',
247-
width: '15%'
250+
width: '15%',
248251
},
249252
];
250253
return (
251254
<React.Fragment>
252255
<Table
253256
size='small'
257+
className='repo-table'
254258
columns={columns}
255259
dataSource={repos}
256260
pagination={false}

src/Settings.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Tabs,
99
Alert,
1010
notification,
11-
Space
11+
Space,
1212
} from 'antd';
1313
import { send } from './utils/ipcClient';
1414
import {
@@ -150,21 +150,26 @@ export default function Settings() {
150150
</TabPane>
151151
<TabPane tab='PRIMEHUB' key='2' forceRender={true}>
152152
<Alert
153-
style={{ margin: '8px 0 16px'}}
153+
style={{ margin: '8px 0 16px' }}
154154
className='primehub-alert'
155155
showIcon
156156
message={`Looking for a full-stack ML platform?`}
157157
description={`It'll just take few minutes by our 1-click installer to setup PrimeHub on AWS`}
158158
action={
159159
<Space>
160-
<Button size='small' type='primary' href='https://one.primehub.io' target='_blank'>
160+
<Button
161+
size='small'
162+
type='primary'
163+
href='https://one.primehub.io'
164+
target='_blank'
165+
>
161166
Ok Let's Do It
162167
</Button>
163168
</Space>
164169
}
165170
closable
166171
closeText={
167-
<Button size='small' type='text' style={{color: '#aaa'}}>
172+
<Button size='small' type='text' style={{ color: '#aaa' }}>
168173
Not right now
169174
</Button>
170175
}
@@ -177,8 +182,11 @@ export default function Settings() {
177182
initialValues={initialValues}
178183
onFinish={onPrimeHubFinish}
179184
>
180-
<Form.Item label='PrimeHub API Endpoint' name='primehub-api-endpoint'>
181-
<Input placeholder='https://example.com/primehub/api/graphql'/>
185+
<Form.Item
186+
label='PrimeHub API Endpoint'
187+
name='primehub-api-endpoint'
188+
>
189+
<Input placeholder='https://example.com/primehub/api/graphql' />
182190
</Form.Item>
183191
<Form.Item label='PrimeHub API Token' name='primehub-api-token'>
184192
<Input.Password

src/Sidebar.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ export default function Sidebar(prop) {
4545
Build
4646
</Link>
4747
</Menu.Item>
48-
<Menu.Item key={(() => {
49-
const path = location.pathname.replaceAll('/', '');
50-
if (path === 'createPrimeHubImage') {
51-
return 'createPrimeHubImage';
52-
}
53-
return 'images'
54-
})()} icon={<OrderedListOutlined />}>
48+
<Menu.Item
49+
key={(() => {
50+
const path = location.pathname.replaceAll('/', '');
51+
if (path === 'createPrimeHubImage') {
52+
return 'createPrimeHubImage';
53+
}
54+
return 'images';
55+
})()}
56+
icon={<OrderedListOutlined />}
57+
>
5558
<Link to='/images' style={{ color: 'white' }}>
5659
Images
5760
</Link>

src/electron/ServerHandlers.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import axios from 'axios';
88
import { createMarkdownArrayTableSync } from 'parse-markdown-table';
99

1010
const docker = new Docker();
11-
const dockerHubCredentialKeyName = "Crane-DockerHub";
12-
const primeHubCredentialKeyName = "Crane-PrimeHub";
11+
const dockerHubCredentialKeyName = 'Crane-DockerHub';
12+
const primeHubCredentialKeyName = 'Crane-PrimeHub';
1313

1414
export function generateDockerfile(options) {
1515
let base_image_url = options['base_image_url'];
@@ -66,7 +66,10 @@ export async function saveCredential(keyname, account, password) {
6666
}
6767

6868
export function writeDockerfile(dockerfileContent) {
69-
fs.writeFileSync(path.join(config.workingDir, 'Dockerfile'), dockerfileContent);
69+
fs.writeFileSync(
70+
path.join(config.workingDir, 'Dockerfile'),
71+
dockerfileContent
72+
);
7073
}
7174

7275
const handlers = {
@@ -79,7 +82,11 @@ const handlers = {
7982
return await getCredential(primeHubCredentialKeyName);
8083
},
8184
'save-dockerhub-credential': async (args) =>
82-
await saveCredential(dockerHubCredentialKeyName ,args.account, args.password),
85+
await saveCredential(
86+
dockerHubCredentialKeyName,
87+
args.account,
88+
args.password
89+
),
8390
'save-primehub-credential': async (args) =>
8491
await saveCredential(primeHubCredentialKeyName, args.endpoint, args.token),
8592
'build-status': async () => {

src/electron/ServerIpc.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@ import * as console from 'console';
22
import * as ipc from 'node-ipc';
33

44
export function init(socketAppspace, socketId, handlers) {
5-
ipc.config.silent = true
6-
console.log("server-ipc:init", socketAppspace, socketId)
7-
ipc.config.appspace = socketAppspace
8-
ipc.config.id = socketId
5+
ipc.config.silent = true;
6+
console.log('server-ipc:init', socketAppspace, socketId);
7+
ipc.config.appspace = socketAppspace;
8+
ipc.config.id = socketId;
99
ipc.serve(() => {
1010
ipc.server.on('message', (data, socket) => {
11-
let msg = JSON.parse(data)
12-
let { id, name, args } = msg
11+
let msg = JSON.parse(data);
12+
let { id, name, args } = msg;
1313

1414
if (handlers[name]) {
1515
handlers[name](args).then(
16-
result => {
16+
(result) => {
1717
ipc.server.emit(
1818
socket,
1919
'message',
2020
JSON.stringify({ type: 'reply', id, result })
21-
)
21+
);
2222
},
23-
error => {
23+
(error) => {
2424
// Up to you how to handle errors, forward them, etc
2525
ipc.server.emit(
2626
socket,
2727
'message',
2828
JSON.stringify({ type: 'error', id })
29-
)
30-
throw error
29+
);
30+
throw error;
3131
}
32-
)
32+
);
3333
} else {
34-
console.warn('Unknown method: ' + name)
34+
console.warn('Unknown method: ' + name);
3535
ipc.server.emit(
3636
socket,
3737
'message',
3838
JSON.stringify({ type: 'reply', id, result: null })
39-
)
39+
);
4040
}
41-
})
42-
})
41+
});
42+
});
4343

44-
ipc.server.start()
44+
ipc.server.start();
4545
}
4646

4747
export function send(name, args) {
48-
ipc.server.broadcast('message', JSON.stringify({ type: 'push', name, args }))
48+
ipc.server.broadcast('message', JSON.stringify({ type: 'push', name, args }));
4949
}

src/electron/client-preload.js

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
const { contextBridge } = require('electron')
1+
const { contextBridge } = require('electron');
22

3-
const opts = parseArgs(window.process.argv)
4-
const socketId = opts.get('--socketId')
3+
const opts = parseArgs(window.process.argv);
4+
const socketId = opts.get('--socketId');
55

6-
const ipc = require('node-ipc')
7-
ipc.config.silent = true
8-
ipc.config.appspace = opts.get('--socketAppspace')
6+
const ipc = require('node-ipc');
7+
ipc.config.silent = true;
8+
ipc.config.appspace = opts.get('--socketAppspace');
99

10-
contextBridge.exposeInMainWorld(
11-
'myapp',
12-
{
13-
uuid: require('uuid'),
14-
isDev: opts.get('--isDev'),
15-
appVersion: opts.get('--appVersion'),
16-
socketId,
17-
ipcOn,
18-
ipcEmit
19-
}
20-
)
10+
contextBridge.exposeInMainWorld('myapp', {
11+
uuid: require('uuid'),
12+
isDev: opts.get('--isDev'),
13+
appVersion: opts.get('--appVersion'),
14+
socketId,
15+
ipcOn,
16+
ipcEmit,
17+
});
2118
function ipcOn(id, handle) {
2219
ipc.connectTo(id, () => {
23-
ipc.of[id].on("message", handle.message)
24-
ipc.of[id].on("connect", handle.connect)
25-
ipc.of[id].on("disconnect", handle.disconnect)
26-
})
20+
ipc.of[id].on('message', handle.message);
21+
ipc.of[id].on('connect', handle.connect);
22+
ipc.of[id].on('disconnect', handle.disconnect);
23+
});
2724
}
2825

2926
function ipcEmit(id, ...args) {
30-
return ipc.of[id].emit(...args)
27+
return ipc.of[id].emit(...args);
3128
}
3229

3330
function parseArgs(argv) {
3431
return argv.reduce((args, arg) => {
35-
const match = arg.split("=")
36-
args.set(match[0], match[1] || true)
37-
return args
38-
}, new Map())
39-
}
32+
const match = arg.split('=');
33+
args.set(match[0], match[1] || true);
34+
return args;
35+
}, new Map());
36+
}

0 commit comments

Comments
 (0)