-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/dashboard #115
Merged
Merged
Feat/dashboard #115
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5e073c0
added basic lpa-overview page
GeorgeGoodall 5b83f49
linting
GeorgeGoodall ce022c9
Merge branch 'main' into feat/dashboard
GeorgeGoodall a46e291
remove unused param
GeorgeGoodall 7cc54a7
move services to service folder
GeorgeGoodall 085e917
added a controller and performanceDbApi service
GeorgeGoodall ed3091b
linting
GeorgeGoodall 0a489c5
now get mock data from the mock api, and use it to populate the template
GeorgeGoodall 3599715
add make dataset slug to readable name filter factory function and mo…
GeorgeGoodall 96f3e91
linting
GeorgeGoodall 62078a1
minor template tweeks
GeorgeGoodall 3eeecfe
added template unit tests for lpa overview page
GeorgeGoodall 1273183
added tests for the lpa overview controller
GeorgeGoodall 0fe19e3
linting
GeorgeGoodall 7901b6f
change in response to rolands pr comment
GeorgeGoodall 18434e5
Merge branch 'staging' into feat/dashboard
GeorgeGoodall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import performanceDbApi from '../services/performanceDbApi.js' // Assume you have an API service module | ||
import logger from '../utils/logger.js' | ||
|
||
const LpaOverviewController = { | ||
async getOverview (req, res, next) { | ||
try { | ||
const lpa = req.params.lpa | ||
|
||
const response = await performanceDbApi.getLpaOverview(lpa) // Make API request | ||
const data = response.data | ||
|
||
const datasets = Object.entries(data.datasets).map(([key, value]) => { | ||
return { ...value, slug: key } | ||
}) | ||
const totalDatasets = datasets.length | ||
const [datasetsWithEndpoints, datasetsWithIssues, datasetsWithErrors] = datasets.reduce((accumulator, dataset) => { | ||
if (dataset.endpoint !== null) accumulator[0]++ | ||
if (dataset.issue) accumulator[1]++ | ||
if (dataset.error) accumulator[2]++ | ||
return accumulator | ||
}, [0, 0, 0]) | ||
|
||
const params = { | ||
organisation: { | ||
name: data.name | ||
}, | ||
datasets, | ||
totalDatasets, | ||
datasetsWithEndpoints, | ||
datasetsWithIssues, | ||
datasetsWithErrors | ||
} | ||
|
||
res.render('manage/lpa-overview.html', params) | ||
} catch (error) { | ||
logger.error(error) | ||
next(error) | ||
} | ||
} | ||
} | ||
|
||
export default LpaOverviewController |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Creates a filter function that takes a dataset slug as input and returns its corresponding readable name. | ||
* The filter function uses a provided dataset name mapping to look up the readable name. | ||
* | ||
* @param {Map<string, string>} datasetNameMapping - A map of dataset slugs to their corresponding readable names. | ||
* @returns {(slug: string) => string} - A filter function that takes a dataset slug as input and returns its corresponding readable name. | ||
*/ | ||
export const makeDatasetSlugToReadableNameFilter = (datasetNameMapping) => { | ||
/** | ||
* A filter function that takes a dataset slug as input and returns its corresponding readable name. | ||
* | ||
* @param {string} slug - The dataset slug to look up. | ||
* @returns {string} - The readable name corresponding to the provided slug. | ||
* @throws {Error} - If the provided slug is not found in the dataset name mapping. | ||
*/ | ||
return (slug) => { | ||
const name = datasetNameMapping.get(slug) | ||
if (!name) { | ||
throw new Error(`Can't find a name for ${slug}`) | ||
} | ||
return name | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param {*} dataSubjects | ||
* @returns {Map<string,string>} | ||
*/ | ||
export const createDatasetMapping = (dataSubjects) => { | ||
const mapping = new Map() | ||
for (const data of Object.values(dataSubjects)) { | ||
for (const dataset of data.dataSets) { | ||
mapping.set(dataset.value, dataset.text) | ||
} | ||
} | ||
return mapping | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import express from 'express' | ||
import LpaOverviewController from '../controllers/LpaOverviewController.js' | ||
|
||
const router = express.Router() | ||
|
||
router.get('/:lpa/overview', LpaOverviewController.getOverview) | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export default { | ||
getLpaOverview: async (lpa) => { | ||
return { | ||
data: { | ||
name: 'Borechester City Council', | ||
datasets: { | ||
'article-4-direction': { | ||
endpoint: null | ||
}, | ||
'article-4-direction-area': { | ||
endpoint: null | ||
}, | ||
'conservation-area': { | ||
endpoint: 'http://conservation-area.json', | ||
error: null, | ||
issue: 'Endpoint has not been updated since 21 May 2023' | ||
}, | ||
'conservation-area-document': { | ||
endpoint: 'http://conservation-area-document.json', | ||
error: null, | ||
issue: null | ||
}, | ||
'listed-building-outline': { | ||
endpoint: 'http://listed-building-outline.json', | ||
error: null, | ||
issue: null | ||
}, | ||
tree: { | ||
endpoint: 'http://tree.json', | ||
error: null, | ||
issue: 'There are 20 issues in this dataset' | ||
}, | ||
'tree-preservation-order': { | ||
endpoint: 'http://tree-preservation-order.json', | ||
error: 'Error connecting to endpoint', | ||
issue: null | ||
}, | ||
'tree-preservation-zone': { | ||
endpoint: 'http://tree-preservation-zone.json', | ||
error: 'Error connecting to endpoint', | ||
issue: null | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not writing any tests for this yet as it will heavily change once infa implement their api