Skip to content

Commit

Permalink
[ALS-7317] Add configuration for analysis page instructions (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
srpiatt authored Jan 31, 2025
1 parent 126a7ed commit 4b839d2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 48 deletions.
22 changes: 13 additions & 9 deletions src/lib/assets/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@
}
]
},
"apiPage": {
"cards": [
{
"header": "Setting Up the PIC-SURE API",
"body": "Step-by-step instructions to get started using the PIC-SURE API",
"link": "/analyze/example"
}
]
},
"explorePage": {
"additionalColumns": [
{
Expand Down Expand Up @@ -120,6 +111,19 @@
],
"stats": ["Variables", "Participants", "Data Sources"]
},
"analysisPage": {
"cards": [
{
"header": "Setting Up the PIC-SURE API",
"body": "Step-by-step instructions to get started using the PIC-SURE API",
"link": "/analyze/example"
}
],
"instructions": {
"connection": "To connect to the PIC-SURE Application Programming Interface (API), you will need your personal access token. Copy your token and save as a text file called \"token.txt\" in the working directory of your chosen analysis workspace.",
"execution": "To start your analysis, copy and execute the following code in your preferred analysis environment to connect to the PIC-SURE API. Note that you will need your personal access token to complete the connection."
}
},
"login": {
"description": "Where searching for, filtering on, and analyzing data is made simple.",
"showSiteName": false,
Expand Down
7 changes: 4 additions & 3 deletions src/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ExpectedResultType } from './models/query/Query';
import * as configJson from './assets/configuration.json' assert { type: 'json' };
import { ExportType } from './models/Variant';
import type {
ApiPageConfig,
ExplorePageConfig,
FooterConfig,
HelpConfig,
Expand All @@ -13,6 +12,7 @@ import type {
LoginConfig,
SiteMapConfig,
PrivacyConfig,
AnalysisConfig,
} from './types';

export interface Branding {
Expand All @@ -29,6 +29,7 @@ export interface Branding {
login: LoginConfig;
help: HelpConfig;
privacyPolicy: PrivacyConfig;
analysisConfig: AnalysisConfig;
}

export const branding: Branding = {
Expand All @@ -39,26 +40,26 @@ export const branding: Branding = {
},
sitemap: [] as SiteMapConfig[],
footer: {} as FooterConfig,
apiPage: {} as ApiPageConfig,
explorePage: {
tourSearchTerm: import.meta.env?.EXPLORE_TOUR_SEARCH_TERM || 'age',
} as ExplorePageConfig,
landing: {} as LandingConfig,
login: {} as LoginConfig,
help: {} as HelpConfig,
privacyPolicy: {} as PrivacyConfig,
analysisConfig: {} as AnalysisConfig,
};

export const initializeBranding = () => {
branding.applicationName = configJson.applicationName;
branding.apiPage = configJson.apiPage;
branding.explorePage = { ...branding.explorePage, ...configJson.explorePage };
branding.landing = configJson.landing;
branding.login = configJson.login;
branding.help = configJson.help;
branding.footer = configJson.footer;
branding.sitemap = configJson.sitemap as SiteMapConfig[];
branding.privacyPolicy = configJson.privacyPolicy;
branding.analysisConfig = configJson.analysisPage;
};

export const routes: Route[] = [
Expand Down
20 changes: 12 additions & 8 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ export interface FooterConfig {
}>;
}

export interface ApiPageConfig {
cards: Array<{
header: string;
body: string;
link: string;
}>;
}

export interface ExplorePageConfig {
additionalColumns: Column[];
tourSearchTerm: string;
Expand Down Expand Up @@ -87,3 +79,15 @@ export interface PrivacyConfig {
content: string;
url: string;
}

export interface AnalysisConfig {
cards: Array<{
header: string;
body: string;
link: string;
}>;
instructions: {
connection: string;
execution: string;
};
}
34 changes: 6 additions & 28 deletions src/routes/(picsure)/(authorized)/analyze/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,11 @@
The PIC-SURE Application Programming Interface (API) can be used in an analysis environment of
your choice. This API is available in both Python and R coding languages.
</p>
<p>
To connect to the PIC-SURE Application Programming Interface (API), you will need your
personal access token. Copy your token and save as a text file called “token.txt” in the
working directory of your chosen analysis workspace, such as <a
href="https://platform.sb.biodatacatalyst.nhlbi.nih.gov/home"
target="_blank"
title="BioData Catalyst Powered by Seven
Bridges"
class="anchor font-bold">BioData Catalyst Powered by Seven Bridges</a
>
or
<a
href="https://terra.biodatacatalyst.nhlbi.nih.gov/#workspaces"
target="_blank"
title="BioData Catalyst Powered by Terra"
class="anchor font-bold">BioData Catalyst Powered by Terra</a
>.
</p>
<div class="flex justify-center">
<UserToken />
</div>
<p>
To start your analysis, copy and execute the following code in an analysis environment, such
as BioData Catalyst Powered by Seven Bridges or BioData Catalyst Powered by Terra, to connect
to the PIC-SURE API. Note that you will need your personal access token to complete the
connection.
</p>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<p>{@html branding.analysisConfig.instructions.connection}</p>
<div class="flex justify-center"><UserToken /></div>
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<p>{@html branding.analysisConfig.instructions.execution}</p>
<TabGroup class="card p-4">
<Tab bind:group={tabSet} name="python" value={0}>Python</Tab>
<Tab bind:group={tabSet} name="r" value={1}>R</Tab>
Expand All @@ -64,7 +42,7 @@
</TabGroup>
</section>
<section id="info-cards" class="w-full flex flex-wrap flex-row justify-center mt-6">
{#each branding.apiPage.cards as card}
{#each branding.analysisConfig.cards as card}
<a
href={card.link}
target={card.link.startsWith('http') ? '_blank' : '_self'}
Expand Down

0 comments on commit 4b839d2

Please sign in to comment.