Skip to content

Commit

Permalink
HOSTSD-319 Fix Drive Space Loading (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fosol authored Mar 28, 2024
1 parent 0ee56d5 commit 70e69d2
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/dashboard/src/components/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { useDashboardFilter } from '.';
* @returns Component
*/
export const Dashboard = () => {
const { download, downloadHistory } = useApiServerItems();
const { download } = useApiServerItems();
const { isReady: isReadyTenants, tenants } = useTenants({ init: true });
const { isReady: isReadyOrganizations, organizations } = useOrganizations({
init: true,
Expand Down Expand Up @@ -198,7 +198,7 @@ export const Dashboard = () => {
dashboardOrganization,
dashboardOperatingSystemItem,
handleExport,
]
],
);

return (
Expand Down
6 changes: 3 additions & 3 deletions src/dashboard/src/hooks/filter/useFilteredFileSystemItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { IFileSystemItemFilter, IFileSystemItemModel, useApiFileSystemItems } fr

export const useFilteredFileSystemItems = () => {
const { find } = useApiFileSystemItems();
const isLoading = useFilteredStore((state) => state.loadingFileSystemItems);
const setIsLoading = useFilteredStore((state) => state.setLoadingFileSystemItems);
const fileSystemItems = useFilteredStore((state) => state.fileSystemItems);
const setFileSystemItems = useFilteredStore((state) => state.setFileSystemItems);

const [isLoading, setIsLoading] = React.useState(false);

const fetch = React.useCallback(
async (filter: IFileSystemItemFilter) => {
try {
Expand All @@ -23,7 +23,7 @@ export const useFilteredFileSystemItems = () => {
setIsLoading(false);
}
},
[find, setFileSystemItems],
[find, setFileSystemItems, setIsLoading],
);

return React.useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {

export const useFilteredOperatingSystemItems = () => {
const { findList } = useApiOperatingSystemItems();
const isLoading = useFilteredStore((state) => state.loadingOperatingSystemItems);
const setIsLoading = useFilteredStore((state) => state.setLoadingOperatingSystemItems);
const { operatingSystemItem } = useFilteredStore((state) => state.values);
const operatingSystemItems = useFilteredStore((state) => state.operatingSystemItems);
const setOperatingSystemItems = useFilteredStore((state) => state.setOperatingSystemItems);

const [isLoading, setIsLoading] = React.useState(false);

const fetch = React.useCallback(
async (filter: IOperatingSystemItemFilter) => {
try {
Expand All @@ -29,7 +29,7 @@ export const useFilteredOperatingSystemItems = () => {
setIsLoading(false);
}
},
[findList, setOperatingSystemItems],
[findList, setIsLoading, setOperatingSystemItems],
);

const options = React.useMemo(
Expand Down
6 changes: 3 additions & 3 deletions src/dashboard/src/hooks/filter/useFilteredOrganizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export interface IFilteredOrganizations {

export const useFilteredOrganizations = ({ includeDisabled }: IFilteredOrganizations = {}) => {
const { findList } = useApiOrganizations();
const isLoading = useFilteredStore((state) => state.loadingOrganizations);
const setIsLoading = useFilteredStore((state) => state.setLoadingOrganizations);
const organizations = useFilteredStore((state) => state.organizations);
const setOrganizations = useFilteredStore((state) => state.setOrganizations);

const [isLoading, setIsLoading] = React.useState(false);

const fetch = React.useCallback(
async (filter: IOrganizationFilter) => {
try {
Expand All @@ -29,7 +29,7 @@ export const useFilteredOrganizations = ({ includeDisabled }: IFilteredOrganizat
setIsLoading(false);
}
},
[findList, setOrganizations],
[findList, setIsLoading, setOrganizations],
);

const options = React.useMemo(
Expand Down
6 changes: 3 additions & 3 deletions src/dashboard/src/hooks/filter/useFilteredServerItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export interface IFilteredServerItemsProps {}

export const useFilteredServerItems = ({}: IFilteredServerItemsProps) => {
const { findList } = useApiServerItems();
const isLoading = useFilteredStore((state) => state.loadingServerItems);
const setIsLoading = useFilteredStore((state) => state.setLoadingServerItems);
const serverItems = useFilteredStore((state) => state.serverItems);
const setFilteredServerItems = useFilteredStore((state) => state.setServerItems);

const [isLoading, setIsLoading] = React.useState(false);

const fetch = React.useCallback(
async (filter: IServerItemFilter) => {
try {
Expand All @@ -26,7 +26,7 @@ export const useFilteredServerItems = ({}: IFilteredServerItemsProps) => {
setIsLoading(false);
}
},
[findList, setFilteredServerItems],
[findList, setFilteredServerItems, setIsLoading],
);

const options = React.useMemo(
Expand Down
6 changes: 3 additions & 3 deletions src/dashboard/src/hooks/filter/useFilteredTenants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export interface IFilteredTenants {

export const useFilteredTenants = ({ includeDisabled }: IFilteredTenants = {}) => {
const { findList } = useApiTenants();
const isLoading = useFilteredStore((state) => state.loadingTenants);
const setIsLoading = useFilteredStore((state) => state.setLoadingTenants);
const tenants = useFilteredStore((state) => state.tenants);
const setTenants = useFilteredStore((state) => state.setTenants);

const [isLoading, setIsLoading] = React.useState(false);

const fetch = React.useCallback(
async (filter: ITenantFilter) => {
try {
Expand All @@ -29,7 +29,7 @@ export const useFilteredTenants = ({ includeDisabled }: IFilteredTenants = {}) =
setIsLoading(false);
}
},
[findList, setTenants],
[findList, setIsLoading, setTenants],
);

const options = React.useMemo(
Expand Down
22 changes: 22 additions & 0 deletions src/dashboard/src/store/useFilteredStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,40 @@ export interface IFilteredStoreState {
setValues: (dispatch: (values: IFilterValues) => IFilterValues) => void;

// Tenants
loadingTenants: boolean;
setLoadingTenants: (value: boolean) => void;
tenantsReady?: boolean;
setTenantsReady: (value?: boolean) => void;
tenants: ITenantListModel[];
setTenants: (values: ITenantListModel[]) => void;

// Organizations
loadingOrganizations: boolean;
setLoadingOrganizations: (value: boolean) => void;
organizationsReady?: boolean;
setOrganizationsReady: (value?: boolean) => void;
organizations: IOrganizationListModel[];
setOrganizations: (values: IOrganizationListModel[]) => void;

// Operating System Items
loadingOperatingSystemItems: boolean;
setLoadingOperatingSystemItems: (value: boolean) => void;
operatingSystemItemsReady?: boolean;
setOperatingSystemItemsReady: (value?: boolean) => void;
operatingSystemItems: IOperatingSystemItemListModel[];
setOperatingSystemItems: (values: IOperatingSystemItemListModel[]) => void;

// Server Items
loadingServerItems: boolean;
setLoadingServerItems: (value: boolean) => void;
serverItemsReady?: boolean;
setServerItemsReady: (value?: boolean) => void;
serverItems: IServerItemListModel[];
setServerItems: (values: IServerItemListModel[]) => void;

// File System Items
loadingFileSystemItems: boolean;
setLoadingFileSystemItems: (value: boolean) => void;
fileSystemItemsReady?: boolean;
setFileSystemItemsReady: (value?: boolean) => void;
fileSystemItems: IFileSystemItemModel[];
Expand All @@ -63,27 +73,39 @@ export const useFilteredStore = create<IFilteredStoreState>((set, get) => ({
},

// Tenants
loadingTenants: false,
setLoadingTenants: (value) => set((state) => ({ ...state, loadingTenants: value })),
setTenantsReady: (value) => set((state) => ({ ...state, tenantsReady: value })),
tenants: [],
setTenants: (values) => set((state) => ({ ...state, tenants: values })),

// Organizations
loadingOrganizations: false,
setLoadingOrganizations: (value) => set((state) => ({ ...state, loadingOrganizations: value })),
setOrganizationsReady: (value) => set((state) => ({ ...state, organizationsReady: value })),
organizations: [],
setOrganizations: (values) => set((state) => ({ ...state, organizations: values })),

// Operating System Items
loadingOperatingSystemItems: false,
setLoadingOperatingSystemItems: (value) =>
set((state) => ({ ...state, loadingOperatingSystemItems: value })),
setOperatingSystemItemsReady: (value) =>
set((state) => ({ ...state, operatingSystemItemsReady: value })),
operatingSystemItems: [],
setOperatingSystemItems: (values) => set((state) => ({ ...state, operatingSystemItems: values })),

// Server Items
loadingServerItems: false,
setLoadingServerItems: (value) => set((state) => ({ ...state, loadingServerItems: value })),
setServerItemsReady: (value) => set((state) => ({ ...state, serverItemsReady: value })),
serverItems: [],
setServerItems: (values) => set((state) => ({ ...state, serverItems: values })),

// File System Items
loadingFileSystemItems: false,
setLoadingFileSystemItems: (value) =>
set((state) => ({ ...state, loadingFileSystemItems: value })),
setFileSystemItemsReady: (value) => set((state) => ({ ...state, fileSystemItemsReady: value })),
fileSystemItems: [],
setFileSystemItems: (values) => set((state) => ({ ...state, fileSystemItems: values })),
Expand Down

0 comments on commit 70e69d2

Please sign in to comment.