feature: добавил поле для ввода пароля входа в сеть ЦЗС
This commit is contained in:
2
dependencies/control_system_client_tdma
vendored
2
dependencies/control_system_client_tdma
vendored
Submodule dependencies/control_system_client_tdma updated: cb0f743535...78694fd775
@@ -122,7 +122,6 @@
|
||||
{
|
||||
"widget": "settings-container",
|
||||
"childs": [
|
||||
{"widget": "text", "label": "Пароль для входа в сеть ЦЗС", "name": "cesPassword"},
|
||||
{"widget": "h3", "label": "Настройки интерфейса управления"},
|
||||
{"widget": "ip-address-mask", "label": "Интерфейс управления (a.d.d.r/mask)", "name": "managementIp"},
|
||||
{"widget": "text", "label": "Имя веб-сервера", "name": "serverName"}
|
||||
|
@@ -63,6 +63,22 @@
|
||||
}
|
||||
this.submitStatus.firmwareUpgradeOta = false
|
||||
},
|
||||
async settingsPerformSetCesPassword() {
|
||||
if (this.submitStatus.cesPassword) { return }
|
||||
this.submitStatus.cesPassword = true
|
||||
try {
|
||||
await fetch('/api/set/cesPassword', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({'password': this.cesPasswordValue})
|
||||
})
|
||||
} catch (e) {
|
||||
console.log("failed to perform set CES password: ", e)
|
||||
}
|
||||
this.submitStatus.cesPassword = false
|
||||
},
|
||||
{% endif %}
|
||||
|
||||
doModemReboot() {
|
||||
|
@@ -23,7 +23,16 @@
|
||||
</div>
|
||||
<button class="action-button" @click="dumpAllSettings()">Сохранить бекап конфигурации</button>
|
||||
<button class="dangerous-button" @click="restoreAllSettings()">Восстановить бекап конфигурации</button>
|
||||
</div>
|
||||
</div>{% endraw %}{% if modem == 'tdma' %}
|
||||
|
||||
<h2>Вход в сеть ЦЗС</h2>
|
||||
<div class="settings-set-container statistics-container">
|
||||
<label>
|
||||
<span>Хеш-строка пароля (выдается оператором NMS)</span>
|
||||
<input v-model="cesPasswordValue" type="text">
|
||||
</label>
|
||||
<button class="action-button" @click="settingsPerformSetCesPassword()">Установить пароль<span class="submit-spinner" v-show="submitStatus.cesPassword"></span></button>
|
||||
</div>{% endif %}{% raw %}
|
||||
|
||||
<h2>Обновление ПО</h2>
|
||||
<div class="settings-set-container statistics-container">
|
||||
|
@@ -99,10 +99,14 @@
|
||||
firmwareUpgrade: false,
|
||||
{% if modem == 'tdma' %}
|
||||
firmwareUpgradeOta: false,
|
||||
cesPassword: false,
|
||||
{% endif %}
|
||||
// когда модем перезагружается, тут должен быть счетчик. Направление счета - к нулю
|
||||
modemReboot: null
|
||||
},
|
||||
{% if modem == 'tdma' %}
|
||||
cesPasswordValue: '',
|
||||
{% endif %}
|
||||
|
||||
// ========== include from 'common/all-params-data.js.j2'
|
||||
{% include 'common/all-params-data.js.j2' %}
|
||||
|
32
src/main.cpp
32
src/main.cpp
@@ -227,7 +227,7 @@ public:
|
||||
resultJson["status"] = "ok";
|
||||
resultJson["state"] = api->loadTerminalState();
|
||||
} catch (std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/qos): Can't set QoS settings: " << e.what();
|
||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/get/statistics): Can't get terminal state: " << e.what();
|
||||
resultJson.clear();
|
||||
resultJson["status"] = "error";
|
||||
resultJson["error"] = e.what();
|
||||
@@ -436,6 +436,36 @@ public:
|
||||
auto result = resultJson.dump();
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
#ifdef MODEM_IS_TDMA
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/set/cesPassword", this->auth, http::auth::User::EDIT_SETTINGS, [this](const http::server::Request& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
return;
|
||||
}
|
||||
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
nlohmann::json resultJson;
|
||||
|
||||
try {
|
||||
auto reqJson = nlohmann::json::parse(std::string(req.payload.begin(), req.payload.end()));
|
||||
auto password = reqJson["password"].get<std::string>();
|
||||
|
||||
this->api->executeInApi([&password](auto& cp) {
|
||||
cp.setNetwork("ces_password", password);
|
||||
});
|
||||
resultJson["status"] = "ok";
|
||||
} catch (std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << "WebHandle(/api/set/cesPassword): Can't set CES password: " << e.what();
|
||||
resultJson.clear();
|
||||
resultJson["status"] = "error";
|
||||
resultJson["error"] = e.what();
|
||||
}
|
||||
|
||||
auto result = resultJson.dump();
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/reboot", this->auth, 0, [this](const auto& req, auto& rep) {
|
||||
|
@@ -241,10 +241,6 @@
|
||||
</div> <div class="tabs-body-item" v-if="activeTab === 'admin' && settingFetchComplete">
|
||||
<h2>Настройки сети</h2>
|
||||
<div class="settings-set-container">
|
||||
<label>
|
||||
<span>Пароль для входа в сеть ЦЗС</span>
|
||||
<input v-model="paramNetwork.cesPassword" type="text">
|
||||
</label>
|
||||
<h3>Настройки интерфейса управления</h3>
|
||||
<label>
|
||||
<span>Интерфейс управления (a.d.d.r/mask)</span>
|
||||
@@ -277,6 +273,14 @@
|
||||
<button class="action-button" @click="dumpAllSettings()">Сохранить бекап конфигурации</button>
|
||||
<button class="dangerous-button" @click="restoreAllSettings()">Восстановить бекап конфигурации</button>
|
||||
</div>
|
||||
<h2>Вход в сеть ЦЗС</h2>
|
||||
<div class="settings-set-container statistics-container">
|
||||
<label>
|
||||
<span>Хеш-строка пароля (выдается оператором NMS)</span>
|
||||
<input v-model="cesPasswordValue" type="text">
|
||||
</label>
|
||||
<button class="action-button" @click="settingsPerformSetCesPassword()">Установить пароль<span class="submit-spinner" v-show="submitStatus.cesPassword"></span></button>
|
||||
</div>
|
||||
|
||||
<h2>Обновление ПО</h2>
|
||||
<div class="settings-set-container statistics-container">
|
||||
@@ -335,9 +339,11 @@
|
||||
firmwareUpload: false,
|
||||
firmwareUpgrade: false,
|
||||
firmwareUpgradeOta: false,
|
||||
cesPassword: false,
|
||||
// когда модем перезагружается, тут должен быть счетчик. Направление счета - к нулю
|
||||
modemReboot: null
|
||||
},
|
||||
cesPasswordValue: '',
|
||||
|
||||
// ========== include from 'common/all-params-data.js.j2'
|
||||
paramRxtx: {
|
||||
@@ -370,7 +376,6 @@
|
||||
delay: 0,
|
||||
},
|
||||
paramNetwork: {
|
||||
cesPassword: null,
|
||||
managementIp: null,
|
||||
serverName: null,
|
||||
},
|
||||
@@ -551,7 +556,6 @@
|
||||
{ if (!confirm("Применение этих настроек может сделать модем недоступным! Продолжить?")) return }
|
||||
|
||||
let query = {
|
||||
"cesPassword": this.paramNetwork.cesPassword,
|
||||
"managementIp": this.paramNetwork.managementIp,
|
||||
"serverName": this.paramNetwork.serverName,
|
||||
}
|
||||
@@ -597,7 +601,6 @@
|
||||
},
|
||||
updateNetworkSettings(vals) {
|
||||
this.submitStatus.network = false
|
||||
this.paramNetwork.cesPassword = vals["settings"]["network"]["cesPassword"]
|
||||
this.paramNetwork.managementIp = vals["settings"]["network"]["managementIp"]
|
||||
this.paramNetwork.serverName = vals["settings"]["network"]["serverName"]
|
||||
},
|
||||
@@ -761,6 +764,22 @@
|
||||
}
|
||||
this.submitStatus.firmwareUpgradeOta = false
|
||||
},
|
||||
async settingsPerformSetCesPassword() {
|
||||
if (this.submitStatus.cesPassword) { return }
|
||||
this.submitStatus.cesPassword = true
|
||||
try {
|
||||
await fetch('/api/set/cesPassword', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({'password': this.cesPasswordValue})
|
||||
})
|
||||
} catch (e) {
|
||||
console.log("failed to perform set CES password: ", e)
|
||||
}
|
||||
this.submitStatus.cesPassword = false
|
||||
},
|
||||
|
||||
doModemReboot() {
|
||||
if (this.submitStatus.modemReboot !== null) {
|
||||
|
Reference in New Issue
Block a user