diff --git a/docroot/statistics/coverage/index.php b/docroot/statistics/coverage/index.php new file mode 100644 index 000000000..ba2a4ff7d --- /dev/null +++ b/docroot/statistics/coverage/index.php @@ -0,0 +1,119 @@ + + + + + Helioviewer Data Coverage + + + +
+
+ +
+ + + + + + + + + diff --git a/docroot/statistics/coverage/js/guest_token.js b/docroot/statistics/coverage/js/guest_token.js new file mode 100644 index 000000000..c27c1c1a1 --- /dev/null +++ b/docroot/statistics/coverage/js/guest_token.js @@ -0,0 +1,20 @@ +/** + * Fetches a guest token from the specified URL. + * + * @async + * @param {string} url - The URL endpoint to fetch the guest token from + * @param {string} body - The JSON string body to send in the POST request + * @returns {Promise} A promise that resolves to the guest token + * @throws {Error} If the fetch request fails or the response is invalid + */ +async function fetchGuestToken(url, body) { + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(body ?? "") + }); + const data = await response.json(); + return data.token; +} diff --git a/docroot/statistics/coverage/js/query.js b/docroot/statistics/coverage/js/query.js new file mode 100644 index 000000000..1785f1a0a --- /dev/null +++ b/docroot/statistics/coverage/js/query.js @@ -0,0 +1,34 @@ +/** + * Finds dashboards from the Superset API using a query filter. + * + * @async + * @param {string} url - The base URL of the Superset instance + * @param {string} token - The guest token for authentication + * @param {Object} query - The query object to filter dashboards + * @returns {Promise} A promise that resolves to the dashboard data + * @throws {Error} If the fetch request fails or the response is invalid + */ +async function findDashboards(url, token, query) { + const queryString = encodeURIComponent(JSON.stringify(query)); + const response = await fetch(`${url}/api/v1/dashboard/?q=${queryString}`, { + method: 'GET', + headers: headers(token) + }); + const data = await response.json(); + return data; +} + +async function getDashboardUUID(url, token, id) { + const response = await fetch(`${url}/api/v1/dashboard/${id}/embedded`, { + method: 'GET', + headers: headers(token) + }); + return await response.json(); +} + +function headers(token) { + return { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }; +} diff --git a/docroot/status/index.php b/docroot/status/index.php index f4ffb6223..28749b571 100644 --- a/docroot/status/index.php +++ b/docroot/status/index.php @@ -33,26 +33,6 @@ "RHESSI" => $PROVIDERS['RHESSI'] ); - const COVERAGE = array ( - "AIA" => "SDO_coverage.html", - "HMI" => "SDO_coverage.html", - "EIT" => "SOHO_coverage.html", - "LASCO" => "SOHO_coverage.html", - "COSMO" => "MLSO_coverage.html", - "EUI" => "SOLO_coverage.html", - "COR1-A" => "STEREO_A_coverage.html", - "COR2-A" => "STEREO_A_coverage.html", - "EUVI-A" => "STEREO_A_coverage.html", - "COR1-B" => "STEREO_B_coverage.html", - "COR2-B" => "STEREO_B_coverage.html", - "EUVI-B" => "STEREO_B_coverage.html", - "IRIS" => "IRIS_coverage.html", - "SWAP" => "PROBA2_coverage.html", - "SXT" => "Yohkoh_coverage.html", - "XRT" => "Hinode_coverage.html", - "RHESSI" => "RHESSI_coverage.html" - ); - const TABLE_ROW_TEMPLATE = "%s%s%s%s%s%s"; function formatDate(?DateTime $date) { @@ -102,13 +82,7 @@ function genRobLink($name, $url) { } function genCoverageLink($source) { - $instrument = explode(" ", $source)[0]; - if (array_key_exists($instrument, COVERAGE)) { - $coverage_page = "/statistics/bokeh/coverages/" . COVERAGE[$instrument]; - } else { - $coverage_page = "#"; - } - return "$source"; + return "$source"; } function safe_max($arr) { diff --git a/settings/Config.Example.ini b/settings/Config.Example.ini index d50a55dce..21d6add51 100644 --- a/settings/Config.Example.ini +++ b/settings/Config.Example.ini @@ -192,3 +192,7 @@ http_export = '' # If running the coordinator locally, then change this to # http://localhost:port coordinator_url = 'http://coordinator' + +[superset] +superset_url = 'http://localhost:8088' +superset_sidecar_url = 'http://localhost:8087'