-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from snaeem3/151-feedback-form
151 feedback form - resolve merge conflicts
- Loading branch information
Showing
21 changed files
with
536 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# VITE_API_BASE_URL=https://balancertestsite.com/ | ||
VITE_API_BASE_URL=http://localhost:8000 | ||
VITE_API_BASE_URL=https://balancertestsite.com/ | ||
# VITE_API_BASE_URL=http://localhost:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
//import Welcome from "../../components/Welcome/Welcome.tsx"; | ||
import Layout from "../Layout/Layout"; | ||
// import image from "./OIP.jpeg"; | ||
import { Link } from "react-router-dom"; | ||
|
||
function About() { | ||
function AdminPortal() { | ||
return ( | ||
<Layout> | ||
<div className=" font_body mt-48 flex w-full flex-col items-center justify-center rounded-md border bg-white p-4 px-8 ring-1 hover:ring-slate-300 md:max-w-6xl"></div> | ||
<div className="font_body mt-48 flex w-full flex-col items-center justify-center rounded-md border bg-white p-4 px-8 ring-1 hover:ring-slate-300 md:max-w-6xl"> | ||
<div className="flex flex-col items-center space-y-4 p-8"> | ||
<Link to="/UploadFile"> | ||
<button className="px-18 mt-1 w-80 rounded-xl bg-blue-500 py-2 text-xl text-white hover:bg-blue-600"> | ||
Upload File | ||
</button> | ||
</Link> | ||
<Link to="/listoffiles"> | ||
<button className="px-18 mt-1 w-80 rounded-xl bg-blue-500 py-2 text-xl text-white hover:bg-blue-600"> | ||
List of Files | ||
</button> | ||
</Link> | ||
<button className="px-18 mt-1 w-80 rounded-xl bg-blue-500 py-2 text-xl text-white hover:bg-blue-600"> | ||
Create process | ||
</button> | ||
</div> | ||
{/* <div className="mt-8 text-sm text-gray-600"> | ||
<p>API status | Help & support</p> | ||
</div> */} | ||
</div> | ||
</Layout> | ||
); | ||
} | ||
|
||
export default About; | ||
export default AdminPortal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
//import Welcome from "../../components/Welcome/Welcome.tsx"; | ||
import { useEffect, useState } from "react"; | ||
import axios from "axios"; | ||
import Layout from "../Layout/Layout"; | ||
// import { Link } from "react-router-dom"; | ||
|
||
interface File { | ||
id: number; | ||
guid: string; | ||
file_name: string; | ||
date_of_upload: string; | ||
size: number; | ||
page_count: number; | ||
file_type: string; | ||
uploaded_by_email: string; | ||
source_url: string | null; | ||
analyzed: boolean | null; | ||
approved: boolean | null; | ||
uploaded_by: number; | ||
} | ||
function ListOfFiles() { | ||
const [files, setFiles] = useState<File[]>([]); | ||
const [isLoading, setIsLoading] = useState(true); | ||
// const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
const fetchFiles = async () => { | ||
try { | ||
const baseUrl = import.meta.env.VITE_API_BASE_URL; | ||
const response = await axios.get(`${baseUrl}/v1/api/uploadFile`, { | ||
headers: { | ||
Authorization: `JWT ${localStorage.getItem("access")}`, // Assuming JWT is used for auth | ||
}, | ||
}); | ||
console.log("Response data:", response.data); | ||
if (Array.isArray(response.data)) { | ||
setFiles(response.data); | ||
} else { | ||
// setError("Unexpected response format"); | ||
} | ||
} catch (error) { | ||
console.error("Error fetching files", error); | ||
// setError("Error fetching files"); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
fetchFiles(); | ||
}, []); | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div>; | ||
} | ||
return ( | ||
<Layout> | ||
<div className="font_body mt-48 flex w-full flex-col items-center justify-center rounded-md border bg-white p-4 px-8 ring-1 hover:ring-slate-300 md:max-w-6xl"> | ||
<div className="mt-8 text-sm text-gray-600"> | ||
<ul> | ||
{files.map((file) => ( | ||
<li key={file.id} className="border-b p-4"> | ||
<p> | ||
<strong>File Name:</strong> {file.file_name} | ||
</p> | ||
<p> | ||
<strong>Date of Upload:</strong>{" "} | ||
{new Date(file.date_of_upload).toLocaleString()} | ||
</p> | ||
<p> | ||
<strong>Size:</strong> {file.size} bytes | ||
</p> | ||
<p> | ||
<strong>Page Count:</strong> {file.page_count} | ||
</p> | ||
<p> | ||
<strong>File Type:</strong> {file.file_type} | ||
</p> | ||
<p> | ||
<strong>Uploaded By:</strong> {file.uploaded_by_email} | ||
</p> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
</Layout> | ||
); | ||
} | ||
|
||
export default ListOfFiles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
server/api/migrations/0004_uploadfile_uploaded_by_email_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 4.2.3 on 2024-07-30 10:19 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0003_alter_uploadfile_date_of_upload_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='uploadfile', | ||
name='uploaded_by_email', | ||
field=models.CharField(blank=True, max_length=255), | ||
), | ||
migrations.AlterField( | ||
model_name='uploadfile', | ||
name='uploaded_by', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 4.2.3 on 2024-07-30 10:21 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import pgvector.django.vector | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0004_uploadfile_uploaded_by_email_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Embeddings', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('guid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)), | ||
('name', models.CharField(max_length=255)), | ||
('text', models.TextField()), | ||
('page_num', models.IntegerField(default=1)), | ||
('chunk_number', models.IntegerField()), | ||
('embedding_sentence_transformers', pgvector.django.vector.VectorField(dimensions=384, null=True)), | ||
('date_of_upload', models.DateTimeField(auto_now_add=True)), | ||
('upload_file', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='embeddings', to='api.uploadfile')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db import models | ||
from django.conf import settings | ||
from pgvector.django import VectorField | ||
import uuid | ||
from ..views.uploadFile.models import UploadFile | ||
|
||
|
||
class Embeddings(models.Model): | ||
upload_file = models.ForeignKey( | ||
UploadFile, related_name='embeddings', on_delete=models.CASCADE) | ||
# This is a new unique GUID for each Embedding | ||
guid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False) | ||
name = models.CharField(max_length=255) | ||
text = models.TextField() | ||
page_num = models.IntegerField(default=1) | ||
chunk_number = models.IntegerField() | ||
embedding_sentence_transformers = VectorField( | ||
dimensions=384, null=True) | ||
date_of_upload = models.DateTimeField(auto_now_add=True, blank=True) | ||
|
||
def __str__(self): | ||
return self.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import uuid | ||
|
||
|
||
def convert_uuids(data): | ||
if isinstance(data, dict): | ||
return {key: convert_uuids(value) for key, value in data.items()} | ||
elif isinstance(data, list): | ||
return [convert_uuids(item) for item in data] | ||
elif isinstance(data, uuid.UUID): | ||
return str(data) | ||
else: | ||
return data |
Oops, something went wrong.