Skip to content

Commit

Permalink
implement preferred object store id
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jun 18, 2022
1 parent 191e869 commit 69507d0
Show file tree
Hide file tree
Showing 37 changed files with 1,392 additions and 110 deletions.
165 changes: 110 additions & 55 deletions client/src/components/History/CurrentHistory/HistoryCounter.vue
Original file line number Diff line number Diff line change
@@ -1,67 +1,112 @@
<template>
<div class="history-size my-1 d-flex justify-content-between">
<b-button
v-b-tooltip.hover
title="Access Dashboard"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="onDashboard">
<icon icon="database" />
<span>{{ history.size | niceFileSize }}</span>
</b-button>
<b-button-group>
<b-button
v-b-tooltip.hover
title="Show active"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="setFilter('')">
<span class="fa fa-map-marker" />
<span>{{ history.contents_active.active }}</span>
</b-button>
<b-button
v-if="history.contents_active.deleted"
v-b-tooltip.hover
title="Show deleted"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="setFilter('deleted:true')">
<icon icon="trash" />
<span>{{ history.contents_active.deleted }}</span>
</b-button>
<b-button
v-if="history.contents_active.hidden"
v-b-tooltip.hover
title="Show hidden"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="setFilter('visible:false')">
<icon icon="eye-slash" />
<span>{{ history.contents_active.hidden }}</span>
</b-button>
<b-button
v-b-tooltip.hover
:title="'Last updated ' + diffToNow"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="reloadContents()">
<span :class="reloadButtonCls" />
</b-button>
</b-button-group>
</div>
<ConfigProvider v-slot="{ config }">
<CurrentUser v-slot="{ user }">
<div class="history-size my-1 d-flex justify-content-between">
<b-button
v-if="config.object_store_allows_id_selection"
:id="`history-stoarge-${history.id}`"
v-b-tooltip.hover
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="showPreferredObjectStoreModal = true">
<icon icon="database" />
<span>{{ history.size | niceFileSize }}</span>
</b-button>
<b-button
v-else
v-b-tooltip.hover
title="Access Dashboard"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="onDashboard">
<icon icon="database" />
<span>{{ history.size | niceFileSize }}</span>
</b-button>
<HistoryTargetPreferredObjectStorePopover
:historyId="history.id"
:historyPreferredObjectStoreId="historyPreferredObjectStoreId"
:user="user">
</HistoryTargetPreferredObjectStorePopover>
<b-button-group>
<b-button
v-b-tooltip.hover
title="Show active"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="setFilter('')">
<span class="fa fa-map-marker" />
<span>{{ history.contents_active.active }}</span>
</b-button>
<b-button
v-if="history.contents_active.deleted"
v-b-tooltip.hover
title="Show deleted"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="setFilter('deleted:true')">
<icon icon="trash" />
<span>{{ history.contents_active.deleted }}</span>
</b-button>
<b-button
v-if="history.contents_active.hidden"
v-b-tooltip.hover
title="Show hidden"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="setFilter('visible:false')">
<icon icon="eye-slash" />
<span>{{ history.contents_active.hidden }}</span>
</b-button>
<b-button
v-b-tooltip.hover
:title="'Last updated ' + diffToNow"
variant="link"
size="sm"
class="rounded-0 text-decoration-none"
@click="reloadContents()">
<span :class="reloadButtonCls" />
</b-button>
</b-button-group>
<b-modal
title="History Preferred Object Store"
v-model="showPreferredObjectStoreModal"
modal-class="history-preferred-object-store-modal"
title-tag="h3"
size="sm"
hide-footer>
<HistorySelectPreferredObjectStore
:user-preferred-object-store-id="user.preferred_object_store_id"
:history="history"
:root="root"
@updated="onUpdatePreferredObjectStoreId" />
</b-modal>
</div>
</CurrentUser>
</ConfigProvider>
</template>

