Skip to content

Commit

Permalink
Merge pull request #73 from sinamics/dev
Browse files Browse the repository at this point in the history
Merge dev branch
  • Loading branch information
sinamics authored Jul 31, 2023
2 parents 0054ddf + d14c81e commit b6f962f
Show file tree
Hide file tree
Showing 8 changed files with 496 additions and 29 deletions.
433 changes: 432 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"react-dom": "18.2.0",
"react-hot-toast": "^2.4.0",
"react-timeago": "^7.1.0",
"sharp": "^0.32.4",
"superjson": "1.9.1",
"unique-names-generator": "^4.7.1",
"usehooks-ts": "^2.9.1",
Expand Down
9 changes: 3 additions & 6 deletions src/components/elements/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ const Modal = () => {
toggleModal();
};
const modalClass = cn({
"modal modal-bottom sm:modal-middle z-20 ": true,
"modal transition-none z-20": true,
"modal-open": isOpen,
});

return (
// we add modal-bottom and modal-middle classes to make it responsive
//add modal-open for now to test the modal
<div className={modalClass}>
{/* we want any content for this modal layout so we just pass the children */}
<dialog className={modalClass}>
<div
className={cn(
"custom-scrollbar modal-box relative bg-base-100",
Expand Down Expand Up @@ -67,7 +64,7 @@ const Modal = () => {
)}
</div>
</div>
</div>
</dialog>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/modules/inviteMemberbyMail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const InviteMemberByMail = () => {
{loadingInvite ? (
<span className="loading loading-spinner"></span>
) : (
<span>{t("inviteMemberByMail.buttonText")}</span>
<>{t("inviteMemberByMail.buttonText")}</>
)}
</button>
</label>
Expand Down
51 changes: 41 additions & 10 deletions src/components/modules/networkIpAssignments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,10 @@ export const NetworkIpAssignment = () => {
{network.autoAssignIp && ipTabs.easy ? (
<div>
<div
className={cn(
"xs:grid-cols-4 grid cursor-pointer grid-cols-3 gap-2 sm:grid-cols-3 md:grid-cols-4",
{
"pointer-events-none cursor-no-drop text-gray-500 opacity-25":
!network.autoAssignIp,
}
)}
className={cn("flex cursor-pointer flex-wrap", {
"pointer-events-none cursor-no-drop text-gray-500 opacity-25":
!network.autoAssignIp,
})}
>
{network.cidr?.map((cidr: string) => {
return network?.routes?.some(
Expand All @@ -182,7 +179,7 @@ export const NetworkIpAssignment = () => {
<div
key={cidr}
className={cn(
"badge badge-ghost badge-outline badge-lg rounded-md text-xs opacity-30 md:text-base",
"badge badge-ghost badge-outline badge-lg m-1 rounded-md text-xs opacity-30 md:text-base",
{
"badge badge-lg rounded-md bg-primary text-xs text-white opacity-70 md:text-base":
network.autoAssignIp,
Expand All @@ -196,7 +193,7 @@ export const NetworkIpAssignment = () => {
key={cidr}
onClick={() => submitUpdate({ ipPool: cidr })}
className={cn(
"badge badge-ghost badge-outline badge-lg rounded-md text-xs opacity-30 md:text-base",
"badge badge-ghost badge-outline badge-lg m-1 rounded-md text-xs opacity-30 md:text-base",
{ "hover:bg-primary": network.autoAssignIp }
)}
>
Expand All @@ -206,7 +203,41 @@ export const NetworkIpAssignment = () => {
})}
</div>
</div>
) : null}
) : // <div
// className={cn("flex cursor-pointer flex-wrap", {
// "pointer-events-none cursor-no-drop text-gray-500 opacity-25":
// !network.autoAssignIp,
// })}
// >
// {network.cidr?.map((cidr: string) => {
// return network?.routes?.some((route) => route.target === cidr) ? (
// <div
// key={cidr}
// className={cn(
// "badge badge-ghost badge-outline badge-lg m-1 rounded-md text-xs sm:m-2 md:text-base",
// {
// "badge badge-lg rounded-md bg-primary text-xs text-white opacity-70 md:text-base":
// network.autoAssignIp,
// }
// )}
// >
// {cidr}
// </div>
// ) : (
// <div
// key={cidr}
// onClick={() => submitUpdate({ ipPool: cidr })}
// className={cn(
// "badge badge-ghost badge-outline badge-lg m-1 rounded-md text-xs sm:m-2 md:text-base",
// { "hover:bg-primary": network.autoAssignIp }
// )}
// >
// {cidr}
// </div>
// );
// })}
// </div>
null}
{network.autoAssignIp && ipTabs.advanced ? (
<div className="mt-4 space-y-2">
{network?.ipAssignmentPools.map((pool) => {
Expand Down
13 changes: 9 additions & 4 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
type NextPage,
type GetServerSideProps,
type GetServerSidePropsResult,
type GetServerSidePropsContext,
} from "next";
import Head from "next/head";
Expand Down Expand Up @@ -100,14 +99,20 @@ interface Props {

export const getServerSideProps: GetServerSideProps<Props> = async (
context: GetServerSidePropsContext
): Promise<GetServerSidePropsResult<Props>> => {
) => {
const session = await getSession(context);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const messages = (await import(`~/locales/${context.locale}/common.json`))
.default;

if (!session || !("user" in session)) {
return { props: {} };
// eslint-disable-next-line
return { props: { messages } };
}

return {
props: { auth: session.user },
// eslint-disable-next-line
props: { auth: session.user, messages },

};
};
15 changes: 9 additions & 6 deletions src/pages/network/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const NetworkById = () => {
<NetworkPrivatePublic />
</div>
<div className="w-5/5 mx-auto flex px-4 text-sm sm:w-4/5 sm:px-10 md:text-base">
<div className="flex flex-col justify-between sm:flex-row sm:space-x-3">
<div className="flex flex-col justify-between lg:flex-row space-y-3 lg:space-y-0 lg:space-x-3 whitespace-nowrap">
<div>
<span className="text-muted font-medium">{t("networkStart")}</span>{" "}
<span
Expand Down Expand Up @@ -271,7 +271,7 @@ const NetworkById = () => {
<div className="w-5/5 divider mx-auto flex px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base">
{t("networkSettings")}
</div>
<div className="w-5/5 mx-auto grid grid-cols-1 px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base xl:flex">
<div className="w-5/5 mx-auto grid grid-cols-1 space-y-3 px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base xl:flex xl:space-y-0">
{/* Ipv4 assignment */}
<div className="w-6/6 xl:w-3/6">
<NetworkIpAssignment />
Expand All @@ -284,7 +284,7 @@ const NetworkById = () => {
<NettworkRoutes />
</div>
</div>
<div className="w-5/5 mx-auto grid grid-cols-1 px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base xl:flex">
<div className="w-5/5 mx-auto grid grid-cols-1 space-y-3 px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base xl:flex xl:space-y-0">
{/* Ipv4 assignment */}
<div className="w-6/6 xl:w-3/6">
<NetworkDns />
Expand Down Expand Up @@ -329,9 +329,12 @@ const NetworkById = () => {
</div>
)}
</div>
<div className="w-5/5 mx-auto flex space-x-5 px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base">
<InviteMemberByMail />
<AddMemberById />
<div className="w-5/5 mx-auto grid grid-cols-1 space-y-3 px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base xl:flex xl:space-y-0">
{/* Ipv4 assignment */}
<div className="flex w-full flex-wrap space-x-0 space-y-5 xl:space-x-5 xl:space-y-0">
<InviteMemberByMail />
<AddMemberById />
</div>
</div>
<div className="w-5/5 mx-auto w-full px-4 py-4 text-sm sm:w-4/5 sm:px-10 md:text-base">
<div className="mb-4 md:mb-0">
Expand Down
1 change: 0 additions & 1 deletion src/utils/ztApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

import fs from "fs";
import axios, { type AxiosError, type AxiosResponse } from "axios";
import { type NetworkAndMembers } from "~/types/network";
Expand Down

0 comments on commit b6f962f

Please sign in to comment.