Skip to content

Commit ae934d2

Browse files
author
Golan Hallel
authored
Merge pull request #233 from kube-HPC/fix-bugs-queue
fix show active to show all active , fix time zone
2 parents 4a72289 + 3a973a9 commit ae934d2

File tree

5 files changed

+56
-26
lines changed

5 files changed

+56
-26
lines changed

src/Routes/Base/Header/TagsFiltersViews.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Tag } from 'antd';
2-
import { instanceFiltersVar, metaVar } from 'cache';
2+
import { instanceFiltersVar, metaVar, isPinActiveJobVar } from 'cache';
33
import { useReactiveVar } from '@apollo/client';
44
import React, { useEffect } from 'react';
55
import PropTypes from 'prop-types';
@@ -10,6 +10,7 @@ import qs from 'qs';
1010

1111
const TagsFiltersViews = ({ sectionName }) => {
1212
const instanceFilters = useReactiveVar(instanceFiltersVar);
13+
const isPinActiveJobs = useReactiveVar(isPinActiveJobVar);
1314
const metaMode = useReactiveVar(metaVar);
1415

1516
const history = useHistory();
@@ -53,7 +54,15 @@ const TagsFiltersViews = ({ sectionName }) => {
5354
// },[])
5455

5556
useEffect(() => {
56-
const _qParams = qs.stringify(instanceFilters[sectionName], {
57+
// write query string params
58+
const paramsToUrl = { ...instanceFilters[sectionName] };
59+
60+
if (sectionName === 'jobs') {
61+
delete paramsToUrl.datesRange;
62+
isPinActiveJobs && delete paramsToUrl.pipelineStatus;
63+
}
64+
65+
const _qParams = qs.stringify(paramsToUrl, {
5766
ignoreQueryPrefix: true,
5867
allowDots: true,
5968
skipNulls: true,
@@ -70,6 +79,11 @@ const TagsFiltersViews = ({ sectionName }) => {
7079
}, [history, instanceFilters, sectionName, urlParams.pathname]);
7180

7281
const cancelPropFilter = ['datesRange', 'experimentName', 'limit'];
82+
83+
if (isPinActiveJobs) {
84+
cancelPropFilter.push('pipelineStatus');
85+
}
86+
7387
const allTags = [];
7488
propFilters &&
7589
Object.entries(propFilters).map(([key, value]) => {

src/Routes/Tables/Jobs/QueryTable/QueryForm.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import React, { useEffect, useMemo, useCallback } from 'react';
1+
import React, { useEffect, useMemo } from 'react';
22
import moment from 'moment';
33
import { Form, AutoComplete, Button } from 'antd';
44
import PropTypes from 'prop-types';
55
import { pipelineStatuses } from '@hkube/consts';
6-
import { useQuery } from '@apollo/client';
6+
import { useQuery, useReactiveVar } from '@apollo/client';
77
import { ALGORITHM_AND_PIPELINE_NAMES } from 'graphql/queries';
88
import { FiltersForms } from 'styles';
99
import { RangePickerNow } from 'components/common';
10+
import { isPinActiveJobVar } from 'cache';
1011

1112
const DateFormat = 'YYYY-MM-DD HH:mm';
1213
const QueryForm = ({ onSubmit, params, zoomDate }) => {
1314
const [form] = Form.useForm();
14-
15+
const isPinActiveJobs = useReactiveVar(isPinActiveJobVar);
1516
const SubmitForm = () => {
1617
// setLoadingJobs(true);
1718
form.submit();
@@ -54,19 +55,15 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
5455
onSubmit(values);
5556
};
5657

57-
const isShowActive = useCallback(
58-
() => form.getFieldValue('pipelineStatus') === 'active',
59-
[form]
60-
);
61-
6258
const onPinActive = () => {
63-
// isPinActiveJobVar(!isPinActiveJobs);
64-
65-
if (form.getFieldValue('pipelineStatus') === 'active') {
66-
form.setFieldsValue({ pipelineStatus: null });
67-
} else {
59+
if (!isPinActiveJobs) {
6860
form.setFieldsValue({ pipelineStatus: 'active' });
61+
} else {
62+
form.setFieldsValue({ pipelineStatus: null });
6963
}
64+
65+
isPinActiveJobVar(!isPinActiveJobs);
66+
7067
SubmitForm();
7168
};
7269

@@ -109,7 +106,7 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
109106
onFinish={onFinish}
110107
spacearound={1}>
111108
<Form.Item label="Time" name="time">
112-
<RangePickerNow onChange={SubmitForm} />
109+
<RangePickerNow isDisabled={isPinActiveJobs} onChange={SubmitForm} />
113110
</Form.Item>
114111
<Form.Item label="Pipeline Name" name="pipelineName">
115112
<AutoComplete
@@ -133,6 +130,7 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
133130
}
134131
onSelect={SubmitForm}
135132
onClear={SubmitForm}
133+
disabled={isPinActiveJobs}
136134
/>
137135
</Form.Item>
138136
<Form.Item label="Algorithm Name" name="algorithmName">
@@ -149,7 +147,7 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
149147
</Form.Item>
150148
<Form.Item>
151149
<Button
152-
type={isShowActive() ? 'primary' : 'dashed'}
150+
type={isPinActiveJobs ? 'primary' : 'dashed'}
153151
htmlType="button"
154152
onClick={onPinActive}
155153
title="Show Active">

src/Routes/Tables/Jobs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const JobsTable = () => {
3333
mergedParams,
3434
dataSourceGraph,
3535
debouncedZoomChanged,
36-
isGraphLoad,
36+
3737
isTableLoad,
3838
onRow,
3939
columns,
@@ -61,7 +61,7 @@ const JobsTable = () => {
6161

6262
<WTable
6363
id="jobsTable"
64-
loading={isTableLoad || isGraphLoad}
64+
loading={isTableLoad}
6565
onRow={onRow}
6666
rowKey={rowKey}
6767
expandIcon={false}

src/Routes/Tables/Jobs/useJobsFunctionsLimit.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
filterToggeledVar,
77
instanceFiltersVar,
88
metaVar,
9-
// isPinActiveJobVar,
9+
isPinActiveJobVar,
1010
} from 'cache';
1111
import { JOB_QUERY, JOB_QUERY_GRAPH } from 'graphql/queries';
1212

@@ -38,6 +38,8 @@ dateNow.setHours(-24);
3838
const useJobsFunctionsLimit = () => {
3939
const instanceFilters = useReactiveVar(instanceFiltersVar);
4040
const filterToggeled = useReactiveVar(filterToggeledVar);
41+
const isPinActiveJob = useReactiveVar(isPinActiveJobVar);
42+
4143
const metaMode = useReactiveVar(metaVar);
4244
const [dataSourceGraph, setDataSourceGraph] = useState([]);
4345
const [zoomedChangedDate, setZoomedChangedDate] = useState(Date.now());
@@ -94,7 +96,17 @@ const useJobsFunctionsLimit = () => {
9496
...mergedParams,
9597

9698
...(mergedParams?.datesRange?.from === null && {
97-
datesRange: { from: defDate, to: mergedParams?.datesRange?.to || null },
99+
datesRange: {
100+
from: defDate,
101+
to: mergedParams?.datesRange?.to || null,
102+
},
103+
}),
104+
105+
...(isPinActiveJob && {
106+
datesRange: {
107+
from: null,
108+
to: null,
109+
},
98110
}),
99111
},
100112

@@ -114,7 +126,10 @@ const useJobsFunctionsLimit = () => {
114126
limit: 100000,
115127
...mergedParams,
116128
...(mergedParams?.datesRange?.from === null && {
117-
datesRange: { from: defDate, to: mergedParams?.datesRange?.to || null },
129+
datesRange: {
130+
from: isPinActiveJob ? null : defDate,
131+
to: isPinActiveJob ? null : mergedParams?.datesRange?.to || null,
132+
},
118133
}),
119134
},
120135
onCompleted: resGraph => {
@@ -167,8 +182,8 @@ const useJobsFunctionsLimit = () => {
167182

168183
if (time) {
169184
datesRange = {
170-
from: getDateTimeZoneString(time?.datesRange?.from) || undefined,
171-
to: getDateTimeZoneString(time?.datesRange?.to) || undefined,
185+
from: time?.datesRange?.from || undefined,
186+
to: time?.datesRange?.to || undefined,
172187
};
173188
}
174189

src/components/common/RangePickerNow.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import moment from 'moment';
77
const DateFormat = 'YYYY-MM-DD HH:mm';
88
const dateNow = new Date();
99
dateNow.setHours(-24);
10-
const RangePickerNow = forwardRef(({ onChange, value }) => {
10+
const RangePickerNow = forwardRef(({ onChange, value, isDisabled }) => {
1111
const [stateDate, setStateDate] = useState(value);
1212

1313
const onChangeHandel = (momentDate, param) => {
@@ -68,6 +68,7 @@ const RangePickerNow = forwardRef(({ onChange, value }) => {
6868
onChange={valueDate => onChangeHandel(valueDate, 'from')}
6969
placeholder="Start Date"
7070
allowClear={false}
71+
disabled={isDisabled}
7172
/>
7273

7374
<ArrowRightOutlined style={{ padding: '2px', fontSize: '12px' }} />
@@ -80,6 +81,7 @@ const RangePickerNow = forwardRef(({ onChange, value }) => {
8081
placeholder="End Date"
8182
disabledDate={date => date.isBefore(stateDate?.datesRange?.from, 'day')}
8283
onChange={valueDate => onChangeHandel(valueDate, 'to')}
84+
disabled={isDisabled}
8385
/>
8486
</>
8587
);
@@ -93,7 +95,8 @@ RangePickerNow.propTypes = {
9395
PropTypes.string,
9496
PropTypes.node,
9597
]).isRequired,
98+
isDisabled: PropTypes.bool,
9699
};
97100

98-
RangePickerNow.defaultProps = {};
101+
RangePickerNow.defaultProps = { isDisabled: false };
99102
export default memo(RangePickerNow);

0 commit comments

Comments
 (0)