diff --git a/deploy/csp/index.js b/deploy/csp/index.js index 51a3cf1598f93b61e0efdc38f4a2e80d40aba68c..7273c69b4e841bc5e0be5aa85d68fb8c10b15e09 100644 --- a/deploy/csp/index.js +++ b/deploy/csp/index.js @@ -111,7 +111,8 @@ module.exports = { 'cdnjs.cloudflare.com/ajax/libs/d3/', // required for preview component 'cdnjs.cloudflare.com/ajax/libs/mathjax/', // math jax 'https://unpkg.com/three-surfer@0.0.11/dist/bundle.js', // for threeSurfer (freesurfer support in browser) - 'https://unpkg.com/ng-layer-tune@0.0.5/dist/ng-layer-tune/', // needed for ng layer control + 'https://unpkg.com/ng-layer-tune@0.0.6/dist/ng-layer-tune/', // needed for ng layer control + 'https://unpkg.com/hbp-connectivity-component@0.6.2/', // needed for connectivity component (req, res) => res.locals.nonce ? `'nonce-${res.locals.nonce}'` : null, ...SCRIPT_SRC, ...WHITE_LIST_SRC, diff --git a/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.spec.ts b/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a7eb1fc32405cd1a4f9128cfda54c018eb45766 --- /dev/null +++ b/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.spec.ts @@ -0,0 +1,52 @@ +import { IDS } from "src/atlasComponents/sapi/constants" +import { SAPI } from "src/atlasComponents/sapi/sapi.service" +import { SapiParcellationModel } from "src/atlasComponents/sapi/type" +import { getTraverseFunctions } from "./parcellationVersion.pipe" + +describe("parcellationVersion.pipe.ts", () => { + describe("getTraverseFunctions", () => { + let julichBrainParcellations: SapiParcellationModel[] = [] + beforeAll(async () => { + const res = await fetch(`${SAPI.bsEndpoint}/atlases/${encodeURIComponent(IDS.ATLAES.HUMAN)}/parcellations`) + const arr: SapiParcellationModel[] = await res.json() + julichBrainParcellations = arr.filter(it => /Julich-Brain Cytoarchitectonic Maps/.test(it.name)) + }) + it("> should be at least 3 parcellations", () => { + expect(julichBrainParcellations.length).toBeGreaterThanOrEqual(3) + }) + + const scenarios = [{ + name: "default", + inputFlag: undefined, + expect25: false + },{ + name: "skipDeprecated set to true", + inputFlag: true, + expect25: false + },{ + name: "skipDeprecated set to false", + inputFlag: false, + expect25: true + }] + + for (const { name, inputFlag, expect25} of scenarios) { + describe(name, () => { + it(`expect to find 25: ${expect25}`, () => { + const { findNewer, findOldest } = typeof inputFlag === "undefined" + ? getTraverseFunctions(julichBrainParcellations) + : getTraverseFunctions(julichBrainParcellations, inputFlag) + let cursor: SapiParcellationModel = findOldest() + let foundFlag: boolean = false + while (cursor) { + if (cursor.name === "Julich-Brain Cytoarchitectonic Maps 2.5") { + if (expect25) foundFlag = true + break + } + cursor = findNewer(cursor) + } + expect(foundFlag).toEqual(expect25) + }) + }) + } + }) +}) \ No newline at end of file diff --git a/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.ts b/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.ts index 506acc493479285eb4271aee38f5cd1798174fda..a2e5e1f3ff73e2b3ec837188c52c5670e4348e46 100644 --- a/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.ts +++ b/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.ts @@ -1,20 +1,28 @@ import { Pipe, PipeTransform } from "@angular/core"; import { SapiParcellationModel } from "src/atlasComponents/sapi/type"; -export function getTraverseFunctions(parcellations: SapiParcellationModel[]) { +export function getTraverseFunctions(parcellations: SapiParcellationModel[], skipDeprecated: boolean = true) { - const getTraverse = (key: 'prev' | 'next') => (parc: SapiParcellationModel) => { - if (!parc.version) { - throw new Error(`parcellation ${parc.name} does not have version defined!`) - } - if (!parc.version[key]) { - return null - } - const found = parcellations.find(p => p["@id"] === parc.version[key]["@id"]) - if (!found) { - throw new Error(`parcellation ${parc.name} references ${parc.version[key]['@id']} as ${key} version, but it cannot be found.`) + const getTraverse = (key: 'prev' | 'next') => { + + const returnFunction = (parc: SapiParcellationModel) => { + if (!parc.version) { + throw new Error(`parcellation ${parc.name} does not have version defined!`) + } + if (!parc.version[key]) { + return null + } + const found = parcellations.find(p => p["@id"] === parc.version[key]["@id"]) + if (!found) { + throw new Error(`parcellation ${parc.name} references ${parc.version[key]['@id']} as ${key} version, but it cannot be found.`) + } + if (skipDeprecated && found.version.deprecated) { + return returnFunction(found) + } + return found } - return found + + return returnFunction } const findNewer = getTraverse('next') diff --git a/src/index.html b/src/index.html index 73874be6ee8682b4dbd5c5ba2a1882568f62c1aa..56e924d2b7181e2344f5bb912174a8013a52bde2 100644 --- a/src/index.html +++ b/src/index.html @@ -16,7 +16,7 @@ <script src="https://unpkg.com/three-surfer@0.0.11/dist/bundle.js" defer></script> <script type="module" src="https://unpkg.com/ng-layer-tune@0.0.6/dist/ng-layer-tune/ng-layer-tune.esm.js"></script> <script type="module" src="https://unpkg.com/hbp-connectivity-component@0.6.2/dist/connectivity-component/connectivity-component.js" ></script> - <title>Interactive Atlas Viewer</title> + <title>Siibra Explorer</title> </head> <body> <atlas-viewer>