Skip to content

Commit

Permalink
chore: remove code toupdate settings
Browse files Browse the repository at this point in the history
It's not allow now.

See torrust/torrust-index#144
  • Loading branch information
josecelano committed Jun 26, 2023
1 parent ddff9b6 commit da64de7
Showing 1 changed file with 1 addition and 46 deletions.
47 changes: 1 addition & 46 deletions pages/admin/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,9 @@
</div>

<template v-if="settings">
<NuxtPage :settings="settingsChanges" class="w-full" />
<NuxtPage :settings="settings" class="w-full" />
</template>

<div class="flex flex-col w-full gap-2">
<template v-if="madeChanges()">
<button
class="btn btn-secondary"
:disabled="!madeChanges() || updatingSettings"
@click="saveSettings()"
>save changes</button>

<button
class="btn btn-error"
:disabled="!madeChanges() || updatingSettings"
@click="clearChanges()"
>clear changes</button>
</template>
</div>
</div>
</div>
</template>
Expand All @@ -55,13 +40,7 @@ const tabs = [
const rest = useRestApi();
const updatingSettings: Ref<Boolean> = ref(false);
const settings: Ref<Settings> = ref(null);
const settingsChanges: Ref<Settings> = ref(null);
watch([settings], () => {
clearChanges();
});
onMounted(() => {
getAdminSettings();
Expand All @@ -74,30 +53,6 @@ function getAdminSettings () {
});
}
function saveSettings () {
updatingSettings.value = true;
rest.value.settings.updateSettings(settingsChanges.value)
.then((v) => {
settings.value = v;
updatingSettings.value = false;
getSettings();
})
.catch(() => {
updatingSettings.value = false;
});
}
function clearChanges () {
// This is how you clone without references in JS...
settingsChanges.value = JSON.parse(JSON.stringify(settings.value));
}
function madeChanges (): boolean {
return JSON.stringify(settingsChanges.value) !== JSON.stringify(settings.value);
}
</script>

<style scoped>
Expand Down

0 comments on commit da64de7

Please sign in to comment.