Skip to content

Commit c578a76

Browse files
committed
Merge branch 'master' of https://github.com/kube-HPC/simulator
2 parents ddb5902 + 12a30d3 commit c578a76

File tree

10 files changed

+35
-43
lines changed

10 files changed

+35
-43
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simulator",
3-
"version": "2.8.11",
3+
"version": "2.8.13",
44
"description": "The Hkube Dashboard",
55
"private": true,
66
"homepage": ".",

src/Routes/Tables/Workers/WorkersActions.react.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,39 @@
1-
import React, { memo, useCallback, useRef, useState, useEffect } from 'react';
1+
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import { StopOutlined } from '@ant-design/icons';
44
import { message, Button, Tooltip } from 'antd';
5-
import { workersStopListVar } from 'cache';
5+
66
import { useActions } from 'hooks';
77
import isEqual from 'lodash/isEqual';
8-
import { useReactiveVar } from '@apollo/client';
98

109
const WorkersActions = ({ algorithm }) => {
11-
const workersStopList = useReactiveVar(workersStopListVar);
1210
const { stopAlgorithm } = useActions();
1311
const [stopWorkerIsRun, setStopWorkerIsRun] = useState(false);
1412
const container = useRef();
1513

1614
const onStopSuccess = () => {
17-
const arrWorkersStopList = [...workersStopListVar()];
18-
const arrWorkersStopListFilter = arrWorkersStopList.filter(
19-
x => x !== algorithm.algorithmName
20-
);
21-
22-
workersStopListVar(arrWorkersStopListFilter);
23-
};
24-
25-
const onStop = useCallback(() => {
15+
setStopWorkerIsRun(true);
2616
message.success(
2717
<>
2818
Stop worker is started. It may take a few moments for the algorithms to
2919
be deleted.
3020
</>
3121
);
32-
const arrWorkersStopList = [...workersStopList];
33-
arrWorkersStopList.push(algorithm.algorithmName);
22+
};
3423

35-
workersStopListVar(arrWorkersStopList);
36-
stopAlgorithm(algorithm.algorithmName);
37-
setStopWorkerIsRun(true);
38-
}, [algorithm.algorithmName, stopAlgorithm, workersStopList]);
24+
const onStop = useCallback(() => {
25+
stopAlgorithm(algorithm.algorithmName, onStopSuccess);
26+
}, [algorithm.algorithmName, stopAlgorithm]);
3927

4028
const stopPropagation = useCallback(e => {
4129
e.stopPropagation();
4230
}, []);
4331

44-
useEffect(() => () => onStopSuccess(), []);
32+
useEffect(() => {
33+
if (algorithm?.exit === 0) {
34+
setStopWorkerIsRun(false);
35+
}
36+
}, [algorithm, algorithm?.exit]);
4537

4638
return (
4739
<div

src/Routes/Tables/Workers/columns.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ const WorkerState = (_, { workerStatus, jobStatus }) => {
2222

2323
const HotWorker = (_, { workerPaused, hotWorker }) => (
2424
<>
25-
{workerPaused && <PauseCircleTwoTone twoToneColor="red" />}
25+
{workerPaused && (
26+
<Tooltip placement="top" title="Stop Worker">
27+
<PauseCircleTwoTone twoToneColor="red" />
28+
</Tooltip>
29+
)}
2630
{hotWorker && (
2731
<Tooltip placement="top" title="Hot Worker">
2832
<FireFilled style={{ color: 'orange' }} />

src/Routes/Tables/Workers/index.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { DownOutlined, RightOutlined } from '@ant-design/icons';
44
import { Card, JsonSwitch, Tabs } from 'components/common';
55
import defaultWorkerData from 'config/template/worker.template';
66
import { useWorkers } from 'hooks/graphql';
7-
import { workersStopListVar } from 'cache';
8-
import { useReactiveVar } from '@apollo/client';
97
import { workersColumns, workersTableStats } from './columns';
108

119
const generateTab = (key, value) => [
@@ -20,17 +18,12 @@ const generateTab = (key, value) => [
2018
},
2119
];
2220

23-
const ExpandedRow = (collection, arrWorkersStopList) => recordRow => {
21+
const ExpandedRow = collection => recordRow => {
2422
const entries = collection[recordRow?.algorithmName] || [];
25-
2623
return (
2724
<Card isMargin>
2825
<Table
29-
rowClassName={
30-
arrWorkersStopList?.includes(recordRow?.algorithmName)
31-
? 'expanded-row-disable'
32-
: ''
33-
}
26+
rowClassName={row => (row?.workerPaused ? 'expanded-row-disable' : '')}
3427
isInner
3528
rowKey={row => row.podName}
3629
columns={workersTableStats}
@@ -56,7 +49,6 @@ const ExpandedRow = (collection, arrWorkersStopList) => recordRow => {
5649
};
5750

5851
const WorkersTable = () => {
59-
const workersStopList = useReactiveVar(workersStopListVar);
6052
const { collection, stats } = useWorkers();
6153
const statsMergedWithDefault = useMemo(
6254
() =>
@@ -73,7 +65,7 @@ const WorkersTable = () => {
7365
columns={workersColumns}
7466
dataSource={statsMergedWithDefault}
7567
expandable={{
76-
expandedRowRender: ExpandedRow(collection, workersStopList),
68+
expandedRowRender: ExpandedRow(collection),
7769
// eslint-disable-next-line react/prop-types
7870
expandIcon: ({ expanded, onExpand, record }) =>
7971
expanded ? (

src/actions/algorithm.action.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ export const runAlgorithm = ({ name, input = [], debug = false }) => ({
3131
},
3232
});
3333

34-
export const stopAlgorithm = algorithmName => ({
34+
export const stopAlgorithm = (algorithmName, onSuccess) => ({
3535
type: actions.REST_REQ_DELETE,
3636
payload: {
3737
url: `kubernetes/algorithms/jobs/${algorithmName}`,
3838
actionType: actions.ALGORITHM_DELETE,
3939
},
40+
meta: { onSuccess },
4041
});

src/cache.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const numberErrorGraphQLVar = makeVar({ error: 0 });
1818
export const isPinActiveJobVar = makeVar(false);
1919
export const filterToggeledVar = makeVar(true);
2020
export const pipelineListVar = makeVar([]);
21-
export const workersStopListVar = makeVar([]);
2221
export const algorithmsListVar = makeVar([]);
2322
export const inactiveModeVar = makeVar(false);
2423
export const instanceCounterVar = makeVar({
@@ -124,11 +123,7 @@ const cache = new InMemoryCache({
124123
return inactiveModeVar();
125124
},
126125
},
127-
workersStopList: {
128-
read() {
129-
return workersStopListVar();
130-
},
131-
},
126+
132127
metaMode: {
133128
read() {
134129
return metaVar();

src/components/InputField.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ const InputField = ({
4747
) : (
4848
<Tooltip
4949
title={
50-
isValid ? '' : tooltip || inputRef.current.input.placeholder
50+
isValid
51+
? ''
52+
: tooltip ||
53+
inputRef?.current?.input?.placeholder ||
54+
placeholder
5155
}>
5256
<WarningOutlined style={{ color: 'red', fontSize: '15px' }} />
5357
</Tooltip>

src/graphql/queries/Workers/workers-query.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const WORKERS_ALL_QUERY = gql`
1111
count
1212
results
1313
status
14+
#exit
15+
#init
16+
#ready
17+
#working
1418
}
1519
}
1620
}

src/styles/GlobalStyle.styles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ body{
109109
.expanded-row-disable,
110110
.expanded-row-disable .ant-table-cell-row-hover,
111111
.expanded-row-disable .ant-table-column-sort {
112-
background:#ccc !important;
112+
background:#aaa !important;
113113
}
114114
115115
`;

0 commit comments

Comments
 (0)