Skip to content

Commit 1509bca

Browse files
committed
improve ui for rules and explain quota table in personal settings
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
1 parent 864d920 commit 1509bca

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/components/PersonalSettings.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
<h4>
8888
{{ t('integration_openai', 'Usage quota info') }}
8989
</h4>
90+
<NcNoteCard v-if="poolUsed" type="info">
91+
{{ t('integration_openai', 'If you see a shared quota usage of 50% and a usage of 10% that means that you have used 10% of the total shared quota, and the sum of all other users affected by this quota is 40%.') }}
92+
</NcNoteCard>
9093
<!-- Loop through all quota types-->
9194
<table class="quota-table">
9295
<thead>

src/components/Rules/QuotaRules.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
-->
55
<template>
66
<div>
7+
<h2>{{ t('integration_openai', 'Quota Rules') }}</h2>
78
<NcNoteCard type="info">
89
{{ t('integration_openai', 'Rules can be set for specific groups or users. These rules will override the global quota settings.') }}
910
{{ t('integration_openai', 'Only the rule with the highest priority is active if multiple rules match.') }}
1011
</NcNoteCard>
11-
<h2>{{ t('integration_openai', 'Quota Rules') }}</h2>
1212
<Rule v-for="(rule, index) in state"
1313
:key="index"
1414
v-model:value="state[index]"

src/components/Rules/Rule.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
@update:model-value="update('pool', $event)">
4545
{{ t('integration_openai', 'Use shared quota') }}
4646
</NcCheckboxRadioSwitch>
47-
<NcButton variant="success" @click="save">
47+
<NcButton v-if="needSaving"
48+
:disabled="saving"
49+
variant="success"
50+
@click="save">
4851
{{ t('integration_openai', 'Save') }}
4952
</NcButton>
5053
<NcButton @click="$emit('delete')">
@@ -92,6 +95,12 @@ export default {
9295
},
9396
9497
emits: ['update:value', 'delete'],
98+
data() {
99+
return {
100+
needSaving: false,
101+
saving: false,
102+
}
103+
},
95104
96105
computed: {
97106
unit() {
@@ -126,14 +135,18 @@ export default {
126135
update(key, value) {
127136
console.debug('update', key, value)
128137
if (value || value === false || value === 0) {
138+
this.needSaving = true
129139
this.$emit('update:value', { ...this.value, [key]: value })
130140
}
131141
},
132142
save() {
143+
this.saving = true
133144
return axios.put(generateUrl('/apps/integration_openai/quota/rule'), {
134145
rule: this.value,
135146
id: this.value.id,
136147
}).then((response) => {
148+
this.saving = false
149+
this.needSaving = false
137150
const data = response.data ?? {}
138151
this.$emit('update:value', data)
139152
showSuccess(t('integration_openai', 'Quota rule saved'))
@@ -168,4 +181,7 @@ export default {
168181
padding: 10px;
169182
margin: 10px 0;
170183
}
184+
.user-selector {
185+
max-width: 600px;
186+
}
171187
</style>

0 commit comments

Comments
 (0)