Skip to content

Commit

Permalink
Merge branch 'master' into fix/network-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendaHijmans authored Oct 11, 2024
2 parents 3d79d41 + 9185e3c commit b579a6f
Show file tree
Hide file tree
Showing 44 changed files with 1,243 additions and 271 deletions.
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,10 @@ jobs:
- post_steps
e2e-test:
docker:
- image: mcr.microsoft.com/playwright:v1.47.0-jammy
- image: mcr.microsoft.com/playwright:v1.48.0-jammy
steps:
- checkout
- run: npm i -D @playwright/test
- run: npx playwright install chrome
- run:
name: Install dependencies
command: yarn install
Expand All @@ -274,14 +273,16 @@ jobs:
- run:
name: Test nuxt ssr catalogue tests
command: |
yarn playwright install chrome
echo "PR number: ${CIRCLE_PULL_REQUEST##*/}"
export E2E_BASE_URL=https://preview-emx2-pr-${CIRCLE_PULL_REQUEST##*/}.dev.molgenis.org/
echo $E2E_BASE_URL
yarn e2e
working_directory: apps/nuxt3-ssr
- run:
name: Run non ssr e2e tests
command: |
command: |
npx playwright install chrome
echo "PR number: ${CIRCLE_PULL_REQUEST##*/}"
export E2E_BASE_URL=https://preview-emx2-pr-${CIRCLE_PULL_REQUEST##*/}.dev.molgenis.org/
echo $E2E_BASE_URL
Expand Down
78 changes: 27 additions & 51 deletions apps/central/src/components/Groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@
/>

<label>{{ count }} databases found</label>
<ButtonOutline
v-if="showChangeColumnButton && !showChangeColumn"
@click="showChangeColumn = true"
class="float-right"
>
Show changelog
</ButtonOutline>
<ButtonOutline
v-if="showChangeColumnButton && showChangeColumn"
@click="showChangeColumn = false"
class="float-right"
>
Hide changelog
</ButtonOutline>

