DmitrMakeev commited on
Commit
88b14cd
·
verified ·
1 Parent(s): 19ced67

Update plot_week.html

Browse files
Files changed (1) hide show
  1. plot_week.html +84 -127
plot_week.html CHANGED
@@ -101,6 +101,90 @@ body {
101
  </head>
102
  <body>
103
  <div id="protection-overlay"></div> <!-- Полупрозрачный фон -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  <script>
105
  const data = {{ data | tojson }};
106
 
@@ -167,133 +251,6 @@ body {
167
  showlegend: false
168
  });
169
  </script>
170
-
171
-
172
-
173
- <!-- Навигационная панель -->
174
- <nav class="navbar navbar-light bg-light w-100">
175
- <div class="container">
176
- <a class="navbar-brand" href="/online">
177
- <img src="https://huggingface.co/spaces/igs-img/stor/resolve/main/list.png" width="30" height="30" class="d-inline-block align-top" alt="">
178
- MackorLab
179
- </a>
180
- <form class="form-inline">
181
- <button id="st_onl" class="btn btn-outline-success" type="button">Онлайн</button>
182
- <button id="st_set" class="btn btn-outline-success" type="button">Настройки</button>
183
- <button id="st_plot" class="btn btn-success" type="button">Графики</button>
184
- <button id="st_table" class="btn btn-outline-success" type="button">Таблица</button>
185
- </form>
186
- </div>
187
- </nav>
188
-
189
- <div class="container text-center mt-3">
190
- <h1>Графики за <span id="week_number">{{ week_number }}</span>-ю неделю</h1>
191
- </div>
192
-
193
- <!-- Кнопки переключения недель -->
194
- <div class="week-buttons">
195
- <button id="prev_week" class="btn btn-success mr-2" onclick="navigateWeek(-1)">Предыдущая неделя</button>
196
- <button id="next_week" class="btn btn-success" onclick="navigateWeek(1)">Следующая неделя</button>
197
- </div>
198
-
199
- {% if data %}
200
- <div class="container">
201
- <div class="graph-container"><div class="graph" id="ph_chart"></div></div>
202
- <div class="graph-container"><div class="graph" id="ec_chart"></div></div>
203
- <div class="graph-container"><div class="graph" id="pump_chart"></div></div>
204
- <div class="graph-container"><div class="graph" id="ts_chart"></div></div>
205
- <div class="graph-container"><div class="graph" id="ta_chart"></div></div>
206
- <div class="graph-container"><div class="graph" id="hdm_chart"></div></div>
207
- <div class="graph-container"><div class="graph" id="sven_chart"></div></div>
208
- </div>
209
-
210
- <script>
211
- function createChart(id, yData, title, yLabel, color, parameterName, unit) {
212
- const trace = {
213
- x: data.dates,
214
- y: yData,
215
- type: "scatter",
216
- mode: "lines+markers",
217
- line: { color: color },
218
- hovertemplate: data.dates.map((date, index) =>
219
- `Неделя: ${data.week}<br>` +
220
- `День: ${data.days_of_week[index]}<br>` +
221
- `Время системы: ${data.sus[index]}<br>` +
222
- `${parameterName}: ${yData[index]} ${unit}<br>` +
223
- `Дата: ${date}<extra></extra>`
224
- )
225
- };
226
-
227
- Plotly.newPlot(id, [trace], {
228
- title: title,
229
- xaxis: { title: "", showticklabels: false },
230
- yaxis: { title: yLabel, titlefont: { size: 14 } },
231
- hovermode: "closest",
232
- showlegend: false
233
- });
234
- }
235
-
236
- // Создание графиков с правильными подсказками
237
- createChart("ph_chart", data.ph, `График pH за ${data.week}-ю неделю`, "Уровень pH", "blue", "pH", "");
238
- createChart("ec_chart", data.ec, `График EC за ${data.week}-ю неделю`, "Уровень EC", "blue", "EC", "мкСм/см");
239
- createChart("ts_chart", data.tS, `Температура раствора за ${data.week}-ю неделю`, "Температура (°C)", "purple", "Температура раствора", "°C");
240
- createChart("ta_chart", data.tA, `Температура воздуха за ${data.week}-ю неделю`, "Температура (°C)", "purple", "Температура воздуха", "°C");
241
- createChart("hdm_chart", data.hDm, `Влажность воздуха за ${data.week}-ю неделю`, "Влажность (%)", "purple", "Влажность воздуха", "%");
242
- createChart("sven_chart", data.sVen, `Обороты вентилятора за ${data.week}-ю неделю`, "Обороты (%)", "purple", "Обороты вентилятора", "%");
243
-
244
- // График насосов
245
- Plotly.newPlot("pump_chart", [
246
- {
247
- x: data.dates,
248
- y: data.onA,
249
- type: "scatter",
250
- mode: "lines+markers",
251
- line: { color: "green" },
252
- hovertemplate: data.dates.map((date, index) =>
253
- `Неделя: ${data.week}<br>` +
254
- `День: ${data.days_of_week[index]}<br>` +
255
- `Время системы: ${data.sus[index]}<br>` +
256
- `Насос A: ${data.onA[index]} сек.<br>` +
257
- `Дата: ${date}<extra></extra>`
258
- )
259
- },
260
- {
261
- x: data.dates,
262
- y: data.onB,
263
- type: "scatter",
264
- mode: "lines+markers",
265
- line: { color: "brown" },
266
- hovertemplate: data.dates.map((date, index) =>
267
- `Неделя: ${data.week}<br>` +
268
- `День: ${data.days_of_week[index]}<br>` +
269
- `Время системы: ${data.sus[index]}<br>` +
270
- `Насос B: ${data.onB[index]} сек.<br>` +
271
- `Дата: ${date}<extra></extra>`
272
- )
273
- },
274
- {
275
- x: data.dates,
276
- y: data.onC,
277
- type: "scatter",
278
- mode: "lines+markers",
279
- line: { color: "orange" },
280
- hovertemplate: data.dates.map((date, index) =>
281
- `Неделя: ${data.week}<br>` +
282
- `День: ${data.days_of_week[index]}<br>` +
283
- `Время системы: ${data.sus[index]}<br>` +
284
- `Насос C: ${data.onC[index]} сек.<br>` +
285
- `Дата: ${date}<extra></extra>`
286
- )
287
- }
288
- ], {
289
- title: `Интервал дозирования насосов для ${data.week}-ой недели`,
290
- xaxis: { title: "", showticklabels: false },
291
- yaxis: { title: "Время ВКЛ(сек.)" },
292
- hovermode: "closest",
293
- showlegend: false
294
- });
295
-
296
- </script>
297
  {% else %}
298
  <div class="no-data-message">
299
  {{ message if message else 'Данных за эту неделю нет в баз�� данных.' }}
 
101
  </head>
102
  <body>
103
  <div id="protection-overlay"></div> <!-- Полупрозрачный фон -->
104
+ <script>
105
+ document.addEventListener("DOMContentLoaded", function () {
106
+ const overlay = document.getElementById("protection-overlay");
107
+ let pageKey = localStorage.getItem("page_key");
108
+ // Функция проверки ключа
109
+ function checkApiKey(apiKey) {
110
+ fetch(`/page_key?api_sys=${apiKey}`)
111
+ .then(response => response.json())
112
+ .then(data => {
113
+ if (data.status === "ok") {
114
+ overlay.style.display = "none"; // ✅ Убираем защиту
115
+ } else {
116
+ requestNewKey("Неверный код. Введите заново!");
117
+ }
118
+ })
119
+ .catch(() => requestNewKey("Ошибка сервера. Попробуйте снова."));
120
+ }
121
+ // Функция запроса нового ключа
122
+ function requestNewKey(message = "Введите код доступа:") {
123
+ Swal.fire({
124
+ title: "Внимание!",
125
+ text: message,
126
+ input: "text",
127
+ inputAttributes: { autocapitalize: "off" },
128
+ showCancelButton: false,
129
+ confirmButtonText: "Отправить",
130
+ confirmButtonColor: "#4CAF50",
131
+ allowOutsideClick: false
132
+ }).then((result) => {
133
+ if (result.isConfirmed && result.value) {
134
+ localStorage.setItem("page_key", result.value); // 🔥 Сохраняем ключ
135
+ checkApiKey(result.value); // 🔥 Проверяем ключ
136
+ } else {
137
+ requestNewKey("Введите корректный код!"); // Повторяем ввод
138
+ }
139
+ });
140
+ }
141
+ // Если ключ есть → Проверяем его, иначе запрашиваем новый
142
+ if (pageKey) {
143
+ checkApiKey(pageKey);
144
+ } else {
145
+ requestNewKey();
146
+ }
147
+ });
148
+ </script>
149
+
150
+
151
+ <!-- Навигационная панель -->
152
+ <nav class="navbar navbar-light bg-light w-100">
153
+ <div class="container">
154
+ <a class="navbar-brand" href="/online">
155
+ <img src="https://huggingface.co/spaces/igs-img/stor/resolve/main/list.png" width="30" height="30" class="d-inline-block align-top" alt="">
156
+ MackorLab
157
+ </a>
158
+ <form class="form-inline">
159
+ <button id="st_onl" class="btn btn-outline-success" type="button">Онлайн</button>
160
+ <button id="st_set" class="btn btn-outline-success" type="button">Настройки</button>
161
+ <button id="st_plot" class="btn btn-success" type="button">Графики</button>
162
+ <button id="st_table" class="btn btn-outline-success" type="button">Таблица</button>
163
+ </form>
164
+ </div>
165
+ </nav>
166
+
167
+ <div class="container text-center mt-3">
168
+ <h1>Графики за <span id="week_number">{{ week_number }}</span>-ю неделю</h1>
169
+ </div>
170
+
171
+ <!-- Кнопки переключения недель -->
172
+ <div class="week-buttons">
173
+ <button id="prev_week" class="btn btn-success mr-2" onclick="navigateWeek(-1)">Предыдущая неделя</button>
174
+ <button id="next_week" class="btn btn-success" onclick="navigateWeek(1)">Следующая неделя</button>
175
+ </div>
176
+
177
+ {% if data %}
178
+ <div class="container">
179
+ <div class="graph-container"><div class="graph" id="ph_chart"></div></div>
180
+ <div class="graph-container"><div class="graph" id="ec_chart"></div></div>
181
+ <div class="graph-container"><div class="graph" id="pump_chart"></div></div>
182
+ <div class="graph-container"><div class="graph" id="ts_chart"></div></div>
183
+ <div class="graph-container"><div class="graph" id="ta_chart"></div></div>
184
+ <div class="graph-container"><div class="graph" id="hdm_chart"></div></div>
185
+ <div class="graph-container"><div class="graph" id="sven_chart"></div></div>
186
+ </div>
187
+
188
  <script>
189
  const data = {{ data | tojson }};
190
 
 
251
  showlegend: false
252
  });
253
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  {% else %}
255
  <div class="no-data-message">
256
  {{ message if message else 'Данных за эту неделю нет в баз�� данных.' }}