airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dimuthu...@apache.org
Subject [airavata-django-portal] branch master updated: Showing the list of registered parsers
Date Mon, 14 Jan 2019 17:28:35 GMT
This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git


The following commit(s) were added to refs/heads/master by this push:
     new cb27a6b  Showing the list of registered parsers
cb27a6b is described below

commit cb27a6b513fe1bc38370de8f36f9b6ddc08247eb
Author: Dimuthu Wannipurage <dimuthu.upeksha2@gmail.com>
AuthorDate: Mon Jan 14 12:28:27 2019 -0500

    Showing the list of registered parsers
---
 django_airavata/apps/api/serializers.py            |  7 ++-
 .../django_airavata_api/js/service_config.js       | 13 +---
 django_airavata/apps/api/views.py                  |  6 +-
 .../js/containers/ParsersManageContainer.vue       | 70 ++++++++++++++++++++++
 .../js/parser-components/ParserList.vue            | 47 +++++++++++++++
 .../js/parser-components/ParserListItem.vue        | 36 +++++++++++
 .../js/parser-listing-entry-point.js               | 22 +++++++
 .../parsers-manage.html                            | 19 ++++++
 django_airavata/apps/dataparsers/views.py          |  9 ++-
 django_airavata/apps/dataparsers/webpack.config.js |  1 +
 django_airavata/settings.py                        |  2 +-
 11 files changed, 217 insertions(+), 15 deletions(-)

diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 74cdf04..a249575 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -764,4 +764,9 @@ class StorageResourceSerializer(
 
 
 class ParserSerializer(thrift_utils.create_serializer_class(Parser)):
-    pass
+    url = FullyEncodedHyperlinkedIdentityField(
+        view_name='django_airavata_api:parser-detail',
+        lookup_field='id',
+        lookup_url_kwarg='parser_id')
+    creationTime = UTCPosixTimestampDateTimeField()
+    updateTime = UTCPosixTimestampDateTimeField()
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
index 9e7a7c8..f633244 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
@@ -274,17 +274,8 @@ export default {
   },
   Parsers: {
     url: "/api/parsers",
-    viewSet: [
-      {
-        name: "retrieve"
-      },
-      {
-        name: "create"
-      },
-      {
-        name: "update"
-      }
-    ],
+    viewSet: true,
+    queryParams: ["limit", "offset"],
     modelClass: Parser
   },
   SharedEntities: {
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 5a8a891..12ad8fd 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -1036,14 +1036,18 @@ class StoragePreferenceViewSet(APIBackedViewSet):
 class ParserViewSet(mixins.CreateModelMixin,
                     mixins.RetrieveModelMixin,
                     mixins.UpdateModelMixin,
+                    mixins.ListModelMixin,
                     GenericAPIBackedViewSet):
     serializer_class = serializers.ParserSerializer
     lookup_field = 'parser_id'
     lookup_value_regex = '[^/]+'
 
+    def get_list(self):
+        return self.request.airavata_client.listAllParsers(self.authz_token, settings.GATEWAY_ID)
+
     def get_instance(self, lookup_value):
         return self.request.airavata_client.getParser(
-            self.authz_token, lookup_value)
+            self.authz_token, lookup_value, settings.GATEWAY_ID)
 
     def perform_create(self, serializer):
         parser = serializer.save()
diff --git a/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/containers/ParsersManageContainer.vue
b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/containers/ParsersManageContainer.vue
new file mode 100755
index 0000000..b70cd42
--- /dev/null
+++ b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/containers/ParsersManageContainer.vue
@@ -0,0 +1,70 @@
+<template>
+    <div>
+        <div class="row">
+            <div class="col">
+                <h1 class="h4 mb-4">Parsers</h1>
+            </div>
+            <div id="col-new-group" class="col-sm-2">
+                <b-button href="create" :variant="'primary'">Create New Parser&nbsp;&nbsp;<i
class="fa fa-plus" aria-hidden="true"></i></b-button>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col">
+                <div class="card">
+                    <div class="card-body">
+                        <parser-list v-bind:parsers="parsers"></parser-list>
+
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</template>
+
+<script>
+
+import ParserList from '../parser-components/ParserList.vue';
+
+import { models, services } from 'django-airavata-api'
+import { components as comps } from 'django-airavata-common-ui'
+
+export default {
+    name: 'parsers-manage-container',
+    props: [],
+    data () {
+        return {
+            parsers: null,
+        }
+    },
+    components: {
+        'parser-list': ParserList,
+        'pager': comps.Pager,
+    },
+    methods: {
+        nextParsers: function(event) {
+            this.parserPaginator.next();
+        },
+        previousParsers: function(event) {
+            this.parserPaginator.previous();
+        },
+    },
+    computed: {
+        // parsers: function() {
+        //     return this.parserPaginator ? this.parserPaginator.results : null;
+        // },
+    },
+    beforeMount: function () {
+        services.ParserService.list()
+            .then(result => this.parsers = result);
+    },
+}
+</script>
+
+<style>
+#col-new-group {
+    text-align: right;
+}
+#modal-new-group {
+    text-align: left;
+}
+</style>
diff --git a/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-components/ParserList.vue
b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-components/ParserList.vue
new file mode 100644
index 0000000..18e7326
--- /dev/null
+++ b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-components/ParserList.vue
@@ -0,0 +1,47 @@
+<template>
+  <div>
+    <b-alert dismissible :variant="alertVariant" :show="showDismissibleAlert" @dismissed="showDismissibleAlert=false">{{
alertMsg }}</b-alert>
+    <table class="table table-hover">
+        <thead>
+            <tr>
+                <th>Id</th>
+                <th>Image Name</th>
+                <th>Execution Command</th>
+            </tr>
+        </thead>
+        <tbody>
+            <parser-list-item v-bind:parser="parser" v-for="parser in parsers" v-bind:key="parser.id">
+            </parser-list-item>
+        </tbody>
+    </table>
+  </div>
+</template>
+
+<script>
+import ParserListItem from './ParserListItem.vue'
+
+export default {
+    name: 'parser-list',
+    props: ['parsers'],
+    data: function () {
+        console.log("Retrieved parsers");
+        return {
+          owner:"owner",
+          alertMsg: null,
+          alertVariant: 'primary',
+          showDismissibleAlert: false,
+        }
+    },
+    components: {
+        ParserListItem
+    },
+    methods: {
+    }
+}
+</script>
+
+<style>
+#parser-list-actions-header {
+    min-width: 150px;
+}
+</style>
diff --git a/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-components/ParserListItem.vue
b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-components/ParserListItem.vue
new file mode 100644
index 0000000..5cc382c
--- /dev/null
+++ b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-components/ParserListItem.vue
@@ -0,0 +1,36 @@
+<template>
+    <tr>
+        <td>{{ parser.id }}</td>
+        <td>{{ parser.imageName }}</td>
+        <td>{{ parser.executionCommand }}</td>
+    </tr>
+</template>
+
+<script>
+
+import { services } from 'django-airavata-api'
+
+export default {
+    name: 'parser-list-item',
+    data() {
+      return {
+        show: false,
+        deleteButtonVariant: 'link',
+        yesButtonVariant: 'danger',
+        noButtonVariant: 'secondary',
+        headerBgVariant: 'danger',
+        bodyBgVariant: 'light',
+        headerTextVariant: 'light',
+        deleting: false,
+      }
+    },
+    props: ['parser'],
+    computed: {
+    },
+    methods: {
+    }
+}
+</script>
+
+<style>
+</style>
diff --git a/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-listing-entry-point.js
b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-listing-entry-point.js
new file mode 100755
index 0000000..57c1852
--- /dev/null
+++ b/django_airavata/apps/dataparsers/static/django_airavata_dataparsers/js/parser-listing-entry-point.js
@@ -0,0 +1,22 @@
+import Vue from 'vue'
+import BootstrapVue from 'bootstrap-vue'
+import ParsersManageContainer from "./containers/ParsersManageContainer.vue";
+
+// This is imported globally on the website so no need to include it again in this view
+// import 'bootstrap/dist/css/bootstrap.css'
+import 'bootstrap-vue/dist/bootstrap-vue.css'
+
+Vue.use(BootstrapVue);
+
+new Vue({
+  el: "#parsers-manage",
+  template: '<parsers-manage-container></parsers-manage-container>',
+  data: {
+      groupsOwnersData: null,
+  },
+  components: {
+      ParsersManageContainer
+  },
+  beforeMount: function () {
+  }
+})
diff --git a/django_airavata/apps/dataparsers/templates/django_airavata_dataparsers/parsers-manage.html
b/django_airavata/apps/dataparsers/templates/django_airavata_dataparsers/parsers-manage.html
new file mode 100644
index 0000000..fc651c4
--- /dev/null
+++ b/django_airavata/apps/dataparsers/templates/django_airavata_dataparsers/parsers-manage.html
@@ -0,0 +1,19 @@
+{% extends './base.html' %}
+
+{% load static %}
+
+{% block css %}
+{{ block.super }}
+<link rel=stylesheet type=text/css href="{% static 'django_airavata_dataparsers/dist/parser-list.css'
%}">
+{% endblock %}
+
+{% block content %}
+
+<div id="parsers-manage"></div>
+
+{% endblock content %}
+
+{% block scripts %}
+{{ block.super }}
+<script src="{% static "django_airavata_dataparsers/dist/parser-list.js" %}"></script>
+{% endblock %}
diff --git a/django_airavata/apps/dataparsers/views.py b/django_airavata/apps/dataparsers/views.py
index 8d7bef9..963ba1a 100644
--- a/django_airavata/apps/dataparsers/views.py
+++ b/django_airavata/apps/dataparsers/views.py
@@ -1,9 +1,16 @@
 from django.shortcuts import render
