куча мелких изменений в вебе

This commit is contained in:
Vladislav Ostapov 2024-11-07 18:07:06 +03:00
parent 4a293e10f6
commit fae7a2ffc8
5 changed files with 161 additions and 47 deletions

View File

@ -162,7 +162,7 @@ public:
})); }));
s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/logout", [this](const auto& req, auto& rep) { s.resources.emplace_back(std::make_unique<http::resource::GenericResource>("/logout", [this](const auto& req, auto& rep) {
if (req.method == "GET") { if (req.method == "GET") {
http::server::httpRedirect(rep, "/"); http::server::httpRedirect(rep, "/login");
rep.headers.push_back({.name = "Set-Cookie", .value = http::auth::jwt::EMPTY_AUTH_COOKIE}); rep.headers.push_back({.name = "Set-Cookie", .value = http::auth::jwt::EMPTY_AUTH_COOKIE});
} else { } else {
http::server::stockReply(http::server::bad_request, rep); http::server::stockReply(http::server::bad_request, rep);

View File

@ -25,17 +25,12 @@ static void loadFile(const std::string& path, std::vector<char>& content) {
http::resource::BasicResource::BasicResource(std::string path): path(std::move(path)) {} http::resource::BasicResource::BasicResource(std::string path): path(std::move(path)) {}
http::resource::StaticFileFactory::StaticFileDef::StaticFileDef(std::string path, server::mime_types::Mime type, bool allowCache): path(std::move(path)), type(type), allowCache(allowCache) { http::resource::StaticFileFactory::StaticFileDef::StaticFileDef(std::string path, server::mime_types::Mime type, bool allowCache): path(std::move(path)), type(type), allowCache(allowCache) {
#ifdef USE_DEBUG
if (allowCache) { if (allowCache) {
BOOST_LOG_TRIVIAL(info) << "Load static file " << this->path; BOOST_LOG_TRIVIAL(info) << "Load static file " << this->path;
loadFile(this->path, this->content); loadFile(this->path, this->content);
} else { } else {
BOOST_LOG_TRIVIAL(info) << "Skip loading static file " << this->path; BOOST_LOG_TRIVIAL(info) << "Skip loading static file " << this->path;
} }
#else
BOOST_LOG_TRIVIAL(info) << "Load static file " << this->path;
loadFile(this->path, this->content);
#endif
} }
http::resource::StaticFileFactory::StaticFileDef::~StaticFileDef() = default; http::resource::StaticFileFactory::StaticFileDef::~StaticFileDef() = default;
@ -48,7 +43,6 @@ void http::resource::StaticFileFactory::registerFile(const std::string &path, se
void http::resource::StaticFileFactory::serve(const std::string &path, server::Reply &rep) { void http::resource::StaticFileFactory::serve(const std::string &path, server::Reply &rep) {
for (auto& f: this->files) { for (auto& f: this->files) {
if (f.path == path) { if (f.path == path) {
#ifdef USE_DEBUG
if (f.allowCache) { if (f.allowCache) {
rep.content.clear(); rep.content.clear();
rep.content.insert(rep.content.end(), f.content.begin(), f.content.end()); rep.content.insert(rep.content.end(), f.content.begin(), f.content.end());
@ -56,10 +50,6 @@ void http::resource::StaticFileFactory::serve(const std::string &path, server::R
BOOST_LOG_TRIVIAL(debug) << "Reload file " << path << " (http path: " << path << ")"; BOOST_LOG_TRIVIAL(debug) << "Reload file " << path << " (http path: " << path << ")";
loadFile(f.path, rep.content); loadFile(f.path, rep.content);
} }
#else
rep.content.clear();
rep.content.insert(rep.content.end(), f.content.begin(), f.content.end());
#endif
rep.status = server::ok; rep.status = server::ok;
// rep.headers.clear(); // rep.headers.clear();
rep.headers.push_back({.name = "Content-Type", .value = server::mime_types::toString(f.type)}); rep.headers.push_back({.name = "Content-Type", .value = server::mime_types::toString(f.type)});

View File

@ -166,8 +166,6 @@ void api_driver::ApiDriver::resetPacketStatistics() const {
} }
std::string api_driver::ApiDriver::loadSettings() const { std::string api_driver::ApiDriver::loadSettings() const {
// constexpr auto* UNKNOWN = "\"?\"";
modulator_settings modSettings{}; modulator_settings modSettings{};
CP_GetModulatorSettings(sid, modSettings); CP_GetModulatorSettings(sid, modSettings);
uint32_t modulatorModcod; uint32_t modulatorModcod;

View File

@ -52,12 +52,15 @@
} }
.tabs-item-flex-container > *, .settings-set-container { .tabs-item-flex-container > *, .settings-set-container {
padding: 1em;
margin: 1em; margin: 1em;
border: 1px solid var(--text-color2); border: 1px solid var(--text-color2);
border-radius: 0.2em; border-radius: 0.2em;
} }
.settings-set-container {
padding: 1em;
}
.tabs-item-flex-container th { .tabs-item-flex-container th {
text-align: left; text-align: left;
padding-right: 1em; padding-right: 1em;
@ -69,29 +72,39 @@
margin-top: 0; margin-top: 0;
} }
form label * { .settings-set-container > h3 {
margin: 0;
}
.settings-set-container label * {
display: block; display: block;
} }
form label { .settings-set-container label {
margin: 1em 0; margin: 1em 0;
display: block; display: block;
background: var(--bg-selected); /*background: var(--bg-selected);*/
color: var(--text-color2); color: var(--text-color2);
} }
form input { .settings-set-container input, .settings-set-container select {
margin-top: 0.5em; margin-top: 0.5em;
border: none; border: none;
border-bottom: solid 2px var(--text-color); border-bottom: solid 2px var(--text-color);
width: 100%; width: 20em;
box-sizing: border-box; box-sizing: border-box;
} }
form input:focus { .settings-set-container input:focus {
outline: none; outline: none;
border: none; border: none;
border-bottom: solid 2px var(--brand-text); border-bottom: solid 2px var(--brand-text);
} }
/* костыль для браузеров, которые некорректно стилизуют элементы option */
select * {
background: var(--bg-selected);
color: var(--text-color);
}
/*********************** Стили для красивых 'switch' ***********************/ /*********************** Стили для красивых 'switch' ***********************/
.toggle-input { .toggle-input {

View File

@ -26,7 +26,7 @@
<a href="/logout" class="tabs-btn">Выход</a> <a href="/logout" class="tabs-btn">Выход</a>
</div> </div>
<div :class="{ value_bad: initState !== 'Успешная инициализация системы' }">{{ initState }}</div> <div :class="{ value_bad: initState !== 'Успешная инициализация системы' }">{{ initState }}</div>
<div class="tabs-body"> <div id="content">
<div class="tabs-body-item tabs-item-flex-container" v-show="activeTab === 'monitoring'"> <div class="tabs-body-item tabs-item-flex-container" v-show="activeTab === 'monitoring'">
<div> <div>
<h2>Статистика приема</h2> <h2>Статистика приема</h2>
@ -98,7 +98,7 @@
</div> </div>
<div class="tabs-body-item" v-show="activeTab === 'setup' && settingFetchComplete"> <div class="tabs-body-item" v-show="activeTab === 'setup' && settingFetchComplete">
<h2>Настройки приема/передачи</h2> <h2>Настройки приема/передачи</h2>
<form class="settings-set-container"> <div class="settings-set-container">
<label> <label>
<span>Режим работы</span> <span>Режим работы</span>
<select v-model="param.general.isCinC"> <select v-model="param.general.isCinC">
@ -106,10 +106,10 @@
<option value="true">CinC</option> <option value="true">CinC</option>
</select> </select>
</label> </label>
</form> </div>
<form class="tabs-item-flex-container"> <div class="tabs-item-flex-container">
<div> <div class="settings-set-container">
<h2>Настройки передатчика</h2> <h3>Настройки передатчика</h3>
<label> <label>
<span>Включить передатчик</span> <span>Включить передатчик</span>
<span class="toggle-input"> <span class="toggle-input">
@ -139,8 +139,8 @@
</select> </select>
</label> </label>
</div> </div>
<div> <div class="settings-set-container">
<h2>Параметры передачи</h2> <h3>Параметры передачи</h3>
<label> <label>
<span>Центральная частота, КГц</span> <span>Центральная частота, КГц</span>
<input v-model="param.tx.centerFreq"/> <input v-model="param.tx.centerFreq"/>
@ -165,8 +165,8 @@
</label> </label>
</div> </div>
<div> <div class="settings-set-container">
<h2>Режим работы DVB-S2</h2> <h3>Режим работы DVB-S2</h3>
<label> <label>
<span>Режим</span> <span>Режим</span>
<select v-model="param.dvbs2.mode"> <select v-model="param.dvbs2.mode">
@ -241,8 +241,8 @@
</select> </select>
</label> </label>
</div> </div>
<div> <div class="settings-set-container">
<h2>Настройки авто-регулировки мощности</h2> <h3>Авто-регулировка мощности</h3>
<label> <label>
<span>Авто-регулировка мощности</span> <span>Авто-регулировка мощности</span>
<span class="toggle-input"> <span class="toggle-input">
@ -263,8 +263,8 @@
<input v-model="param.acm.requiredSnr"/> <input v-model="param.acm.requiredSnr"/>
</label> </label>
</div> </div>
<div> <div class="settings-set-container">
<h2>Настройка приемника</h2> <h3>Настройка приемника</h3>
<label> <label>
<span>Режим управления усилением</span> <span>Режим управления усилением</span>
<select v-model="param.rx.gainMode"> <select v-model="param.rx.gainMode">
@ -306,11 +306,11 @@
<input v-model="param.rx.attenuation"/> <input v-model="param.rx.attenuation"/>
</label> </label>
</div> </div>
</form> </div>
<button>Сохранить</button> <button>Сохранить</button>
<h2 v-show="param.general.isCinC">Настройки режима CinC</h2> <h2 v-show="param.general.isCinC">Настройки режима CinC</h2>
<form v-show="param.general.isCinC" class="settings-set-container"> <div v-show="param.general.isCinC" class="settings-set-container">
<label> <label>
<span>Метод расчета задержки</span> <span>Метод расчета задержки</span>
<select v-model="param.cinc.mode"> <select v-model="param.cinc.mode">
@ -342,12 +342,12 @@
<span>до, мс</span> <span>до, мс</span>
<input v-model="param.cinc.delayMax"/> <input v-model="param.cinc.delayMax"/>
</label> </label>
</form> </div>
<button v-show="param.general.isCinC" type="submit">Сохранить</button> <button v-show="param.general.isCinC" type="submit">Сохранить</button>
<h2>Настройки питания и опорного генератора</h2> <h2>Настройки питания и опорного генератора</h2>
<div class="tabs-item-flex-container"> <div class="tabs-item-flex-container">
<form> <div class="settings-set-container">
<h3>Настройки BUC</h3> <h3>Настройки BUC</h3>
<label> <label>
<span>Подача опоры 10МГц</span> <span>Подача опоры 10МГц</span>
@ -364,9 +364,8 @@
<option value="48">48В</option> <option value="48">48В</option>
</select> </select>
</label> </label>
</form> </div>
<div class="settings-set-container">
<form>
<h3>Настройки LNB</h3> <h3>Настройки LNB</h3>
<label> <label>
<span>Подача опоры 10МГц</span> <span>Подача опоры 10МГц</span>
@ -384,9 +383,8 @@
<option value="24">24В</option> <option value="24">24В</option>
</select> </select>
</label> </label>
</form> </div>
<div class="settings-set-container">
<form>
<h3>Сервисные настройки</h3> <h3>Сервисные настройки</h3>
<label> <label>
<span>Подача опоры 10МГц на 'Выход 10МГц'</span> <span>Подача опоры 10МГц на 'Выход 10МГц'</span>
@ -402,18 +400,83 @@
<span class="slider"></span> <span class="slider"></span>
</span> </span>
</label> </label>
</form> </div>
</div> </div>
<button type="submit">Сохранить</button> <button type="submit">Сохранить</button>
</div> </div>
<div class="tabs-body-item" v-show="activeTab === 'qos'"> <div class="tabs-body-item" v-show="activeTab === 'qos'">
<h2>Настройки QoS</h2>
<div class="settings-set-container">
<label>
<span>Активировать QoS</span>
<span class="toggle-input"><input type="checkbox" v-model="qos.en" /><span class="slider"></span></span>
</label>
</div>
<h3>Классы CD</h3>
<button @click="qosAddClass('cd')">Добавить класс CD</button>
<details v-for="(rule, index) in qos.cd" :key="index" class="settings-set-container">
<summary >#{{ index }} CIR={{ rule.cir }}кбит, PIR={{ rule.pir }}кбит {{ rule.description }}</summary>
<label>
<span>CIR</span>
<input v-model="rule.cir" type="number"/>
</label>
<label>
<span>PIR</span>
<input v-model="rule.pir" type="number"/>
</label>
<label>
<span>Описание</span>
<input v-model="rule.description"/>
</label>
<h3>Фильтры ({{ rule.filters.length }})</h3>
<button @click="qosClassAddRule('cd', index)">Добавить правило</button>
<details v-for="filter in rule.filters" class="settings-set-container">
<!-- :key="filterIndex"-->
<!-- <summary>Правило #{{ filterIndex }}</summary>-->
<label>
<span>vlan</span>
<input v-model="filter.vlan" type="text">
</label>
<label>
<span>proto</span>
<input v-model="filter.proto" type="text">
</label>
<label>
<span>sport</span>
<input v-model="filter.sport" type="text">
</label>
<label>
<span>dport</span>
<input v-model="filter.dport" type="text">
</label>
<label>
<span>ip_src</span>
<input v-model="filter.ip_src" type="text">
</label>
<label>
<span>ip_dest</span>
<input v-model="filter.ip_dest" type="text">
</label>
<label>
<span>dscp</span>
<input v-model="filter.dscp" type="text">
</label>
</details>
<button @click="qosDelClass('cd', index)">Del</button>
</details>
<button>Применить</button>
<p> <p>
Эти настройки пока недоступны, но скоро разработчик это поправит. А пока купи разработчику банку <strike>пива</strike> колы) Эти настройки пока недоступны, но скоро разработчик это поправит. А пока купи разработчику банку <strike>пива</strike> колы)
</p> </p>
<video preload="auto" controls style="max-width: 100%"> <video preload="auto" controls style="max-width: 100%">
<source src="/vid/video_2024-11-06_15-49-35.mp4" type="video/mp4" /> <source src="/vid/video_2024-11-06_15-49-35.mp4" type="video/mp4" />
</video> </video>
</div> </div>
<div class="tabs-body-item" v-show="activeTab === 'admin'"> <div class="tabs-body-item" v-show="activeTab === 'admin'">
<p> <p>
@ -639,7 +702,15 @@
}, },
}, },
testState: '?', qos: {
en: false,
rt1: [{cir: 100, description: 'test class'}],
rt2: [],
rt3: [],
cd: [],
},
testState: false,
initState: '', initState: '',
lastUpdateTime: new Date(), lastUpdateTime: new Date(),
activeTab: getCurrentTab(), activeTab: getCurrentTab(),
@ -776,6 +847,48 @@
this.param.lnb.powering = vals["settings"]["lnb.powering"] this.param.lnb.powering = vals["settings"]["lnb.powering"]
this.param.serviceSettings.refClk10M = vals["settings"]["serviceSettings.refClk10M"] this.param.serviceSettings.refClk10M = vals["settings"]["serviceSettings.refClk10M"]
this.param.serviceSettings.autoStart = vals["settings"]["serviceSettings.autoStart"] this.param.serviceSettings.autoStart = vals["settings"]["serviceSettings.autoStart"]
},
// addQosClass()
qosAddClass(name) {
let res = {
cir: 0,
pir: 0,
filters: []
}
switch (name) {
case 'rt1': this.qos.rt1.push(res); break
case 'rt2': this.qos.rt2.push(res); break
case 'rt3': this.qos.rt3.push(res); break
case 'cd': this.qos.cd.push(res); break
}
},
qosClassAddRule(name, index) {
let rule = {
vlan: "",
proto: "tcp",
sport: "22,80,448",
dport: "5000-6000",
ip_src: "192.168.0.0/24",
ip_dest: "192.168.0.0/24,172.16.0.0/16,95.127.91.34",
dscp: ""
}
switch (name) {
case 'rt1': this.qos.rt1[index].filters.push(rule); break
case 'rt2': this.qos.rt2[index].filters.push(rule); break
case 'rt3': this.qos.rt3[index].filters.push(rule); break
case 'cd': this.qos.cd[index].filters.push(rule); break
}
},
qosDelClass(name, index) {
switch (name) {
case 'rt1': this.qos.rt1.splice(index, 1); break
case 'rt2': this.qos.rt2.splice(index, 1); break
case 'rt3': this.qos.rt3.splice(index, 1); break
case 'cd': this.qos.cd.splice(index, 1); break
}
} }
}, },
mounted() { mounted() {