This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit f0014ff754de475b268e47f79155960bd4ab0052 Author: Marcus Christie <[email protected]> AuthorDate: Wed Aug 28 10:58:35 2019 -0400 AIRAVATA-3188 image custom output display type --- django_airavata/apps/api/urls.py | 2 + django_airavata/apps/api/views.py | 13 ++++++ .../output-displays/ImageOutputDisplay.vue | 46 ++++++++++++++++++++++ .../output-displays/OutputDisplayContainer.vue | 4 ++ 4 files changed, 65 insertions(+) diff --git a/django_airavata/apps/api/urls.py b/django_airavata/apps/api/urls.py index 9f59eb1..9548cca 100644 --- a/django_airavata/apps/api/urls.py +++ b/django_airavata/apps/api/urls.py @@ -97,6 +97,8 @@ urlpatterns = [ views.notebook_output_view, name="notebook-output"), url(r'^html-output', views.html_output_view, name="html-output"), + url(r'^image-output', + views.image_output_view, name="image-output"), ] if logger.isEnabledFor(logging.DEBUG): diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py index 068d43b..d0c8a07 100644 --- a/django_airavata/apps/api/views.py +++ b/django_airavata/apps/api/views.py @@ -1755,3 +1755,16 @@ def html_output_view(request): experiment_output_name, experiment_id) return JsonResponse(data) + + +def image_output_view(request): + provider_id = request.GET['provider-id'] + experiment_id = request.GET['experiment-id'] + experiment_output_name = request.GET['experiment-output-name'] + data = output_views.generate_data(request, + provider_id, + experiment_output_name, + experiment_id) + # data should contain 'image' as a file-like object or raw bytes with the + # file data and 'mime-type' with the images mimetype + return HttpResponse(data['image'], content_type=data['mime-type']) diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/output-displays/ImageOutputDisplay.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/output-displays/ImageOutputDisplay.vue new file mode 100644 index 0000000..ab6da61 --- /dev/null +++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/output-displays/ImageOutputDisplay.vue @@ -0,0 +1,46 @@ +<template> + <img :src="url" /> +</template> + +<script> +import { models, utils } from "django-airavata-api"; +export default { + name: "image-output-display", + props: { + experimentOutput: { + type: models.OutputDataObjectType, + required: true + }, + dataProducts: { + type: Array, + required: true + }, + experimentId: { + type: String, + required: true + }, + providerId: { + type: String, + required: true + } + }, + data() { + return { + rawOutput: null + }; + }, + computed: { + url() { + return ( + "/api/image-output?" + + "experiment-id=" + + encodeURIComponent(this.experimentId) + + "&experiment-output-name=" + + encodeURIComponent(this.experimentOutput.name) + + "&provider-id=" + + encodeURIComponent(this.providerId) + ); + } + } +}; +</script> diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/output-displays/OutputDisplayContainer.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/output-displays/OutputDisplayContainer.vue index 40387ab..2ae3498 100644 --- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/output-displays/OutputDisplayContainer.vue +++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/output-displays/OutputDisplayContainer.vue @@ -34,6 +34,7 @@ import { models } from "django-airavata-api"; import { components } from "django-airavata-common-ui"; import DefaultOutputDisplay from "./DefaultOutputDisplay"; import HtmlOutputDisplay from "./HtmlOutputDisplay"; +import ImageOutputDisplay from "./ImageOutputDisplay"; import LinkDisplay from "./LinkDisplay"; import NotebookOutputDisplay from "./NotebookOutputDisplay"; @@ -62,6 +63,7 @@ export default { "data-product-viewer": components.DataProductViewer, DefaultOutputDisplay, HtmlOutputDisplay, + ImageOutputDisplay, LinkDisplay, NotebookOutputDisplay }, @@ -83,6 +85,8 @@ export default { return "notebook-output-display"; } else if (this.currentView["display-type"] === "html") { return "html-output-display"; + } else if (this.currentView["display-type"] === "image") { + return "image-output-display"; } else { return null; }
