diff --git a/README.md b/README.md index 1a26e55..4c521a9 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ This is an app I'm creating to visualise data I've created (in JSON form) describing my self-hosted (professional, volunteer, & personal) webservices. -## Credits - -Developed by Dave Lane, [Open Source Technologist](https://oerfoundation.org/about/staff/#Dave_Lane) at the [OER Foundation](https://oerfoundation.org). Many thanks to support from the Foundation for this exploratory work! ## Installing the Webservices App diff --git a/src/colours.js b/src/colours.js deleted file mode 100644 index 6e38a5a..0000000 --- a/src/colours.js +++ /dev/null @@ -1,35 +0,0 @@ -// source: https://mokole.com/palette.html 20 colors with default settings otherwise -const colours = [ - '#808080', - '#7f0000', - '#006400', - '#808000', - '#483d8b', - '#008b8b', - '#cd853f', - '#00008b', - '#7f007f', - '#8fbc8f', - '#b03060', - '#ff0000', - '#ff8c00', - '#00ff00', - '#9400d3', - '#00ff7f', - '#dc143c', - '#00ffff', - '#00bfff', - '#0000ff', - '#f08080', - '#adff2f', - '#1e90ff', - '#ffff54', - '#90ee90', - '#add8e6', - '#ff1493', - '#7b68ee', - '#ee82ee', - '#ffe4b5' -]; - -export { colours }; diff --git a/src/lib/processData.svelte b/src/lib/processData.svelte deleted file mode 100644 index f3c3bfe..0000000 --- a/src/lib/processData.svelte +++ /dev/null @@ -1,112 +0,0 @@ - - diff --git a/src/references.js b/src/references.js deleted file mode 100644 index ebaa201..0000000 --- a/src/references.js +++ /dev/null @@ -1,3 +0,0 @@ -const References = {}; - -export { References }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 1f334bb..59306d1 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -3,13 +3,149 @@ export let data; const { webservices } = data; - //import References from '../references.js'; - import { colours } from '../colours.js'; - import { processData } from '../lib/processData.svelte'; + // source: https://mokole.com/palette.html 20 colors with default settings otherwise + const colours30 = [ + '#808080', + '#7f0000', + '#006400', + '#808000', + '#483d8b', + '#008b8b', + '#cd853f', + '#00008b', + '#7f007f', + '#8fbc8f', + '#b03060', + '#ff0000', + '#ff8c00', + '#00ff00', + '#9400d3', + '#00ff7f', + '#dc143c', + '#00ffff', + '#00bfff', + '#0000ff', + '#f08080', + '#adff2f', + '#1e90ff', + '#ffff54', + '#90ee90', + '#add8e6', + '#ff1493', + '#7b68ee', + '#ee82ee', + '#ffe4b5' + ]; - console.log('colours: ', colours); + // digest and return useful info from the Webservices JSON feed + function processData(webservices) { + let instances = 0; + let current = []; + let future = []; + // properties of technologies + let category_list = []; + let analogue_list = []; + let license_list = []; + // properties of instances + let status_list = []; + let affiliate_list = []; + let host_list = []; + // actual objects + let hosts = []; + let affiliates = []; + // + // just a trivial reassignment + //let hosts = webservices.hosts; + // + // pull out relevant info in useful chunks. + for (let key in webservices.technologies) { + let tech = webservices.technologies[key]; + if (tech.hasOwnProperty('categories') && tech.categories.constructor === Array) { + tech.categories.forEach(function (category, index) { + if (category_list.hasOwnProperty(category)) category_list[category]++; + else category_list[category] = 1; + }); + } + if (tech.hasOwnProperty('analogues') && tech.analogues.constructor === Array) { + tech.analogues.forEach(function (analogue, index) { + if (analogue_list.hasOwnProperty(analogue)) analogue_list[analogue]++; + else analogue_list[analogue] = 1; + }); + } + if (tech.hasOwnProperty('license')) { + let license = tech.license; + if (license_list.hasOwnProperty(license)) license_list[license]++; + else license_list[license] = 1; + } + if (hasInstances(tech)) { + tech['name'] = key; + current.push(tech); + //console.log(tech.name + ': ' + tech.instances.length + ' instances...'); + tech.instances.forEach(function (instance, i) { + instances++; + if (instance.hasOwnProperty('status')) { + let tag = instance.status; + if (status_list.hasOwnProperty(tag)) status_list[tag]++; + else status_list[tag] = 1; + } + if (instance.hasOwnProperty('affiliation')) { + let tag = instance.affiliation; + if (affiliate_list.hasOwnProperty(tag)) affiliate_list[tag]++; + else affiliate_list[tag] = 1; + } + if (instance.hasOwnProperty('host')) { + let tag = instance.host; + if (host_list.hasOwnProperty(tag)) host_list[tag]++; + else host_list[tag] = 1; + } + }); + } else { + future[key] = tech; + } + } + for (let key in webservices.hosts) { + //console.log('key: ', key); + let host = webservices.hosts[key]; + host['name'] = key; + //console.log('host: ', host); + if ( + host.hasOwnProperty('domain') && + !(host.hasOwnProperty('status') && host.status == 'retired') + ) { + hosts[key] = host; + } + } + //console.log('webservices.affiliates: ', webservices.affiliates); + for (let key in webservices.affiliates) { + //console.log('key: ', key); + let affiliate = webservices.affiliates[key]; + //console.log('affiliate assignment: ', affiliate); + affiliates[key] = affiliate; + // if (affiliate.hasOwnProperty('name')) { + // affiliate_data[key] = affiliate; + // } + } + + return { + total_instances: instances, + active_services: current, + candidate_services: future, + tech_lists: { + category_list: category_list, + analogue_list: analogue_list, + license_list: license_list + }, + instance_lists: { + status_list: status_list, + affiliate_list: affiliate_list, + host_list: host_list + }, + hosts: hosts, + affiliates: affiliates + }; + } // console.log(technologies); // return true if a tech object includes valid instances @@ -165,10 +301,10 @@ //console.log('host_data: ', results.hosts); const affiliates = results.affiliates; //console.log('affiliate_data: ', results.affiliates); - const host_colours = hostColours(host_list, colours, hosts); + const host_colours = hostColours(host_list, colours30, hosts); //console.log('host_colours:', host_colours); - colours.sort(); - const affiliate_colours = affiliateColours(affiliate_list, colours, affiliates); + colours30.sort(); + const affiliate_colours = affiliateColours(affiliate_list, colours30, affiliates); //console.log('affiliate_colours:',affiliate_colours); //console.log('categories array: ', results.tech_tags.categories);