This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): calculate completed scans count correctly (#898)
* fix(scans-count): completed scans count * refactor(scans-count): create separate displays * refactor(scans-count): remove default export * refactor(scans-count): simplify logic * refactor(scans-count): simplify logic
- Loading branch information
1 parent
d479053
commit 7cbbc42
Showing
2 changed files
with
40 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,47 @@ | ||
import React from 'react'; | ||
import { useFetch } from 'hooks'; | ||
import { formatNumber } from 'utils/utils'; | ||
import React, {useMemo} from 'react'; | ||
import {useFetch} from 'hooks'; | ||
import {formatNumber} from 'utils/utils'; | ||
|
||
import COLORS from "../../../utils/scss_variables.module.scss"; | ||
import {APIS} from "../../../utils/systemConsts"; | ||
|
||
import './counter-display.scss'; | ||
|
||
const CounterDisplay = ({url, title, background}) => { | ||
export const ScanCounterDisplay = () => { | ||
const [{data, error, loading}] = useFetch( | ||
APIS.SCANS, | ||
{ | ||
queryParams: { | ||
"$count": true, | ||
"$top": 1, | ||
"$select": "id", | ||
"$filter": "state eq 'Aborted' or state eq 'Failed' or state eq 'Done'", | ||
} | ||
} | ||
); | ||
|
||
return ( | ||
<div className="dashboard-counter" style={{background: COLORS["color-gradient-green"]}}> | ||
{loading || error ? "" : | ||
<div className="dashboard-counter-content"> | ||
<div className="dashboard-counter-count">{formatNumber(data.count)}</div> | ||
Completed scans | ||
</div> | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
export const CounterDisplay = ({url, title, background}) => { | ||
const [{data, error, loading}] = useFetch(url, {queryParams: {"$count": true, "$top": 1, "$select": "id"}}); | ||
|
||
return ( | ||
<div className="dashboard-counter" style={{background}}> | ||
{loading || error ? "" : | ||
<div className="dashboard-counter-content"><div className="dashboard-counter-count">{formatNumber(data.count)}</div>{` ${title}`}</div> | ||
{loading || error ? "" : | ||
<div className="dashboard-counter-content"> | ||
<div className="dashboard-counter-count">{formatNumber(data.count)}</div> | ||
{` ${title}`}</div> | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
export default CounterDisplay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters