Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 177: | Line 177: | ||
const FUNC_KEY = 'functions'; | const FUNC_KEY = 'functions'; | ||
const DESC_KEY = 'description'; | const DESC_KEY = 'description'; | ||
/** @type Map<string, { [DESC_KEY]: string, [FUNC_KEY]: string[] } */ | |||
const functionsData = new Map(); | |||
const hasFunction = (dctResult, subfunctions) => subfunctions.some(func => { | const hasFunction = (dctResult, subfunctions) => subfunctions.some(func => { | ||
Line 190: | Line 193: | ||
const functionsQueryResults = functionsQueryResponse.query.results; | const functionsQueryResults = functionsQueryResponse.query.results; | ||
Object.keys(functionsQueryResults).forEach(key => { | Object.keys(functionsQueryResults).forEach(key => { | ||
const functionCategory = functionsQueryResults[key]; | const functionCategory = functionsQueryResults[key]; | ||
Line 202: | Line 203: | ||
[FUNC_KEY]: functionCategory.printouts[FUNC_KEY].map(subfunction => removePrefix(subfunction.fulltext)) | [FUNC_KEY]: functionCategory.printouts[FUNC_KEY].map(subfunction => removePrefix(subfunction.fulltext)) | ||
} | } | ||
) | ); | ||
}) | }); | ||
const allFunctions = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat(); | |||
const dctQuery = '[[Category:Disaster Community Technology]]' + | const dctQuery = '[[Category:Disaster Community Technology]]' + | ||
Line 278: | Line 213: | ||
'|?Image' + | '|?Image' + | ||
'|?Data Sources' + | '|?Data Sources' + | ||
'|?' + | '|?' + allFunctions.join('|?'); | ||
const | const dctResponse = await fetch(getQueryUrl(dctQuery)).then(response => response.json()); | ||
console.log( | console.log(dctResponse.query.results) | ||
const dctList = Object. | const dctList = Object.keys(dctResponse.query.results).map(dctKey => { | ||
const dctResult = dctResponse.query.results[dctKey]; | |||
/** @type {DCT} */ | /** @type {DCT} */ | ||
const dct = {}; | const dct = {}; | ||
dct.name = dctKey; | dct.name = dctKey; | ||
dct.url = dctResult.fullurl; | dct.url = dctResult.fullurl; | ||
dct.dataSources = dctResult.printouts['Data Sources'].map(source => source.fulltext).sort(); | dct.dataSources = dctResult.printouts['Data Sources'].map(source => source.fulltext).sort(); | ||
dct.logo = dctResult.printouts['Image'][0] ? getFilePath(dctResult.printouts['Image'][0].fulltext) : | dct.logo = dctResult.printouts['Image'][0] ? getFilePath(dctResult.printouts['Image'][0].fulltext) : undefined; | ||
dct.functions = []; | dct.functions = []; | ||
if (hasFunction(dctResult, searchFunctions)) dct.functions.push(FN_SEARCH); | // functionsData.forEach((value, key) => { | ||
if (hasFunction(dctResult, postFunctions)) dct.functions.push(FN_POST); | // if (value[FUNC_KEY].some(func =>)) | ||
if (hasFunction(dctResult, analysisFunctions)) dct.functions.push(FN_ANALYSIS); | // }); | ||
if (hasFunction(dctResult, metricsFunctions)) dct.functions.push(FN_METRICS); | |||
if (hasFunction(dctResult, reportFunctions)) dct.functions.push(FN_REPORT); | // if (hasFunction(dctResult, searchFunctions)) dct.functions.push(FN_SEARCH); | ||
if (hasFunction(dctResult, collaborationFunctions)) dct.functions.push(FN_COLLAB); | // if (hasFunction(dctResult, postFunctions)) dct.functions.push(FN_POST); | ||
if (hasFunction(dctResult, interoperabilityFunctions)) dct.functions.push(FN_INTEROP); | // if (hasFunction(dctResult, analysisFunctions)) dct.functions.push(FN_ANALYSIS); | ||
if (hasFunction(dctResult, metaFunctions)) dct.functions.push(FN_META); | // if (hasFunction(dctResult, metricsFunctions)) dct.functions.push(FN_METRICS); | ||
// if (hasFunction(dctResult, reportFunctions)) dct.functions.push(FN_REPORT); | |||
// if (hasFunction(dctResult, collaborationFunctions)) dct.functions.push(FN_COLLAB); | |||
// if (hasFunction(dctResult, interoperabilityFunctions)) dct.functions.push(FN_INTEROP); | |||
// if (hasFunction(dctResult, metaFunctions)) dct.functions.push(FN_META); | |||
return dct; | return dct; |
Revision as of 15:02, 30 August 2022
Development verstion of the DCT List.
Not ready for production!