<script>
import { backboneRoute } from "components/plugins/legacyNavigation";
import prettyBytes from "pretty-bytes";
import { formatDistanceToNowStrict } from "date-fns";
import ConfigProvider from "components/providers/ConfigProvider";
import CurrentUser from "components/providers/CurrentUser";
import HistorySelectPreferredObjectStore from "./HistorySelectPreferredObjectStore";
import HistoryTargetPreferredObjectStorePopover from "./HistoryTargetPreferredObjectStorePopover";
import { getAppRoot } from "onload/loadConfig";
export default {
components: {
ConfigProvider,
CurrentUser,
HistoryTargetPreferredObjectStorePopover,
HistorySelectPreferredObjectStore,
},
filters: {
niceFileSize(rawSize = 0) {
return prettyBytes(rawSize);
Expand All @@ -75,6 +120,9 @@ export default {
return {
diffToNow: 0,
reloadButtonCls: "fa fa-sync",
showPreferredObjectStoreModal: false,
historyPreferredObjectStoreId: history.preferred_object_store_id,
root: getAppRoot(),
};
},
mounted() {
Expand All @@ -99,6 +147,13 @@ export default {
this.reloadButtonCls = "fa fa-sync";
}, 1000);
},
onUpdatePreferredObjectStoreId(preferredObjectStoreId) {
this.showPreferredObjectStoreModal = false;
// ideally this would be pushed back to the history object somehow
// and tracked there... but for now this is only component using
// this information.
this.historyPreferredObjectStoreId = preferredObjectStoreId;
},
},
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<template>
<div>
<loading-span v-if="loading" :message="loadingObjectStoreInfoMessage" />
<div v-else>
<b-alert v-if="error" variant="danger" show>
{{ error }}
</b-alert>
<b-row>
<b-col cols="7">
<b-button-group vertical size="lg" style="width: 100%">
<b-button
:variant="variant(null)"
id="no-preferred-object-store-button"
@click="handleSubmit(null)"
><i>User Preference Defined Default</i></b-button
>
<b-button
:variant="variant(object_store.object_store_id)"
:id="`preferred-object-store-button-${object_store.object_store_id}`"
v-for="object_store in objectStores"
:key="object_store.object_store_id"
@click="handleSubmit(object_store.object_store_id)"
>{{ object_store.name }}
<ObjectStoreBadges :badges="object_store.badges" size="lg" :more-on-hover="false" />
<ProvidedQuotaSourceUsageBar :objectStore="object_store" :compact="true">
</ProvidedQuotaSourceUsageBar>
</b-button>
</b-button-group>
</b-col>
<b-col cols="5">
<p style="float: right" localize>
{{ whyIsSelectionPreferredText }}
</p>
</b-col>
</b-row>
<b-popover
target="no-preferred-object-store-button"
triggers="hover"
:placement="popoverPlacement"
v-if="userPreferredObjectStoreId">
<template v-slot:title
><span v-localize>{{ userSelectionDefalutTitle }}</span></template
>
<span v-localize>{{ userSelectionDefalutDescription }}</span>
</b-popover>
<b-popover target="no-preferred-object-store-button" triggers="hover" :placement="popoverPlacement" v-else>
<template v-slot:title
><span v-localize>{{ galaxySelectionDefalutTitle }}</span></template
>
<span v-localize>{{ galaxySelectionDefalutTitle }}</span>
</b-popover>
<b-popover
v-for="object_store in objectStores"
:key="object_store.object_store_id"
:target="`preferred-object-store-button-${object_store.object_store_id}`"
triggers="hover"
:placement="popoverPlacement">
<template v-slot:title>{{ object_store.name }}</template>
<DescribeObjectStore :what="newDatasetsDescription" :storage-info="object_store"> </DescribeObjectStore>
</b-popover>
</div>
</div>
</template>

<script>
import axios from "axios";
import selectionMixin from "components/ObjectStore/selectionMixin";
export default {
mixins: [selectionMixin],
props: {
userPreferredObjectStoreId: {
type: String,
required: true,
},
history: {
type: Object,
required: true,
},
},
data() {
const selectedObjectStoreId = this.history.preferred_object_store_id;
return {
selectedObjectStoreId: selectedObjectStoreId,
newDatasetsDescription: "New dataset outputs from tools and workflows executed in this history",
popoverPlacement: "left",
userSelectionDefalutTitle: "Use Your User Preference Defaults",
userSelectionDefalutDescription:
"Selecting this will cause the history to not set a default and to fallback to your user preference defined default.",
};
},
methods: {
async handleSubmit(preferredObjectStoreId) {
const payload = { preferred_object_store_id: preferredObjectStoreId };
try {
await axios.put(`${this.root}api/histories/${this.history.id}`, payload);
} catch (e) {
this.handleError(e);
}
this.selectedObjectStoreId = preferredObjectStoreId;
this.$emit("updated", preferredObjectStoreId);
},
},
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<b-popover :target="`history-stoarge-${historyId}`" triggers="hover" placement="bottomleft">
<template v-slot:title>Preferred Target Object Store</template>
<p class="history-preferred-object-store-inherited" v-if="historyPreferredObjectStoreId">
This target object store has been set at the history level.
</p>
<p class="history-preferred-object-store-not-inherited" v-else>
This target object store has been inherited from your user preferences (set in User -> Preferences ->
Preferred Object Store). If that option is updated, this history will target that new default.
</p>
<ObjectStoreDetailsProvider
:id="preferredObjectStoreId"
v-if="preferredObjectStoreId"
v-slot="{ result: storageInfo, loading: isLoadingStorageInfo }">
<b-spinner v-if="isLoadingStorageInfo" />
<DescribeObjectStore
v-else
what="Galaxy will default to storing this history's datasets in "
:storage-info="storageInfo">
</DescribeObjectStore>
</ObjectStoreDetailsProvider>
<div>Change this preference object store target by clicking on the storage button in the history panel.</div>
</b-popover>
</template>

<script>
import { ObjectStoreDetailsProvider } from "components/providers/ObjectStoreProvider";
import DescribeObjectStore from "components/ObjectStore/DescribeObjectStore";
export default {
components: {
DescribeObjectStore,
ObjectStoreDetailsProvider,
},
props: {
historyId: {
type: String,
required: true,
},
historyPreferredObjectStoreId: {
type: String,
},
user: { type: Object, required: true },
},
computed: {
preferredObjectStoreId() {
let id = this.historyPreferredObjectStoreId;
if (!id) {
id = this.user.preferred_object_store_id;
}
return id;
},
},
};
</script>
Loading

0 comments on commit 69507d0

Please sign in to comment.