Compare commits

..

No commits in common. "ddaf7638ace7b5512f730c306f41a6bf2f3584f1" and "289ff78b60a61eba9285be10e66182cfec6fba43" have entirely different histories.

10 changed files with 199 additions and 230 deletions

View file

@ -1,37 +1,23 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
// Define the available model options const Models: React.FC = () => {
const offlineModels = [ const modelOptions = [
'Offline Fast', 'Offline Fast',
'Offline Fast (FOSS)', 'Offline Fast (FOSS)',
'Offline Slow', 'Offline Slow',
'Offline Slow (FOSS)', 'Offline Slow (FOSS)',
]; 'Online (La Plateforme)',
'Online (FOSS) (La Plateforme)',
'Online Cheap (OpenAI)',
'Online Expensive (OpenAI)',
'Online Cheap (Anthropic)',
'Online Expensive (Anthropic)',
'Online Cheap (Google)',
'Online Expensive (Google)',
];
const onlineModels = [
'Online (La Plateforme)',
'Online (FOSS) (La Plateforme)',
'Online Cheap (OpenAI)',
'Online Expensive (OpenAI)',
'Online Cheap (Anthropic)',
'Online Expensive (Anthropic)',
'Online Cheap (Google)',
'Online Expensive (Google)',
];
const fossModels = [
'Offline Fast (FOSS)',
'Offline Slow (FOSS)',
'Online (FOSS) (La Plateforme)',
];
// Define the properties passed to the Models component
interface ModelsProps {
selectedOption: string; // Privacy setting: "Offline", "AI Online", "None"
}
const Models: React.FC<ModelsProps> = ({ selectedOption }) => {
const [selectedModel, setSelectedModel] = useState<string>(() => { const [selectedModel, setSelectedModel] = useState<string>(() => {
// Load the selected model from localStorage on initial render
return localStorage.getItem('selectedModel') || 'Offline Fast'; return localStorage.getItem('selectedModel') || 'Offline Fast';
}); });
@ -40,45 +26,31 @@ const Models: React.FC<ModelsProps> = ({ selectedOption }) => {
setSelectedModel(newModel); setSelectedModel(newModel);
}; };
const isOfflineModel = (model: string) => offlineModels.includes(model); const isOfflineModel = (model: string) => {
const isOnlineModel = (model: string) => onlineModels.includes(model); return model.includes('Offline');
const isFossModel = (model: string) => fossModels.includes(model); };
// Save selected model to localStorage whenever it changes
useEffect(() => { useEffect(() => {
localStorage.setItem('selectedModel', selectedModel); localStorage.setItem('selectedModel', selectedModel);
}, [selectedModel]); }, [selectedModel]);
const filteredModels = (() => {
switch (selectedOption) {
case 'Offline':
return offlineModels; // Show only offline models
case 'AI Online':
return onlineModels; // Show only online models
default:
return [...offlineModels, ...onlineModels]; // Show all models
}
})();
return ( return (
<div className="model-background"> <div className="model-background">
<div className="models"> <div className="models">
<div className="title"> <div className="titel">
<h3>Different AI models</h3> <h1>Different AI models</h1>
</div> </div>
{/* Model Selection Dropdown */}
<div className="model-dropdown"> <div className="model-dropdown">
<label htmlFor="model-select">Select AI Model:</label> <label htmlFor="model-select">Select AI Model:</label>
<select id="model-select" value={selectedModel} onChange={handleModelChange}> <select id="model-select" value={selectedModel} onChange={handleModelChange}>
{filteredModels.map((model) => ( {modelOptions.map((model) => (
<option key={model} value={model}> <option key={model} value={model}>
{model} {model}
</option> </option>
))} ))}
</select> </select>
</div> </div>
{/* Model Grid with Cards */}
<div className="grid"> <div className="grid">
<button className="code-model model-box"> <button className="code-model model-box">
<div className="overlay"> <div className="overlay">

View file

@ -6,17 +6,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
const getItemFromLocalStorage = (key: string) => { const getItemFromLocalStorage = (key: string) => {
const item = localStorage.getItem(key); const item = localStorage.getItem(key);
return item ? JSON.parse(item) : false; // Default to false if item is null
if (item) {
try {
return JSON.parse(item); // Attempt to parse the item
} catch (e) {
console.error(`Error parsing JSON for key "${key}":`, e);
return false; // Return false if parsing fails
}
}
return false; // Default to false if item is null or empty
}; };
// Active section // Active section
@ -24,29 +14,30 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
// Language setting // Language setting
const [preferredLanguage, setPreferredLanguage] = useState(() => localStorage.getItem('preferredLanguage') || 'en'); const [preferredLanguage, setPreferredLanguage] = useState(() => localStorage.getItem('preferredLanguage') || 'en');
// Currency setting // Currency setting
const [preferredCurrency, setPreferredCurrency] = useState(() => localStorage.getItem('preferredCurrency') || 'usd'); const [preferredCurrency, setPreferredCurrency] = useState(() => localStorage.getItem('preferredCurrency') || 'usd');
// Date and time format settings // Date and time format settings
const [dateFormat, setDateFormat] = useState(() => localStorage.getItem('dateFormat') || 'mm/dd/yyyy'); const [dateFormat, setDateFormat] = useState(() => localStorage.getItem('dateFormat') || 'mm/dd/yyyy');
const [timeFormat, setTimeFormat] = useState(() => localStorage.getItem('timeFormat') || '12-hour'); const [timeFormat, setTimeFormat] = useState(() => localStorage.getItem('timeFormat') || '12-hour');
const [timeZone, setTimeZone] = useState(() => localStorage.getItem('timeZone') || 'GMT'); const [timeZone, setTimeZone] = useState(() => localStorage.getItem('timeZone') || 'GMT');
// Online AI and chat history settings // Online AI and chat history settings
const [selectedOption, setSelectedOption] = useState('Offline'); // Default to 'Offline' // State declarations
const [disableOnlineAI, setDisableOnlineAI] = useState(() => getItemFromLocalStorage('disableOnlineAI'));
const [disableChatHistory, setDisableChatHistory] = useState(() => getItemFromLocalStorage('disableChatHistory')); const [disableChatHistory, setDisableChatHistory] = useState(() => getItemFromLocalStorage('disableChatHistory'));
const [disableAIMemory, setDisableAIMemory] = useState(() => getItemFromLocalStorage('disableAIMemory')); const [disableAIMemory, setDisableAIMemory] = useState(() => getItemFromLocalStorage('disableAIMemory'));
const [openSourceMode, setOpenSourceMode] = useState(() => getItemFromLocalStorage('openSourceMode')); const [openSourceMode, setOpenSourceMode] = useState(() => getItemFromLocalStorage('openSourceMode'));
// User credentials // User credentials
const [newName, setNewName] = useState(() => localStorage.getItem('newName') || ''); const [newName, setNewName] = useState(() => localStorage.getItem('newName') || '');
const [newEmail, setNewEmail] = useState(() => localStorage.getItem('newEmail') || ''); const [newEmail, setNewEmail] = useState(() => localStorage.getItem('newEmail') || '');
const [newPassword, setNewPassword] = useState(() => localStorage.getItem('newPassword') || ''); const [newPassword, setNewPassword] = useState(() => localStorage.getItem('newPassword') || '');
// Measurement setting // Measurement setting
const [preferredMeasurement, setPreferredMeasurement] = useState(() => localStorage.getItem('preferredMeasurement') || 'Metric'); const [preferredMeasurement, setPreferredMeasurement] = useState(() => localStorage.getItem('preferredMeasurement') || 'Metric');
// Theme settings // Theme settings
const [backgroundColor, setBackgroundColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--background-color').trim()); const [backgroundColor, setBackgroundColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--background-color').trim());
const [textColor, setTextColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--text-color').trim()); const [textColor, setTextColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--text-color').trim());
@ -67,124 +58,174 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
const [inputBorderColor, setInputBorderColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--input-border-color').trim()); const [inputBorderColor, setInputBorderColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--input-border-color').trim());
const [fontFamily, setFontFamily] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-family').trim()); const [fontFamily, setFontFamily] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-family').trim());
const [fontSize, setFontSize] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-size').trim()); const [fontSize, setFontSize] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-size').trim());
const [burgerMenu, setBurgerMenu] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color').trim()); const [burgerMenu, setBurgerMenu] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color:').trim());
// Theme selection // Theme selection
const [selectedTheme, setSelectedTheme] = useState(() => localStorage.getItem('selectedTheme') || 'default'); const [selectedTheme, setSelectedTheme] = useState(() => localStorage.getItem('selectedTheme') || 'default');
// API Keys // API Keys
const [laPlateforme, setLaPlateforme] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-la-plateforme').trim()); const [laPlateforme, setLaPlateforme] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-la-plateforme').trim());
const [openAI, setOpenAI] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-openai').trim()); const [openAI, setOpenAI] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-openai').trim());
const [anthropic, setAnthropic] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-anthropic').trim()); const [anthropic, setAnthropic] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-anthropic').trim());
const [google, setGoogle] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-google').trim()); const [google, setGoogle] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--online-cheap-google').trim());
// Effect hooks to update localStorage whenever any state changes // Effect hooks to update localStorage whenever any state changes
useEffect(() => { useEffect(() => {
const settings = { localStorage.setItem('activeSection', activeSection);
activeSection, }, [activeSection]);
preferredLanguage,
preferredCurrency, useEffect(() => {
dateFormat, localStorage.setItem('preferredLanguage', preferredLanguage);
timeFormat, }, [preferredLanguage]);
timeZone,
selectedOption, useEffect(() => {
disableChatHistory, localStorage.setItem('preferredCurrency', preferredCurrency);
disableAIMemory, }, [preferredCurrency]);
openSourceMode,
newName, useEffect(() => {
newEmail, localStorage.setItem('dateFormat', dateFormat);
newPassword, }, [dateFormat]);
preferredMeasurement,
backgroundColor, useEffect(() => {
textColor, localStorage.setItem('timeFormat', timeFormat);
inputBackgroundColor, }, [timeFormat]);
inputButtonColor,
inputButtonHoverColor, useEffect(() => {
userMessageBackgroundColor, localStorage.setItem('timeZone', timeZone);
userMessageTextColor, }, [timeZone]);
aiMessageBackgroundColor,
aiMessageTextColor, useEffect(() => {
buttonBackgroundColor, localStorage.setItem('disableOnlineAI', JSON.stringify(disableOnlineAI));
buttonHoverBackgroundColor, }, [disableOnlineAI]);
modelsBackgroundColor,
historyBackgroundColor, useEffect(() => {
leftPanelBackgroundColor, localStorage.setItem('disableChatHistory', JSON.stringify(disableChatHistory));
conversationBackgroundColor, }, [disableChatHistory]);
popUpTextColor,
inputBorderColor, useEffect(() => {
fontFamily, localStorage.setItem('disableAIMemory', JSON.stringify(disableAIMemory));
fontSize, }, [disableAIMemory]);
burgerMenu,
selectedTheme, useEffect(() => {
laPlateforme, localStorage.setItem('openSourceMode', JSON.stringify(openSourceMode));
openAI, }, [openSourceMode]);
anthropic,
google, useEffect(() => {
}; localStorage.setItem('newName', newName);
}, [newName]);
// Update local storage
for (const [key, value] of Object.entries(settings)) { useEffect(() => {
if (typeof value === 'boolean') { localStorage.setItem('newEmail', newEmail);
localStorage.setItem(key, JSON.stringify(value)); }, [newEmail]);
} else {
localStorage.setItem(key, value); useEffect(() => {
} localStorage.setItem('newPassword', newPassword);
} }, [newPassword]);
}, [
activeSection, useEffect(() => {
preferredLanguage, localStorage.setItem('preferredMeasurement', preferredMeasurement);
preferredCurrency, }, [preferredMeasurement]);
dateFormat,
timeFormat, useEffect(() => {
timeZone, localStorage.setItem('backgroundColor', backgroundColor);
selectedOption, }, [backgroundColor]);
disableChatHistory,
disableAIMemory, useEffect(() => {
openSourceMode, localStorage.setItem('textColor', textColor);
newName, }, [textColor]);
newEmail,
newPassword, useEffect(() => {
preferredMeasurement, localStorage.setItem('inputBackgroundColor', inputBackgroundColor);
backgroundColor, }, [inputBackgroundColor]);
textColor,
inputBackgroundColor, useEffect(() => {
inputButtonColor, localStorage.setItem('inputButtonColor', inputButtonColor);
inputButtonHoverColor, }, [inputButtonColor]);
userMessageBackgroundColor,
userMessageTextColor, useEffect(() => {
aiMessageBackgroundColor, localStorage.setItem('inputButtonHoverColor', inputButtonHoverColor);
aiMessageTextColor, }, [inputButtonHoverColor]);
buttonBackgroundColor,
buttonHoverBackgroundColor, useEffect(() => {
modelsBackgroundColor, localStorage.setItem('userMessageBackgroundColor', userMessageBackgroundColor);
historyBackgroundColor, }, [userMessageBackgroundColor]);
leftPanelBackgroundColor,
conversationBackgroundColor, useEffect(() => {
popUpTextColor, localStorage.setItem('userMessageTextColor', userMessageTextColor);
inputBorderColor, }, [userMessageTextColor]);
fontFamily,
fontSize, useEffect(() => {
burgerMenu, localStorage.setItem('aiMessageBackgroundColor', aiMessageBackgroundColor);
selectedTheme, }, [aiMessageBackgroundColor]);
laPlateforme,
openAI, useEffect(() => {
anthropic, localStorage.setItem('aiMessageTextColor', aiMessageTextColor);
google, }, [aiMessageTextColor]);
]);
useEffect(() => {
useEffect(() => { localStorage.setItem('buttonBackgroundColor', buttonBackgroundColor);
const savedOption = localStorage.getItem('radioSelection'); }, [buttonBackgroundColor]);
if (savedOption) {
setSelectedOption(savedOption); // Set saved selection useEffect(() => {
} localStorage.setItem('buttonHoverBackgroundColor', buttonHoverBackgroundColor);
}, []); }, [buttonHoverBackgroundColor]);
const handleRadioChange = (newValue: string) => { useEffect(() => {
setSelectedOption(newValue); // Update the state with the selected option localStorage.setItem('modelsBackgroundColor', modelsBackgroundColor);
localStorage.setItem('radioSelection', newValue); // Save the selection for persistence }, [modelsBackgroundColor]);
};
useEffect(() => {
localStorage.setItem('historyBackgroundColor', historyBackgroundColor);
}, [historyBackgroundColor]);
useEffect(() => {
localStorage.setItem('leftPanelBackgroundColor', leftPanelBackgroundColor);
}, [leftPanelBackgroundColor]);
useEffect(() => {
localStorage.setItem('conversationBackgroundColor', conversationBackgroundColor);
}, [conversationBackgroundColor]);
useEffect(() => {
localStorage.setItem('popUpTextColor', popUpTextColor);
}, [popUpTextColor]);
useEffect(() => {
localStorage.setItem('inputBorderColor', inputBorderColor);
}, [inputBorderColor]);
useEffect(() => {
localStorage.setItem('fontFamily', fontFamily);
}, [fontFamily]);
useEffect(() => {
localStorage.setItem('fontSize', fontSize);
}, [fontSize]);
useEffect(() => {
localStorage.setItem('burgerMenu', burgerMenu);
}, [fontSize]);
useEffect(() => {
localStorage.setItem('selectedTheme', selectedTheme);
}, [selectedTheme]);
useEffect(() => {
localStorage.setItem('laPlateforme', laPlateforme);
}, [laPlateforme]);
useEffect(() => {
localStorage.setItem('openAI', openAI);
}, [openAI]);
useEffect(() => {
localStorage.setItem('anthropic', anthropic);
}, [anthropic]);
useEffect(() => {
localStorage.setItem('google', google);
}, [google]);
// Apply imported settings to the CSS variables // Apply imported settings to the CSS variables
const applySettings = (settings: any) => { const applySettings = (settings: any) => {
if (settings.backgroundColor) { if (settings.backgroundColor) {
@ -398,33 +439,16 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
return ( return (
<div className="settings-section"> <div className="settings-section">
<h2>Privacy Settings</h2> <h2>Privacy Settings</h2>
{/* AI Mode Radio Options */}
<div className="settings-option"> <div className="settings-option">
<p>Disable Options:</p> <label>
<div className="slider"> <input
<div type="checkbox"
className={`slider-option ${selectedOption === 'Offline' ? 'active' : ''}`} checked={disableOnlineAI}
onClick={() => handleRadioChange('Offline')} // Handle selection onChange={() => setDisableOnlineAI(!disableOnlineAI)}
> />
Offline tools Disable Online AI
</div> </label>
<div
className={`slider-option ${selectedOption === 'AI Online' ? 'active' : ''}`}
onClick={() => handleRadioChange('AI Online')}
>
Online tools
</div>
<div
className={`slider-option ${selectedOption === 'None' ? 'active' : ''}`}
onClick={() => handleRadioChange('None')}
>
None
</div>
</div>
</div> </div>
{/* Disable Chat History Checkbox */}
<div className="settings-option"> <div className="settings-option">
<label> <label>
<input <input
@ -435,8 +459,6 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
Disable Chat History Disable Chat History
</label> </label>
</div> </div>
{/* Disable AI Memory Checkbox */}
<div className="settings-option"> <div className="settings-option">
<label> <label>
<input <input
@ -919,7 +941,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
dateFormat, dateFormat,
timeFormat, timeFormat,
timeZone, timeZone,
selectedOption, disableOnlineAI,
disableChatHistory, disableChatHistory,
disableAIMemory, disableAIMemory,
openSourceMode, openSourceMode,

View file

@ -159,29 +159,4 @@
background-color: var(--button-hover-background-color); background-color: var(--button-hover-background-color);
padding: 10px; padding: 10px;
margin: 10px; margin: 10px;
} }
.slider {
display: flex;
justify-content: space-between;
margin-top: 10px;
}
.slider-option {
cursor: pointer;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
transition: background-color 0.3s;
}
.slider-option.active {
background-color: #007bff; /* Change to your active color */
color: white;
border-color: #007bff;
}
input[type="radio"] {
display: none; /* Hide the default radio buttons */
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 KiB

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB