mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
Continue making web interface
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
],
|
],
|
||||||
"state": "conf.csv",
|
"state": "conf.csv",
|
||||||
"style": "width:100%;",
|
"style": "width:100%;",
|
||||||
|
"action": "/set?delete",
|
||||||
"class": "btn btn-block btn-default"
|
"class": "btn btn-block btn-default"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
9
include/DeviceList.h
Normal file
9
include/DeviceList.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
extern void addElement(String name);
|
||||||
|
extern void delAllElement();
|
||||||
|
extern void delElement();
|
||||||
|
extern void do_delElement();
|
||||||
@@ -111,6 +111,7 @@ extern boolean updateFlag;
|
|||||||
extern boolean mqttParamsChanged;
|
extern boolean mqttParamsChanged;
|
||||||
extern boolean udp_data_parse;
|
extern boolean udp_data_parse;
|
||||||
extern boolean mqtt_send_settings_to_udp;
|
extern boolean mqtt_send_settings_to_udp;
|
||||||
|
extern boolean delElementFlag;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Запрос на скарнирование шины
|
* Запрос на скарнирование шины
|
||||||
|
|||||||
41
src/DeviceList.cpp
Normal file
41
src/DeviceList.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#include "DeviceList.h"
|
||||||
|
|
||||||
|
static const char* firstLine PROGMEM = "Удалить;Тип элемента;Id;Виджет;Имя вкладки;Имя виджета;Позиция виджета";
|
||||||
|
|
||||||
|
void addElement(String name) {
|
||||||
|
String item = readFile("items/" + name + ".txt", 1024);
|
||||||
|
item.replace("\r\n", "");
|
||||||
|
item.replace("\r", "");
|
||||||
|
item.replace("\n", "");
|
||||||
|
addFile("conf.csv", "\n" + item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delAllElement() {
|
||||||
|
removeFile("conf.csv");
|
||||||
|
addFile("conf.csv", String(firstLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_delElement() {
|
||||||
|
if (delElementFlag) {
|
||||||
|
delElementFlag = false;
|
||||||
|
delElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void delElement() {
|
||||||
|
File configFile = LittleFS.open("/conf.csv", "r");
|
||||||
|
if (!configFile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configFile.seek(0, SeekSet); //поставим курсор в начало файла
|
||||||
|
String finalConf;
|
||||||
|
while (configFile.position() != configFile.size()) {
|
||||||
|
String item = configFile.readStringUntil('\n');
|
||||||
|
if (selectToMarker(item, ";") == "0") {
|
||||||
|
finalConf += "\n" + item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
removeFile("conf.csv");
|
||||||
|
addFile("conf.csv", String(firstLine) + "\n" + finalConf);
|
||||||
|
configFile.close();
|
||||||
|
}
|
||||||
@@ -82,3 +82,4 @@ boolean mqtt_send_settings_to_udp = false;
|
|||||||
BusScanner_t busToScan;
|
BusScanner_t busToScan;
|
||||||
boolean busScanFlag = false;
|
boolean busScanFlag = false;
|
||||||
boolean fsCheckFlag = false;
|
boolean fsCheckFlag = false;
|
||||||
|
boolean delElementFlag = false;
|
||||||
18
src/Web.cpp
18
src/Web.cpp
@@ -1,3 +1,4 @@
|
|||||||
|
#include "DeviceList.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Init.h"
|
#include "Init.h"
|
||||||
|
|
||||||
@@ -40,13 +41,20 @@ void web_init() {
|
|||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
if (request->hasArg("element")) {
|
if (request->hasArg("element")) {
|
||||||
String name = request->getParam("element")->value();
|
String name = request->getParam("element")->value();
|
||||||
String item = readFile("items/" + name + ".txt", 1024);
|
addElement(name);
|
||||||
item.replace("\r\n", "");
|
|
||||||
item.replace("\r", "");
|
|
||||||
item.replace("\n", "");
|
|
||||||
addFile("conf.csv", "\n" + item);
|
|
||||||
request->redirect("/?setn.device");
|
request->redirect("/?setn.device");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request->hasArg("cleanconf")) {
|
||||||
|
delAllElement();
|
||||||
|
request->redirect("/?setn.device");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request->hasArg("delete")) {
|
||||||
|
delElementFlag = true;
|
||||||
|
request->redirect("/?setn.device");
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
if (request->hasArg("devinit")) {
|
if (request->hasArg("devinit")) {
|
||||||
Device_init();
|
Device_init();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Bus/BusScannerFactory.h"
|
#include "Bus/BusScannerFactory.h"
|
||||||
#include "Utils/Timings.h"
|
#include "Utils/Timings.h"
|
||||||
#include "Class/Switch.h"
|
#include "Class/Switch.h"
|
||||||
|
#include "DeviceList.h"
|
||||||
|
|
||||||
void not_async_actions();
|
void not_async_actions();
|
||||||
|
|
||||||
@@ -124,6 +125,8 @@ void not_async_actions() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_scan_bus();
|
do_scan_bus();
|
||||||
|
|
||||||
|
do_delElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getURL(const String& urls) {
|
String getURL(const String& urls) {
|
||||||
|
|||||||
Reference in New Issue
Block a user