Skip to content
Snippets Groups Projects
Commit d042d0d9 authored by geant-release-service's avatar geant-release-service
Browse files

Finished release 0.6.

parents 4b2aa4fc 83c86f6c
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
## [0.7] - 2023-02-22
- Fix API call URL http -> https redirect bug
## [0.6] - 2023-02-22
- API for budget data
- Initial processing of Budget data from survey DB into presentation DB
......
export default "images/compendium_header.png";
\ No newline at end of file
This diff is collapsed.
......@@ -18,6 +18,8 @@
* Released under the MIT License
*/
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
/**
* @license React
* react-dom.production.min.js
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='compendium-v2',
version="0.5",
version="0.6",
author='GEANT',
author_email='swd@geant.org',
description='Flask and React project for displaying '
......
......@@ -23,7 +23,7 @@ export const options = {
};
function DataAnalysis(): ReactElement {
function api<T>(url: string, options: RequestInit): Promise<T> {
function api<T>(url: string, options: RequestInit | undefined = undefined): Promise<T> {
return fetch(url, options)
.then((response) => {
if (!response.ok) {
......@@ -42,13 +42,12 @@ function DataAnalysis(): ReactElement {
const [selectedDataEntry, setSelectedDataEntry] = useState<number>(0);
useEffect(() => {
// let timeoutRef = 0;
const getDataEntries = () => {
// hardcode selected section for now
const dataEntrySectionResponse: DataEntrySection = {
description: "Org",
items: [
{
id: 2,
id: 0,
title: "NREN Budgets per year, in Millions EUR",
url: "/api/data-entries/item/2"
}
......@@ -61,35 +60,20 @@ function DataAnalysis(): ReactElement {
name: "Organisation"
}
setDataEntrySection(dataEntrySectionResponse);
console.log("getDataEntries " + dataEntrySection);
// Autoload the first graph
if (dataEntrySectionResponse.items.length > 0) {
setSelectedDataEntry(dataEntrySectionResponse.items[0].id);
}
}
const loadData = () => {
console.log("selectedDataEntry " + selectedDataEntry)
if (selectedDataEntry == 0) {
getDataEntries();
return;
}
console.log("budgetResponse " + budgetResponse)
if (budgetResponse == undefined) {
api<Budget[]>('/api/budget', {
referrerPolicy: "unsafe-url",
headers: {
"Access-Control-Allow-Origin": "*",
"Content-Type": "text/plain",
"Access-Control-Allow-Methods": "GET, POST, PATCH, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Origin, Content-Type, X-Auth-Token"
}, [])
}
})
useEffect(() => {
const loadData = async () => {
if (budgetResponse == undefined) {
api<Budget[]>('/api/budget/', {})
.then((budget: Budget[]) => {
if (selectedDataEntry == 2)
options.plugins.title.text = 'NREN Budgets per year, in Millions EUR';
console.log('budget:', budget)
const entry = dataEntrySection?.items.find(i => i.id == selectedDataEntry)
console.log(selectedDataEntry, dataEntrySection, entry)
if (entry)
options.plugins.title.text = entry.title;
setBudget(budget)
console.log("API positive response Budget : " + budget)
convertToBudgetPerYearDataResponse(budget)
})
.catch(error => {
......@@ -101,7 +85,7 @@ function DataAnalysis(): ReactElement {
}
loadData()
}, [selectedDataEntry]);
}, [dataEntrySection, selectedDataEntry]);
const empty_bar_response = {
data: {
......@@ -128,13 +112,10 @@ function DataAnalysis(): ReactElement {
const convertToBudgetPerYearDataResponse = (budgetResponse: Budget[]) => {
console.log("convertToBudgetPerYearDataResponse budgetResponse " + budgetResponse);
const barResponse = budgetResponse != undefined ? budgetResponse : empty_budget_response;
const labelsYear = [...new Set(barResponse.map((item) => item.BUDGET_YEAR))];
const labelsNREN = [...new Set(barResponse.map((item) => item.NREN))];
console.log("convertToBudgetPerYearDataResponse " + barResponse);
function getRandomColor() {
const red = Math.floor(Math.random() * 256).toString(16).padStart(2, '0'); // generates a value between 00 and ff
......@@ -173,7 +154,7 @@ function DataAnalysis(): ReactElement {
}
})
if (selectedDataEntry == 2) {
if (selectedDataEntry == 0) {
const dataResponse: BudgetMatrix = {
data: {
datasets: datasetPerNREN,
......@@ -186,7 +167,7 @@ function DataAnalysis(): ReactElement {
" have been higher. (For comparison, the total budget" +
" according to the 2021 survey results based on the data" +
" for all responding NRENs that year is €555 M). The" +
" percentage change is based on the previous years" +
" percentage change is based on the previous year's" +
" budget.",
id: "3",
settings: {},
......
......@@ -75,7 +75,6 @@ const config: Configuration = {
},
output: {
path: path.resolve(__dirname, "..", "compendium_v2", "static"),
publicPath: '/static/',
filename: "bundle.js",
},
devServer: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment