LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
Feat: Allowing users to be part of multiple organizations. (#125)
Rahul Johnya3c4ea940ee7
diff --git a/backend/account/authentication_controller.py b/backend/account/authentication_controller.pyindex 32415c0f7..629b992bf 100644--- a/backend/account/authentication_controller.py+++ b/backend/account/authentication_controller.py@@ -358,22 +358,15 @@ class AuthenticationController:)user_response = {}user_response["email"] = email- message: str = "User invitation successful"- if user:- # Already in organization- status = False- message = "User is already part of current organization."- else:- try:- self.auth_service.check_user_organization_association(- user_email=email- )- status = self.auth_service.invite_user(- admin_user, org_id, email, role=role- )- except Exception as exception:- status = False- message = exception.message # type: ignore+ status = False+ message = "User is already part of current organization"+ # Check if user is already part of current organization+ if not user:+ status = self.auth_service.invite_user(+ admin_user, org_id, email, role=role+ )+ message = "User invitation successful."+response.append(UserInviteResponse(email=email,diff --git a/frontend/src/components/navigations/top-nav-bar/TopNavBar.css b/frontend/src/components/navigations/top-nav-bar/TopNavBar.cssindex 9506f67a9..511f62628 100644--- a/frontend/src/components/navigations/top-nav-bar/TopNavBar.css+++ b/frontend/src/components/navigations/top-nav-bar/TopNavBar.css@@ -1,56 +1,60 @@/* Styles for TopNavBar */.top-navbar-dp {- height: 25px;- width: 25px;- display: flex;- align-items: center;- justify-content: center;- background-color: #184772;- border-radius: 5px;- cursor: pointer;+ height: 25px;+ width: 25px;+ display: flex;+ align-items: center;+ justify-content: center;+ background-color: #184772;+ border-radius: 5px;+ cursor: pointer;}.top-navbar-dp .navbar-img {- border-radius: 5px;+ border-radius: 5px;}.top-navbar-dp .initials {- font-size: 12px;- font-weight: bold;- color: white;+ font-size: 12px;+ font-weight: bold;+ color: white;}.topbar-logo {- width: 120px;- height: auto;- margin-inline-end: 12px;+ width: 120px;+ height: auto;+ margin-inline-end: 12px;}-.logout-button{- color: inherit;- background: inherit;- box-shadow: none;- text-align: left;- padding: 0;- height: auto;- border-radius: 0;- border-color: transparent;+.logout-button {+ color: inherit;+ background: inherit;+ box-shadow: none;+ text-align: left;+ padding: 0;+ height: auto;+ border-radius: 0;+ border-color: transparent;}-.logout-button:active{- color: inherit !important;- border-color: transparent !important;+.logout-button:active {+ color: inherit !important;+ border-color: transparent !important;}.top-nav-alert-col {- display: flex;- justify-content: center;+ display: flex;+ justify-content: center;}.top-nav-alert-col .top-nav-alert-msg {- margin-right: 6px;+ margin-right: 6px;}.top-nav-alert-col .top-nav-alert-link {- text-decoration: underline;-}\ No newline at end of file+ text-decoration: underline;+}++.switch-org-menu .ant-dropdown-menu-title-content .ant-space {+ display: block;+}diff --git a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsxindex cd73f53f3..76e9d2186 100644--- a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx+++ b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx@@ -11,7 +11,10 @@ import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate.js";import useLogout from "../../../hooks/useLogout.js";import "../../../layouts/page-layout/PageLayout.css";import { useSessionStore } from "../../../store/session-store.js";+import { useAlertStore } from "../../../store/alert-store";+import { ConfirmModal } from "../../widgets/confirm-modal/ConfirmModal.jsx";import "./TopNavBar.css";+import axios from "axios";let TrialDaysInfo;try {@@ -24,12 +27,14 @@ try {function TopNavBar() {const navigate = useNavigate();const { sessionDetails } = useSessionStore();- const { orgName, remainingTrialDays } = sessionDetails;+ const { orgName, remainingTrialDays, allOrganization, orgId } =+ sessionDetails;const baseUrl = getBaseUrl();const onBoardUrl = baseUrl + `/${orgName}/onboard`;const logout = useLogout();const axiosPrivate = useAxiosPrivate();const [showOnboardBanner, setShowOnboardBanner] = useState(false);+ const { setAlertDetails } = useAlertStore();useEffect(() => {getAdapters();@@ -55,6 +60,52 @@ function TopNavBar() {.finally(() => {});};+ const cascadeOptions = allOrganization.map((org) => {+ return {+ key: org.id,+ label:+ org.id === sessionDetails?.orgId ? (+ <div+ onClick={() =>+ setAlertDetails({+ type: "error",+ content: `You are already in ${org.display_name}`,+ })+ }+ >+ {org.display_name}+ </div>+ ) : (+ <ConfirmModal+ handleConfirm={() => handleContinue(org.id)}+ content={`Want to switch to ${org.display_name} `}+ >+ <div>{org.display_name}</div>+ </ConfirmModal>+ ),+ };+ });++ const handleContinue = async (selectedOrg) => {+ const requestOptions = {+ method: "GET",+ url: "/api/v1/organization",+ };+ const csrfToken = ("; " + document.cookie)+ .split(`; csrftoken=`)+ .pop()+ .split(";")[0];++ requestOptions.url = `/api/v1/organization/${selectedOrg}/set`;+ requestOptions.headers = {+ "X-CSRFToken": csrfToken,+ };+ requestOptions.method = "POST";++ await axios(requestOptions);+ window.location.reload();+ };+// Dropdown itemsconst items = [{@@ -76,6 +127,23 @@ function TopNavBar() {</Button>),},+ allOrganization.length > 1 && {+ key: "3",+ label: (+ <Dropdown+ placeholder="Switch Organization"+ menu={{+ items: cascadeOptions,+ selectable: true,+ selectedKeys: [orgId],+ className: "switch-org-menu",+ }}+ placement="left"+ >+ <div>Switch Org</div>+ </Dropdown>+ ),+ },];// Function to get the initials from the user namediff --git a/frontend/src/components/set-org/SetOrg.css b/frontend/src/components/set-org/SetOrg.cssnew file mode 100644index 000000000..202a924bf--- /dev/null+++ b/frontend/src/components/set-org/SetOrg.css@@ -0,0 +1,20 @@+.org-container {+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ height: 100vh;+}++.select-org {+ width: 320px;+ margin-bottom: 16px;+}++.continue-button {+ width: 320px;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ display: inline-block;+}diff --git a/frontend/src/components/set-org/SetOrg.jsx b/frontend/src/components/set-org/SetOrg.jsxnew file mode 100644index 000000000..fbc0e3daf--- /dev/null+++ b/frontend/src/components/set-org/SetOrg.jsx@@ -0,0 +1,74 @@+import { useEffect, useState } from "react";+import { Select, Button } from "antd";+import { useLocation, useNavigate } from "react-router-dom";+import "./SetOrg.css"; // Import your CSS file for styling+import axios from "axios";++function SetOrg() {+ const { state } = useLocation();+ const navigate = useNavigate();+ const [selectedOrg, setSelectedOrg] = useState(null);+ const signedInOrgId =+ document?.cookie+ ?.split("; ")+ ?.find((row) => row.startsWith("org_id="))+ ?.split("=")[1] || null;+ useEffect(() => {+ if (!state || signedInOrgId) {+ navigate("/");+ }+ }, []);++ const handleChange = (value) => {+ setSelectedOrg(value);+ };++ const handleContinue = async () => {+ const requestOptions = {+ method: "GET",+ url: "/api/v1/organization",+ };+ const csrfToken = ("; " + document.cookie)+ .split(`; csrftoken=`)+ .pop()+ .split(";")[0];++ requestOptions.url = `/api/v1/organization/${selectedOrg}/set`;+ requestOptions.headers = {+ "X-CSRFToken": csrfToken,+ };+ requestOptions.method = "POST";++ await axios(requestOptions);+ window.location.reload();+ };++ const options = state?.map((org) => {+ return {+ value: org.id,+ label: org.display_name,+ };+ });++ return (+ <div className="org-container">+ <Select+ className="select-org"+ placeholder="Please select an Organization"+ options={options}+ onChange={handleChange}+ value={selectedOrg}+ />+ <Button+ type="primary"+ className="continue-button"+ onClick={handleContinue}+ disabled={!selectedOrg}+ >+ Continue as {options?.find((org) => org.value === selectedOrg)?.label}+ </Button>+ </div>+ );+}++export { SetOrg };diff --git a/frontend/src/helpers/GetSessionData.js b/frontend/src/helpers/GetSessionData.jsindex 201ac02d2..8eb04f263 100644--- a/frontend/src/helpers/GetSessionData.js+++ b/frontend/src/helpers/GetSessionData.js@@ -21,6 +21,7 @@ function getSessionData(sessionData) {adapters: sessionData?.adapters,logEventsId: sessionData?.logEventsId,remainingTrialDays: sessionData?.remainingTrialDays,+ allOrganization: sessionData?.allOrganization,};}diff --git a/frontend/src/hooks/useSessionValid.js b/frontend/src/hooks/useSessionValid.jsindex 4fb477287..26e9d8953 100644--- a/frontend/src/hooks/useSessionValid.js+++ b/frontend/src/hooks/useSessionValid.js@@ -3,6 +3,7 @@ import axios from "axios";import { getSessionData } from "../helpers/GetSessionData";import { useSessionStore } from "../store/session-store";import { useExceptionHandler } from "../hooks/useExceptionHandler.jsx";+import { useNavigate } from "react-router-dom";let getTrialDetails;try {@@ -14,7 +15,14 @@ try {function useSessionValid() {const setSessionDetails = useSessionStore((state) => state.setSessionDetails);const handleException = useExceptionHandler();-+ const navigate = useNavigate();+ const signedInOrgId =+ (document.cookie &&+ document.cookie+ .split("; ")+ .find((row) => row.startsWith("org_id="))+ ?.split("=")[1]) ||+ null;return async () => {try {// API to get the list of organizations@@ -27,8 +35,12 @@ function useSessionValid() {if (!orgs?.length) {throw Error("Organizations not available.");}+ if (orgs?.length > 1 && !signedInOrgId?.length) {+ navigate("/setOrg", { state: orgs });+ return;+ }let userAndOrgDetails = null;- const orgId = orgs[0]?.id;+ const orgId = signedInOrgId || orgs[0].id;const csrfToken = ("; " + document.cookie).split(`; csrftoken=`).pop()@@ -84,6 +96,7 @@ function useSessionValid() {if (remainingTrialDays)userAndOrgDetails["remainingTrialDays"] = remainingTrialDays;}+ userAndOrgDetails["allOrganization"] = orgs;// Set the session detailssetSessionDetails(getSessionData(userAndOrgDetails));diff --git a/frontend/src/pages/SetOrgPage.jsx b/frontend/src/pages/SetOrgPage.jsxnew file mode 100644index 000000000..b12b46cab--- /dev/null+++ b/frontend/src/pages/SetOrgPage.jsx@@ -0,0 +1,7 @@+import { SetOrg } from "../components/set-org/SetOrg";++function SetOrgPage() {+ return <SetOrg />;+}++export { SetOrgPage };diff --git a/frontend/src/routes/Router.jsx b/frontend/src/routes/Router.jsxindex dd89fd34e..38c29edad 100644--- a/frontend/src/routes/Router.jsx+++ b/frontend/src/routes/Router.jsx@@ -28,6 +28,7 @@ import { ToolsSettingsPage } from "../pages/ToolsSettingsPage.jsx";import { UsersPage } from "../pages/UsersPage.jsx";import { WorkflowsPage } from "../pages/WorkflowsPage.jsx";import { OutputAnalyzerPage } from "../pages/OutputAnalyzerPage.jsx";+import { SetOrgPage } from "../pages/SetOrgPage.jsx";let TrialRoutes;try {@@ -47,6 +48,7 @@ function Router() {<Route path="landing" element={<LandingPage />} /></Route>{/* protected routes */}+ <Route path="setOrg" element={<SetOrgPage />} /><Route path="" element={<RequireAuth />}><Route path=":orgName" element={<FullPageLayout />}><Route path="onboard" element={<OnBoardPage />} />