DmitrMakeev commited on
Commit
8b55834
·
verified ·
1 Parent(s): 3dcddfb

Update settings.html

Browse files
Files changed (1) hide show
  1. settings.html +40 -37
settings.html CHANGED
@@ -126,44 +126,47 @@
126
  .catch(error => console.error('Error:', error));
127
  }
128
 
129
- function saveSettings() {
130
- const form = document.getElementById('settingsForm');
131
- const formData = new FormData(form);
132
- const data = {};
133
- formData.forEach((value, key) => {
134
- if (value !== '') {
135
- data[key] = value;
136
- }
137
- });
138
- fetch('/save_settings', {
139
- method: 'POST',
140
- headers: {
141
- 'Content-Type': 'application/json'
142
- },
143
- body: JSON.stringify({ action: 'save', data: data, api_key_sys: data.api_key_sys })
144
- })
145
- .then(response => response.json())
146
- .then(data => {
147
- console.log('Success:', data);
148
- Toastify({
149
- text: "Данные сохранены",
150
- duration: 3000,
151
- gravity: "top",
152
- position: "right",
153
- backgroundColor: "#4CAF50",
154
- }).showToast();
155
- })
156
- .catch(error => {
157
- console.error('Error:', error);
158
- Toastify({
159
- text: "Ошибка при сохранении данных",
160
- duration: 3000,
161
- gravity: "top",
162
- position: "right",
163
- backgroundColor: "#FF0000",
164
- }).showToast();
165
- });
166
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
  function refreshSettings() {
169
  loadSettings();
 
126
  .catch(error => console.error('Error:', error));
127
  }
128
 
129
+ function saveSettings() {
130
+ const form = document.getElementById('settingsForm');
131
+ const formData = new FormData(form);
132
+ const data = {};
133
+ formData.forEach((value, key) => {
134
+ if (value !== '') {
135
+ data[key] = value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
+ });
138
+ const apiKeySys = data.api_key_sys;
139
+ delete data.api_key_sys; // Удаляем api_key_sys из данных формы
140
+
141
+ fetch('/save_settings', {
142
+ method: 'POST',
143
+ headers: {
144
+ 'Content-Type': 'application/json'
145
+ },
146
+ body: JSON.stringify({ action: 'save', data: data, api_key_sys: apiKeySys })
147
+ })
148
+ .then(response => response.json())
149
+ .then(data => {
150
+ console.log('Success:', data);
151
+ Toastify({
152
+ text: "Данные сохранены",
153
+ duration: 3000,
154
+ gravity: "top",
155
+ position: "right",
156
+ backgroundColor: "#4CAF50",
157
+ }).showToast();
158
+ })
159
+ .catch(error => {
160
+ console.error('Error:', error);
161
+ Toastify({
162
+ text: "Ошибка при сохранении данных",
163
+ duration: 3000,
164
+ gravity: "top",
165
+ position: "right",
166
+ backgroundColor: "#FF0000",
167
+ }).showToast();
168
+ });
169
+ }
170
 
171
  function refreshSettings() {
172
  loadSettings();