<table class="table table-hover table-bordered bg-white">
<thead>
Expand Down Expand Up @@ -90,14 +76,8 @@
</td>
<td v-if="showChangeColumn">
<LastUpdateField
v-if="changelogSchemas.includes(schema.id)"
:schema="schema.id"
@input="
(i) => {
schema.update = new Date(i);
handleLastUpdateChange();
}
"
v-if="schema.update"
:lastUpdate="schema.update"
/>
</td>
</tr>
Expand Down Expand Up @@ -167,8 +147,7 @@ export default {
search: null,
sortColumn: "name",
sortOrder: null,
changelogSchemas: [],
showChangeColumn: false,
lastUpdates: [],
};
},
computed: {
Expand All @@ -186,8 +165,8 @@ export default {
this.session.roles.includes("Manager"))
);
},
showChangeColumnButton() {
return this.hasManagerPermission;
showChangeColumn() {
return this.session.email == "admin";
},
},
created() {
Expand Down Expand Up @@ -219,34 +198,31 @@ export default {
},
getSchemaList() {
this.loading = true;
request("graphql", "{_schemas{id,label,description}}")
const schemaFragment = "_schemas{id,label,description}";
const lastUpdateFragment =
"_lastUpdate{schemaName, tableName, stamp, userId, operation}";
request(
"graphql",
`{${schemaFragment} ${this.showChangeColumn ? lastUpdateFragment : ""}}`
)
.then((data) => {
this.schemas = data._schemas;
this.loading = false;
if (this.hasManagerPermission && this.showChangeColumn) {
this.fetchChangelogStatus();
}
})
.catch(
(error) =>
(this.graphqlError = "internal server graphqlError" + error)
);
},
fetchChangelogStatus() {
this.schemas.forEach((schema) => {
request(
`/${schema.id}/settings/graphql`,
`{_settings (keys: ["isChangelogEnabled"]){ key, value }}`
)
.then((data) => {
if (data._settings[0].value.toLowerCase() === "true") {
this.changelogSchemas.push(schema.id);
const lastUpdates = data._lastUpdate ?? [];
lastUpdates.forEach((lastUpdate) => {
const schemaLastUpdate = this.schemas.find(
(schema) => schema.id === lastUpdate.schemaName
);
if (schemaLastUpdate) {
schemaLastUpdate.update = lastUpdate;
}
})
.catch((error) => {
console.log(error);
});
});
this.loading = false;
})
.catch((error) => {
console.error("internal server error", error);
this.graphqlError = "internal server error" + error;
this.loading = false;
});
},
filterSchema(unfiltered) {
let filtered = unfiltered;
Expand All @@ -268,7 +244,7 @@ export default {
if (this.sortColumn === "lastUpdate") {
sorted = unsortedCopy.sort((a, b) => {
if (a.update && b.update) {
return a.update.getTime() - b.update.getTime();
return new Date(a.update.stamp) - new Date(b.update.stamp);
} else if (a.update && !b.update) {
return 1;
} else if (!a.update && b.update) {
Expand Down
63 changes: 15 additions & 48 deletions apps/central/src/components/LastUpdateField.vue
Original file line number Diff line number Diff line change
@@ -1,56 +1,23 @@
<template>
<span v-if="loading"><Spinner></Spinner></span>
<span v-else-if="update">
<a :href="`/${this.schema}/settings/#/changelog`">
{{ formatStamp(update.stamp) }} ({{ update.tableName }})
<span>
<a :href="`/${lastUpdate.schema}/settings/#/changelog`">
{{ timeStamp }} ({{ lastUpdate.tableName }})
</a>
</span>
<span v-else
><em>{{ statusMessage }}</em></span
>
</template>

<script>
import { request } from "graphql-request";
import { Spinner } from "molgenis-components";
export default {
name: "LastUpdateField",
components: { Spinner },
props: {
schema: {
String,
required: true,
},
},
data() {
return {
update: null,
loading: true,
statusMessage: "",
};
},
methods: {
formatStamp(stamp) {
const date = new Date(stamp);
return date.toLocaleDateString();
},
},
async created() {
const resp = await request(
`/${this.schema}/settings/graphql`,
"{_changes(limit: 1) {operation, stamp, userId, tableName}}"
).catch((error) => {
this.statusMessage = "failed to fetch updated";
console.log(error);
});
<script setup lang="ts">
import { computed } from "vue";
this.update = resp ? resp["_changes"][0] : null;
const props = defineProps<{
lastUpdate: {
stamp: number;
tableName: string;
schema: string;
};
}>();
if (this.update && this.update.stamp) {
// emit timestamp for use in row sort
this.$emit("input", this.update.stamp);
}
this.loading = false;
},
};
const timeStamp = computed(() => {
return new Date(props.lastUpdate.stamp).toLocaleDateString();
});
</script>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script setup lang="ts">
import type { ICollectionEvents } from "~/interfaces/catalogue";
const { collectionEvents } = defineProps<{
title: string;
description?: string;
collectionEvents?: IResourceCollectionEvent[];
collectionEvents?: ICollectionEvents[];
}>();
const dataCategories = collectionEvents
Expand Down
33 changes: 18 additions & 15 deletions apps/nuxt3-ssr/components/header/Catalogue.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<script setup lang="ts">
import type { UIResource, UIResourceType } from "~/interfaces/types";
const route = useRoute();
const config = useRuntimeConfig();
const props = defineProps<{
catalogue: any;
catalogue?: UIResource;
variableCount: number;
resourceTypes: UIResourceType[];
}>();
const cohortOnly = computed(() => {
Expand All @@ -23,18 +26,16 @@ if (route.params.resourceType) {
});
}
if (props.catalogue.resources_groupBy?.length) {
props.catalogue.resources_groupBy.forEach(
(sub: { type: { name: string }; count: string }) => {
const resourceTypeMetadata = getResourceMetadataForType(sub.type.name);
menu.push({
label: resourceTypeMetadata.plural,
link:
`/${route.params.schema}/ssr-catalogue/${catalogueRouteParam}/` +
resourceTypeMetadata.path,
});
}
);
if (props.resourceTypes.length > 0) {
props.resourceTypes.forEach((resourceType) => {
const resourceTypeMetadata = getResourceMetadataForType(
resourceType.type.name
);
menu.push({
label: resourceTypeMetadata.plural,
link: `/${route.params.schema}/ssr-catalogue/${catalogueRouteParam}/${resourceTypeMetadata.path}`,
});
});
}
if (!cohortOnly.value && props.variableCount > 0)
Expand Down Expand Up @@ -73,7 +74,9 @@ if (!cohortOnly.value) {
<div class="items-center justify-between hidden xl:flex h-25">
<Logo
:link="`/${route.params.schema}/ssr-catalogue/${catalogueRouteParam}`"
:image="catalogueRouteParam === 'all' ? null : catalogue?.logo?.url"
:image="
catalogueRouteParam === 'all' ? undefined : catalogue?.logo?.url
"
/>
<MainNavigation :navigation="menu" :invert="true" />
<!-- <div class="w-[450px]">
Expand All @@ -91,7 +94,7 @@ if (!cohortOnly.value) {
<LogoMobile
:link="`/${route.params.schema}/ssr-catalogue/${catalogueRouteParam}`"
:image="
catalogueRouteParam === 'all' ? null : catalogue?.logo?.url
catalogueRouteParam === 'all' ? undefined : catalogue?.logo?.url
"
/>
</div>
Expand Down
7 changes: 3 additions & 4 deletions apps/nuxt3-ssr/components/layouts/DetailPage.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script setup lang="ts">
const route = useRoute();
const headerData = await useHeaderData();
const catalogue = headerData.catalogue;
const variableCount = headerData.variableCount;
const bannerData = await useBannerData();
const bannerHtml = computed(() => {
Expand All @@ -15,8 +13,9 @@ const bannerHtml = computed(() => {

<HeaderCatalogue
v-if="route.params.catalogue"
:catalogue="catalogue"
:variableCount="variableCount"
:catalogue="headerData.catalogue"
:variableCount="headerData.variableCount"
:resourceTypes="headerData.resourceTypes"
/>

<HeaderGlobal v-else />
Expand Down
8 changes: 3 additions & 5 deletions apps/nuxt3-ssr/components/layouts/LandingPage.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<script setup lang="ts">
const route = useRoute();
const headerData = await useHeaderData();
const catalogue = headerData.catalogue;
const variableCount = headerData.variableCount;
const bannerData = await useBannerData();
const bannerHtml = computed(() => {
return bannerData.data;
Expand All @@ -15,8 +12,9 @@ const bannerHtml = computed(() => {

<HeaderCatalogue
v-if="route.params.catalogue"
:catalogue="catalogue"
:variableCount="variableCount"
:catalogue="headerData.catalogue"
:variableCount="headerData.variableCount"
:resourceTypes="headerData.resourceTypes"
/>
<HeaderGlobal v-else />
<Container>
Expand Down
8 changes: 3 additions & 5 deletions apps/nuxt3-ssr/components/layouts/SearchPage.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<script setup>
const route = useRoute();
const headerData = await useHeaderData();
const catalogue = headerData.catalogue;
const variableCount = headerData.variableCount;
const bannerData = await useBannerData();
const bannerHtml = computed(() => {
return bannerData.data;
Expand All @@ -15,8 +12,9 @@ const bannerHtml = computed(() => {

<HeaderCatalogue
v-if="route.params.catalogue"
:catalogue="catalogue"
:variableCount="variableCount"
:catalogue="headerData.catalogue"
:variableCount="headerData.variableCount"
:resourceTypes="headerData.resourceTypes"
/>

<HeaderGlobal v-else />
Expand Down
2 changes: 1 addition & 1 deletion apps/nuxt3-ssr/composables/fetchMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StorageSerializers, useSessionStorage } from "@vueuse/core";

import metadataGql from "~~/gql/metadata";
import { type ISchemaMetaData } from "metadata-utils";
import type { ISchemaMetaData } from "../../metadata-utils/src/types";

const query = moduleToString(metadataGql);

Expand Down
Loading

0 comments on commit b579a6f

Please sign in to comment.