Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement 3rd layer single event screenshot and movie making and fetching prev/next image per source id #385

Merged
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9262b2e
preflight OPTIONS requests , handled seperately from application
mudhoney Jun 4, 2024
55384c3
add new endpoints
mudhoney Jun 4, 2024
ef668a7
400 for validation errors in api, also handle json and respond with 4…
mudhoney Jun 4, 2024
59d84d9
use production urls for help and api doc messages
mudhoney Jun 4, 2024
18431f6
add eventsState columns to screenshot and movies tables
mudhoney Jun 4, 2024
795ad56
events manager usage , now using eventsState into the database
mudhoney Jun 4, 2024
626cd74
fix bug when fail to open movie frames directory
mudhoney Jun 4, 2024
7666a4c
new event state implementation
mudhoney Jun 4, 2024
9e3d8f4
add autoloader to queue jobs
mudhoney Jun 4, 2024
46e63cf
eventManager in composite_image handling 3rd level event_instances
mudhoney Jun 4, 2024
b258ac5
update statistics
mudhoney Jun 4, 2024
3b85b34
fix index php syntax
mudhoney Jun 5, 2024
07de8db
fix statistics for postMovie endpoint
mudhoney Jun 5, 2024
d6ca2d6
new functions for testing, makeIdFunction to be used tests, fix some …
mudhoney Jun 5, 2024
5524bec
events manager tests
mudhoney Jun 5, 2024
2688bd4
rebuild movies should handle if movie not found
mudhoney Jun 5, 2024
5e9f812
404 on not found screenshots
mudhoney Jun 10, 2024
3f48ee6
db function to query prev and next images
mudhoney Jun 10, 2024
f354756
remove code
mudhoney Jun 10, 2024
ace298c
add http endpoint to read before and after closest images
mudhoney Jun 10, 2024
b4856f0
Merge branch 'main' into feature/next-prev-image
mudhoney Jun 10, 2024
fdcc4dc
updates for comments, new validation method array_ints and tests for …
mudhoney Jun 10, 2024
600f832
fix bug about ROI for movies and enable requeue tests
mudhoney Jun 10, 2024
cc11c09
documentation for postMovies and postScreenshots and eventStates strings
mudhoney Jun 12, 2024
245dd36
handle markers_visible if it is not there
mudhoney Jun 13, 2024
6e05c2c
prevent and dublication in short labels and labels of HEK Events
mudhoney Jun 17, 2024
e37c96d
add more comments about old event fields
mudhoney Jun 17, 2024
910c2e6
Merge branch 'main' into feature/next-prev-image
mudhoney Jun 17, 2024
93f4918
remove flv from docs
mudhoney Jun 17, 2024
e13d13d
Update docs/src/source/api/api_groups/movies/postMovie.rst
dgarciabriseno Jun 17, 2024
5e7a81a
Update docs/src/source/api/api_groups/movies/postMovie.rst
dgarciabriseno Jun 17, 2024
06fbd74
Update docs/src/source/api/api_groups/movies/postMovie.rst
dgarciabriseno Jun 17, 2024
6972230
Update docs/src/source/appendix/events_state.rst
dgarciabriseno Jun 17, 2024
8db3778
Update docs/src/source/appendix/events_state.rst
dgarciabriseno Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docroot/docs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
// Script was called directly. Redirect to an API-version specific URL.
if (realpath(__FILE__) == $_SERVER['SCRIPT_FILENAME']) {
require_once dirname(realpath(__FILE__)).'/../../src/Config.php';
$config = new Config(dirname(realpath(__FILE__))
. '/../../settings/Config.ini');
$config = new Config(dirname(realpath(__FILE__)) . '/../../settings/Config.ini');
header('Location: '.HV_WEB_ROOT_URL.'/docs/'.$api_version);
}


