Skip to content

Commit

Permalink
Custom website names, and capture logo and aspect ratio in Kubernetes (
Browse files Browse the repository at this point in the history
…#1062)

* custom website names

* now working

* fix vitest

* switch to website config and add logo and aspect ratio

* Update vitest.setup.ts

* Update values.yaml
  • Loading branch information
theosanderson authored Feb 22, 2024
1 parent 02dcfa5 commit 15a448d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions kubernetes/loculus/templates/_common-metadata.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fields:
{{/* Generate website config from passed config object */}}
{{- define "loculus.generateWebsiteConfig" }}
name: {{ $.Values.name }}
logo: {{ $.Values.logo | toYaml | nindent 6 }}
accessionPrefix: {{ $.Values.accessionPrefix }}
{{- $commonMetadata := (include "loculus.commonMetadata" . | fromYaml).fields }}
instances:
Expand Down
4 changes: 4 additions & 0 deletions kubernetes/loculus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ disablePreprocessing: false
siloImportLimitSeconds: 3600
accessionPrefix: "LOC_"
name: "Loculus"
logo:
url: "/favicon.svg"
width: 100
height: 100
instances:
dummy-organism:
schema:
Expand Down
2 changes: 1 addition & 1 deletion website/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getConfigDir(): string {
return configDir;
}

function getWebsiteConfig(): WebsiteConfig {
export function getWebsiteConfig(): WebsiteConfig {
if (_config === null) {
_config = readTypedConfigFile('website_config.json', websiteConfig);
}
Expand Down
16 changes: 14 additions & 2 deletions website/src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import '../styles/base.scss';
import Navigation from '../components/Navigation/Navigation.astro';
import OrganismSelector from '../components/Navigation/OrganismSelector.astro';
import { getWebsiteConfig } from '../config';
import { navigationItems } from '../routes';
const websiteConfig = getWebsiteConfig();
const { name: websiteName, logo } = websiteConfig;
interface Props {
title: string;
Expand All @@ -27,8 +30,17 @@ const { title } = Astro.props;
<div class='flex justify-start'>
<div class='flex flex-col'>
<div class='flex flex-row pb-3'>
<a href='/'><img class='h-8 mr-4' src='/favicon.svg' alt='icon' /></a>
<a href='/' class='fancytitle mr-4'>Loculus</a>
<a href='/'
><img
class='h-8 mr-4'
src={logo.url}
alt='icon'
style={{
aspectRatio: `${logo.width}/${logo.height}`,
}}
/></a
>
<a href='/' class='fancytitle mr-4'>{websiteName}</a>
</div>
<OrganismSelector />
</div>
Expand Down
8 changes: 8 additions & 0 deletions website/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ export const instanceConfig = z.object({
});
export type InstanceConfig = z.infer<typeof instanceConfig>;

const logoConfig = z.object({
url: z.string(),
width: z.number(),
height: z.number(),
});

export const websiteConfig = z.object({
instances: z.record(instanceConfig),
name: z.string(),
logo: logoConfig,
});
export type WebsiteConfig = z.infer<typeof websiteConfig>;
2 changes: 2 additions & 0 deletions website/src/types/runtimeConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { z } from 'zod';

export const name = z.string().min(1);

const serviceUrls = z.object({
backendUrl: z.string(),
lapisUrls: z.record(z.string(), z.string()),
Expand Down

0 comments on commit 15a448d

Please sign in to comment.