Skip to content

Commit

Permalink
Merge pull request #129 from SpeciesFileGroup/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
José Luis Pereira authored and GitHub committed Aug 29, 2023
2 parents df4f57d + b3816f7 commit f4cb578
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 88 deletions.
67 changes: 67 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Bug
description: Open a new issue to describe a bug.
title: "[Bug]: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: >
Please describe the details of any bug you have found. Developers need to know specific details of what you found, where, and how this different from what you expect. _Need help filling this out? Once you have your feature details in hand, contact us and we'll help step you through filling out this issue._
- type: markdown
attributes:
value: |
# Describe the bug
_Please provide a summary about the bug in the following form._
- type: textarea
id: repro
attributes:
label: Steps to reproduce the bug
description: "How do you trigger this bug? Please walk us through it step by step. Try something like, When I do x, then I do y, and do z, I see this error"
value: |
1.
2.
3.
...
render: bash
validations:
required: true
- type: textarea
id: bug_screenshot
attributes:
label: Screenshot
description: Drag/drop your image/s here
validations:
required: false
- type: textarea
id: expected_behavior
attributes:
label: Expected behavior
description: Describe briefly what you expect to happen.
placeholder: When I do a, I expect b, c, d
validations:
required: false
- type: textarea
id: extra_screenshots
attributes:
label: Additional Screenshots
description: If applicable, add screenshots to help explain your problem. Drag/drop your image/s here
validations:
required: false
- type: input
id: taxonpages_site
attributes:
label: TaxonPages Site URL
description: Which website has this bug, please put the URL here, use "local for development environments
placeholder: https://orthoptera.speciesfile.org/, local
- type: input
id: taxonpages_panel
attributes:
label: TaxonPages Panel
description: (optional) Provide which TaxonPages Panel has this bug
placeholder: Nomenclature, Map, Literature
- type: input
id: browser_used
attributes:
label: Browser Used
description: Please share the browser and its version you were using.
placeholder: (e.g. chrome, firefox)
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Feature request or enhancement
description: Open a new issue to describe and request a new feature or enhancement. These will be auto-labeled with _enhancement_. Be sure to provide an informative title.
labels: ["enhancement"]
body:
- type: textarea
id: summary
attributes:
label: Feature or enhancement
description: Please describe what you would like to be able to do or see. Consider telling a story, e.g. first I do x, then y, then I see z.
placeholder: E.g. When I am at X, then I need Y, and when I click, then I will see Z.
validations:
required: true
- type: input
id: summary_target
attributes:
label: Location
description: Stepping back, where should this feature be found? Providing a URL path can help (e.g. /taxon_names/123).
placeholder: Nomenclature Panel
validations:
required: true
- type: textarea
id: figures
attributes:
label: Screenshot, napkin sketch of interface, or conceptual description
description: Provide drawings or screenshots mocking-up (illustrating) your feature, or feature progression.
placeholder: Drag/drop your image(s) here
validations:
required: false
- type: input
id: summary_x
attributes:
label: Your role
description: Who are you, i.e. in what role are you making this feature request?
placeholder: Graduate student biologist
validations:
required: false
27 changes: 14 additions & 13 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,22 @@ export async function createServer(
render = (await import('./dist/server/entry-server.js')).render
}

const [appHtml, appState, preloadLinks, tagMeta] = await render(
url,
manifest,
origin
)
const [appHtml, appState, preloadLinks, tagMeta, redirectRoute] =
await render(url, manifest, origin)

