Skip to content

Commit

Permalink
added about and user org
Browse files Browse the repository at this point in the history
  • Loading branch information
cophilot committed Dec 21, 2023
1 parent faaa794 commit 324e4f9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 44 deletions.
19 changes: 10 additions & 9 deletions src/components/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ function About() {
<span className="db">db</span>?
</h1>
<p style={{ width: '50%', fontSize: '20px' }}>
WannaDB allows users to explore unstructured text
collections by automatically organizing the relevant
information nuggets in a table. It supports ad-hoc SQL
queries over text collections using a novel two-phased
approach: First, a superset of information nuggets is
extracted from the texts using existing extractors such as
named entity recognizers. The extractions are then
interactively matched to a structured table definition as
requested by the user.
WannaDB represents a method for efficiently searching and
analyzing large collections of text. With this tool, it is
possible to apply SQL queries directly to texts, similar to
a database query. It transforms unstructured text data into
structured, easily understandable information. Instead of
manually searching through endless texts, WannaDB allows for
targeted inquiries for specific information and presents
them in a clear format. This tool is ideal for anyone who
wants to quickly and effortlessly extract desired data from
extensive texts.
</p>
<div className="hor linkIcons">
<a
Expand Down
4 changes: 4 additions & 0 deletions src/components/CreateOrg/CreateOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function CreateOrg() {
);
return;
}
if (name.toLowerCase().endsWith('org')) {
setErrorMessage('Organization name cannot end with "Org"');
return;
}
APIService.createOrganization(name).then((id) => {
if (!id) {
setErrorMessage('Organization already exists');
Expand Down
69 changes: 38 additions & 31 deletions src/components/FileUpload/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,39 +89,46 @@ function FileUpload() {

return (
<div className="FileUpload">
<div className="hor mb">
{getOrganizations().length === 1 && (
<p>
<b>Select a Organization:</b>
<b>Organization:</b> {getOrganizations()[0].name}
</p>
<select
className="btn"
style={{
width: '200px',
marginLeft: '20px',
}}
name="organization"
id="organization"
onChange={(e) => {
console.log(e.target.value);
const name = e.target.value;
const organization = getOrganizations().find(
(org) => org.name === name
);
if (organization === undefined) return;
setSelectedOrg(organization.id);
}}
>
{getOrganizations().map((organization) => (
<option
value={organization.name}
key={organization.id}
selected={organization.id === selectedOrg}
>
{organization.name}
</option>
))}
</select>
</div>
)}
{getOrganizations().length > 1 && (
<div className="hor mb">
<p>
<b>Select a Organization:</b>
</p>
<select
className="btn"
style={{
width: '200px',
marginLeft: '20px',
}}
name="organization"
id="organization"
onChange={(e) => {
console.log(e.target.value);
const name = e.target.value;
const organization = getOrganizations().find(
(org) => org.name === name
);
if (organization === undefined) return;
setSelectedOrg(organization.id);
}}
>
{getOrganizations().map((organization) => (
<option
value={organization.name}
key={organization.id}
selected={organization.id === selectedOrg}
>
{organization.name}
</option>
))}
</select>
</div>
)}
<div className="hor mb">
<input
type="file"
Expand Down
10 changes: 7 additions & 3 deletions src/utils/ApiService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('APIService', () => {
let saltOrganisationID: number | undefined = undefined;

beforeAll(async () => {
await APIService.register(salt, salt);
await APIService.register(salt, salt, false);
saltOrganisationID = await APIService.createOrganization(salt);
});

Expand Down Expand Up @@ -66,14 +66,18 @@ describe('APIService', () => {
});

test('registers a user successfully and sets the user token', async () => {
const result = await APIService.register(alternative, alternative);
const result = await APIService.register(
alternative,
alternative,
false
);
expect(result).toBe(true);
const token = APIService.getUserToken();
expect(typeof token).toBe('string');
await APIService.deleteUser(alternative, alternative);
});
test('should delete a user successfully and clear the user token', async () => {
await APIService.register(alternative, alternative);
await APIService.register(alternative, alternative, false);
const token1 = APIService.getUserToken();
expect(typeof token1).toBe('string');
const result = await APIService.deleteUser(alternative, alternative);
Expand Down
6 changes: 5 additions & 1 deletion src/utils/ApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class APIService {
*/
static async register(
username: string,
password: string
password: string,
addOrg = true
): Promise<boolean | undefined> {
try {
const url = `${this.host}/register`;
Expand All @@ -50,6 +51,9 @@ class APIService {
if (resp.status === 201) {
const token = resp.data.token;
sessionStorage.setItem('user-token', token);
if (addOrg) {
await this.createOrganization(username + 'Org');
}
return true;
}
return false;
Expand Down

0 comments on commit 324e4f9

Please sign in to comment.