Skip to content

Commit

Permalink
Updated npm packages (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fosol authored May 30, 2024
1 parent c2944e0 commit 30bc2ba
Show file tree
Hide file tree
Showing 10 changed files with 1,668 additions and 1,070 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# review when someone opens a pull request.

- @Fosol @wkaspryk
- @Fosol

# Order is important; the last matching pattern takes the most

Expand Down
2,161 changes: 1,360 additions & 801 deletions src/dashboard/package-lock.json

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions src/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@
},
"dependencies": {
"@react-icons/all-files": "^4.1.0",
"@types/lodash": "^4.14.202",
"@types/lodash": "^4.17.4",
"@uidotdev/usehooks": "^2.4.1",
"axios": "^1.6.2",
"chart.js": "^4.4.1",
"axios": "^1.7.2",
"chart.js": "^4.4.3",
"classnames": "^2.5.1",
"cryptr": "^6.3.0",
"jsonwebtoken": "^9.0.2",
"jwk-to-pem": "^2.0.5",
"jws": "^4.0.0",
"jwt-decode": "^4.0.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"next": "14.0.4",
"next-auth": "^4.24.5",
"qs": "^6.11.2",
"react": "^18.2.0",
"moment": "^2.30.1",
"next": "14.2.3",
"next-auth": "^4.24.7",
"qs": "^6.12.1",
"react": "^18.3.1",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.12.0",
"react-toastify": "^10.0.4",
"sharp": "^0.33.0",
"zustand": "^4.4.7"
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"react-toastify": "^10.0.5",
"sharp": "^0.33.4",
"zustand": "^4.5.2"
},
"devDependencies": {
"@types/chart.js": "^2.9.41",
"@types/jsonwebtoken": "^9.0.5",
"@types/jsonwebtoken": "^9.0.6",
"@types/jwk-to-pem": "^2.0.3",
"@types/jws": "^3.2.9",
"@types/node": "^20.10.4",
"@types/qs": "^6.9.10",
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@types/jws": "^3.2.10",
"@types/node": "^20.12.13",
"@types/qs": "^6.9.15",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-icons": "^3.0.0",
"autoprefixer": "^10.4.16",
"autoprefixer": "^10.4.19",
"eslint": "^8.55.0",
"eslint-config-next": "14.0.4",
"postcss": "^8.4.32",
"sass": "^1.69.5",
"tailwindcss": "^3.3.6",
"typescript": "^5.3.3"
"eslint-config-next": "14.2.3",
"postcss": "^8.4.38",
"sass": "^1.77.3",
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5"
}
}
99 changes: 99 additions & 0 deletions src/dashboard/src/app/client/servers/ServerDashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
'use client';

import { AllocationTable, useDashboardFilter } from '@/components';
import { useApiServerItems } from '@/hooks';
import {
useOperatingSystemItems,
useOrganizations,
useServerItems,
useTenants,
} from '@/hooks/lists';
import { useFilteredStore } from '@/store';
import { useRouter } from 'next/navigation';
import { toast } from 'react-toastify';

