kopia lustrzana https://github.com/bugout-dev/moonstream
Apply requested fixes.
rodzic
9cb079a918
commit
c1a5d607c9
|
@ -40,7 +40,6 @@ const Analytics = () => {
|
|||
const router = useRouter();
|
||||
const overlay = useContext(OverlayContext);
|
||||
const { dashboardId } = router.params;
|
||||
const [refreshingStatus, setRefreshingStatus] = useState(false);
|
||||
const {
|
||||
dashboardCache,
|
||||
dashboardLinksCache,
|
||||
|
@ -89,13 +88,11 @@ const Analytics = () => {
|
|||
|
||||
const plotMinW = "250px";
|
||||
|
||||
const referesh_graf = function () {
|
||||
const referesh_charts = () => {
|
||||
refreshDashboard.mutate({
|
||||
dashboardId: dashboardCache.data.id,
|
||||
setStatus: setRefreshingStatus,
|
||||
timeRange: timeRange,
|
||||
});
|
||||
setRefreshingStatus(true);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -159,13 +156,15 @@ const Analytics = () => {
|
|||
icon={<BsGear />}
|
||||
/>
|
||||
<IconButton
|
||||
isLoading={refreshingStatus}
|
||||
isLoading={
|
||||
refreshDashboard.isLoading || refreshDashboard.isFetching
|
||||
}
|
||||
icon={<RepeatIcon />}
|
||||
variant="ghost"
|
||||
colorScheme="green"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
referesh_graf();
|
||||
referesh_charts();
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
|
@ -203,8 +202,6 @@ const Analytics = () => {
|
|||
presignedRequest={s3PresignedURLs[timeRange]}
|
||||
id={dashboardId}
|
||||
refetchLinks={dashboardLinksCache.refetch}
|
||||
refreshingStatus={refreshingStatus}
|
||||
setRefreshingStatus={setRefreshingStatus}
|
||||
/>
|
||||
</Flex>
|
||||
);
|
||||
|
|
|
@ -144,4 +144,4 @@ const SuggestABI = ({ subscriptionId, state }) => {
|
|||
|
||||
const ChakraSuggestABI = chakra(SuggestABI);
|
||||
|
||||
export default ChakraSuggestABI;
|
||||
export default ChakraSuggestABI;
|
||||
|
|
|
@ -27,7 +27,7 @@ const SubscriptionReport = ({
|
|||
refetchLinks,
|
||||
}) => {
|
||||
const { data, isLoading, failureCount, isFetching } = usePresignedURL({
|
||||
presignedRequest: presignedRequest,
|
||||
...presignedRequest,
|
||||
isEnabled: true,
|
||||
id: id,
|
||||
cacheType: `${timeRange} subscription_report`,
|
||||
|
@ -104,10 +104,11 @@ const SubscriptionReport = ({
|
|||
flexBasis={plotMinW}
|
||||
direction="column"
|
||||
>
|
||||
<Text
|
||||
fontSize="xs"
|
||||
textAlign="right"
|
||||
>{`Latest block number: ${data?.blocks_state.latest_labelled_block}`}</Text>
|
||||
<Text fontSize="xs" textAlign="right">{`Latest block number: ${
|
||||
data?.blocks_state?.latest_labelled_block != undefined
|
||||
? data?.blocks_state?.latest_labelled_block
|
||||
: "Not available"
|
||||
}`}</Text>
|
||||
<Flex
|
||||
bgColor="blue.50"
|
||||
direction={["column", "row", null]}
|
||||
|
|
|
@ -121,36 +121,31 @@ const useDashboard = (dashboardId) => {
|
|||
);
|
||||
|
||||
const refreshDashboard = useMutation(DashboardService.refreshDashboard, {
|
||||
onSuccess: (data, variables) => {
|
||||
let new_state = {};
|
||||
onSuccess: (data) => {
|
||||
let newData = {};
|
||||
|
||||
let current_links_state = queryClient.getQueryData([
|
||||
let oldData = queryClient.getQueryData([
|
||||
"dashboardLinks",
|
||||
{ dashboardId: dashboardId },
|
||||
]);
|
||||
|
||||
new_state = current_links_state;
|
||||
newData = oldData;
|
||||
|
||||
Object.keys(data.data).map((subscription) => {
|
||||
Object.keys(data.data[subscription]).map((timeScale) => {
|
||||
new_state.data[subscription][timeScale] =
|
||||
newData.data[subscription][timeScale] =
|
||||
data.data[subscription][timeScale];
|
||||
});
|
||||
});
|
||||
|
||||
queryClient.setQueryData(
|
||||
["dashboardLinks", { dashboardId: dashboardId }],
|
||||
new_state
|
||||
newData
|
||||
);
|
||||
variables.setStatus(false);
|
||||
},
|
||||
onError: (error, variables) => {
|
||||
variables.setStatus(false);
|
||||
onError: (error) => {
|
||||
toast(error.error, "error", "Fail");
|
||||
},
|
||||
onSettled: () => {
|
||||
dashboardsListCache.refetch();
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { useQuery, useQueryClient } from "react-query";
|
||||
import { useQuery } from "react-query";
|
||||
import { queryCacheProps } from "./hookCommon";
|
||||
import { useToast } from ".";
|
||||
import axios from "axios";
|
||||
|
||||
const usePresignedURL = ({
|
||||
presignedRequest,
|
||||
url,
|
||||
headers,
|
||||
cacheType,
|
||||
id,
|
||||
requestNewURLCallback,
|
||||
|
@ -15,16 +16,16 @@ const usePresignedURL = ({
|
|||
|
||||
const getFromPresignedURL = async () => {
|
||||
let request_parameters = {
|
||||
url: presignedRequest.url,
|
||||
url: url,
|
||||
// You can uncomment this to use mockupsLibrary in development
|
||||
// url: `https://example.com/s3`,
|
||||
headers: {},
|
||||
method: "GET",
|
||||
};
|
||||
|
||||
if ("headers" in presignedRequest) {
|
||||
Object.keys(presignedRequest.headers).map((key) => {
|
||||
request_parameters["headers"][key] = presignedRequest.headers[key];
|
||||
if (headers != undefined) {
|
||||
Object.keys(headers).map((key) => {
|
||||
request_parameters["headers"][key] = headers[key];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,8 +33,8 @@ const usePresignedURL = ({
|
|||
return response.data;
|
||||
};
|
||||
|
||||
const { data, isLoading, error, failureCount, refetch, isFetching } = useQuery(
|
||||
["presignedURL", cacheType, id, presignedRequest.url],
|
||||
const { data, isLoading, error, failureCount, isFetching } = useQuery(
|
||||
["presignedURL", cacheType, id, url],
|
||||
getFromPresignedURL,
|
||||
{
|
||||
...queryCacheProps,
|
||||
|
@ -41,7 +42,7 @@ const usePresignedURL = ({
|
|||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
staleTime: Infinity,
|
||||
enabled: isEnabled && presignedRequest.url ? true : false,
|
||||
enabled: isEnabled && url ? true : false,
|
||||
keepPreviousData: true,
|
||||
onSuccess: () => {},
|
||||
onError: (e) => {
|
||||
|
@ -51,6 +52,7 @@ const usePresignedURL = ({
|
|||
) {
|
||||
requestNewURLCallback();
|
||||
} else if (e?.response?.status === 304) {
|
||||
// If not modified.
|
||||
} else {
|
||||
!hideToastOn404 && toast(error, "error");
|
||||
}
|
||||
|
@ -63,8 +65,7 @@ const usePresignedURL = ({
|
|||
isLoading,
|
||||
error,
|
||||
failureCount,
|
||||
refetch,
|
||||
isFetching
|
||||
isFetching,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue