diff --git a/kadi_apps/app.py b/kadi_apps/app.py index e627df7..727809d 100755 --- a/kadi_apps/app.py +++ b/kadi_apps/app.py @@ -23,9 +23,23 @@ def internal_error(e): return render_template('500.html'), 500 +def index(): + """Return main page""" + return render_template( + 'index.html', + ) + + +def api_index(): + """Return main API page""" + return render_template( + 'api_index.html', + ) + + def get_app(name=__name__, settings='devel'): import kadi_apps - from kadi_apps.blueprints import auth, test, astromon, ska_api as api, kadi, find_attitude + from kadi_apps.blueprints import auth, test, ska_api as api, kadi, find_attitude from kadi_apps.blueprints import mica, star_hist, pcad_acq logger = pyyaks.logger.get_logger(name='kadi_apps', level='INFO') @@ -53,7 +67,10 @@ def get_app(name=__name__, settings='devel'): app.register_error_handler(404, page_not_found) app.register_error_handler(500, internal_error) - app.register_blueprint(kadi.blueprint, url_prefix='/') + app.add_url_rule("/", view_func=index) + app.add_url_rule("/api", view_func=api_index) + + app.register_blueprint(kadi.blueprint, url_prefix='/kadi') app.register_blueprint(find_attitude.blueprint, url_prefix='/find_attitude') app.register_blueprint(mica.blueprint, url_prefix='/mica') app.register_blueprint(star_hist.blueprint, url_prefix='/star_hist') @@ -62,7 +79,7 @@ def get_app(name=__name__, settings='devel'): app.register_blueprint(auth.blueprint, url_prefix='/api/auth') app.register_blueprint(test.blueprint, url_prefix='/api/test') app.register_blueprint(api.blueprint, url_prefix='/api/ska_api') - app.register_blueprint(astromon.blueprint, url_prefix='/api/astromon') + # app.register_blueprint(astromon.blueprint, url_prefix='/api/astromon') return app diff --git a/kadi_apps/blueprints/kadi/kadi.py b/kadi_apps/blueprints/kadi/kadi.py index af63fd2..b4e7cfe 100644 --- a/kadi_apps/blueprints/kadi/kadi.py +++ b/kadi_apps/blueprints/kadi/kadi.py @@ -64,14 +64,6 @@ def filter_events( return queryset -@blueprint.route("/") -def index(): - """Return help page for web-kadi API access""" - return render_template( - 'index.html', - ) - - @blueprint.route("/events/") def events(): """Return help page for web-kadi API access""" @@ -182,7 +174,7 @@ def event_detail(model_name, primary_key): ) -@blueprint.route("/events//list") +@blueprint.route("/events//list/") def event_list(model_name): """Return a list of kadi events""" diff --git a/kadi_apps/blueprints/kadi/templates/events/event_list.html b/kadi_apps/blueprints/kadi/templates/events/event_list.html index 0a75f99..2e5d478 100644 --- a/kadi_apps/blueprints/kadi/templates/events/event_list.html +++ b/kadi_apps/blueprints/kadi/templates/events/event_list.html @@ -26,8 +26,14 @@

{{ model_description }} list

{% endif %} -
- Filter: ? + + + Filter: ? +
diff --git a/kadi_apps/blueprints/ska_api/api.py b/kadi_apps/blueprints/ska_api/api.py index 219f889..821ca5b 100644 --- a/kadi_apps/blueprints/ska_api/api.py +++ b/kadi_apps/blueprints/ska_api/api.py @@ -1,4 +1,4 @@ -from flask import Blueprint, render_template +from flask import Blueprint from flask import request import logging @@ -20,12 +20,6 @@ blueprint = Blueprint('ska_api', __name__, template_folder='templates') -@blueprint.route("/") -def show_help(): - """Return help page for web-kadi API access""" - return render_template('help.html') - - class NotFound(Exception): pass diff --git a/kadi_apps/blueprints/ska_api/templates/help.html b/kadi_apps/blueprints/ska_api/templates/help.html deleted file mode 100644 index 9c22288..0000000 --- a/kadi_apps/blueprints/ska_api/templates/help.html +++ /dev/null @@ -1,435 +0,0 @@ - - - - - - -Web-kadi API help - - - -
-