export default function ServerDashboard() {
const router = useRouter();
const { tenants } = useTenants({ init: true });
const { organizations } = useOrganizations({
init: true,
includeTenants: true,
});
const { operatingSystemItems } = useOperatingSystemItems({
init: true,
});
const { isReady, serverItems } = useServerItems({ init: true });
const setFilteredValues = useFilteredStore((state) => state.setValues);
const setFilteredOrganizations = useFilteredStore((state) => state.setOrganizations);
const setFilteredServerItems = useFilteredStore((state) => state.setServerItems);
const { download } = useApiServerItems();

const updateDashboard = useDashboardFilter();

return (
<AllocationTable
margin={-75}
serverItems={serverItems}
loading={!isReady}
onClick={async (serverItem) => {
if (serverItem) {
const tenant = tenants.find((tenant) => tenant.id === serverItem?.tenantId);
const organization = organizations.find(
(organization) => organization.id === serverItem?.organizationId,
);
const operatingSystemItem = operatingSystemItems.find(
(operatingSystemItem) => operatingSystemItem.id === serverItem?.operatingSystemItemId,
);
const filteredOrganizations = tenant
? organizations.filter((o) => o.tenants?.some((t) => t.id === tenant?.id))
: organizations;
const filteredServerItems = serverItems.filter(
(si) =>
(!tenant || si.tenantId === tenant.id) &&
(!organization || si.organizationId === organization.id) &&
(!operatingSystemItem || si.operatingSystemItemId === operatingSystemItem.id),
);
setFilteredOrganizations(filteredOrganizations);
setFilteredServerItems(filteredServerItems);
setFilteredValues((state) => ({
serverItem,
tenant,
organization,
operatingSystemItem,
}));
await updateDashboard({
tenant,
tenants,
organization,
organizations: filteredOrganizations,
operatingSystemItem,
operatingSystemItems,
serverItem,
serverItems: filteredServerItems,
fetchFileSystemItems: false,
});
router.push(`/client/dashboard?serverItem=${serverItem?.serviceNowKey}`);
}
}}
showExport
onExport={async (search) => {
const toastLoading = toast.loading('Generating Excel document...');

try {
await download({
search: search ? search : undefined,
});

toast.dismiss(toastLoading);
toast.success('Excel document has been downloaded successfully.');
} catch (ex) {
toast.dismiss(toastLoading);

const error = ex as Error;
toast.error('Failed to download data. ' + error.message);
console.error(error);
}
}}
/>
);
}
94 changes: 7 additions & 87 deletions src/dashboard/src/app/client/servers/page.tsx
Original file line number Diff line number Diff line change
@@ -1,101 +1,21 @@
'use client';

import { AllocationTable, useDashboardFilter } from '@/components';
import { LoadingAnimation } from '@/components/loadingAnimation';
import { useApiServerItems, useAuth } from '@/hooks';
import {
useOperatingSystemItems,
useOrganizations,
useServerItems,
useTenants,
} from '@/hooks/lists';
import { useFilteredStore } from '@/store';
import { redirect, useRouter } from 'next/navigation';
import { toast } from 'react-toastify';
import { useAuth } from '@/hooks';
import { redirect } from 'next/navigation';
import { Suspense } from 'react';
import ServerDashboard from './ServerDashboard';

export default function Page() {
const router = useRouter();
const state = useAuth();
const { tenants } = useTenants({ init: true });
const { organizations } = useOrganizations({
init: true,
includeTenants: true,
});
const { operatingSystemItems } = useOperatingSystemItems({
init: true,
});
const { isReady, serverItems } = useServerItems({ init: true });
const setFilteredValues = useFilteredStore((state) => state.setValues);
const setFilteredOrganizations = useFilteredStore((state) => state.setOrganizations);
const setFilteredServerItems = useFilteredStore((state) => state.setServerItems);
const { download } = useApiServerItems();

const updateDashboard = useDashboardFilter();

// Only allow Client role to view this page.
if (state.status === 'loading') return <LoadingAnimation />;
if (!state.isClient) redirect('/');

return (
<AllocationTable
margin={-75}
serverItems={serverItems}
loading={!isReady}
onClick={async (serverItem) => {
if (serverItem) {
const tenant = tenants.find((tenant) => tenant.id === serverItem?.tenantId);
const organization = organizations.find(
(organization) => organization.id === serverItem?.organizationId,
);
const operatingSystemItem = operatingSystemItems.find(
(operatingSystemItem) => operatingSystemItem.id === serverItem?.operatingSystemItemId,
);
const filteredOrganizations = tenant
? organizations.filter((o) => o.tenants?.some((t) => t.id === tenant?.id))
: organizations;
const filteredServerItems = serverItems.filter(
(si) =>
(!tenant || si.tenantId === tenant.id) &&
(!organization || si.organizationId === organization.id) &&
(!operatingSystemItem || si.operatingSystemItemId === operatingSystemItem.id),
);
setFilteredOrganizations(filteredOrganizations);
setFilteredServerItems(filteredServerItems);
setFilteredValues((state) => ({ serverItem, tenant, organization, operatingSystemItem }));
await updateDashboard({
tenant,
tenants,
organization,
organizations: filteredOrganizations,
operatingSystemItem,
operatingSystemItems,
serverItem,
serverItems: filteredServerItems,
fetchFileSystemItems: false,
});
router.push(`/client/dashboard?serverItem=${serverItem?.serviceNowKey}`);
}
}}
showExport
onExport={async (search) => {
const toastLoading = toast.loading("Generating Excel document...");

try {
await download({
search: search ? search : undefined,
});

toast.dismiss(toastLoading);
toast.success('Excel document has been downloaded successfully.');

} catch (ex) {
toast.dismiss(toastLoading);

const error = ex as Error;
toast.error('Failed to download data. ' + error.message);
console.error(error);
}
}}
/>
<Suspense fallback={<LoadingAnimation />}>
<ServerDashboard />
</Suspense>
);
}
94 changes: 94 additions & 0 deletions src/dashboard/src/app/hsb/servers/ServerDashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
'use client';