const html = template
.replace(`<!--preload-links-->`, preloadLinks)
.replace(`<!--app-state-->`, appState)
.replace(`<!--head-tags-->`, tagMeta.headTags)
.replace(`<!--body-tags-open-->`, tagMeta.bodyTagsOpen)
.replace(`<!--body-tags-->`, tagMeta.bodyTags)
.replace(makeAppContainer(), makeAppContainer(appHtml))
if (redirectRoute) {
res.redirect(redirectRoute)
} else {
const html = template
.replace(`<!--preload-links-->`, preloadLinks)
.replace(`<!--app-state-->`, appState)
.replace(`<!--head-tags-->`, tagMeta.headTags)
.replace(`<!--body-tags-open-->`, tagMeta.bodyTagsOpen)
.replace(`<!--body-tags-->`, tagMeta.bodyTags)
.replace(makeAppContainer(), makeAppContainer(appHtml))

res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
res.status(200).set({ 'Content-Type': 'text/html' }).end(html)
}
} catch (e) {
vite && vite.ssrFixStacktrace(e)
console.log(e.stack)
Expand Down
5 changes: 4 additions & 1 deletion src/entry-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export async function render(url, manifest, originUrl) {
// itself on ctx.modules. After the render, ctx.modules would contain all the
// components that have been instantiated during this render call.
const ctx = {}
const initialRoute = router.currentRoute.value.path
const html = await renderToString(app, ctx)
const latestRoute = router.currentRoute.value.path
const redirectRoute = initialRoute !== latestRoute && latestRoute
const headPayload = await renderSSRHead(getActiveHead())
const renderState = `
<script>
Expand All @@ -34,7 +37,7 @@ export async function render(url, manifest, originUrl) {
// which we can then use to determine what files need to be preloaded for this
// request.
const preloadLinks = renderPreloadLinks(ctx.modules, manifest)
return [html, renderState, preloadLinks, headPayload]
return [html, renderState, preloadLinks, headPayload, redirectRoute]
}

function renderPreloadLinks(modules, manifest) {
Expand Down
7 changes: 0 additions & 7 deletions src/modules/404/router/index.js

This file was deleted.

15 changes: 15 additions & 0 deletions src/modules/httpErrorPages/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import internalError from '../view/500.vue'
import notFound from '../view/404.vue'

export default [
{
path: '/500',
name: 'httpError500',
component: internalError
},
{
path: '/:pathMatch(.*)*',
name: 'httpError400',
component: notFound
}
]
File renamed without changes.
11 changes: 11 additions & 0 deletions src/modules/httpErrorPages/view/500.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="container mx-auto text-center relative top-1/4">
<h1 class="text-7xl text-base-lighter">500</h1>
<p>Internal Server Error.</p>
<p class="m-4 my-10 text-xl">
Uh oh, looks like something went wrong!<br />
We track these errors automatically, but if the problem persists feel free
to contact us.
</p>
</div>
</template>
9 changes: 0 additions & 9 deletions src/modules/otus/store/actions/loadCachedMap.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/modules/otus/store/actions/loadCatalog.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/modules/otus/store/actions/loadTaxonomy.js

This file was deleted.

55 changes: 36 additions & 19 deletions src/modules/otus/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { defineStore } from 'pinia'
import TaxonWorks from '../services/TaxonWorks'
import { useOtuPageRequest } from '../helpers/useOtuPageRequest'
import { useOtuPageRequestStore } from './request'
import {
actionLoadCatalog,
actionLoadTaxonomy,
actionLoadCachedMap
} from './actions'

export const useOtuStore = defineStore('otuStore', {
state: () => {
Expand Down Expand Up @@ -40,28 +35,50 @@ export const useOtuStore = defineStore('otuStore', {
this.otu = otu.data
},

async loadTaxonomy(otuId, { signal }) {
const { data } = await TaxonWorks.getTaxonomy(otuId, {
params: {
max_descendants_depth: 0,
extend: ['common_names']
},
signal
})

this.taxonomy = {
commonNames: data.common_names,
synonyms: data.nomenclatural_synonyms
}
},

async loadCatalog(taxonId, { signal }) {
this.catalog.isLoading = true

const response = await useOtuPageRequest('taxonomy', () =>
TaxonWorks.getTaxonNameCitations(taxonId, { signal })
)

this.catalog = {
...response.data,
sources: response.data.sources.map(({ cached, url }) =>
cached.replace(url, `<a href="${url}">${url}</a>`)
),
isLoading: false
}
},

async loadInit({ otuId, controller }) {
const requestStore = useOtuPageRequestStore()
const { signal } = controller

requestStore.$reset()

try {
await this.loadOtu(otuId, { signal })
await this.loadTaxon(this.otu.taxon_name_id, {
signal
})
await this.loadCatalog(this.otu.taxon_name_id, {
signal
})
await this.loadTaxonomy(otuId, { signal })
await this.loadOtu(otuId, controller)
await this.loadTaxon(this.otu.taxon_name_id, controller)
await this.loadCatalog(this.otu.taxon_name_id, controller)
await this.loadTaxonomy(otuId, controller)
} catch (error) {
return Promise.reject(error)
}
},

...actionLoadCatalog,
...actionLoadTaxonomy,
...actionLoadCachedMap
}
}
})
13 changes: 12 additions & 1 deletion src/modules/otus/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,22 @@ async function loadInitialData() {
updateMetadata()
} catch (e) {
if (e.name !== RESPONSE_ERROR.CanceledError) {
router.replace({ name: 'notFound' })
redirectOnError(e)
}
}
}
function redirectOnError(error) {
switch (error?.response?.status) {
case 404:
router.replace({ name: 'httpError400' })
break
case 500:
router.replace({ name: 'httpError500' })
break
}
}
function updateMetadata() {
useHead({
title: `${__APP_ENV__.project_name} - ${taxon.value.full_name}`
Expand Down

0 comments on commit f4cb578

Please sign in to comment.