Update index.tsx

This commit is contained in:
Stefan Pejcic 2024-06-01 14:34:08 +02:00 committed by GitHub
parent 1848058174
commit 56c566c3d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,124 +6,88 @@ import { CommonLayout } from "@site/src/refine-theme/common-layout";
import clsx from "clsx"; import clsx from "clsx";
const Install: React.FC = () => { const Install: React.FC = () => {
const [options, setOptions] = useState({ const [installOptions, setInstallOptions] = useState({
port: false, hostname: "",
lang: false, version: "",
hostname: false, skipRequirements: false,
email: false, skipPanelCheck: false,
password: false, skipAptUpdate: false,
apache: true, // Default to true overlay2: false,
phpfpm: true, // Default to true skipFirewall: false,
// Add more options as needed skipImages: false,
skipBlacklists: false,
skipSSL: false,
withModsec: false,
ips: "",
noSSH: false,
enableFTP: false,
enableMail: false,
postInstall: "",
screenshots: "",
debug: false,
repair: false,
}); });
const [inputValues, setInputValues] = useState({ const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
// Define initial input values if needed const { name, value, type, checked } = e.target;
portValue: "", setInstallOptions(prevState => ({
langValue: "", ...prevState,
hostnameValue: "", [name]: type === "checkbox" ? checked : value,
emailValue: "",
passwordValue: "",
});
const handleOptionChange = (option: string) => {
setOptions((prevOptions) => ({
...prevOptions,
[option]: !prevOptions[option],
}));
};
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = event.target;
setInputValues((prevInputValues) => ({
...prevInputValues,
[name]: value,
})); }));
}; };
const generateInstallCommand = () => { const generateInstallCommand = () => {
let command = "Your install command here"; let command = "bash <(curl -sSL https://get.openpanel.co/)";
// Logic to generate install command based on selected options and input values for (const option in installOptions) {
// For example: if (installOptions[option]) {
if (options.port) { if (typeof installOptions[option] === "boolean") {
command += ` --port ${inputValues.portValue}`; command += ` --${option}`;
} else {
command += ` --${option}=${installOptions[option]}`;
}
} }
if (options.lang) {
command += ` --lang ${inputValues.langValue}`;
} }
// Add more options as needed
return command; return command;
}; };
return ( return (
<CommonLayout> <CommonLayout>
<Head title="Install | OpenPanel"> <Head title="Install | OpenPanel">
<html data-page="support" data-customized="true" /> <html data-page="install" data-customized="true" />
</Head> </Head>
<div className="refine-prose"> <div className="refine-prose">
<CommonHeader hasSticky={true} /> <CommonHeader hasSticky={true} />
<div className="flex-1 flex flex-col pt-8 lg:pt-16 pb-32 max-w-[800px] w-full mx-auto px-2"> <div className="flex-1 flex flex-col pt-8 lg:pt-16 pb-32 max-w-[800px] w-full mx-auto px-2">
<h2 className="u-text-center">Installation instructions</h2> <h1>Installation</h1>
<p className="u-mb10">
Log in to your server e.g.{" "}
<code>ssh root@your.server</code> then download the installation
script:
</p>
{/* Implement CopyToClipboardInput for first command */}
<p className="u-mb10"> <div className="mb-8">
Check you are running as the <code>root</code> user, configure the <h2>Install Command:</h2>
options you want below, then run: <pre>{generateInstallCommand()}</pre>
</p> </div>
{/* Implement CopyToClipboardInput for second command */}
<h2 className="u-text-center">Configure options</h2> <div className="mb-8">
<ul className="option-list"> <h2>Advanced Install Settings:</h2>
{Object.keys(options).map((option) => ( <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<li {/* Input fields for advanced install settings */}
key={option} {/* Example for hostname */}
className={clsx("option-item", "is-clickable", { <div>
"is-active": options[option], <label htmlFor="hostname">Hostname:</label>
})}
>
<div className="option-header">
<div className="form-check">
<input
type="checkbox"
className="form-check-input"
id={option}
checked={options[option]}
onChange={() => handleOptionChange(option)}
/>
<label htmlFor={option}>{option}</label>
</div>
{/* Implement tooltip icon */}
</div>
{/* Input fields for each option */}
{options[option] && (
<input <input
type="text" type="text"
name={`${option}Value`} id="hostname"
value={inputValues[`${option}Value`]} name="hostname"
value={installOptions.hostname}
onChange={handleInputChange} onChange={handleInputChange}
placeholder={`Enter value for ${option}`}
/> />
)} </div>
</li> {/* Repeat similar structure for other options */}
))} </div>
</ul> </div>
{/* Implement input fields for additional input values */} <button className="bg-blue-500 text-white px-4 py-2" onClick={generateInstallCommand}>
{/* Implement a button to generate the install command */}
<button
className="bg-blue-500 text-white px-4 py-2"
onClick={() => generateInstallCommand()}
>
Generate Install Command Generate Install Command
</button> </button>
{/* Display the generated command */}
<p>{generateInstallCommand()}</p>
</div> </div>
<BlogFooter /> <BlogFooter />
</div> </div>