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 124: Line 124:
     let table;
     let table;


     const FN_SEARCH = 'Search & Monitor';
     const FN_SEARCH   = 'Search & Monitor';
     const FN_POST = 'Post & Schedule';
     const FN_POST     = 'Post & Schedule';
     const FN_ANALYSIS = 'Analysis';
     const FN_ANALYSIS = 'Analysis';
     const FN_METRICS = 'Metrics';
     const FN_METRICS = 'Metrics';
     const FN_REPORT = 'Report';
     const FN_REPORT   = 'Report';
     const FN_COLLAB = 'Collaboration';
     const FN_COLLAB   = 'Collaboration';
     const FN_INTEROP = 'Interoperability';
     const FN_INTEROP = 'Interoperability';
     const FN_META = 'Meta';
     const FN_META     = 'Meta';


     const fnImages = {};
     const fnImages = {};
     fnImages[FN_SEARCH] = '/index.php/Special:FilePath/File:Func_search.svg';
     fnImages[FN_SEARCH]   = '/index.php/Special:FilePath/File:Func_search.svg';
     fnImages[FN_POST] = '/index.php/Special:FilePath/File:Func_post.svg';
     fnImages[FN_POST]     = '/index.php/Special:FilePath/File:Func_post.svg';
     fnImages[FN_ANALYSIS] = '/index.php/Special:FilePath/File:Func_analysis.svg';
     fnImages[FN_ANALYSIS] = '/index.php/Special:FilePath/File:Func_analysis.svg';
     fnImages[FN_METRICS] = '/index.php/Special:FilePath/File:Func_metrics.svg';
     fnImages[FN_METRICS] = '/index.php/Special:FilePath/File:Func_metrics.svg';
     fnImages[FN_REPORT] = '/index.php/Special:FilePath/File:Func_report.svg';
     fnImages[FN_REPORT]   = '/index.php/Special:FilePath/File:Func_report.svg';
     fnImages[FN_COLLAB] = '/index.php/Special:FilePath/File:Func_collaboration.svg';
     fnImages[FN_COLLAB]   = '/index.php/Special:FilePath/File:Func_collaboration.svg';
     fnImages[FN_INTEROP] = '/index.php/Special:FilePath/File:Func_interoperability.svg';
     fnImages[FN_INTEROP] = '/index.php/Special:FilePath/File:Func_interoperability.svg';
     fnImages[FN_META] = '/index.php/Special:FilePath/File:Func_meta.svg';
     fnImages[FN_META]     = '/index.php/Special:FilePath/File:Func_meta.svg';


     const sourcesLayout = [
     const sourcesLayout = [
Line 155: Line 155:


     const getUrl = title =>  title ? '/index.php/Special:FilePath/' + title : title;
     const getUrl = title =>  title ? '/index.php/Special:FilePath/' + title : title;
     const escapeAttr = text => text ? text.replace(/\s/g, '-') : text;
     const escapeAttr = text => text ? text.replace(/\s/g, '-') : text;
     const hasFunction = (dctResult, subfunctions) => subfunctions.some(func => {
     const hasFunction = (dctResult, subfunctions) => subfunctions.some(func => {
         const printoutResult = dctResult.printouts[func];
         const printoutResult = dctResult.printouts[func];
Line 249: Line 247:
         const dctResponse = await fetch(dctQueryUrl).then(response => response.json());
         const dctResponse = await fetch(dctQueryUrl).then(response => response.json());


       
         const results = dctResponse.query.results;
         const results = dctResponse.query.results;
        console.log('Fetch res:', results)
         const dctList = Object.getOwnPropertyNames(results).map(dctKey => {
         const dctList = Object.getOwnPropertyNames(results).map(dctKey => {


Line 307: Line 307:
         const selectedFunctions = functionOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
         const selectedFunctions = functionOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);


         // If all checkboxes are checked, disable the filter.
         // If all checkboxes are checked, disable the filter property.
         filterState.functions = selectedFunctions.length === functionOptions.length ? undefined : selectedFunctions;
         filterState.functions = selectedFunctions.length === functionOptions.length ? undefined : selectedFunctions;


Line 313: Line 313:
         const selectedSources = sourceOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);
         const selectedSources = sourceOptions.filter(checkbox => checkbox.checked).map(checkbox => checkbox.value);


         // If all checkboxes are checked, disable the filter.
         // If all checkboxes are checked, disable the filter property.
         filterState.dataSources = selectedSources.length === sourceOptions.length ? undefined : selectedSources;
         filterState.dataSources = selectedSources.length === sourceOptions.length ? undefined : selectedSources;


Line 396: Line 396:
                         const val = cell.getValue();
                         const val = cell.getValue();
                         let out = '';
                         let out = '';
                        // let x = groupedSources.reduce((acc, curr) => acc.concat(curr.sources), []);
                        // console.log(x)


                         groupedSources.forEach((group, gIndex) => {
                         groupedSources.forEach((group, gIndex) => {
Line 407: Line 405:
                                 } else {
                                 } else {
                                     return curr.image
                                     return curr.image
                                         ? prev + '<img class="data-source-img" data-value="' + curr.name + '" src="' + curr.image + '" alt="' + curr.name +'" title="' + curr.name + '">'
                                         ? prev + '<img class="data-source-img" data-value="' + curr.name
                                              + '" src="' + curr.image  
                                              + '" alt="' + curr.name  
                                              +'" title="' + curr.name + '">'
                                         : prev + ' ' + curr.name;
                                         : prev + ' ' + curr.name;
                                 }
                                 }

Revision as of 15:44, 25 August 2022

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