Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

Feat/custom logo (#1254)

Athul505f0f8ae0ca
diff --git a/frontend/default.conf b/frontend/default.conf
new file mode 100644
index 000000000..832c082e4
--- /dev/null
+++ b/frontend/default.conf
@@ -0,0 +1,17 @@
+server {
+ listen 80;
+ server_name frontend.unstract.localhost;
+ root /usr/share/nginx/html;
+ index index.html;
+
+ # SPA routing - redirect all requests to index.html
+ location / {
+ try_files $uri $uri/ /index.html;
+ }
+
+ # Serve static files
+ location /static/ {
+ alias /usr/share/nginx/html/static/;
+ expires 30d;
+ }
+}
diff --git a/frontend/generate-runtime-config.sh b/frontend/generate-runtime-config.sh
new file mode 100755
index 000000000..b004dbc52
--- /dev/null
+++ b/frontend/generate-runtime-config.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# This script generates a runtime config file with environment variables
+# It will be executed when the container starts
+
+# Create config directory if it doesn't exist
+mkdir -p /usr/share/nginx/html/config
+
+# Generate the runtime-config.js file with the current environment variables
+cat > /usr/share/nginx/html/config/runtime-config.js << EOF
+// This file is auto-generated at runtime. Do not modify manually.
+window.RUNTIME_CONFIG = {
+ faviconPath: "${REACT_APP_FAVICON_PATH}",
+ logoUrl: "${REACT_APP_CUSTOM_LOGO_URL}"
+};
+EOF
+
+# Make sure nginx can read the file
+chmod 755 /usr/share/nginx/html/config/runtime-config.js
+
+echo "Runtime configuration generated successfully with logo URL: ${REACT_APP_CUSTOM_LOGO_URL:-<not set>}"
diff --git a/frontend/public/index.html b/frontend/public/index.html
index eea6f6464..881bd7301 100644
--- a/frontend/public/index.html
+++ b/frontend/public/index.html
@@ -2,15 +2,34 @@
<html lang="en">
<head>
<meta charset="utf-8" />
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Unstract" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Unstract</title>
+ <!-- Runtime configuration - loaded before app starts -->
+ <script src="/config/runtime-config.js"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
+ <script type="module">
+ // Set favicon dynamically based on configuration
+ import config from '../src/config.js';
+
+ // Create a new link element for the favicon
+ const faviconLink = document.createElement('link');
+ faviconLink.rel = 'icon';
+ faviconLink.type = 'image/svg+xml';
+ faviconLink.href = config.favicon;
+
+ // Replace any existing favicon or add if none exists
+ const existingFavicon = document.querySelector('link[rel="icon"]');
+ if (existingFavicon) {
+ document.head.removeChild(existingFavicon);
+ }
+ document.head.appendChild(faviconLink);
+
+ </script>
</body>
</html>
diff --git a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
index 5a566d086..f18376e16 100644
--- a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
+++ b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
@@ -3,10 +3,10 @@ import {
Button,
Col,
Dropdown,
- Image,
Row,
Space,
Typography,
+ Image,
} from "antd";
import {
UserOutlined,
@@ -35,6 +35,7 @@ import "./TopNavBar.css";
import { useAlertStore } from "../../../store/alert-store.js";
import { ConfirmModal } from "../../widgets/confirm-modal/ConfirmModal.jsx";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import config from "../../../config";
let TrialDaysInfo;
try {
@@ -69,6 +70,34 @@ try {
// Ignore if hook not available
}
+const CustomLogo = ({ onClick, className }) => {
+ // Use Ant Design Image and config.logoUrl
+ if (config.logoUrl) {
+ return (
+ <Image
+ src={config.logoUrl}
+ preview={false}
+ className={className}
+ onClick={onClick}
+ alt="logo"
+ style={{
+ cursor: onClick ? "pointer" : undefined,
+ background: "transparent",
+ }}
+ onError={() => {
+ // If image fails to load, component will re-render and use UnstractLogo
+ // since we'll set config.logoUrl to null
+ if (config.logoUrl) {
+ // Only modify if it's not already null to avoid infinite re-renders
+ config.logoUrl = null;
+ }
+ }}
+ />
+ );
+ }
+ return <UnstractLogo className={className} onClick={onClick} />;
+};
+
let unstractSubscriptionPlan;
let unstractSubscriptionPlanStore;
let UNSTRACT_SUBSCRIPTION_PLANS;
@@ -338,7 +367,7 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
<Row align="middle" className="topNav">
<Col span={6} className="platform-switch-container">
{isUnstract ? (
- <UnstractLogo
+ <CustomLogo
className="topbar-logo cursor-pointer"
onClick={() =>
navigate(`/${sessionDetails?.orgName}/${homePagePath}`)
@@ -413,4 +442,9 @@ TopNavBar.propTypes = {
topNavBarOptions: PropTypes.node,
};
+CustomLogo.propTypes = {
+ onClick: PropTypes.func.isRequired,
+ className: PropTypes.string.isRequired,
+};
+
export { TopNavBar };
diff --git a/frontend/src/config.js b/frontend/src/config.js
new file mode 100644
index 000000000..c89aec9c7
--- /dev/null
+++ b/frontend/src/config.js
@@ -0,0 +1,23 @@
+/**
+ * Application configuration
+ * This file centralizes all configuration values and provides defaults
+ * Configuration values are loaded from multiple sources with the following priority:
+ * 1. Runtime configuration (from window.RUNTIME_CONFIG) - for containerized environments
+ * 2. Environment variables (from import.meta.env) - for development
+ * 3. Default values - fallback
+ */
+
+// Check if runtime config is available (in containerized environments)
+const runtimeConfig =
+ typeof window !== "undefined" ? window.RUNTIME_CONFIG || {} : {};
+
+const config = {
+ favicon:
+ runtimeConfig.faviconPath ||
+ process.env.REACT_APP_FAVICON_PATH ||
+ "../public/favicon.ico",
+ logoUrl: runtimeConfig.logoUrl || process.env.REACT_APP_CUSTOM_LOGO_URL,
+ // Add more values as OR case, if needed for fallback.
+};
+
+export default config;