Web-kadi API help

- -

A subset of Ska3 Python data APIs are accessible via the -http://web-kadi.cfa.harvard.edu/api web interface. Available data sets are:

- -
-

API URL syntax

-

The general URL syntax for querying data via the API interface is as follows:

-
-  {{ url_for('ska_api.api', path='asdasdasd', _external=True) }}/<package>/<module>/<function>?<arg1>=<val1>&<arg2>=val2...
-
-

This roughly equivalent to the Python pseudo-code:

-
-from <package>.<module> import <function>
-<function>(arg1=val1, arg2=val2)
-
-

For example:

-

{{ url_for('ska_api.api', path='kadi/events/manvrs/filter', _external=True) }}?start=2019:001&stop=2019:002

-

This is equivalent to the Python code:

-
-from kadi.events import manvrs
-manvrs.filter(start='2019:001', stop='2019:002')
-
-
-
-

Outputs

-
-

Data format

-

The web API query returns a JSON-encoded version of the manvrs data structure -(Content-type: application/json).

-
-
-

Table format

-

One special option which is common to all queries is the table_format, which can take the value -rows or columns (default=``rows``). This specifies whether to return any tabular data as -either a list of dicts (rows) or a dict of lists (columns). For large query results the -columns option will generally be more compact because the table column names are not repeated for -every row. For example:

-

{{ url_for('ska_api.api', path='kadi/events/manvrs/filter', _external=True) }}?start=2019:001&stop=2019:002&table_format=columns

-
-
-

Timing

-

A second special option is report_timing, which returns timing information on the query -instead of the query data. This may be useful for characterizing the performance of the -web service (which is not very speedy). Example:

-

{{ url_for('ska_api.api', path='kadi/events/manvrs/filter', _external=True) }}?start=2019:001&stop=2019:002&report_timing=1

-
-
-
-

Available APIs

-

The full list of available API functions are:

