Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(JAQPOT-215): associatedWith org changes #42

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 79 additions & 18 deletions src/app/api.schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@


export interface paths {
"/v1/auth/validate": {
/**
* Validate JWT
* @description Validate a JWT token
*/
get: operations["validateJWT"];
};
"/v1/models": {
/** Create a new model */
post: operations["createModel"];
Expand Down Expand Up @@ -116,12 +123,12 @@ export interface paths {
*/
post: operations["resendInvitation"];
};
"/v1/organizations/{orgName}/associated-models": {
"/v1/organizations/{orgName}/affiliated-models": {
/**
* Get all models associated with an organization
* @description This endpoint allows users to retrieve all models associated with a specific organization.
* Get all models affiliated with an organization
* @description This endpoint allows users to retrieve all models affiliated with a specific organization.
*/
get: operations["getAllAssociatedModels"];
get: operations["getAllAffiliatedModels"];
};
"/v1/organizations/{name}/invitations/{uuid}": {
/**
Expand Down Expand Up @@ -155,14 +162,13 @@ export interface components {
name: string;
/** @example A description of your model */
description?: string;
/** @enum {string} */
type: "SKLEARN" | "TORCH" | "R_BNLEARN_DISCRETE" | "R_CARET" | "R_GBM" | "R_NAIVE_BAYES" | "R_PBPK" | "R_RF" | "R_RPART" | "R_SVM" | "R_TREE_CLASS" | "R_TREE_REGR" | "QSAR_TOOLBOX";
type: components["schemas"]["ModelType"];
/** @example 1.0.0 */
jaqpotpyVersion: string;
libraries: components["schemas"]["Library"][];
dependentFeatures: components["schemas"]["Feature"][];
independentFeatures: components["schemas"]["Feature"][];
organizations?: components["schemas"]["Organization"][];
sharedWithOrganizations?: components["schemas"]["Organization"][];
visibility: components["schemas"]["ModelVisibility"];
/** @example false */
pretrained?: boolean;
Expand All @@ -175,7 +181,7 @@ export interface components {
/** @description If the current user can edit the model */
canEdit?: boolean;
isAdmin?: boolean;
associatedOrganization?: components["schemas"]["Organization"];
affiliatedOrganizations?: components["schemas"]["Organization"][];
tags?: string;
legacyPredictionService?: string;
/**
Expand All @@ -190,6 +196,45 @@ export interface components {
*/
updatedAt?: Record<string, never>;
};
ModelSummary: {
/**
* Format: int64
* @example 0
*/
id: number;
/** @example My Model */
name: string;
visibility: components["schemas"]["ModelVisibility"];
/** @example A description of your model */
description?: string;
creator?: components["schemas"]["User"];
type: components["schemas"]["ModelType"];
dependentFeaturesLength?: number;
independentFeaturesLength?: number;
sharedWithOrganizations: components["schemas"]["OrganizationSummary"][];
/**
* Format: date-time
* @description The date and time when the feature was created.
* @example 2023-01-01T12:00:00Z
*/
createdAt: Record<string, never>;
/**
* @description The date and time when the feature was last updated.
* @example 2023-01-01T12:00:00Z
*/
updatedAt?: Record<string, never>;
};
OrganizationSummary: {
/**
* Format: int64
* @example 0
*/
id: number;
/** @example My Organization */
name: string;
};
/** @enum {string} */
ModelType: "SKLEARN" | "TORCH" | "R_BNLEARN_DISCRETE" | "R_CARET" | "R_GBM" | "R_NAIVE_BAYES" | "R_PBPK" | "R_RF" | "R_RPART" | "R_SVM" | "R_TREE_CLASS" | "R_TREE_REGR" | "QSAR_TOOLBOX";
/** @enum {string} */
ModelVisibility: "PUBLIC" | "ORG_SHARED" | "PRIVATE";
Library: {
Expand Down Expand Up @@ -400,6 +445,22 @@ export type external = Record<string, never>;

export interface operations {

/**
* Validate JWT
* @description Validate a JWT token
*/
validateJWT: {
responses: {
/** @description JWT is valid */
200: {
content: never;
};
/** @description Unauthorized */
401: {
content: never;
};
};
};
/** Create a new model */
createModel: {
requestBody: {
Expand Down Expand Up @@ -432,7 +493,7 @@ export interface operations {
200: {
content: {
"application/json": {
content?: components["schemas"]["Model"][];
content?: components["schemas"]["ModelSummary"][];
totalElements?: number;
totalPages?: number;
pageSize?: number;
Expand Down Expand Up @@ -460,7 +521,7 @@ export interface operations {
200: {
content: {
"application/json": {
content?: components["schemas"]["Model"][];
content?: components["schemas"]["ModelSummary"][];
totalElements?: number;
totalPages?: number;
pageSize?: number;
Expand All @@ -481,14 +542,15 @@ export interface operations {
page?: number;
size?: number;
sort?: string[];
organizationId?: number;
};
};
responses: {
/** @description Paginated list of shared models */
200: {
content: {
"application/json": {
content?: components["schemas"]["Model"][];
content?: components["schemas"]["ModelSummary"][];
totalElements?: number;
totalPages?: number;
pageSize?: number;
Expand Down Expand Up @@ -655,9 +717,8 @@ export interface operations {
name: string;
description?: string;
visibility: components["schemas"]["ModelVisibility"];
organizationIds?: number[];
/** Format: int64 */
associatedOrganizationId?: number;
sharedWithOrganizationIds?: number[];
affiliatedOrganizationIds?: number[];
};
};
};
Expand Down Expand Up @@ -1006,10 +1067,10 @@ export interface operations {
};
};
/**
* Get all models associated with an organization
* @description This endpoint allows users to retrieve all models associated with a specific organization.
* Get all models affiliated with an organization
* @description This endpoint allows users to retrieve all models affiliated with a specific organization.
*/
getAllAssociatedModels: {
getAllAffiliatedModels: {
parameters: {
query?: {
page?: number;
Expand All @@ -1026,7 +1087,7 @@ export interface operations {
200: {
content: {
"application/json": {
content?: components["schemas"]["Model"][];
content?: components["schemas"]["ModelSummary"][];
totalElements?: number;
totalPages?: number;
pageSize?: number;
Expand Down
1 change: 1 addition & 0 deletions src/app/api.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { components, operations } from './api.schema.d';

export type ModelDto = components['schemas']['Model'];
export type ModelSummaryDto = components['schemas']['ModelSummary'];
export type FeatureDto = components['schemas']['Feature'];
export type FeaturePossibleValueDto =
components['schemas']['FeaturePossibleValue'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function GET(
}

const res = await fetch(
`${process.env.API_URL}/v1/organizations/${params.organizationSlug}/associated-models`,
`${process.env.API_URL}/v1/organizations/${params.organizationSlug}/affiliated-models`,
{
headers: {
...authorizationHeader,
Expand Down
6 changes: 6 additions & 0 deletions src/app/api/user/shared-models/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export async function GET(
}

const searchParams = generatePaginationAndSortingSearchParams(request);
if (request.nextUrl.searchParams.has('organizationId')) {
searchParams.append(
'organizationId',
request.nextUrl.searchParams.get('organizationId')!,
);
}

const res = await fetch(
`${process.env.API_URL}/v1/user/shared-models?${searchParams.toString()}`,
Expand Down
32 changes: 21 additions & 11 deletions src/app/dashboard/models/[modelId]/[tabName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,32 @@ export default async function Page({ params }: { params: ModelPageParams }) {
)}
</div>
<div className="flex items-center text-sm text-gray-400">
{model.associatedOrganization &&
model.associatedOrganization.visibility === 'PUBLIC' && (
{model.affiliatedOrganizations &&
model.affiliatedOrganizations.length > 0 && (
<>
<Tooltip
content="This model was developed under the auspices of this project/organization."
content="This model was developed under the auspices of these projects/organizations."
closeDelay={0}
>
<BuildingOfficeIcon className="mr-2 size-5" />
<BuildingOfficeIcon className="mr-1 size-5" />
</Tooltip>
<Link
color="foreground"
href={`/dashboard/organizations/${model.associatedOrganization.name}`}
className="font-medium"
>
@{model.associatedOrganization.name}
</Link>
{model.affiliatedOrganizations.map((org, index) => (
<>
<Link
key={org.id}
color="foreground"
href={`/dashboard/organizations/${org.name}`}
className="font-medium"
>
@{org.name}
</Link>
<span className="mr-0.5 font-medium">
{index < model.affiliatedOrganizations!.length - 1
? ', '
: ''}
</span>
</>
))}
</>
)}
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/app/dashboard/models/[modelId]/components/ModelTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import FeaturesTab from '@/app/dashboard/models/[modelId]/components/tabs/Featur
import PredictTab from '@/app/dashboard/models/[modelId]/components/tabs/PredictTab';
import ModelEditTab from '@/app/dashboard/models/[modelId]/components/tabs/ModelEditTab';
import MarkdownRenderer from '@/app/dashboard/models/[modelId]/components/MarkdownRenderer';
import ModelAdminTab from '@/app/dashboard/models/[modelId]/components/tabs/ModelAdminTab';

interface ModelTabsProps {
model: ModelDto;
Expand Down Expand Up @@ -57,6 +58,11 @@ export default function ModelTabs({ model }: ModelTabsProps) {
<ModelEditTab model={model} />
</Tab>
)}
{model.isAdmin && (
<Tab key="admin" title="Admin" href={`${pathnameWithoutTab}/admin`}>
<ModelAdminTab model={model} />
</Tab>
)}
<Tab
key="discussion"
title="Discussion"
Expand Down
Loading
Loading