feat: dual-engine charting - official exness mt5 webterminal, uncrowded minimalist toolbar, zero collision on laptop 1366x768 screens

This commit is contained in:
2026-10-23 01:05:40 +06:00
parent 64cb59eaae
commit 63b8489c35
3 changed files with 214 additions and 80 deletions
+2
View File
@@ -268,6 +268,8 @@ export default function TitanQuantTerminalPage() {
onOpenConnectModal={() => setShowConnectModal(true)}
isTheaterMode={workspaceMode === "focus"}
onToggleTheaterMode={() => setWorkspaceMode(workspaceMode === "focus" ? "pro" : "focus")}
exnessAccount={exnessAccount}
exnessServer={exnessServer}
/>
{/* Lower 4-Tab Analytical Cockpit Dock */}
@@ -2,17 +2,17 @@
import React, { useState, useRef, useEffect } from "react";
import { TradingViewAdvancedChart } from "./TradingViewAdvancedChart";
import { ExnessWebTerminalChart } from "./ExnessWebTerminalChart";
import { TimeframeSelector } from "./TimeframeSelector";
import {
Maximize2,
Minimize2,
KeyRound,
Sparkles,
ShieldCheck,
LineChart,
Server,
Columns,
Activity,
Layers,
Expand,
Shrink
Layers
} from "lucide-react";
import { soundFX } from "@/lib/soundEffects";
@@ -24,6 +24,8 @@ interface ChartStageContainerProps {
onOpenConnectModal: () => void;
isTheaterMode?: boolean;
onToggleTheaterMode?: () => void;
exnessAccount?: string;
exnessServer?: string;
}
export const ChartStageContainer: React.FC<ChartStageContainerProps> = ({
@@ -34,9 +36,12 @@ export const ChartStageContainer: React.FC<ChartStageContainerProps> = ({
onOpenConnectModal,
isTheaterMode = false,
onToggleTheaterMode,
exnessAccount = "425437997",
exnessServer = "Exness-MT5Real15",
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const [isFullscreen, setIsFullscreen] = useState(false);
const [engineMode, setEngineMode] = useState<"tradingview" | "exness" | "split">("tradingview");
useEffect(() => {
const handleFullscreenChange = () => {
@@ -66,6 +71,11 @@ export const ChartStageContainer: React.FC<ChartStageContainerProps> = ({
}
};
const handleSwitchEngine = (mode: "tradingview" | "exness" | "split") => {
soundFX.playClick();
setEngineMode(mode);
};
const bid = liveTick?.bid || 2735.40;
const ask = liveTick?.ask || 2735.54;
const spread = liveTick?.spread_pips || 1.4;
@@ -77,41 +87,73 @@ export const ChartStageContainer: React.FC<ChartStageContainerProps> = ({
isFullscreen ? "p-3 bg-[#04080f] fixed inset-0 z-50" : ""
}`}
>
{/* Top Chart Navigation Bar */}
<div className="bg-[#070d18] border border-[#14233d] rounded-xl px-3 py-2 flex items-center justify-between gap-3 shadow-lg select-none">
{/* Left: Symbol & Live Price */}
<div className="flex items-center gap-3">
<div>
<div className="flex items-center gap-2">
<span className="font-extrabold text-amber-400 text-sm font-mono tracking-wider">
{symbol}.PRO
{/* Streamlined Top Chart Toolbar - Minimalist, Non-Colliding Layout */}
<div className="bg-[#070d18] border border-[#14233d] rounded-xl px-3 py-1.5 flex items-center justify-between gap-2 shadow-lg select-none flex-nowrap overflow-x-auto no-scrollbar">
{/* Left: Symbol & Live Price Pill */}
<div className="flex items-center gap-2.5 shrink-0">
<div className="flex items-center gap-1.5">
<span className="font-extrabold text-amber-400 text-xs font-mono tracking-wider">
{symbol}
</span>
<span className="text-[10px] font-mono px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20 font-bold flex items-center gap-1">
<span className="text-[9px] font-mono px-1.5 py-0.2 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20 font-bold flex items-center gap-1">
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse" />
OANDA LIVE
LIVE
</span>
</div>
<div className="text-[10px] text-gray-400 font-mono flex items-center gap-2">
<div className="text-[10px] text-gray-400 font-mono flex items-center gap-1.5 hidden sm:flex">
<span>Bid: <strong className="text-gray-100">{bid.toFixed(2)}</strong></span>
<span>Ask: <strong className="text-gray-100">{ask.toFixed(2)}</strong></span>
<span className="text-emerald-400 font-bold">Sp: {spread}p</span>
</div>
</div>
<div className="h-6 w-px bg-[#14233d] hidden sm:block" />
{/* Center: Dual-Engine Chart Switcher Tabs */}
<div className="flex items-center p-0.5 rounded-lg bg-[#050914] border border-[#182e52] text-[11px] font-mono shrink-0">
<button
onClick={() => handleSwitchEngine("tradingview")}
className={`px-2 py-1 rounded-md flex items-center gap-1 transition ${
engineMode === "tradingview"
? "bg-gradient-to-r from-cyan-600 to-blue-600 text-white font-bold shadow-sm"
: "text-gray-400 hover:text-gray-200"
}`}
title="TradingView Advanced Chart with OANDA Real Feed"
>
<LineChart className="w-3 h-3 text-cyan-300" />
<span className="hidden md:inline">TradingView</span>
</button>
{/* Institutional Badge */}
<div className="hidden md:flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-[#050914] border border-[#14233d] text-xs font-mono">
<Activity className="w-3.5 h-3.5 text-cyan-400" />
<span className="text-gray-300 font-bold">TradingView Advanced</span>
<span className="text-[9px] px-1 rounded bg-cyan-950/80 text-cyan-300 border border-cyan-500/30">
SMART MONEY PRO
</span>
</div>
<button
onClick={() => handleSwitchEngine("exness")}
className={`px-2 py-1 rounded-md flex items-center gap-1 transition ${
engineMode === "exness"
? "bg-gradient-to-r from-amber-600 to-yellow-600 text-white font-bold shadow-sm"
: "text-gray-400 hover:text-gray-200"
}`}
title="Official Exness MT5 WebTerminal with Real Server Candles"
>
<Server className="w-3 h-3 text-amber-300" />
<span className="hidden md:inline">Exness MT5</span>
</button>
<button
onClick={() => handleSwitchEngine("split")}
className={`px-2 py-1 rounded-md flex items-center gap-1 transition ${
engineMode === "split"
? "bg-gradient-to-r from-emerald-600 to-teal-600 text-white font-bold shadow-sm"
: "text-gray-400 hover:text-gray-200"
}`}
title="Dual Split View: TradingView + Exness MT5"
>
<Columns className="w-3 h-3 text-emerald-300" />
<span className="hidden lg:inline">Split</span>
</button>
</div>
{/* Right: Timeframes, Fullscreen & Controls */}
<div className="flex items-center gap-2">
{/* Right: Timeframe Selector & Clean Fullscreen Button */}
<div className="flex items-center gap-1.5 shrink-0">
{engineMode !== "exness" && (
<TimeframeSelector
activeTimeframe={timeframe}
onSelect={(tf) => {
@@ -119,43 +161,15 @@ export const ChartStageContainer: React.FC<ChartStageContainerProps> = ({
onSelectTimeframe(tf);
}}
/>
{/* In-App Theater Mode Toggle */}
{onToggleTheaterMode && (
<button
onClick={() => {
soundFX.playClick();
onToggleTheaterMode();
}}
title={isTheaterMode ? "Exit Theater Mode (Restore Sidebars)" : "Enter Theater Mode (Expand Chart)"}
className={`p-1.5 rounded-lg border transition text-xs font-mono flex items-center gap-1 ${
isTheaterMode
? "bg-amber-950/40 border-amber-500/40 text-amber-300"
: "bg-[#0b172a] hover:bg-[#122240] border-[#182e52] text-gray-300"
}`}
>
{isTheaterMode ? <Shrink className="w-3.5 h-3.5" /> : <Expand className="w-3.5 h-3.5" />}
<span className="hidden lg:inline">{isTheaterMode ? "RESTORE" : "THEATER"}</span>
</button>
)}
{/* 1-Click Native Fullscreen Toggle */}
{/* Clean 1-Click Fullscreen Button (No text bloat, no wrapping) */}
<button
onClick={toggleFullscreen}
title={isFullscreen ? "Exit Fullscreen (ESC)" : "1-Click Fullscreen TradingView Chart"}
className="p-1.5 rounded-lg bg-gradient-to-r from-cyan-600/20 to-blue-600/20 hover:from-cyan-600/30 hover:to-blue-600/30 border border-cyan-500/40 text-cyan-300 transition text-xs font-mono flex items-center gap-1 shadow-sm"
title={isFullscreen ? "Exit Fullscreen (ESC)" : "Toggle 1-Click Fullscreen"}
className="p-1.5 rounded-lg bg-[#0b172a] hover:bg-[#122240] border border-[#182e52] text-cyan-300 transition text-xs font-mono flex items-center gap-1 shadow-sm active:scale-95"
>
{isFullscreen ? (
<>
<Minimize2 className="w-3.5 h-3.5" />
<span className="hidden sm:inline">EXIT FULLSCREEN</span>
</>
) : (
<>
<Maximize2 className="w-3.5 h-3.5" />
<span className="hidden sm:inline">FULLSCREEN</span>
</>
)}
{isFullscreen ? <Minimize2 className="w-3.5 h-3.5" /> : <Maximize2 className="w-3.5 h-3.5" />}
</button>
<button
@@ -163,22 +177,52 @@ export const ChartStageContainer: React.FC<ChartStageContainerProps> = ({
soundFX.playClick();
onOpenConnectModal();
}}
title="Exness MT5 Connection Settings"
className="hidden sm:flex bg-[#0b172a] hover:bg-[#122240] border border-[#182e52] text-gray-300 text-xs px-2.5 py-1.5 rounded-lg items-center gap-1.5 transition font-mono"
title="Link Exness MT5 Server"
className="hidden xl:flex bg-[#0b172a] hover:bg-[#122240] border border-[#182e52] text-gray-300 text-xs px-2 py-1.5 rounded-lg items-center gap-1 transition font-mono"
>
<KeyRound className="w-3.5 h-3.5 text-cyan-400" /> MT5
<KeyRound className="w-3 h-3 text-cyan-400" />
<span>MT5</span>
</button>
</div>
</div>
{/* Main TradingView Advanced Chart Canvas */}
{/* Main Chart Canvas Stage */}
<div className="flex-1 bg-[#070d18] border border-[#14233d] rounded-xl overflow-hidden min-h-[480px] shadow-xl relative">
{engineMode === "tradingview" && (
<TradingViewAdvancedChart
symbol={symbol}
timeframe={timeframe}
height="100%"
/>
)}
{engineMode === "exness" && (
<ExnessWebTerminalChart
accountId={exnessAccount}
server={exnessServer}
height="100%"
/>
)}
{engineMode === "split" && (
<div className="grid grid-cols-1 lg:grid-cols-2 gap-1.5 h-full w-full">
<div className="h-full border-r border-[#14233d]">
<TradingViewAdvancedChart
symbol={symbol}
timeframe={timeframe}
height="100%"
/>
</div>
<div className="h-full">
<ExnessWebTerminalChart
accountId={exnessAccount}
server={exnessServer}
height="100%"
/>
</div>
</div>
)}
</div>
</div>
);
};
@@ -0,0 +1,88 @@
"use client";
import React, { useState } from "react";
import { ExternalLink, ShieldCheck, RefreshCw, KeyRound, Server } from "lucide-react";
import { soundFX } from "@/lib/soundEffects";
interface ExnessWebTerminalChartProps {
accountId?: string;
server?: string;
height?: string | number;
}
export const ExnessWebTerminalChart: React.FC<ExnessWebTerminalChartProps> = ({
accountId = "425437997",
server = "Exness-MT5Real15",
height = "100%",
}) => {
const [iframeKey, setIframeKey] = useState(0);
const [isLoading, setIsLoading] = useState(true);
// Official MetaQuotes / Exness WebTerminal Embed URL
const terminalUrl = `https://metatraderweb.app/trade?servers=${server}&trade_server=${server}&login=${accountId}&startup_mode=open_account&lang=en&save_password=off`;
const handleRefresh = () => {
soundFX.playClick();
setIsLoading(true);
setIframeKey((prev) => prev + 1);
};
const handleOpenExternal = () => {
soundFX.playClick();
window.open(terminalUrl, "_blank", "noopener,noreferrer");
};
return (
<div className="flex flex-col h-full w-full bg-[#050914] rounded-xl overflow-hidden relative border border-[#14233d]">
{/* Exness Header Strip */}
<div className="bg-[#081224] border-b border-[#14233d] px-3 py-1.5 flex items-center justify-between text-xs font-mono select-none">
<div className="flex items-center gap-2">
<div className="w-2 h-2 rounded-full bg-amber-400 animate-pulse" />
<span className="font-bold text-amber-400 flex items-center gap-1 text-[11px]">
<Server className="w-3 h-3 text-amber-400" />
EXNESS MT5 REALTERMINAL
</span>
<span className="text-gray-400 text-[10px] hidden sm:inline">
&bull; Server: <strong className="text-gray-200">{server}</strong>
</span>
<span className="text-gray-400 text-[10px] hidden sm:inline">
&bull; Login: <strong className="text-cyan-300">#{accountId}</strong>
</span>
</div>
<div className="flex items-center gap-2">
<button
onClick={handleRefresh}
title="Reload Exness WebTerminal"
className="p-1 rounded bg-[#0b172a] hover:bg-[#122240] border border-[#182e52] text-gray-300 transition"
>
<RefreshCw className="w-3 h-3 text-cyan-400" />
</button>
<button
onClick={handleOpenExternal}
title="Open in full external window"
className="px-2 py-1 rounded bg-[#0b172a] hover:bg-[#122240] border border-[#182e52] text-gray-200 text-[10px] flex items-center gap-1 transition"
>
<ExternalLink className="w-2.5 h-2.5 text-amber-400" />
<span className="hidden sm:inline">POPUP</span>
</button>
</div>
</div>
{/* Embedded MetaQuotes MT5 WebTerminal */}
<div className="flex-1 w-full h-full relative">
<iframe
key={iframeKey}
src={terminalUrl}
title="Exness MT5 Real WebTerminal"
className="w-full h-full border-0"
style={{ minHeight: "450px" }}
allow="fullscreen; clipboard-write"
sandbox="allow-scripts allow-same-origin allow-popups allow-forms allow-modals"
onLoad={() => setIsLoading(false)}
/>
</div>
</div>
);
};