-
-/api/kadi/events/<event_type>/filter
-/api/kadi/commands/states/get_states
-/api/kadi/commands/get_cmds
-/api/mica/starcheck/get_att
-/api/mica/starcheck/get_dither
-/api/mica/starcheck/get_monitor_windows
-/api/mica/starcheck/get_mp_dir
-/api/mica/starcheck/get_starcat
-/api/mica/starcheck/get_starcheck_catalog
-/api/mica/starcheck/get_starcheck_catalog_at_date
-
-
-
- - diff --git a/kadi_apps/settings/devel.py b/kadi_apps/settings/devel.py index 3338c2e..1f90d41 100644 --- a/kadi_apps/settings/devel.py +++ b/kadi_apps/settings/devel.py @@ -7,4 +7,4 @@ LOG_LEVEL = 'INFO' TOKEN_VERSION = (1, 0) -SEND_FILE_MAX_AGE_DEFAULT = 60 +SEND_FILE_MAX_AGE_DEFAULT = 5 diff --git a/kadi_apps/static/kadi.css b/kadi_apps/static/kadi.css index c8d8cff..f72a730 100644 --- a/kadi_apps/static/kadi.css +++ b/kadi_apps/static/kadi.css @@ -24,40 +24,21 @@ table.srclist thead tr .SortBy { } .tooltip { - display: none; - position: absolute; - z-index: 999; font-weight: normal; font-size: 0.77778rem; line-height: 1.3; padding: 0.66667rem; - max-width: 85%; left: 50%; - width: 100%; - color: #fff; - background: #333; } - -.tooltip > .nub { - display: block; - left: 5px; - position: absolute; - width: 0; - height: 0; - border: solid 5px; - border-color: transparent transparent #333 transparent; - top: -10px; } -.tooltip > .nub.rtl { - left: auto; - right: 5px; } -.tooltip.radius { - border-radius: 3px; } -.tooltip.round { - border-radius: 1000px; } -.tooltip.round > .nub { - left: 2rem; } -.tooltip.opened { - color: #008CBA !important; - border-bottom: dotted 1px #004054 !important; } + max-width: 100%; + width: 600px !important; +} + + +.tooltip-inner{ + max-width: 100%; + width: 600px !important; + text-align: left !important; +} /* img { padding:2; } diff --git a/kadi_apps/templates/api_index.html b/kadi_apps/templates/api_index.html new file mode 100644 index 0000000..3d5ca8a --- /dev/null +++ b/kadi_apps/templates/api_index.html @@ -0,0 +1,86 @@ +{% extends "base.html" %} + +{% block body_attributes -%} +class="with-background" +{%- endblock %} + +{% block content %} +

Ska API

+ +

+ The Ska API is a generic API that wraps a subset of the Ska3 Python API. It is accessible via + the {{ url_for('ska_api.api', path="", _external=True) }} + web interface. The available data sets are: +

+ + + +

API URL syntax

+ +

+ The general URL syntax for querying data via the API interface is as follows: +

+
+    {{ url_for('ska_api.api', path="", _external=True) }}<package>/<module>/<function>?<arg1>=<val1>&<arg2>=val2...
+
+

+ This roughly equivalent to the Python pseudo-code: +

+
+    from <package>.<module> import <function>
+    <function>(arg1=val1, arg2=val2)
+
+ +

For example:

+

{{ url_for('ska_api.api', path='kadi/events/manvrs/filter', _external=True) }}?start=2019:001&stop=2019:002

+

is equivalent to the Python code:

+
+    from kadi.events import manvrs
+    manvrs.filter(start='2019:001', stop='2019:002')
+
+ +

Outputs

+ +

Data format

+

The web API query returns a JSON-encoded version of the manvrs data structure +(Content-type: application/json).

+

Table format

+

One special option which is common to all queries is the table_format, which can take the value +rows or columns (default=``rows``). This specifies whether to return any tabular data as +either a list of dicts (rows) or a dict of lists (columns). For large query results the +columns option will generally be more compact because the table column names are not repeated for +every row. For example:

+

{{ url_for('ska_api.api', path='kadi/events/manvrs/filter', _external=True) }}/kadi?start=2019:001&stop=2019:002&table_format=columns

+ +

Available entrypoints

+

The full list of available entrypoints:

+
+  {{ url_for('ska_api.api', path="") }}agasc/get_star
+  {{ url_for('ska_api.api', path="") }}agasc/get_stars
+  {{ url_for('ska_api.api', path="") }}agasc/get_star_cone
+  {{ url_for('ska_api.api', path="") }}kadi/events/<event_type>/filter
+  {{ url_for('ska_api.api', path="") }}kadi/commands/states/get_states
+  {{ url_for('ska_api.api', path="") }}kadi/commands/get_cmds
+  {{ url_for('ska_api.api', path="") }}kadi/commands/get_observations
+  {{ url_for('ska_api.api', path="") }}kadi/commands/get_starcats
+  {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_id
+  {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_ids
+  {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_image
+  {{ url_for('ska_api.api', path="") }}mica/archive/aca_dark/dark_cal/get_dark_cal_props
+  {{ url_for('ska_api.api', path="") }}mica/starcheck/get_att
+  {{ url_for('ska_api.api', path="") }}mica/starcheck/get_dither
+  {{ url_for('ska_api.api', path="") }}mica/starcheck/get_monitor_windows
+  {{ url_for('ska_api.api', path="") }}mica/starcheck/get_mp_dir
+  {{ url_for('ska_api.api', path="") }}mica/starcheck/get_starcat
+  {{ url_for('ska_api.api', path="") }}mica/starcheck/get_starcheck_catalog
+  {{ url_for('ska_api.api', path="") }}mica/starcheck/get_starcheck_catalog_at_date
+
+ +{% endblock %} diff --git a/kadi_apps/templates/base.html b/kadi_apps/templates/base.html index e1d443e..19f6454 100644 --- a/kadi_apps/templates/base.html +++ b/kadi_apps/templates/base.html @@ -24,7 +24,7 @@ {% block titlebar %}