From 2b492f84d9bc08e433919641670cf2e0b1353f8e Mon Sep 17 00:00:00 2001 From: Piyush Kumar Date: Thu, 5 Sep 2024 13:53:14 +0530 Subject: [PATCH 1/2] removing get cluster from environment context --- .../console/page-components/app/compute.tsx | 66 +++++++++---------- .../$account+/env+/$environment+/_layout.tsx | 34 +++++----- .../$environment+/apps/apps-resources-v2.tsx | 18 +++-- .../external-apps/external-app-resource.tsx | 56 ++++++++-------- .../managed-resources-resource-v2.tsx | 16 ++--- .../$environment+/new-app/app-compute.tsx | 47 ++++++------- .../$environment+/routers/handle-router.tsx | 63 +++++++++--------- 7 files changed, 146 insertions(+), 154 deletions(-) diff --git a/src/apps/console/page-components/app/compute.tsx b/src/apps/console/page-components/app/compute.tsx index 28d17aae4..b415a4256 100644 --- a/src/apps/console/page-components/app/compute.tsx +++ b/src/apps/console/page-components/app/compute.tsx @@ -1,23 +1,17 @@ +import { useEffect, useState } from 'react'; +import { Button } from '~/components/atoms/button'; import { NumberInput } from '~/components/atoms/input'; +import Select from '~/components/atoms/select'; import Slider from '~/components/atoms/slider'; +import { BottomNavigation } from '~/console/components/commons'; +import ExtendedFilledTab from '~/console/components/extended-filled-tab'; import { useAppState } from '~/console/page-components/app-states'; -import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form'; -import Yup from '~/root/lib/server/helpers/yup'; import { FadeIn, parseValue } from '~/console/page-components/util'; -import Select from '~/components/atoms/select'; -import ExtendedFilledTab from '~/console/components/extended-filled-tab'; -import { parseName, parseNodes } from '~/console/server/r-utils/common'; -import useCustomSwr from '~/lib/client/hooks/use-custom-swr'; -import { useConsoleApi } from '~/console/server/gql/api-provider'; -import { useMapper } from '~/components/utils'; -import { BottomNavigation } from '~/console/components/commons'; -import { useOutletContext } from '@remix-run/react'; -import { useEffect, useState } from 'react'; -import { Button } from '~/components/atoms/button'; -import { IEnvironmentContext } from '~/console/routes/_main+/$account+/env+/$environment+/_layout'; +import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form'; import { useUnsavedChanges } from '~/root/lib/client/hooks/use-unsaved-changes'; -import { plans } from './datas'; +import Yup from '~/root/lib/server/helpers/yup'; import appInitialFormValues, { mapFormValuesToApp } from './app-utils'; +import { plans } from './datas'; const valueRender = ({ label, @@ -50,25 +44,25 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => { getReadOnlyContainer, getContainer, } = useAppState(); - const api = useConsoleApi(); - const { cluster } = useOutletContext(); + // const api = useConsoleApi(); + // const { cluster } = useOutletContext(); const [advancedOptions, setAdvancedOptions] = useState(false); const { performAction } = useUnsavedChanges(); - const { - data: nodepoolData, - isLoading: nodepoolLoading, - error: nodepoolLoadingError, - } = useCustomSwr('/nodepools', async () => { - return api.listNodePools({ - clusterName: parseName(cluster), - pagination: { - first: 100, - orderBy: 'updateTime', - sortDirection: 'DESC', - }, - }); - }); + // const { + // data: nodepoolData, + // isLoading: nodepoolLoading, + // error: nodepoolLoadingError, + // } = useCustomSwr('/nodepools', async () => { + // return api.listNodePools({ + // clusterName: parseName(cluster), + // pagination: { + // first: 100, + // orderBy: 'updateTime', + // sortDirection: 'DESC', + // }, + // }); + // }); const { values, errors, handleChange, isLoading, submit, resetValues } = useForm({ @@ -91,10 +85,10 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => { }, }); - const nodepools = useMapper(parseNodes(nodepoolData), (val) => ({ - label: val.metadata?.name || '', - value: val.metadata?.name || '', - })); + // const nodepools = useMapper(parseNodes(nodepoolData), (val) => ({ + // label: val.metadata?.name || '', + // value: val.metadata?.name || '', + // })); /** ---- Only for edit mode in settings ----* */ useEffect(() => { @@ -275,7 +269,7 @@ const AppCompute = ({ mode = 'new' }: { mode: 'edit' | 'new' }) => { }} /> - {advancedOptions && ( + {/* {advancedOptions && ( { loading={nodepoolLoading} showclear /> - )} + )} */} {advancedOptions && ( >; @@ -33,7 +32,7 @@ const Root = (props: IDialog) => { const { environment: envName } = useParams(); - const { cluster } = useOutletContext(); + // const { cluster } = useOutletContext(); const { data, @@ -44,7 +43,8 @@ const Root = (props: IDialog) => { search: { clusterName: { matchType: 'exact', - exact: parseName(cluster), + // exact: parseName(cluster), + exact: 'localhost', }, }, }); @@ -54,19 +54,19 @@ const Root = (props: IDialog) => { useForm({ initialValues: isUpdate ? { - name: parseName(props.data), - displayName: props.data.displayName, - domains: [], - isNameError: false, - isTlsEnabled: props.data.spec.https?.enabled || false, - } + name: parseName(props.data), + displayName: props.data.displayName, + domains: [], + isNameError: false, + isTlsEnabled: props.data.spec.https?.enabled || false, + } : { - name: '', - displayName: '', - domains: [], - isNameError: false, - isTlsEnabled: false, - }, + name: '', + displayName: '', + domains: [], + isNameError: false, + isTlsEnabled: false, + }, validationSchema: Yup.object({ displayName: Yup.string().required(), name: Yup.string().required(), @@ -83,7 +83,7 @@ const Root = (props: IDialog) => { if (!isUpdate) { const { errors: e } = await api.createRouter({ envName, - + router: { displayName: val.displayName, metadata: { @@ -104,7 +104,7 @@ const Root = (props: IDialog) => { } else { const { errors: e } = await api.updateRouter({ envName, - + router: { displayName: val.displayName, metadata: { @@ -142,8 +142,8 @@ const Root = (props: IDialog) => { domains, isUpdate ? props.data.spec.domains - .filter((d) => !domains.find((f) => f.value === d)) - .map((d) => ({ label: d, value: d })) + .filter((d) => !domains.find((f) => f.value === d)) + .map((d) => ({ label: d, value: d })) : [] ); @@ -216,7 +216,8 @@ const Root = (props: IDialog) => { All the domain CNames should be pointed to following Cluster DNS Name{' '} - `{cluster.spec.publicDNSHost}` + {/* `{cluster.spec.publicDNSHost}` */} + "localhost" } From 3f8d609e22627b6b623c63ad532b3f973500c212 Mon Sep 17 00:00:00 2001 From: Piyush Kumar Date: Mon, 9 Sep 2024 15:01:23 +0530 Subject: [PATCH 2/2] update webinar changes --- src/apps/auth/routes/_providers+/login.tsx | 7 +- src/apps/webinar/.env.development | 1 + src/apps/webinar/package.json | 2 +- .../webinar/src/app/api/get-user/route.ts | 37 ++++++++++ .../src/app/components/join-webinar.tsx | 21 +++--- src/apps/webinar/src/app/page.tsx | 68 ++++++++++++++----- .../webinar/src/app/pages/meeting/page.tsx | 13 +++- src/apps/webinar/tsconfig.json | 26 +++++-- 8 files changed, 139 insertions(+), 36 deletions(-) create mode 100644 src/apps/webinar/.env.development create mode 100644 src/apps/webinar/src/app/api/get-user/route.ts diff --git a/src/apps/auth/routes/_providers+/login.tsx b/src/apps/auth/routes/_providers+/login.tsx index aed8c8a23..2be699fd2 100644 --- a/src/apps/auth/routes/_providers+/login.tsx +++ b/src/apps/auth/routes/_providers+/login.tsx @@ -115,6 +115,10 @@ const Login = () => { const { githubLoginUrl, gitlabLoginUrl, googleLoginUrl } = useOutletContext(); const [searchParams, _setSearchParams] = useSearchParams(); + const callback = searchParams.get('callback'); + const loginUrl = callback + ? `/login?mode=email&callback=${callback}` + : `/login?mode=email`; return ( { variant="outline" content={Continue with email} prefix={} - to="/login/?mode=email" + // to="/login/?mode=email" + to={loginUrl} block linkComponent={Link} /> diff --git a/src/apps/webinar/.env.development b/src/apps/webinar/.env.development new file mode 100644 index 000000000..9eacca9a5 --- /dev/null +++ b/src/apps/webinar/.env.development @@ -0,0 +1 @@ +NEXT_PUBLIC_AUTH_URL="https://auth.dev.kloudlite.io" \ No newline at end of file diff --git a/src/apps/webinar/package.json b/src/apps/webinar/package.json index 9417b9b72..426a13500 100644 --- a/src/apps/webinar/package.json +++ b/src/apps/webinar/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev", + "dev": "next dev -p 4000", "build": "next build", "start": "next start", "lint": "next lint" diff --git a/src/apps/webinar/src/app/api/get-user/route.ts b/src/apps/webinar/src/app/api/get-user/route.ts new file mode 100644 index 000000000..6a852f0ec --- /dev/null +++ b/src/apps/webinar/src/app/api/get-user/route.ts @@ -0,0 +1,37 @@ +// import axios from 'axios'; +// import { cookies } from 'next/headers'; +// import { NextResponse } from 'next/server'; + +import { NextResponse } from "next/server"; + + +// // To handle a GET request to /api +// export async function GET(request) { +// // Do whatever you want +// const cookie = cookies().get("hotspot-session") +// console.log("cookies ++++++>>>>>>>>>>>>>>", +// cookies().get("hotspot-session"), "lkkk", cookie?.value); +// const res = await axios({ +// url: "https://auth1.dev.kloudlite.io/api", +// method: 'post', +// // withCredentials: true, +// data: { +// method: 'whoAmI', +// args: [{}], +// }, +// headers: { +// 'Content-Type': 'application/json; charset=utf-8', +// connection: 'keep-alive', +// cookie: 'hotspot-session=' + cookie?.value + ';', +// }, +// }); +// console.log("++++++>>>>>>>>>>>>>> response", res); +// return NextResponse.json(res.data); + +// } + +// To handle a POST request to /api +export async function POST() { + // Do whatever you want + return NextResponse.json({ message: "Hello World" }, { status: 200 }); +} \ No newline at end of file diff --git a/src/apps/webinar/src/app/components/join-webinar.tsx b/src/apps/webinar/src/app/components/join-webinar.tsx index 0826361a9..3e3ecb7cc 100644 --- a/src/apps/webinar/src/app/components/join-webinar.tsx +++ b/src/apps/webinar/src/app/components/join-webinar.tsx @@ -1,17 +1,18 @@ 'use client'; import { ArrowRightLg } from '@jengaicons/react'; +//@ts-ignore import { Button } from 'kl-design-system/atoms/button'; -import { useSearchParams } from 'next/navigation'; +type UesrData = { + id: string, + email: string, + verified: boolean, + name: string, + approved: boolean, +} -export const JoinWebinar = () => { +export const JoinWebinar = ({ userData }: { userData: UesrData }) => { - const params = useSearchParams(); - const userData = params.get('userData'); - const decodedUserData = atob(userData || ''); - const searchParams = new URLSearchParams(decodedUserData); - const name = searchParams.get('name'); - const email = searchParams.get('email'); return (
{ suffix={} block onClick={() => { - window.location.href = `/pages/meeting?email=${email}&name=${name}&meetingId=${process.env.NEXT_PUBLIC_DYTE_MEETING_ID}` + window.location.href = `/pages/meeting?email=${userData.email}&name=${userData.name}&meetingId=${process.env.NEXT_PUBLIC_DYTE_MEETING_ID}` }} />
) -} \ No newline at end of file +} diff --git a/src/apps/webinar/src/app/page.tsx b/src/apps/webinar/src/app/page.tsx index b2278f9a7..249959dc0 100644 --- a/src/apps/webinar/src/app/page.tsx +++ b/src/apps/webinar/src/app/page.tsx @@ -1,25 +1,59 @@ +import axios from 'axios'; +//@ts-ignore import { cn } from 'kl-design-system/utils'; +import { cookies } from 'next/headers'; +import { redirect } from "next/navigation"; import { JoinWebinar } from './components/join-webinar'; +// interface HomeProps { +// userData: UserData | null; // Adjust this based on whether userData can be null +// } -export default function Home() { - return ( -
-
-
-
-
-
- Join Kloudlite webinar -
-
- Join webinar and experience the power of Kloudlite +export default async function Home() { + + const cookie = cookies().get("hotspot-session") + const callbackUrl = "https://auth-piyush.dev.kloudlite.io"; + const redirectUrl = "https://auth.dev.kloudlite.io/login?callback=" + callbackUrl; + try { + const res = await axios({ + url: `${process.env.NEXT_PUBLIC_AUTH_URL}/api` || 'https://auth.kloudlite.io/api', + method: 'post', + data: { + method: 'whoAmI', + args: [{}], + }, + headers: { + 'Content-Type': 'application/json; charset=utf-8', + connection: 'keep-alive', + cookie: 'hotspot-session=' + cookie?.value + ';', + }, + }); + const data = res.data.data; + if (data) { + return ( +
+
+
+
+
+
+ Join Kloudlite webinar +
+
+ Join webinar and experience the power of Kloudlite +
+
+ + {data.email}
-
-
-
-
- ); + + ); + } + redirect(redirectUrl); + } catch (e) { + redirect(redirectUrl); + } + } diff --git a/src/apps/webinar/src/app/pages/meeting/page.tsx b/src/apps/webinar/src/app/pages/meeting/page.tsx index bbee146a8..42a4a5b80 100644 --- a/src/apps/webinar/src/app/pages/meeting/page.tsx +++ b/src/apps/webinar/src/app/pages/meeting/page.tsx @@ -2,10 +2,10 @@ import { DyteProvider, useDyteClient } from '@dytesdk/react-web-core'; import axios from 'axios'; import { useSearchParams } from 'next/navigation'; -import { useEffect, useState } from 'react'; +import { Suspense, useEffect, useState } from 'react'; import { MyMeetingUI } from '../../orgs/my-meeting-ui'; -export default function App() { +const Meeting = () => { const [meeting, initMeeting] = useDyteClient(); const [authToken, setAuthToken] = useState(''); @@ -66,4 +66,13 @@ export default function App() { ); +} + +export default function App() { + + return ( + + + + ); } \ No newline at end of file diff --git a/src/apps/webinar/tsconfig.json b/src/apps/webinar/tsconfig.json index 7b2858930..cf14c845f 100644 --- a/src/apps/webinar/tsconfig.json +++ b/src/apps/webinar/tsconfig.json @@ -1,6 +1,10 @@ { "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -18,9 +22,21 @@ } ], "paths": { - "@/*": ["./src/*"] + "@/*": [ + "./src/*" + ], + "~/root/*": [ + "./../../../*" + ] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file