diff --git a/docs/participating-organizations.html b/docs/participating-organizations.html new file mode 100644 index 0000000000000000000000000000000000000000..dae1236f74bb32f60ec7e38ebfea9a18ae6db152 --- /dev/null +++ b/docs/participating-organizations.html @@ -0,0 +1,317 @@ + + + + + + + + + + + + + Eclipse - The Eclipse Foundation open source community website | The Eclipse Foundation + + + + + + + + + + + + + + + + + + + Skip to main content +
+
+ +
+
+
+
+
+
+ +
+
+ +
+ + +
+
+
+

Sample code used for this page:

+
 <div data-project-short-id="iot" class="eclipsefdn-participating-organizations col-md-18 col-md-offset-3" />
+ +

Note that you will need to import eclipsefdn.projects.js as follow: + + import 'eclipsefdn-solstice-assets/js/solstice/eclipsefdn.participating-organizations.js'

+ + +
+ +
+
+
+
+ +

+ Back to the top +

+ +
+ + + + + + \ No newline at end of file diff --git a/js/api/eclipsefdn.project-organizations.js b/js/api/eclipsefdn.project-organizations.js new file mode 100644 index 0000000000000000000000000000000000000000..9c2fc56d215f1bbae9a50424d4582ce00581b617 --- /dev/null +++ b/js/api/eclipsefdn.project-organizations.js @@ -0,0 +1,33 @@ +import $, { type } from 'jquery'; +import { validateURL } from '../utils/utils'; +import 'isomorphic-fetch'; + +const getParticipatingOrganizations = (url) => { + if (validateURL(url)) { + return new Promise((resolve, reject) => + fetch(url) + .then((response) => { + if (response.status !== 200) { + throw `${response.status}: ${response.statusText}`; + } + response + .json() + .then((data) => { + let orgs = data; + $(orgs).each(function (key, org) { + orgs[key].version = 'none'; + }); + + orgs.sort((a, b) => a.name.localeCompare(b.name)); + resolve(orgs); + }) + .catch(reject); + }) + .catch((err) => { + reject(err); + }) + ); + } +}; + +export default getParticipatingOrganizations; diff --git a/js/main.js b/js/main.js index bf6a9efdaba0f02daeff858f8fe1d3349cc7ed22..de54b5d258366b566c419e6c5493c21e1d004def 100644 --- a/js/main.js +++ b/js/main.js @@ -24,4 +24,4 @@ import './privacy' import './solstice' // Bootstrap -import './bootstrap' +import './bootstrap' \ No newline at end of file diff --git a/js/solstice/eclipsefdn.participating-organizations.js b/js/solstice/eclipsefdn.participating-organizations.js new file mode 100644 index 0000000000000000000000000000000000000000..8c7c0a2e24527e32215b84352e2c80b2f07cea89 --- /dev/null +++ b/js/solstice/eclipsefdn.participating-organizations.js @@ -0,0 +1,48 @@ +/*! + * Copyright (c) 2021 Eclipse Foundation, Inc. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * Contributors: + * Olivier Goulet + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import jQuery from 'jquery'; +import templateLoading from './templates/loading-icon.mustache'; +import getParticipatingOrganizations from '../api/eclipsefdn.project-organizations'; +import template from "./templates/participating-organizations.mustache"; + +const alphabeticalComparator = (a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1; + +const EclipseFdnParticipatingOrganizations = (async function ($, document) { + const element = document.querySelector('.eclipsefdn-participating-organizations'); + if (!element) return; + + element.innerHTML = templateLoading(); + + const baseUrl = 'https://membership.eclipse.org/api/projects/'; + + const projectShortId = element.getAttribute('data-project-short-id'); + + if (!projectShortId) return; + + const url = `${baseUrl}/${projectShortId}/organizations`; + + let participatingOrganizations = await getParticipatingOrganizations(url); + + if (!participatingOrganizations) return; + + participatingOrganizations = participatingOrganizations.sort(alphabeticalComparator); + + const data = { + items: participatingOrganizations + }; + + element.innerHTML = template(data); +})(jQuery, document); + +export default EclipseFdnParticipatingOrganizations; \ No newline at end of file diff --git a/js/solstice/index.js b/js/solstice/index.js index dc6158ae6045ebca627c8d68e4170e78f32ddaec..c6fa8fc4ba16009d2ab051cd14ce0c9025d12bed 100644 --- a/js/solstice/index.js +++ b/js/solstice/index.js @@ -24,3 +24,4 @@ import './eclipsefdn.solstice-slider'; import './eclipsefdn.time-conversion'; import './eclipsefdn.wgs-list.js' import './eclipsefdn.newsroom-resources.js' +import './eclipsefdn.participating-organizations.js' diff --git a/js/solstice/templates/participating-organizations.mustache b/js/solstice/templates/participating-organizations.mustache new file mode 100644 index 0000000000000000000000000000000000000000..3b9b964740472cf6741eb39ab690e1fbfae4c64b --- /dev/null +++ b/js/solstice/templates/participating-organizations.mustache @@ -0,0 +1,7 @@ + \ No newline at end of file