function import_xml($api_version, &$api_xml_path, &$xml) {
$api_xml_path = dirname(realpath(__FILE__)) . '/' . $api_version
. '/api_definitions.xml';
$xml = simplexml_load_file($api_xml_path);
$api_xml_url = sprintf("%s/docs/%s/api_definitions.xml", "https://api.helioviewer.org", $api_version);
$xml = simplexml_load_file($api_xml_url);
$api_xml_path = dirname(realpath(__FILE__)) . '/' . $api_version. '/api_definitions.xml';
}

function output_html($api_version) {
Expand Down
164 changes: 97 additions & 67 deletions docroot/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
date_default_timezone_set('UTC');
register_shutdown_function('shutdownFunction');

if ( array_key_exists('docs', $_GET) ) {
printAPIDocs();
// Options requests are just for validating CORS
// Lets just pass them through
if ( array_key_exists('REQUEST_METHOD', $_SERVER) && $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ) {
echo 'OK';
exit;
}

Expand All @@ -52,6 +54,7 @@
echo json_encode([
'success' => false,
'message' => $re->getMessage(),
'data' => [],
]);
exit;
}
Expand All @@ -75,68 +78,65 @@
function loadModule($params) {

$valid_actions = array(
'downloadScreenshot' => 'WebClient',
'getClosestImage' => 'WebClient',
'getDataSources' => 'WebClient',
'getJP2Header' => 'WebClient',
'getNewsFeed' => 'WebClient',
'getStatus' => 'WebClient',
'getSciDataScript' => 'WebClient',
'getTile' => 'WebClient',
'downloadImage' => 'WebClient',
'getUsageStatistics' => 'WebClient',
'getDataCoverageTimeline' => 'WebClient',
'getDataCoverage' => 'WebClient',
'updateDataCoverage' => 'WebClient', // Deprecated, remove in V3, replaced by management scripts
'shortenURL' => 'WebClient',
'goto' => 'WebClient',
'saveWebClientState' => 'WebClient',
'getWebClientState' => 'WebClient',
'takeScreenshot' => 'WebClient',
'getRandomSeed' => 'WebClient',
'getJP2Image' => 'JHelioviewer',
'getJPX' => 'JHelioviewer',
'getJPXClosestToMidPoint' => 'JHelioviewer',
'launchJHelioviewer' => 'JHelioviewer',
'downloadMovie' => 'Movies',
'getMovieStatus' => 'Movies',
'playMovie' => 'Movies',
'queueMovie' => 'Movies',
'reQueueMovie' => 'Movies',
'uploadMovieToYouTube' => 'Movies',
'checkYouTubeAuth' => 'Movies',
'getYouTubeAuth' => 'Movies',
'getUserVideos' => 'Movies',
'getObservationDateVideos' => 'Movies',
'events' => 'SolarEvents',
'getEventFRMs' => 'SolarEvents',
'getEvent' => 'SolarEvents',
'getFRMs' => 'SolarEvents',
'getDefaultEventTypes' => 'SolarEvents',
'getEvents' => 'SolarEvents',
'importEvents' => 'SolarEvents', // Deprecated, remove in V3, replaced by management scripts
'getEventsByEventLayers' => 'SolarEvents',
'getEventGlossary' => 'SolarEvents',
'getSolarBodiesGlossary' => 'SolarBodies',
'getSolarBodies' => 'SolarBodies',
'getTrajectoryTime' => 'SolarBodies',
'logNotificationStatistics' => 'WebClient',
'getEclipseImage' => 'WebClient'
'downloadScreenshot' => 'WebClient',
'getClosestImage' => 'WebClient',
'getDataSources' => 'WebClient',
'getJP2Header' => 'WebClient',
'getNewsFeed' => 'WebClient',
'getStatus' => 'WebClient',
'getSciDataScript' => 'WebClient',
'getTile' => 'WebClient',
'downloadImage' => 'WebClient',
'getUsageStatistics' => 'WebClient',
'getDataCoverageTimeline' => 'WebClient',
'getDataCoverage' => 'WebClient',
'updateDataCoverage' => 'WebClient', // Deprecated, remove in V3, replaced by management scripts
'shortenURL' => 'WebClient',
'goto' => 'WebClient',
'saveWebClientState' => 'WebClient',
'getWebClientState' => 'WebClient',
'takeScreenshot' => 'WebClient',
'postScreenshot' => 'WebClient',
'getRandomSeed' => 'WebClient',
'getJP2Image' => 'JHelioviewer',
'getJPX' => 'JHelioviewer',
'getJPXClosestToMidPoint' => 'JHelioviewer',
'launchJHelioviewer' => 'JHelioviewer',
'downloadMovie' => 'Movies',
'getMovieStatus' => 'Movies',
'playMovie' => 'Movies',
'queueMovie' => 'Movies',
'postMovie' => 'Movies',
'reQueueMovie' => 'Movies',
'uploadMovieToYouTube' => 'Movies',
'checkYouTubeAuth' => 'Movies',
'getYouTubeAuth' => 'Movies',
'getUserVideos' => 'Movies',
'getObservationDateVideos' => 'Movies',
'events' => 'SolarEvents',
'getEventFRMs' => 'SolarEvents',
'getEvent' => 'SolarEvents',
'getFRMs' => 'SolarEvents',
'getDefaultEventTypes' => 'SolarEvents',
'getEvents' => 'SolarEvents',
'importEvents' => 'SolarEvents', // Deprecated, remove in V3, replaced by management scripts
'getEventsByEventLayers' => 'SolarEvents',
'getEventGlossary' => 'SolarEvents',
'getSolarBodiesGlossary' => 'SolarBodies',
'getSolarBodies' => 'SolarBodies',
'getTrajectoryTime' => 'SolarBodies',
'logNotificationStatistics' => 'WebClient',
'getEclipseImage' => 'WebClient',
'getClosestImageDatesForSources' => 'WebClient',
);

include_once HV_ROOT_DIR.'/../src/Validation/InputValidator.php';

try {
if ( !array_key_exists('action', $params) ||
!array_key_exists($params['action'], $valid_actions) ) {

$url = HV_WEB_ROOT_URL.'/docs/';
throw new Exception(
'Invalid action specified.<br />Consult the <a href="'.$url.'">' .
'API Documentation</a> for a list of valid actions.', 26
);
}
else {
if ( !array_key_exists($params['action'], $valid_actions) ) {
throw new \InvalidArgumentException('Invalid action specified.<br />Consult the <a href="https://api.helioviewer.org/docs/v2/">API Documentation</a> for a list of valid actions.');
} else {

//Set-up variables for rate-limiting
$prefix = HV_RATE_LIMIT_PREFIX;
//Use IP address as identifier.
Expand Down Expand Up @@ -170,13 +170,19 @@ function loadModule($params) {
$module->execute();

// Update usage stats
$actions_to_keep_stats_for = array('getClosestImage',
'takeScreenshot', 'getJPX', 'getJPXClosestToMidPoint', 'uploadMovieToYouTube', 'getRandomSeed');
$actions_to_keep_stats_for = [
'getClosestImage',
'takeScreenshot',
'postScreenshot',
'getJPX',
'getJPXClosestToMidPoint',
'uploadMovieToYouTube',
'getRandomSeed',
];

// Note that in addition to the above, buildMovie requests and
// addition to getTile when the tile was already in the cache.
if ( HV_ENABLE_STATISTICS_COLLECTION &&
in_array($params['action'], $actions_to_keep_stats_for) ) {
if ( HV_ENABLE_STATISTICS_COLLECTION && in_array($params['action'], $actions_to_keep_stats_for) ) {

include_once HV_ROOT_DIR.'/../src/Database/Statistics.php';
$statistics = new Database_Statistics();
Expand All @@ -198,9 +204,34 @@ function loadModule($params) {
//limit exceeded
}
}
}
catch (Exception $e) {
} catch (\InvalidArgumentException $e) {

// Proper response code
http_response_code(400);

// Determine the content type of the request
$content_type = $_SERVER['CONTENT_TYPE'] ?? '';

// If the request is posting JSON
if('application/json' === $content_type) {

// Set the content type to JSON
header('Content-Type: application/json');

echo json_encode([
'success' => false,
'message' => $e->getMessage(),
'data' => [],
]);
exit;
}

printHTMLErrorMsg($e->getMessage());

} catch (Exception $e) {

printHTMLErrorMsg($e->getMessage());

}

return true;
Expand Down Expand Up @@ -263,8 +294,7 @@ function shutDownFunction() {
$error = error_get_last();

if (!is_null($error) && $error['type'] == 1) {
handleError(sprintf("%s:%d - %s", $error['file'], $error['line'],
$error['message']), $error->getCode());
handleError(sprintf("%s:%d - %s", $error['file'], $error['line'], $error['message']));
}
}
?>
6 changes: 3 additions & 3 deletions docroot/statistics/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ var colors = ["#D32F2F", "#9bd927", "#27d9be", "#6527d9", "#0091EA", "#FF6F00",
var heirarchy = {
"Total":["total","rate_limit_exceeded"],
"Client Sites":["standard","embed","minimal"],
"Images":["takeScreenshot","getTile","getClosestImage","getJP2Image-web","getJP2Image-jpip","getJP2Image","downloadScreenshot","getJPX","getJPXClosestToMidPoint", "downloadImage"],
"Movies":["buildMovie","getMovieStatus","queueMovie","reQueueMovie","playMovie","downloadMovie","getUserVideos","getObservationDateVideos","uploadMovieToYouTube","checkYouTubeAuth","getYouTubeAuth"],
"Images":["takeScreenshot","postScreenshot","getTile","getClosestImage","getJP2Image-web","getJP2Image-jpip","getJP2Image","downloadScreenshot","getJPX","getJPXClosestToMidPoint", "downloadImage"],
dgarciabriseno marked this conversation as resolved.
Show resolved Hide resolved
"Movies":["buildMovie","getMovieStatus","queueMovie","postMovie","reQueueMovie","playMovie","downloadMovie","getUserVideos","getObservationDateVideos","uploadMovieToYouTube","checkYouTubeAuth","getYouTubeAuth"],
"Events":["getEventGlossary", "events", "getEvents","getFRMs","getEvent","getEventFRMs","getDefaultEventTypes","getEventsByEventLayers","importEvents"],
"Data":["getRandomSeed","getDataSources","getJP2Header","getDataCoverage","getStatus","getNewsFeed","getDataCoverageTimeline","getClosestData","getSolarBodiesGlossary","getSolarBodies","getTrajectoryTime","sciScript-SSWIDL","sciScript-SunPy","getSciDataScript","updateDataCoverage","getEclipseImage"],
"Data":["getRandomSeed","getDataSources","getJP2Header","getDataCoverage","getStatus","getNewsFeed","getDataCoverageTimeline","getClosestData","getSolarBodiesGlossary","getSolarBodies","getTrajectoryTime","sciScript-SSWIDL","sciScript-SunPy","getSciDataScript","updateDataCoverage","getEclipseImage","getClosestImageDatesForSources"],
"Other":["shortenURL", "goto", "getUsageStatistics","movie-notifications-granted","movie-notifications-denied","logNotificationStatistics","launchJHelioviewer", "saveWebClientState", "getWebClientState"],
"WebGL":["getTexture","getGeometryServiceData"]
};
Expand Down
1 change: 1 addition & 0 deletions docs/src/source/api/api_groups/movies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ See the Coordinates Appendix for more infomration about working with the coordin
used by Helioviewer.org.

.. include:: movies/queueMovie.rst
.. include:: movies/postMovie.rst
.. include:: movies/reQueueMovie.rst
.. include:: movies/getMovieStatus.rst
.. include:: movies/downloadMovie.rst
Expand Down
Loading
Loading