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 24849f9bb64d2b58d4f0a7ab6cee76635eb7f84e Author: Marcus Christie <[email protected]> AuthorDate: Mon Sep 17 17:20:27 2018 -0400 AIRAVATA-2876 Delete application (module/interface/deployments) --- .../applications/ApplicationEditorContainer.vue | 29 +++++++++++++++++++--- .../applications/ApplicationModuleEditor.vue | 6 +++++ .../src/store/applications/app_deployments.js | 6 ++--- .../src/store/applications/app_interfaces.js | 2 +- django_airavata/apps/api/serializers.py | 3 ++- django_airavata/apps/api/views.py | 8 ++++++ .../js/entry-create-experiment.js | 11 ++++---- 7 files changed, 51 insertions(+), 14 deletions(-) diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue index a736641..1e0667c 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue @@ -14,8 +14,8 @@ <b-nav-item exact-active-class="active" exact :to="{name: 'application_interface', params: {id: id}}" :disabled="!id">Interface</b-nav-item> <b-nav-item active-class="active" :to="{name: 'application_deployments', params: {id: id}}" :disabled="!id">Deployments</b-nav-item> </b-nav> - <router-view name="module" v-if="module" v-model="module" @save="saveModule" @cancel="cancelModule" :readonly="!module.userHasWriteAccess" - /> + <router-view name="module" v-if="module" v-model="module" @save="saveModule" @cancel="cancelModule" @delete="deleteApplication" + :readonly="!module.userHasWriteAccess" /> <router-view name="interface" v-if="appInterface" v-model="appInterface" @save="saveInterface" @cancel="cancelInterface" :readonly="!appInterface.userHasWriteAccess" /> <router-view name="deployments" v-if="deployments" :deployments="deployments" @new="createNewDeployment" @delete="deleteDeployment" @@ -108,7 +108,9 @@ export default { }); this.loadApplicationDeployments(this.id); } else { - this.module = new models.ApplicationModule(); + this.module = new models.ApplicationModule({ + userHasWriteAccess: true + }); } }, saveModule() { @@ -232,6 +234,27 @@ export default { }, deploymentSharingChanged(deploymentSharedEntity) { this.deploymentSharedEntity = deploymentSharedEntity; + }, + deleteApplication(appModule) { + const deleteAllDeployments = this.deployments.map(dep => + services.ApplicationDeploymentService.delete({ + lookup: dep.appDeploymentId + }) + ); + return Promise.all(deleteAllDeployments) + .then(() => { + if (this.appInterface && this.appInterface.applicationInterfaceId) { + return services.ApplicationInterfaceService.delete({ + lookup: this.appInterface.applicationInterfaceId + }); + } + }) + .then(() => { + return services.ApplicationModuleService.delete({ lookup: this.id }); + }) + .then(() => { + this.$router.push({ path: "/applications" }); + }); } }, watch: { diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue index 5eddc14..09ba589 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue @@ -21,6 +21,9 @@ <b-button variant="primary" @click="save" :disabled="readonly"> Save </b-button> + <b-button v-if="data.appModuleId" variant="danger" @click="deleteApplicationModule" :disabled="readonly"> + Delete + </b-button> <b-button variant="secondary" @click="cancel"> Cancel </b-button> @@ -51,6 +54,9 @@ export default { }, cancel() { this.$emit("cancel"); + }, + deleteApplicationModule() { + this.$emit("delete", this.data); } } }; diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_deployments.js b/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_deployments.js index 65c05f8..bc01af3 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_deployments.js +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_deployments.js @@ -16,14 +16,14 @@ export default { }, actions: { loadApplicationDeployments({ commit }, appModuleId) { - services.ApplicationModuleService.getApplicationDeployments({ lookup: appModuleId }) + return services.ApplicationModuleService.getApplicationDeployments({ lookup: appModuleId }) .then(appDeployments => { commit('setDeployments', appDeployments); return appDeployments; }); }, loadApplicationDeployment({ commit }, appDeploymentId) { - services.ApplicationDeploymentService.retrieve({ lookup: appDeploymentId }) + return services.ApplicationDeploymentService.retrieve({ lookup: appDeploymentId }) .then(appDeployment => { commit('setCurrentDeployment', appDeployment); return appDeployment; @@ -44,7 +44,7 @@ export default { }) }, deleteApplicationDeployment({ commit }, appDeployment) { - return services.ApplicationDeploymentService.delete({lookup: appDeployment.appDeploymentId }) + return services.ApplicationDeploymentService.delete({ lookup: appDeployment.appDeploymentId }) .then(() => { commit('setCurrentDeployment', null); return null; diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_interfaces.js b/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_interfaces.js index cfdffae..c22094b 100644 --- a/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_interfaces.js +++ b/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_interfaces.js @@ -21,7 +21,7 @@ export default { .catch(error => { if (error.details.status === 404) { // If there is no interface, just create a new instance - const appInterface = new models.ApplicationInterfaceDefinition(); + const appInterface = new models.ApplicationInterfaceDefinition({ userHasWriteAccess: true }); appInterface.addStandardOutAndStandardErrorOutputs(); commit('setCurrentInterface', appInterface); return Promise.resolve(null); diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py index 90369ab..ea014c3 100644 --- a/django_airavata/apps/api/serializers.py +++ b/django_airavata/apps/api/serializers.py @@ -274,7 +274,8 @@ class ApplicationInterfaceDescriptionSerializer( lookup_url_kwarg='app_interface_id') applicationInputs = OrderedListField( order_by='inputOrder', - child=InputDataObjectTypeSerializer()) + child=InputDataObjectTypeSerializer(), + allow_null=True) userHasWriteAccess = serializers.SerializerMethodField() def get_userHasWriteAccess(self, appDeployment): diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py index dd7df09..bee1725 100644 --- a/django_airavata/apps/api/views.py +++ b/django_airavata/apps/api/views.py @@ -274,6 +274,10 @@ class ApplicationModuleViewSet(APIBackedViewSet): def perform_update(self, serializer): app_module = serializer.save() self.request.airavata_client.updateApplicationModule(self.authz_token, app_module.appModuleId, app_module) + + def perform_destroy(self, instance): + self.request.airavata_client.deleteApplicationModule( + self.authz_token, instance.appModuleId) @detail_route() def application_interface(self, request, app_module_id): @@ -378,6 +382,10 @@ class ApplicationInterfaceViewSet(APIBackedViewSet): self.request.airavata_client.updateApplicationInterface(self.authz_token, application_interface.applicationInterfaceId, application_interface) + + def perform_destroy(self, instance): + self.request.airavata_client.deleteApplicationInterface( + self.authz_token, instance.applicationInterfaceId) @detail_route() def compute_resources(self, request, app_interface_id): diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/entry-create-experiment.js b/django_airavata/apps/workspace/static/django_airavata_workspace/js/entry-create-experiment.js index 1df69e7..6c68f7a 100644 --- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/entry-create-experiment.js +++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/entry-create-experiment.js @@ -12,15 +12,14 @@ new Vue({ el: '#create-experiment', template: '<create-experiment-container v-bind:appModuleId="appModuleId"></create-experiment-container>', data: { - appModuleId: null, + appModuleId: null, }, components: { - CreateExperimentContainer, + CreateExperimentContainer, }, beforeMount: function () { - if (this.$el.dataset.appModuleId) { - this.appModuleId = this.$el.dataset.appModuleId; - } + if (this.$el.dataset.appModuleId) { + this.appModuleId = this.$el.dataset.appModuleId; + } } - })
