Widget: DCTList: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 170: Line 170:
                               '|?-Subproperty_of=' + FUNC_KEY +
                               '|?-Subproperty_of=' + FUNC_KEY +
                               '|?Has_description=' + DESC_KEY;
                               '|?Has_description=' + DESC_KEY;
         const functionsQueryResponse = await fetch(getQueryUrl(functionsQuery)).then(response => response.json());
         const functionsQueryResponse = await fetch(getQueryUrl(functionsQuery)).then(response => response.json());
        const functionsQueryResults = functionsQueryResponse.query.results;
          
          
         Object.keys(functionsQueryResults).forEach(key => {
         Object.keys(functionsQueryResponse.query.results).forEach(key => {
             const functionCategory = functionsQueryResults[key];
             const functionCategory = functionsQueryResponse.query.results[key];
             functionsData.set(
             functionsData.set(
                 removePrefix(functionCategory.fulltext),
                 removePrefix(functionCategory.fulltext),
Line 185: Line 183:
         });
         });


         // TODO: Remove properties that are not relevant for the filter, e.g. 'Supported content types'.
         // TODO: Remove properties that are not relevant for the filter? (e.g. 'Supported content types')
         const allFunctions = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat();
         const allFunctions = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat();


        const DATASRC_PROP = 'Data Sources';
        const IMG_PROP = 'Image';
         const dctQuery = '[[Category:Disaster Community Technology]]' +
         const dctQuery = '[[Category:Disaster Community Technology]]' +
                         '[[Is Archived::No]]' +
                         '[[Is Archived::No]]' +
                         '|limit=500' +
                         '|limit=500' +
                         '|?Image' +
                         '|?' + IMG_PROP +
                         '|?Data Sources' +
                         '|?' + DATASRC_PROP +
                         '|?' + allFunctions.join('|?');
                         '|?' + allFunctions.join('|?');


         const dctResponse = await fetch(getQueryUrl(dctQuery)).then(response => response.json());
         const dctResponse = await fetch(getQueryUrl(dctQuery)).then(response => response.json());
         const dctList = Object.keys(dctResponse.query.results).map(dctKey => {
         const dctList = Object.keys(dctResponse.query.results).map(dctName => {
             const dctResult = dctResponse.query.results[dctKey];
             const dctResult = dctResponse.query.results[dctName];


             /** @type {DCT} */
             /** @type {DCT} */
             const dct = {};
             const dct = {};
             dct.name = dctKey;
             dct.name = dctName;
             dct.url = dctResult.fullurl;
             dct.url = dctResult.fullurl;
             dct.dataSources = dctResult.printouts['Data Sources'].map(source => source.fulltext).sort();
             dct.dataSources = dctResult.printouts[DATASRC_PROP].map(source => source.fulltext).sort();
             dct.logo = dctResult.printouts['Image'][0] ? getFilePath(dctResult.printouts['Image'][0].fulltext) : undefined;
             dct.logo = dctResult.printouts[IMG_PROP][0] ? getFilePath(dctResult.printouts[IMG_PROP][0].fulltext) : undefined;
 
             dct.functions = [];
             dct.functions = [];
             functionsData.forEach((value, key) => {
             functionsData.forEach((value, key) => {
                 if (value[FUNC_KEY].some(
                 if (value[FUNC_KEY].some(

Revision as of 09:32, 31 August 2022

Development verstion of the DCT List.
Not ready for production!