+from rest_framework.renderers import JSONRenderer
 
+from django_airavata.apps.api.views import (
+    ParserViewSet
+)
 
 def home(request):
-    return render(request, 'django_airavata_dataparsers/home.html')
 
+    request.active_nav_item = "manage"
+    response = ParserViewSet.as_view({'get': 'list'})(request)
+    parsers_json = JSONRenderer().render(response.data)
+    return render(request, 'django_airavata_dataparsers/parsers-manage.html')
 
 def parser_details(request, parser_id):
     return render(request, 'django_airavata_dataparsers/parser-details.html', {
diff --git a/django_airavata/apps/dataparsers/webpack.config.js b/django_airavata/apps/dataparsers/webpack.config.js
index 20f0290..4f80fd0 100644
--- a/django_airavata/apps/dataparsers/webpack.config.js
+++ b/django_airavata/apps/dataparsers/webpack.config.js
@@ -6,6 +6,7 @@ const CleanWebpackPlugin = require('clean-webpack-plugin');
 module.exports = {
   entry: {
       'parser-details': './static/django_airavata_dataparsers/js/entry-parser-details',
+      'parser-list': './static/django_airavata_dataparsers/js/parser-listing-entry-point.js',
   },
   output: {
     path: path.resolve(__dirname, './static/django_airavata_dataparsers/dist/'),
diff --git a/django_airavata/settings.py b/django_airavata/settings.py
index ba8bc91..4128c1a 100644
--- a/django_airavata/settings.py
+++ b/django_airavata/settings.py
@@ -44,7 +44,7 @@ INSTALLED_APPS = [
     'rest_framework',
     'django_airavata.apps.api.apps.ApiConfig',
     'django_airavata.apps.groups.apps.GroupsConfig',
-    # 'django_airavata.apps.dataparsers.apps.DataParsersConfig',
+    'django_airavata.apps.dataparsers.apps.DataParsersConfig',
 
     # wagtail related apps
     'wagtail.contrib.forms',


Mime
View raw message