-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from digital-land/feat/dashboard
Feat/dashboard
- Loading branch information
Showing
28 changed files
with
585 additions
and
44 deletions.
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.