import { AllocationTable, useDashboardFilter } from '@/components';
import { useApiServerItems } from '@/hooks';
import {
useOperatingSystemItems,
useOrganizations,
useServerItems,
useTenants,
} from '@/hooks/lists';
import { useFilteredStore } from '@/store';
import { useRouter } from 'next/navigation';
import { toast } from 'react-toastify';

export default function ServerDashboard() {
const router = useRouter();
const { tenants } = useTenants({ init: true });
const { organizations } = useOrganizations({
init: true,
includeTenants: true,
});
const { operatingSystemItems } = useOperatingSystemItems({
init: true,
});
const { isReady, serverItems } = useServerItems({ init: true });
const setFilteredValues = useFilteredStore((state) => state.setValues);
const setFilteredOrganizations = useFilteredStore((state) => state.setOrganizations);
const setFilteredServerItems = useFilteredStore((state) => state.setServerItems);
const { download } = useApiServerItems();

const updateDashboard = useDashboardFilter();

return (
<AllocationTable
margin={-75}
serverItems={serverItems}
loading={!isReady}
onClick={async (serverItem) => {
if (serverItem) {
const tenant = tenants.find((tenant) => tenant.id === serverItem?.tenantId);
const organization = organizations.find(
(organization) => organization.id === serverItem?.organizationId,
);
const operatingSystemItem = operatingSystemItems.find(
(operatingSystemItem) => operatingSystemItem.id === serverItem?.operatingSystemItemId,
);
const filteredOrganizations = tenant
? organizations.filter((o) => o.tenants?.some((t) => t.id === tenant?.id))
: organizations;
const filteredServerItems = serverItems.filter(
(si) =>
(!tenant || si.tenantId === tenant.id) &&
(!organization || si.organizationId === organization.id) &&
(!operatingSystemItem || si.operatingSystemItemId === operatingSystemItem.id),
);
setFilteredOrganizations(filteredOrganizations);
setFilteredServerItems(filteredServerItems);
setFilteredValues((state) => ({ serverItem, tenant, organization, operatingSystemItem }));
await updateDashboard({
tenant,
tenants,
organization,
organizations: filteredOrganizations,
operatingSystemItem,
operatingSystemItems,
serverItem,
serverItems: filteredServerItems,
fetchFileSystemItems: false,
});
router.push(`/hsb/dashboard?serverItem=${serverItem?.serviceNowKey}`);
}
}}
showExport
onExport={async (search) => {
const toastLoading = toast.loading('Generating Excel document...');

try {
await download({
search: search ? search : undefined,
});

toast.dismiss(toastLoading);
toast.success('Excel document has been downloaded successfully.');
} catch (ex) {
toast.dismiss(toastLoading);

const error = ex as Error;
toast.error('Failed to download data. ' + error.message);
console.error(error);
}
}}
/>
);
}
Loading

0 comments on commit 30bc2ba

Please sign in to comment.