|
|
|
@ -189,14 +189,36 @@ export default {
|
|
|
|
|
* @param {string} [currentPassword] Only need for disableAuth to true
|
|
|
|
|
*/
|
|
|
|
|
saveSettings(callback, currentPassword) {
|
|
|
|
|
this.$root.getSocket().emit("setSettings", this.settings, currentPassword, (res) => {
|
|
|
|
|
this.$root.toastRes(res);
|
|
|
|
|
this.loadSettings();
|
|
|
|
|
let valid = this.validateSettings();
|
|
|
|
|
if (valid.success) {
|
|
|
|
|
this.$root.getSocket().emit("setSettings", this.settings, currentPassword, (res) => {
|
|
|
|
|
this.$root.toastRes(res);
|
|
|
|
|
this.loadSettings();
|
|
|
|
|
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.$root.toastError(valid.msg);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
if (callback) {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
/**
|
|
|
|
|
* Ensure settings are valid
|
|
|
|
|
* @returns {Object} Contains success state and error msg
|
|
|
|
|
*/
|
|
|
|
|
validateSettings() {
|
|
|
|
|
if (this.settings.keepDataPeriodDays < 0) {
|
|
|
|
|
return {
|
|
|
|
|
success: false,
|
|
|
|
|
msg: this.$t("dataRetentionTimeError"),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
msg: "",
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|