Settings form and handling
This commit is contained in:
parent
6f155ada66
commit
06380e48c5
10 changed files with 485 additions and 135 deletions
|
@ -50,14 +50,32 @@ export const useSettingStore = defineStore("setting", {
|
|||
return res;
|
||||
});
|
||||
},
|
||||
async uploadImage(data: { key: SettingString; value?: File }[]): Promise<AxiosResponse<any, any>> {
|
||||
const formData = new FormData();
|
||||
for (let entry of data) {
|
||||
if (entry.value) formData.append(entry.key, entry.value);
|
||||
}
|
||||
return await http.put("/admin/setting/img", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
},
|
||||
async updateSettings<K extends SettingString>(
|
||||
data: { key: K; value: SettingValueMapping[K] }[]
|
||||
): Promise<AxiosResponse<any, any>> {
|
||||
return await http.put("/admin/setting", data);
|
||||
},
|
||||
async updateSetting<K extends SettingString>(
|
||||
key: K,
|
||||
val: SettingValueMapping[K]
|
||||
value: SettingValueMapping[K]
|
||||
): Promise<AxiosResponse<any, any>> {
|
||||
return await http.put("/admin/setting", {
|
||||
setting: key,
|
||||
value: val,
|
||||
});
|
||||
return await http.put("/admin/setting", [
|
||||
{
|
||||
setting: key,
|
||||
value: value,
|
||||
},
|
||||
]);
|
||||
},
|
||||
async resetSetting(key: SettingString): Promise<AxiosResponse<any, any>> {
|
||||
return await http.delete(`/admin/setting/${key}`);
|
||||
|
|
|
@ -10,6 +10,8 @@ export const useConfigurationStore = defineStore("configuration", {
|
|||
clubWebsite: "",
|
||||
appCustom_login_message: "",
|
||||
appShow_link_to_calendar: false as boolean,
|
||||
|
||||
serverOffline: false as boolean,
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
|
@ -24,7 +26,9 @@ export const useConfigurationStore = defineStore("configuration", {
|
|||
this.appCustom_login_message = res.data["app.custom_login_message"];
|
||||
this.appShow_link_to_calendar = res.data["app.show_link_to_calendar"];
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch(() => {
|
||||
this.serverOffline = true;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue