-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement quota tracking options per ObjectStore.
- Loading branch information
Showing
33 changed files
with
1,133 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<div> | ||
<b>{{ quotaUsage.name }}</b> | ||
<progress-bar | ||
:note="title" | ||
:ok-count="quotaUsage.quota_percent" | ||
:total="100" | ||
v-if="quotaUsage.quota_percent < 99" | ||
/> | ||
<progress-bar :note="title" :error-count="quotaUsage.quota_percent" :total="100" v-else /> | ||
<p> | ||
<i>Using {{ quotaUsage.nice_total_disk_usage }} out of {{ quotaUsage.quota }}.</i> | ||
</p> | ||
<hr /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import Vue from "vue"; | ||
import BootstrapVue from "bootstrap-vue"; | ||
import ProgressBar from "components/ProgressBar"; | ||
Vue.use(BootstrapVue); | ||
export default { | ||
components: { | ||
ProgressBar, | ||
}, | ||
props: { | ||
quotaUsage: { | ||
type: Object, | ||
}, | ||
}, | ||
computed: { | ||
title() { | ||
if (this.quotaUsage.quota_percent == null) { | ||
return `Unlimited`; | ||
} else { | ||
return `Using ${this.quotaUsage.quota_percent}%.`; | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<template> | ||
<b-modal visible ok-only ok-title="Close" hide-header> | ||
<b-alert v-if="errorMessage" variant="danger" show v-html="errorMessage" /> | ||
<div v-else-if="usage == null"> | ||
<span class="fa fa-spinner fa-spin" /> | ||
<span>Please wait...</span> | ||
</div> | ||
<div class="d-block" style="overflow: hidden;" v-else> | ||
<div v-for="item in effectiveQuotaSourceLabels" :key="item.id"> | ||
<quota-usage :quotaUsage="item" /> | ||
</div> | ||
</div> | ||
</b-modal> | ||
</template> | ||
|
||
<script> | ||
import axios from "axios"; | ||
import Vue from "vue"; | ||
import BootstrapVue from "bootstrap-vue"; | ||
import { getAppRoot } from "onload/loadConfig"; | ||
import { errorMessageAsString } from "utils/simple-error"; | ||
import QuotaUsage from "./QuotaUsage"; | ||
Vue.use(BootstrapVue); | ||
export default { | ||
components: { | ||
QuotaUsage, | ||
}, | ||
props: { | ||
quotaSourceLabels: { | ||
type: Array, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
usage: null, | ||
errorMessage: null, | ||
}; | ||
}, | ||
created() { | ||
const url = `${getAppRoot()}api/users/current/usage`; | ||
axios | ||
.get(url) | ||
.then((response) => { | ||
this.usage = response.data; | ||
}) | ||
.catch((error) => { | ||
this.errorMessage = errorMessageAsString(error); | ||
}); | ||
}, | ||
computed: { | ||
effectiveQuotaSourceLabels() { | ||
const labels = []; | ||
const usageAsDict = this.usageAsDict; | ||
labels.push({ id: "_default_", name: "Default Quota", ...usageAsDict["_default_"] }); | ||
for (const label of this.quotaSourceLabels) { | ||
const usage = usageAsDict[label]; | ||
labels.push({ id: label, name: `Quota Source: ${label}`, ...usage }); | ||
} | ||
return labels; | ||
}, | ||
usageAsDict() { | ||
const asDict = {}; | ||
for (const usage of this.usage) { | ||
if (usage.quota_source_label == null) { | ||
asDict["_default_"] = usage; | ||
} else { | ||
asDict[usage.quota_source_label] = usage; | ||
} | ||
} | ||
return asDict; | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { showQuotaDialog } from "./show"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Vue from "vue"; | ||
import QuotaUsageDialog from "./QuotaUsageDialog"; | ||
|
||
export function showQuotaDialog(options = {}) { | ||
const instance = Vue.extend(QuotaUsageDialog); | ||
const vm = document.createElement("div"); | ||
document.body.appendChild(vm); | ||
new instance({ | ||
propsData: options, | ||
}).$mount(vm); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.