You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2020/03/25 20:07:15 UTC
[airavata-django-portal] 03/09: AIRAVATA-3126 Add support for
deleting all expired reservations
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 1a4b75609ebcffc0c1caf5fd3e3151e83f5b5a5d
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri Mar 20 17:26:37 2020 -0400
AIRAVATA-3126 Add support for deleting all expired reservations
---
.../ComputePreference.vue | 10 ++++--
.../ComputeResourceReservationList.vue | 38 +++++++++++++++-------
.../js/models/ComputeResourceReservation.js | 4 +++
.../static/common/js/components/DeleteButton.vue | 6 +++-
.../static/common/js/layouts/ListLayout.vue | 2 ++
5 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
index 74294d8..5ad366e 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
@@ -479,10 +479,16 @@ export default {
addReservation(reservation) {
this.data.reservations.push(reservation);
},
- deleteReservation(reservationIndex) {
+ deleteReservation(reservation) {
+ const reservationIndex = this.data.reservations.findIndex(
+ r => r.key === reservation.key
+ );
this.data.reservations.splice(reservationIndex, 1);
},
- updateReservation(reservation, reservationIndex) {
+ updateReservation(reservation) {
+ const reservationIndex = this.data.reservations.findIndex(
+ r => r.key === reservation.key
+ );
this.data.reservations.splice(reservationIndex, 1, reservation);
}
},
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputeResourceReservationList.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputeResourceReservationList.vue
index 2415291..8c23922 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputeResourceReservationList.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputeResourceReservationList.vue
@@ -6,6 +6,16 @@
new-item-button-text="New Reservation"
:new-button-disabled="readonly"
>
+ <template slot="additional-buttons">
+ <delete-button
+ class="mr-2"
+ @delete="deleteAllExpiredReservations"
+ label="Delete All Expired"
+ :disabled="expiredReservations.length === 0"
+ >
+ Are you sure you want to delete all expired reservations?
+ </delete-button>
+ </template>
<template slot="new-item-editor">
<b-card v-if="showNewItemEditor" title="New Reservation">
<compute-resource-reservation-editor
@@ -38,12 +48,15 @@
</template>
<template slot="item-list" slot-scope="slotProps">
<b-table
- striped
hover
:fields="fields"
:items="slotProps.items"
sort-by="startTime"
>
+ <template slot="reservationName" slot-scope="data">
+ {{ data.value }}
+ <b-badge v-if="data.item.isExpired">Expired</b-badge>
+ </template>
<template slot="queueNames" slot-scope="data">
<ul v-for="queueName in data.item.queueNames" :key="queueName">
<li>{{ queueName }}</li>
@@ -54,7 +67,7 @@
v-if="!readonly"
class="action-link"
@click="toggleDetails(data)"
- :disabled="isReservationInvalid(data.item.key)"
+ :disabled="isReservationInvalid(data.item.key)"
>
Edit
<i class="fa fa-edit" aria-hidden="true"></i>
@@ -101,7 +114,8 @@ export default {
"delete-link": components.DeleteLink,
"human-date": components.HumanDate,
"list-layout": layouts.ListLayout,
- ComputeResourceReservationEditor
+ ComputeResourceReservationEditor,
+ "delete-button": components.DeleteButton
},
props: {
reservations: {
@@ -174,26 +188,25 @@ export default {
(!this.showNewItemEditor || this.newReservationValid) &&
this.invalidReservations.length === 0
);
+ },
+ expiredReservations() {
+ return this.reservations
+ ? this.reservations.filter(r => r.isExpired)
+ : [];
}
},
created() {},
methods: {
updatedReservation(newValue) {
- const reservationIndex = this.reservations.findIndex(
- r => r.key === newValue.key
- );
- this.$emit("updated", newValue, reservationIndex);
+ this.$emit("updated", newValue);
},
toggleDetails(row) {
row.toggleDetails();
this.showingDetails[row.item.key] = !this.showingDetails[row.item.key];
},
deleteReservation(reservation) {
- const reservationIndex = this.reservations.findIndex(
- r => r.key === reservation.key
- );
this.removeInvalidReservation(reservation.key);
- this.$emit("deleted", reservationIndex);
+ this.$emit("deleted", reservation);
},
addNewReservation() {
this.newReservation = new models.ComputeResourceReservation();
@@ -230,6 +243,9 @@ export default {
} else {
this.$emit("invalid");
}
+ },
+ deleteAllExpiredReservations() {
+ this.expiredReservations.forEach(this.deleteReservation);
}
}
};
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/ComputeResourceReservation.js b/django_airavata/apps/api/static/django_airavata_api/js/models/ComputeResourceReservation.js
index c4a8921..2303ad7 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/ComputeResourceReservation.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/ComputeResourceReservation.js
@@ -43,4 +43,8 @@ export default class ComputeResourceReservation extends BaseModel {
}
return validationResults;
}
+ get isExpired() {
+ const now = new Date();
+ return now > this.endTime;
+ }
}
diff --git a/django_airavata/static/common/js/components/DeleteButton.vue b/django_airavata/static/common/js/components/DeleteButton.vue
index f1a22aa..0e07c43 100644
--- a/django_airavata/static/common/js/components/DeleteButton.vue
+++ b/django_airavata/static/common/js/components/DeleteButton.vue
@@ -1,7 +1,7 @@
<template>
<div class="delete-button">
<b-button variant="danger" @click="$refs.modal.show()" :disabled="disabled">
- Delete
+ {{ label }}
</b-button>
<confirmation-dialog ref="modal" :title="dialogTitle" @ok="$emit('delete')">
<slot></slot>
@@ -21,6 +21,10 @@ export default {
disabled: {
type: Boolean,
default: false
+ },
+ label: {
+ type: String,
+ default: "Delete"
}
},
components: {
diff --git a/django_airavata/static/common/js/layouts/ListLayout.vue b/django_airavata/static/common/js/layouts/ListLayout.vue
index d94628f..dfd77fa 100644
--- a/django_airavata/static/common/js/layouts/ListLayout.vue
+++ b/django_airavata/static/common/js/layouts/ListLayout.vue
@@ -7,6 +7,8 @@
</slot>
</div>
<div class="col-auto">
+ <slot name="additional-buttons">
+ </slot>
<slot name="new-item-button">
<b-btn variant="primary" @click="addNewItem" :disabled="newButtonDisabled">
{{ newItemButtonText }}