diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 4fe634eb..2f582cd7 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -99,6 +99,30 @@ @change="updateSetting($event, settingGroup.key, setting.key)"/> +
{{ setting.description }}
@@ -153,6 +177,19 @@ export default { return this.data[this.setting.key] === ':disabled' ? ':disabled' : Object.keys(this.data[this.setting.key])[0] + }, + rateLimitAllUsers() { + return this.data[this.setting.key] ? Object.entries(this.data[this.setting.key])[0] : [null, null] + }, + rateLimitAuthUsers() { + return Array.isArray(this.data[this.setting.key]) + ? Object.entries(this.data[this.setting.key][1])[0] + : false + }, + rateLimitUnauthUsers() { + return Array.isArray(this.data[this.setting.key]) + ? Object.entries(this.data[this.setting.key][0])[0] + : false } }, methods: { @@ -194,6 +231,22 @@ export default { console.log(updatedValue) this.updateSetting(updatedValue, this.settingGroup.key, this.setting.key) }, + parseRateLimiter(value, input, typeOfInput, typeOfLimit, currentValue) { + if (typeOfLimit === 'oneLimit') { + const valueToSend = typeOfInput === 'scale' ? { 'tuple': [value, currentValue[1]] } : { 'tuple': [currentValue[0], value] } + this.updateSetting(valueToSend, 'rate_limit', input) + } else if (typeOfLimit === 'authUserslimit') { + const valueToSend = typeOfInput === 'scale' + ? [{ 'tuple': [currentValue[0][0], currentValue[0][1]] }, { 'tuple': [value, currentValue[1][1]] }] + : [{ 'tuple': [currentValue[0][0], currentValue[0][1]] }, { 'tuple': [currentValue[1][0], value] }] + this.updateSetting(valueToSend, 'rate_limit', input) + } else if (typeOfLimit === 'unauthUsersLimit') { + const valueToSend = typeOfInput === 'scale' + ? [{ 'tuple': [value, currentValue[0][1]] }, { 'tuple': [currentValue[1][0], currentValue[1][1]] }] + : [{ 'tuple': [currentValue[0][0], value] }, { 'tuple': [currentValue[1][0], currentValue[1][1]] }] + this.updateSetting(valueToSend, 'rate_limit', input) + } + }, processNestedData(value, tab, inputName, childName) { const updatedValue = { ...this.$store.state.settings.settings[tab][inputName], ...{ [childName]: value }} this.updateSetting(updatedValue, tab, inputName) @@ -209,6 +262,9 @@ export default { toggleAtomTuple(value, tab, input) { console.log(value) }, + toggleLimits(value, input) { + this.updateSetting(value, 'rate_limit', input) + }, updateSetting(value, tab, input) { this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) } diff --git a/src/views/settings/components/RateLimiters.vue b/src/views/settings/components/RateLimiters.vue index f0381846..5c079b83 100644 --- a/src/views/settings/components/RateLimiters.vue +++ b/src/views/settings/components/RateLimiters.vue @@ -1,221 +1,6 @@ -