Merge pull request #1205 from arc53/dartpain/add-github-loader

Github remote loader
This commit is contained in:
Alex
2024-10-05 22:06:00 +01:00
committed by GitHub
8 changed files with 102 additions and 3 deletions

View File

@@ -85,6 +85,7 @@
"train": "Train",
"link": "Link",
"urlLink": "URL Link",
"repoUrl": "Repository URL",
"reddit": {
"id": "Client ID",
"secret": "Client Secret",

View File

@@ -85,6 +85,7 @@
"train": "Entrenar",
"link": "Enlace",
"urlLink": "Enlace URL",
"repoUrl": "URL del Repositorio",
"reddit": {
"id": "ID de Cliente",
"secret": "Secreto de Cliente",

View File

@@ -85,6 +85,7 @@
"train": "トレーニング",
"link": "リンク",
"urlLink": "URLリンク",
"repoUrl": "リポジトリURL",
"reddit": {
"id": "クライアントID",
"secret": "クライアントシークレット",

View File

@@ -85,6 +85,7 @@
"train": "训练",
"link": "链接",
"urlLink": "URL 链接",
"repoUrl": "存储库 URL",
"reddit": {
"id": "客户端 ID",
"secret": "客户端密钥",

View File

@@ -24,6 +24,7 @@ function Upload({
const [docName, setDocName] = useState('');
const [urlName, setUrlName] = useState('');
const [url, setUrl] = useState('');
const [repoUrl, setRepoUrl] = useState(''); // P3f93
const [redditData, setRedditData] = useState({
client_id: '',
client_secret: '',
@@ -48,6 +49,7 @@ function Upload({
// { label: 'Sitemap', value: 'sitemap' },
{ label: 'Link', value: 'url' },
{ label: 'Reddit', value: 'reddit' },
{ label: 'GitHub', value: 'github' }, // P3f93
];
const [urlType, setUrlType] = useState<{ label: string; value: string }>({
@@ -238,6 +240,9 @@ function Upload({
formData.set('name', 'other');
formData.set('data', JSON.stringify(redditData));
}
if (urlType.value === 'github') {
formData.append('repo_url', repoUrl); // Pdeac
}
const apiHost = import.meta.env.VITE_API_HOST;
const xhr = new XMLHttpRequest();
xhr.upload.addEventListener('progress', (event) => {
@@ -376,7 +381,7 @@ function Upload({
size="w-full"
rounded="3xl"
/>
{urlType.label !== 'Reddit' ? (
{urlType.label !== 'Reddit' && urlType.label !== 'GitHub' ? (
<>
<Input
placeholder={`Enter ${t('modals.uploadDoc.name')}`}
@@ -403,6 +408,33 @@ function Upload({
</span>
</div>
</>
) : urlType.label === 'GitHub' ? ( // P3f93
<>
<Input
placeholder={`Enter ${t('modals.uploadDoc.name')}`}
type="text"
value={urlName}
onChange={(e) => setUrlName(e.target.value)}
borderVariant="thin"
></Input>
<div className="relative bottom-12 left-2 mt-[-20px]">
<span className="bg-white px-2 text-xs text-gray-4000 dark:bg-outer-space dark:text-silver">
{t('modals.uploadDoc.name')}
</span>
</div>
<Input
placeholder={t('modals.uploadDoc.repoUrl')}
type="text"
value={repoUrl}
onChange={(e) => setRepoUrl(e.target.value)}
borderVariant="thin"
></Input>
<div className="relative bottom-12 left-2 mt-[-20px]">
<span className="bg-white px-2 text-xs text-gray-4000 dark:bg-outer-space dark:text-silver">
{t('modals.uploadDoc.repoUrl')}
</span>
</div>
</>
) : (
<div className="flex flex-col gap-1 mt-2">
<div>